【问题标题】:How to display both an RGB and a grascale image in the same figure in MATLAB如何在 MATLAB 中同时显示 RGB 和灰度图像
【发布时间】:2014-07-08 00:17:33
【问题描述】:

我在同一个图中要显示两件事:surf 绘图和灰度图像。它们必须显示在同一图中,并且情节必须是彩色的。如果我先显示绘图并逐步执行代码,绘图以彩色显示就好了,但是在显示灰度图像的那一刻,一切都变成了灰度。

注意:我尝试过更改颜色图,但它也更改了灰度图像。有什么办法可以让情节变成彩色的吗?

这是我的代码的 sn-p:

figure;
subplot(1,2,1);
surf(data), shading interp;
subplot(1,2,2);
imshow(grayimg);

【问题讨论】:

    标签: matlab rgb grayscale figure


    【解决方案1】:

    问题是 Matlab 每个图形只支持一个颜色图,您尝试使用两个:gray 用于图像,jet 用于冲浪图。

    一种解决方法是让 Matlab 相信图像是彩色的;)

    figure;
    subplot(1,2,1); surf(data); shading interp;
    subplot(1,2,2); imshow( grayimg(:,:,[1 1 1]) ); % this is the trick: you convert one channel image to RGB image with all pixels shades of gray...
    

    【讨论】:

    • 非常感谢您的澄清和技巧,现在非常有意义!你是救生员。
    猜你喜欢
    • 2015-05-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-12-03
    • 1970-01-01
    • 2018-02-14
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多