1. 函数定义

	void warpPolar(
		InputArray src, 
		OutputArray dst,
		Size dsize,
		Point2f center,
		double maxRadius, 
		int flags
		);
  • dsize: 目标图像尺寸
  • center:变换中心(圆心)
  • maxRadius:要变换的圆形的半径,也是反向变换的圆的半径
  • flags:插值方法+映射模式
    • WARP_POLAR_LINEAR:线性极坐标映射
    • WARP_POLAR_LOG:半对数极坐标映射
    • WARP_INVERSE_MAP:反向映射

2. 例程

在这里插入图片描述

#include "stdafx.h"
#include <opencv.hpp>
using namespace cv;

int main()
{
	Mat img = imread("标准圆.bmp");

	Mat img1, img2;
	Point2f center = Point2f(img.cols / 2, img.rows/2);  
															 
	//直角坐标系图像转为极坐标系图像
	warpPolar(img, img1, Size(300,600), center, center.x,INTER_LINEAR + WARP_POLAR_LINEAR);
	//极坐标系图像转为直角坐标系图像
	warpPolar(img1, img2, Size(img.rows,img.cols), center, center.x,INTER_LINEAR + WARP_POLAR_LINEAR + WARP_INVERSE_MAP);

	imshow("原图", img);
	imshow("直角坐标-极坐标", img1); 
	imshow("极坐标-直角坐标", img2);
	waitKey(0);
	return 0;
}

3. Halcon的极坐标转换算子

在这里插入图片描述
halcon代码:

read_image (Image, '标准圆.bmp')

* 图像分割
binary_threshold (Image, Region, 'max_separability', 'dark', UsedThreshold)
smallest_circle (Region, Row, Column, Radius)

* 极坐标转换
ImageWidth:=2*rad(180)*Radius
polar_trans_image_ext (Image, PolarTransImage, Row, Column, rad(0), rad(360), 0, 2*Radius, ImageWidth, 2*Radius, 'nearest_neighbor')

dev_display (PolarTransImage)

转载自:https://liuhui.blog.csdn.net/article/details/121914408