Effacer les filtres
Effacer les filtres

How to project a 2D image to another plane?

20 vues (au cours des 30 derniers jours)
Jingtao
Jingtao le 13 Avr 2020
Commenté : darova le 13 Avr 2020
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 commentaires
Matt J
Matt J le 13 Avr 2020
Modifié(e) : Matt J le 13 Avr 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 le 13 Avr 2020
I expect the projection result to be similar to the right figure.

Connectez-vous pour commenter.

Réponse acceptée

darova
darova le 13 Avr 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 commentaires
Jingtao
Jingtao le 13 Avr 2020
Modifié(e) : darova le 13 Avr 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
darova
darova le 13 Avr 2020
happy to help

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Lighting, Transparency, and Shading dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by