Circular kernel fixes 4.x-dev

Fri, 16 Jul 2021 09:18:47 +0300

author
yakupbeyoglu
date
Fri, 16 Jul 2021 09:18:47 +0300
branch
4.x-dev
changeset 1720
229fcfacb5cb
parent 1716
d02bc2e9b8ed
child 1721
d969488f5f06

Circular kernel fixes

Source/Gorgon/ImageProcessing/Kernel.cpp file | annotate | diff | comparison | revisions
--- a/Source/Gorgon/ImageProcessing/Kernel.cpp	Thu Jul 15 01:36:46 2021 +0300
+++ b/Source/Gorgon/ImageProcessing/Kernel.cpp	Fri Jul 16 09:18:47 2021 +0300
@@ -80,8 +80,9 @@
     
     Kernel Kernel::CircularFilter(float kernelsize) {
         Kernel nkernel;
-        nkernel.Resize({kernelsize, kernelsize});
-        nkernel.createcircularfilter(1.0 /(kernelsize * kernelsize), 0);
+        int size = std::ceil(kernelsize);
+        nkernel.Resize({size, size});
+        nkernel.createcircularfilter(0, 255);
         return nkernel;
     }
 
@@ -132,8 +133,8 @@
     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++) {
+        for(int y = -size.Height/2; y < size.Height/2; y++) {
+            for(int x= -size.Width/2; x < size.Width/2; x++) {
                 Gorgon::Geometry::Point current = {x,y};
                 auto distance = current.EuclideanSquare();
                 if(distance <= rs) 

mercurial