How to project a 2D image to another plane?

조회 수: 18 (최근 30일)
Jingtao
Jingtao 2020년 4월 13일
댓글: darova 2020년 4월 13일
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
darova
darova 2020년 4월 13일
happy to help

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

Community Treasure Hunt

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

Start Hunting!

Translated by