【问题标题】:Polar to Cartesian image conversion in MATLABMATLAB中的极坐标到笛卡尔图像转换
【发布时间】:2015-03-13 00:14:14
【问题描述】:

我在将 [R,theta] 格式的图像转换为 [x,y] 时遇到问题

我正在尝试使用 interp2。

[nZ,nX] = size(im);
theta = ((0:(nX-1)))*0.0071; %0.0071 is known angular separation of columns
rr = (0:(nZ-1))*0.0039; %0.0039 is resolution of rows

然后我会这样做:

%% Create grids and convert polar coordinates to rectangular
[THETA,RR] = meshgrid(theta,rr);
[XX,YY] = pol2cart(THETA,RR);

最后:

im_out=interp2(theta,rr,im,XX,YY,'linear');
im_out(isnan(im_out)) = 0;

但图片不正确!

这是输入图像(图 1)(带有 R,theta 几何):

我想在笛卡尔网格上重建它(使用 interp2),所以它看起来像这样(图 2):

Polar 图像(图 1)中的所有数据都应映射到笛卡尔图像的红色区域(图 2)。

【问题讨论】:

  • 你能展示你想要的图片和你得到的那个吗?
  • 这是输入图像(带有 R,theta 几何):dropbox.com/s/g5vllc0puftqm9k/input.png?dl=0 我想在笛卡尔网格上重建它(使用 interp2),所以它看起来像这样:dropbox.com/s/yvmprufb5zc3e1a/required_output.png?dl=0
  • 你知道极坐标采样的中心在笛卡尔坐标的什么位置吗?显然不是左上角。
  • Polar 图像(图 1)中的所有数据应映射到笛卡尔图像的红色扇区(图 2)。使用 interp2 后,NAN 应设置为 0(即笛卡尔图像的蓝色区域(忽略红色区域的噪声))。 Polar 图像中的 (0,0) 应映射到笛卡尔图像中红色扇区的左上角。感谢您的帮助!
  • 极坐标图像中的(0,0)映射到笛卡尔图像中的(274,50)。

标签: image matlab image-processing polar-coordinates


【解决方案1】:

我已经设法做到了如下:

我在 im 矩阵的顶部添加了零以正确定义曲率半径(在我的情况下为 1018 像素,即 ROC)和极坐标原点:

im = IML';   % scan_lines (rotated for now)
sector=75;   % [degrees]
im_depth=16; % [cm] (depth + ROC)

ROC=3.98;
im_depth=16+ROC;

col_size=size(im,2);
zeros_row = zeros(1018, col_size);
im=[zeros_row; im];
scan_lines = im;

[nY, nX] = size(im);

min_ang=(sector/nX)*pi/180;% [rad.]
theta = -nX/2*min_ang:min_ang:nX/2*min_ang; % total angle/num. lines [radians]
theta = theta(2:end);

steering_angles=theta; % angles [radians]

num_samples=im_depth/nY;
rr = (0:(nY-1))*num_samples; % im. depth/num. samples
r = rr; 

image_size = [26.15,16+ROC]; % [cm]

x_resolution = 480; % image resolution [pix]
y_resolution = 640;

% assign the inputs
x = image_size(2);
y = image_size(1);

disp_rr=max(rr)/(im_depth-ROC);

%plot input image
%subplot(1,2,1); imagesc(theta*(180/pi), rr/disp_rr, fliplr(IML')); title('polar geometry'); colormap(gray)
%xlabel('theta [deg]')
%ylabel('r [cm]'); hold on;

% number of scan lines
Nt = length(scan_lines(1, :));

% create regular Cartesian grid to remap to
pos_vec_y_new = (0:1/(y_resolution-1):1).*y - y/2;
pos_vec_y_new = pos_vec_y_new';
pos_vec_x_new = (0:1/(x_resolution-1):1).*x;
[pos_mat_x_new, pos_mat_y_new] = ndgrid(pos_vec_x_new, pos_vec_y_new);

% convert new points to polar coordinates
[th_cart, r_cart] = cart2pol(pos_mat_x_new, pos_mat_y_new);

% interpolate using linear interpolation
op = interp2(steering_angles,r, scan_lines, th_cart, r_cart, 'linear').';

% set any values outside of the interpolation range to be 0
% op(isnan(op)) = max(b_mode(:));
op(isnan(op)) = 0;

%plot output image
subplot(2,2,4); 
imagesc(pos_vec_y_new, pos_vec_x_new-ROC, op'); title('Cartesian geometry'); colormap(gray); 
xlabel('lat [cm]')
ylabel('ax [cm]');
caxis([7.2,max(max(op))])

【讨论】:

  • 干得好。我开始玩弄你的形象,然后不得不放弃做实际的工作。
猜你喜欢
  • 2013-08-05
  • 1970-01-01
  • 2013-10-10
  • 1970-01-01
  • 1970-01-01
  • 2017-06-04
  • 1970-01-01
  • 2016-04-14
  • 2015-06-17
相关资源
最近更新 更多