将图像坐标转换为圆坐标 [英] Transforming an image coordinate to circle coordinates

查看:63
本文介绍了将图像坐标转换为圆坐标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我正在尝试将图像坐标(即普通的正方形x,y坐标)转换为圆形坐标,如下所示.

So I'm trying to transform an image coordinate which is the ordinary square x,y coordinate to a circular coordinate as shown below.

为此,正方形图像的中心必须是原点,在圆坐标系中该原点为0.

In order to do so, the center of the square image must be the origin which is 0 in the circular coordinate system.

在Matlab中,它们具有一个名为"cart2pol"的函数,其中:

In Matlab they have a function called 'cart2pol' where:

cart2pol(x,y)

但是,x,y参数是圆坐标,因此在使用cart2pol之前,如何将普通的方形坐标系统转换为圆坐标?

However, the x,y argument are the circular coordinates hence before using cart2pol, how do i convert the ordinary square coordinate system to a circular one?

推荐答案

我认为您应该可以使用 cart2pol(x,y),它可以为您提供极坐标(2d)或圆柱(3d)某些直角坐标输入 x y (对于圆柱体为 z )的坐标.

I think you should be able to use cart2pol(x,y), which gives you the polar (2d) or cylinder (3d) coordinates for some cartesian inputs x and y (and z for cylindrical).

第一张图片中的坐标: i j .您第二张图片中的坐标: theta rho .

Coordinates in your 1st image: i, j. Coordinates in your 2nd image: theta, rho.

N = 400; % example: 400x400 pixels

% shift origin into center
% Matlab uses 1 to N indexing not 0 to N-1
xo = (N)/2; % center of image
yo = (N)/2;

% Define some sample points in the image (coords from top-left of image)
% 0 deg, 90 deg, 180 deg, 270 deg
i = [350 200 50 200];
j = [200 1 200 350];

% get polar coordinates from cartesian ones (theta in radians)
% -(j-yo) due to opposite direction of j to mathematical positive direction of coord.system
[theta, rho] = cart2pol(i-xo, -(j-yo));
rho = rho/(N/2); % scaling for unit circle

theta 的范围是 -pi到pi ,因此如果您需要 0到2pi 0到360 您仍然需要进行映射.

theta is in the range -pi to pi, so if you need 0 to 2pi or 0 to 360 you still need to do a mapping.

这篇关于将图像坐标转换为圆坐标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆