1

我正在尝试在灰度图像上叠加彩色图像。但是,当我尝试绘制“颜色条”并设置“爬升”时。Matlab 总是根据下面的灰度图像生成一个颜色条。

但是,我想获得叠加彩色图像的颜色条。任何建议将不胜感激。非常感谢。

%% Example codes:
  greyImage = imread('AT3_1m4_08.tif');
  colorImage = imread('hestain.png');

  figure,

  greyImagePlot = image(greyImage); colormap(gray); hold on;

  overlayImage = imagesc(colorImage, ...
      'CDataMapping', 'scaled', 'HitTest', 'off');
  alF = 0.5.*ones(size(colorImage, 1), size(colorImage, 2));
  set(overlayImage, 'AlphaData', alF);
  colorbar; % This will show a grey scale colorbar not the colour one I want
  set('CLim', [0 100]); % Also, the colormap limit here is not working

  axis off          
  axis image        
4

1 回答 1

3

可以在此处找到单个图形/多个颜色图的参考 http://www.mathworks.fr/support/solutions/en/data/1-GNRWEH/index.html

特别是使用图像,可以使用“子图像”功能。

当自制解决方案太棘手时,我还使用“matlabcentral”中的“FreezeColor”和“cbfreeze”函数。 http://www.mathworks.com/matlabcentral/fileexchange/7943-freezecolors-unfreezecolors http://www.mathworks.com/matlabcentral/fileexchange/24371

一个简单且懒惰的解决方案,用于在同一轴内的多个绘图中保持颜色条:首先绘制彩色图像及其颜色条,冻结颜色条,然后在灰度图像上绘制(无透明度),最后绘制彩色图像再次(透明度)。

这是一段代码。

figure;

%first step: RGB image and colorbar
overlayImage = imagesc(colorImage, 'CDataMapping', 'scaled', 'HitTest', 'off');
alF = 0.5.*ones(size(colorImage, 1), size(colorImage, 2));
set(overlayImage, 'AlphaData', alF);
colorbar; 
set(gca, 'CLim', [0 100]); 

cbfreeze; %from 'COLORMAP and COLORBAR utilities' in Matlab Central

%second step: gray image (no transparency)
greyImagePlot = image(greyImage); colormap(gray); hold on;

%third step: plot colour image
overlayImage = imagesc(colorImage, ...
  'CDataMapping', 'scaled', 'HitTest', 'off');
alF = 0.5.*ones(size(colorImage, 1), size(colorImage, 2));
set(overlayImage, 'AlphaData', alF);

axis off          
axis image   
于 2013-06-27T15:10:55.257 回答