How to project a 2D image to another plane?

21 次查看(过去 30 天)
Dear all,
I would like to project an image with 2D Gaussian intensity distribution to another plane, which is rotated by an angle of theta with respect to x-axis, for instance.
How to calculate the new intensity distribution F(x', y')?
Thanks in advance.
  2 个评论
Matt J
Matt J 2020-4-13
编辑:Matt J 2020-4-13
What sort of projection? Given a point (x',y') on the new plane, how is its image (x,y) on the old plane defined?
Jingtao
Jingtao 2020-4-13
I expect the projection result to be similar to the right figure.

请先登录,再进行评论。

采纳的回答

darova
darova 2020-4-13
Use rotate in-built function
[x,y] = meshgrid(-10:0.5:10);
z = 10*sin(hypot(x,y))./hypot(x,y);
h = surf(x,y,z);
% rotate data around X axis
% angle 10 degrees
% point of rotation [0 10 0]
rotate(h,[1 0 0],10,[0 10 0]);
axis vis3d equal
X = get(h,'xdata');
Y = get(h,'ydata');
Z = get(h,'zdata');
figure
pcolor(X,Y,Z)
  2 个评论
Jingtao
Jingtao 2020-4-13
编辑:darova 2020-4-13
Dear darova,
Thanks for your prompt reply. Your code works excellent !
I made a minor revision in accordance with my request.
sigma = 1; % in mm
[x,y] = meshgrid(linspace(-sigma.*3, sigma.*3, 51));
z = exp(-(x.^2 + y.^2)./(2.* sigma.^2)); % general 2D Gaussian surface
z0 = z.*0; % base plane
subplot(131); % draw 2D Gaussian surface and base plane
h = surf(x,y,z); hold on
h0 = surf(x,y,z0); hold off
direction = [1 0 0]; % rotate data around X axis
rotAngle = 45; % rotation angle in degree
origin = [0 0 0]; % point of rotation
rotate(h, direction, rotAngle, origin); % rotate 2D Gaussian surface by 45 deg.
rotate(h0, direction, rotAngle, origin); % rotate base plane by 45 deg.
axis vis3d equal
X = get(h,'xdata');
Y = get(h,'ydata');
Z = get(h,'zdata');
X0 = get(h0,'xdata');
Y0 = get(h0,'ydata');
Z0 = get(h0,'zdata');
subplot(132); % draw projected 2D Gaussian surface
pcolor(X,Y,Z); axis image
subplot(133); % draw projected 2D Gaussian surface corrected by the base plane
pcolor(X,Y,Z-Z0); axis image

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Lighting, Transparency, and Shading 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by