* Circular Kernel 4.x-dev

Thu, 15 Jul 2021 01:36:46 +0300

author
yakupbeyoglu
date
Thu, 15 Jul 2021 01:36:46 +0300
branch
4.x-dev
changeset 1716
d02bc2e9b8ed
parent 1715
32784d399331
child 1717
2ec8ce4582c3
child 1720
229fcfacb5cb

* Circular Kernel

Source/Gorgon/ImageProcessing/Kernel.cpp file | annotate | diff | comparison | revisions
Source/Gorgon/ImageProcessing/Kernel.h file | annotate | diff | comparison | revisions
--- a/Source/Gorgon/ImageProcessing/Kernel.cpp	Tue Jul 13 11:22:43 2021 +0300
+++ b/Source/Gorgon/ImageProcessing/Kernel.cpp	Thu Jul 15 01:36:46 2021 +0300
@@ -77,6 +77,13 @@
         
         return nkernel;
     }
+    
+    Kernel Kernel::CircularFilter(float kernelsize) {
+        Kernel nkernel;
+        nkernel.Resize({kernelsize, kernelsize});
+        nkernel.createcircularfilter(1.0 /(kernelsize * kernelsize), 0);
+        return nkernel;
+    }
 
     Kernel Kernel::EdgeDetection(int kernelsize) {
         Kernel nkernel;
@@ -122,4 +129,18 @@
         }
     }
     
+    void Kernel::createcircularfilter(float centervalue, float others) {
+        auto rs = size.Height * size.Width ;
+
+        for(int y = 0; y < size.Height; y++) {
+            for(int x= 0; x < size.Width; x++) {
+                Gorgon::Geometry::Point current = {x,y};
+                auto distance = current.EuclideanSquare();
+                if(distance <= rs) 
+                        Get(x, y) = centervalue;
+                else
+                    Get(x, y) = others;
+            }
+        }
+    }
 } }
--- a/Source/Gorgon/ImageProcessing/Kernel.h	Tue Jul 13 11:22:43 2021 +0300
+++ b/Source/Gorgon/ImageProcessing/Kernel.h	Thu Jul 15 01:36:46 2021 +0300
@@ -120,6 +120,9 @@
         /// purpose.
         static Kernel BoxFilter(int kernelsize);
         
+        ///Creates a Circular filter, it can be used by the openning/closing
+        static Kernel CircularFilter(float kernelsize);
+        
         /// A kernel that can be used for edge detection.
         static Kernel EdgeDetection(int kernelsize);
         
@@ -132,6 +135,8 @@
         
     private :
         void createboxfilter(float centervalue, float others);
+        void createcircularfilter(float centervlaue, float others);
+        
         
         Geometry::Size size = {0, 0};
         

mercurial