フィルターのクリア

How to project a 2D image to another plane?

20 ビュー (過去 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 件)

カテゴリ

Help Center および File ExchangeLighting, Transparency, and Shading についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by