Clear Filters
Clear Filters

How to project a 2D image to another plane?

20 views (last 30 days)
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 Comments
Matt J
Matt J on 13 Apr 2020
Edited: Matt J on 13 Apr 2020
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 on 13 Apr 2020
I expect the projection result to be similar to the right figure.

Sign in to comment.

Accepted Answer

darova
darova on 13 Apr 2020
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 Comments
Jingtao
Jingtao on 13 Apr 2020
Edited: darova on 13 Apr 2020
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

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!