【问题标题】:Display an image on the X-Z plane (instead of the default X-Y)在 X-Z 平面上显示图像(而不是默认的 X-Y)
【发布时间】:2016-08-23 15:11:42
【问题描述】:

我可以使用imagesc 在 X-Y 平面上获得图像图,但现在我想将它放在 X-Z 平面上以供进一步使用。有什么办法吗?谢谢!

【问题讨论】:

    标签: image matlab plot matlab-figure axes


    【解决方案1】:

    我会使用surface 而不是imagesc:

    INPUT = [3,4,5
             4,5,6];
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    figure(); 
    ZZ = padarray(INPUT,[1 1],0,'post'); % See note #2
    [XX,YY] = meshgrid((1:size(INPUT,2)+1)-0.5,(1:size(INPUT,1)+1)-0.5);
    % imagesc
    subplot(3,1,1); imagesc(INPUT); xlim([0 4]); ylim([0.5 2.5]);
    view([-50 50]); xlabel('x'); ylabel('y'); zlabel('z'); grid on;
    title('imagesc');
    % Normal (X-Y):
    subplot(3,1,2); surface(XX,YY,0*XX,ZZ,'EdgeColor','none','FaceColor','flat'); 
    view([-50 50]); xlabel('x'); ylabel('y'); zlabel('z'); axis ij; box on; grid on;
    title('X-Y surface'); caxis([min(INPUT(:)),max(INPUT(:))]);
    % Rotated (X-Z):
    subplot(3,1,3); surface(XX,0*ZZ,YY,ZZ,'EdgeColor','none','FaceColor','flat');
    view([-50 50]); xlabel('x'); ylabel('y'); zlabel('z'); axis ij; box on; grid on;
    title('X-Z surface'); caxis([min(INPUT(:)),max(INPUT(:))]);
    

    几点说明:

    1. 您可能需要flipud 或fliplr 2ndsurface 图中的某些输入(取决于您如何定义Y -> Z 转换)。
    2. 在表示方面,输出是相同的,但是,如果您尝试比较节点的值,您将不会在 X-Y 和 imagesc 输出之间得到相同的结果。原因是表面是使用顶点定义的,而 Image 对象是使用每个正方形中心的值定义的。

    输出:

    【讨论】:

    • @dinex 对第一个 3 个输入进行另一个排列:XX,YY,0*ZZ => YY,0*ZZ,XX => 0*ZZ,XX,YY :)
    • @Dev-iL 但是如果我的输入矩阵是[3,4,5;4,5,6],是否还可以使用你的代码来绘制呢?
    猜你喜欢
    • 2013-02-26
    • 2018-07-29
    • 1970-01-01
    • 2014-10-22
    • 2019-11-24
    • 2019-06-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多