灰度背景图像上叠加索引图像的彩色图和颜色条?

时间:2012-12-10 15:12:43

标签: colorbar

我使用以下示例代码覆盖背景图像上的索引图像(在下面的示例中它是RGB但是对于我的问题,背景是灰色的图像)。然后我的问题是:

  1. 如何在叠加图像的一侧显示彩条? colorbar应该是叠加索引图像的颜色条而不是背景图像的颜色条。

  2. 如何修复重叠索引图像的颜色映射范围?我有几对灰度背景+叠加索引图像(使用'jet'颜色图)。我需要它们以相同的比例显示。我尝试使用set(iim2,'caxis', [0 1]);,但Matlab中的'image'没有'caxis'的属性。

  3. 请帮助和非常感谢!

    % Create the background
    % This example uses a blend of colors from left to right, converted to a TrueColor image
    % Use repmat to replicate the pattern in the matrix
    % Use the "jet" colormap to specify the color space
    bg = ind2rgb(repmat(1:64,64,1),jet(64));
    
    % Create an image and its corresponding transparency data
    % This example uses a random set of pixels to create a TrueColor image
    im = rand(100,100,3);
    % Make the image fade in from left to right by designing its alphadata
    % Use repmat to replicate the pattern in the transparency fading
    imAlphaData = repmat(0:1/size(im,2):1-1/size(im,2),size(im,1),1);
    
    % Display the images created in subplots
    hf = figure('units','normalized','position',[.2 .2 .6 .6]);
    ax1 = subplot(2,3,1);
    ibg = image(bg);
    axis off
    title('Background')
    ax2 = subplot(2,3,4);
    iim = image(im);
    axis off
    title('Image without transparency yet')
    
    % Now set up axes that overlay the background with the image
    % Notice how the image is resized from specifying the spatial
    % coordinates to locate it in the axes.
    ax3 = subplot(2,3,[2:3, 5:6]);
    ibg2 = image(bg);
    axis off
    hold on
    % Overlay the image, and set the transparency previously calculated
    iim2 = image(im,'XData',[30 50],'YData',[10 30]);
    set(iim2,'AlphaData',imAlphaData);
    title(sprintf('Using transparency while overlaying images:\nresult is multiple image objects.'))
    

0 个答案:

没有答案