原理:
数极坐标是对物体视场的一种不变表示,比如所有的正方形都是一样的,产生了一类二维旋转和尺度的不变性
rho=M*log(sqrt(x2+y2))
phi=atan(y/x)
核心函数:
cvLogPolar
效果:
代码:
#include "cv.h"
#include "cxcore.h"
#include "highgui.h"
#include <iostream>
int LogPolar(int argc,char** argv) //polar:两级的,极地的
{
IplImage* src=cvLoadImage("e:\\picture\\zenfanxin.JPG");
IplImage* dst=cvCreateImage(cvGetSize(src),src->depth,src->nChannels);
IplImage* src2=cvCreateImage(cvGetSize(src),src->depth,src->nChannels);
double M=80; //貌似在一定范围M越大复原后的图像越清晰
cvLogPolar(src,dst,cvPoint2D32f(src->width/2,src->height/4),M,CV_INTER_LINEAR | CV_WARP_FILL_OUTLIERS); //CV_INTER_LINEAR:双线性插值,默认使用 OUTLIERS:局外,笛卡尔坐标转换为数极坐标
cvLogPolar(dst,src2,cvPoint2D32f(src->width/2,src->height/4),M,CV_INTER_LINEAR | CV_WARP_INVERSE_MAP); //数极坐标转换为笛卡尔坐标
cvNamedWindow("src");
cvNamedWindow("dst");
cvNamedWindow("src2");
cvShowImage("src",src);
cvShowImage("dst",dst);
cvShowImage("src2",src2);
cvWaitKey(0);
cvDestroyWindow("src");
cvDestroyWindow("dst");
cvDestroyWindow("src2");
cvReleaseImage(&src);
cvReleaseImage(&dst);
cvReleaseImage(&src2);
return 0;
}
转载于:https://blog.51cto.com/flyclc/1539816