OpenCV笛卡尔坐标到极坐标变换函数LogPolar

        对数极坐标图像几何学首先是从生物视觉系统的视网膜生理结构获得灵感的,具有数据压缩特性。在人工视觉系统中,与常见的笛卡尔坐标系中的图像对比,在没有减小视域大小和视网膜中心部分图像的分辨率的情况下,对数极坐标图像允许更加快速的采样率。
        形状相同,但是大小不同或者旋转角度不同的图像在极坐标下表现为X或Y轴的偏移。经过一定的移动可以得到相同的极坐标图,因此可以根据极坐标图计算图像的旋转角度和缩放比例。本文介绍的应用是将笛卡尔坐标下的圆环转换成极坐标下的矩形。
基本知识:
       对于二维图像,Log-Polar转换表示从笛卡尔坐标到极坐标的变换。
       OpenCV中用于这个变换的函数是cvLogPolar,其函数原型如下:
void  cvLogPolar ( const CvArr*  src , CvArr*  dst , CvPoint2D32f  center , double  M , int flags =CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS  )
Parameters:
  • src – Source image
  • dst – Destination image
  • center – The transformation center; where the output precision is maximal
  • M – Magnitude scale parameter. See below
  • flags –

    A combination of interpolation methods and the following optional flags:

    • CV_WARP_FILL_OUTLIERS fills all of the destination image pixels. If some of them correspond to outliers in the source image, they are set to zero
    • CV_WARP_INVERSE_MAP See below

The function cvLogPolar transforms the source image using the following transformation:

  • Forward transformation (CV_WARP_INVERSE_MAP is not set):

  • Inverse transformation (CV_WARP_INVERSE_MAP is set):


where
                                   


    本人平时习惯使用C++接口,所以写了一个函数来调用cvLogPolar 函数:
Mat translateToPolar(Mat image ,  int  centerx,  int  centery,  int  m)
{
      if (image.empty())
          return  image;
     cv::Mat pImage = cv::Mat::zeros(image.size(), CV_8UC1);
     IplImage ipl_a = image, ipl_pa = pImage;
     cvLogPolar(&ipl_a, &ipl_pa, cvPoint2D32f(centerx, centery), m);
      return  pImage;
}

应用:将笛卡尔坐标下的圆环转换成极坐标下的矩形
OpenCV笛卡尔坐标到极坐标变换函数LogPolar_第1张图片

                       图1 笛卡尔坐标下的圆环
OpenCV笛卡尔坐标到极坐标变换函数LogPolar_第2张图片
                           图2 极坐标下的矩形

你可能感兴趣的:(图像处理)