我需要使用Octave生成黑色/白色棋盘格。 我想用这个虚拟图像将笛卡儿转换成极坐标或透视投影。 任何人都可以显示脚本?感谢
我试过这个:
clear all
close all
clc
img = magic(16);
%# convert coordinates from cartesian to polar
[r c] = size(img);
[X Y] = meshgrid(1:c,1:r);
[theta rho] = cart2pol(X, Y);
figure
subplot(121), image(img), axis square
colormap(gray(256))
subplot(122), surf(theta, rho,img),axis square;
view(0,90)
答案 0 :(得分:2)
这正是OP所寻求的。但几个月前就提出了这个问题!
略微修改OP的代码。
clear all
close all
clc
%my changes start
img = zeros(8,8);
img(1:2:end,1:2:end)=255;
img(2:2:end,2:2:end)=255;
%my changes end
%# convert coordinates from cartesian to polar
[r c] = size(img);
[X Y] = meshgrid(1:c,1:r);
[theta rho] = cart2pol(X, Y);
figure
subplot(121), image(img), axis square
colormap(gray(256))
subplot(122), surf(theta, rho,img),axis square;
view(0,90)