]> rtime.felk.cvut.cz Git - opencv.git/commitdiff
corrected off-by-one errors in cvLogPolar & cvLogLinear (ticket #208). Thanks to...
authorvp153 <vp153@73c94f0f-984f-4a5f-82bc-2d8db8d8ee08>
Fri, 2 Apr 2010 20:34:12 +0000 (20:34 +0000)
committervp153 <vp153@73c94f0f-984f-4a5f-82bc-2d8db8d8ee08>
Fri, 2 Apr 2010 20:34:12 +0000 (20:34 +0000)
git-svn-id: https://code.ros.org/svn/opencv/trunk@2971 73c94f0f-984f-4a5f-82bc-2d8db8d8ee08

opencv/src/cv/cvimgwarp.cpp

index 2b172423af88e2d4eecc4a241f523c909ea9cf58..fafc11b54a790af7c31b4883834440325a011c20 100644 (file)
@@ -3238,8 +3238,8 @@ cvLogPolar( const CvArr* srcarr, CvArr* dstarr,
 
         for( phi = 0; phi < dsize.height; phi++ )
         {
-            double cp = cos(phi*2*CV_PI/(dsize.height-1));
-            double sp = sin(phi*2*CV_PI/(dsize.height-1));
+            double cp = cos(phi*2*CV_PI/dsize.height);
+            double sp = sin(phi*2*CV_PI/dsize.height);
             float* mx = (float*)(mapx->data.ptr + phi*mapx->step);
             float* my = (float*)(mapy->data.ptr + phi*mapy->step);
 
@@ -3258,7 +3258,7 @@ cvLogPolar( const CvArr* srcarr, CvArr* dstarr,
     {
         int x, y;
         CvMat bufx, bufy, bufp, bufa;
-        double ascale = (ssize.height-1)/(2*CV_PI);
+        double ascale = ssize.height/(2*CV_PI);
         cv::AutoBuffer<float> _buf(4*dsize.width);
         float* buf = _buf;
 
@@ -3351,14 +3351,14 @@ void cvLinearPolar( const CvArr* srcarr, CvArr* dstarr,
 
         for( phi = 0; phi < dsize.height; phi++ )
         {
-            double cp = cos(phi*2*CV_PI/(dsize.height-1));
-            double sp = sin(phi*2*CV_PI/(dsize.height-1));
+            double cp = cos(phi*2*CV_PI/dsize.height);
+            double sp = sin(phi*2*CV_PI/dsize.height);
             float* mx = (float*)(mapx->data.ptr + phi*mapx->step);
             float* my = (float*)(mapy->data.ptr + phi*mapy->step);
 
             for( rho = 0; rho < dsize.width; rho++ )
             {
-                double r = maxRadius*(rho+1)/double(dsize.width-1);
+                double r = maxRadius*(rho+1)/dsize.width;
                 double x = r*cp + center.x;
                 double y = r*sp + center.y;
 
@@ -3371,8 +3371,8 @@ void cvLinearPolar( const CvArr* srcarr, CvArr* dstarr,
     {
         int x, y;
         CvMat bufx, bufy, bufp, bufa;
-        const double ascale = (ssize.height-1)/(2*CV_PI);
-        const double pscale = (ssize.width-1)/maxRadius;
+        const double ascale = ssize.height/(2*CV_PI);
+        const double pscale = ssize.width/maxRadius;
 
         cv::AutoBuffer<float> _buf(4*dsize.width);
         float* buf = _buf;