【opencv】几何变换——极坐标变换(3 cartToPolar(x, y, r, theta, true)笛卡尔转极坐标)

3 利用函数cartToPolar(x,y,magnitude[,angle[,angelInDegrees]]])实现极坐标变换;

  • x:array数组,数据类型为浮点型、float32、float64;
  • y:和x具有相同尺寸和数据类型的array数组;
  • angleInDegrees:当值为true时,返回值angle是角度;反之,为弧度;
  • 距离变换中心相等的点转换为极坐标后在极坐标系位于同一条直线上;
#include
#include
#include
#define PI acos(-1)
using namespace cv;
using namespace std;
int main()
{
	Mat x = (Mat_<float>(3, 3) << 0, 1, 2, 0, 1, 2, 0, 1, 2) - 1;
	Mat y = (Mat_<float>(3, 3) << 0, 0, 0, 1, 1, 1, 2, 2, 2) - 1;
	Mat r, theta;
	cartToPolar(x, y, r, theta, true);
	cout << r << endl;
	cout << theta << endl;

	return 0;
}

【opencv】几何变换——极坐标变换(3 cartToPolar(x, y, r, theta, true)笛卡尔转极坐标)_第1张图片

你可能感兴趣的:(opencv,人工智能,计算机视觉)