【问题标题】:Display multiple images on one window in MATLAB在 MATLAB 的一个窗口上显示多个图像
【发布时间】:2017-10-28 15:34:50
【问题描述】:

这些是我需要在一个图中显示的原始图像,

以下是我的源码,

function draw_multiple_images(image_list)    
    N = length(image_list);
    [m, n] = factor_out(N);

    % create the subplots
    figure;

    if(iscell(image_list))    
        for k=1:N
            h = subplot(m,n,k);
            image(image_list{k},'Parent',h);
            set(gca,'xtick',[],'ytick',[])
        end    
    elseif(isvector(image_list))
         for k=1:N
            h = subplot(m,n,k);
            image(image_list(k),'Parent',h);
            set(gca,'xtick',[],'ytick',[])
        end
    end
end

输出

为什么我看到它们是蓝黄色的?

我需要将它们显示为黑白。

【问题讨论】:

  • 你的问题是什么?
  • Image_list 是图片名称的列表?
  • 还是图像是矩阵?
  • 我想知道的是你是怎么看图片的。
  • 请尝试:image(uint8(image_list(k)),'Parent',h);

标签: image matlab subplot


【解决方案1】:

我在figure 命令之后使用colormap(gray(256)); 解决了这个问题。

function draw_multiple_images(image_list)    
    d = size(image_list);
    l = length(d);

    figure;
    hold all
    colormap(gray(256));  

    if(l==2)
        N = length(image_list);
        [m, n] = factor_out(N);

        if(iscell(image_list))    
            for k=1:N
                h = subplot(m,n,k);
                image(image_list{k},'Parent',h);
                set(gca,'xtick',[],'ytick',[])
            end    
        elseif(isvector(image_list))
            for k=1:N
                h = subplot(m,n,k);
                image(image_list(k),'Parent',h);
                set(gca,'xtick',[],'ytick',[])
            end
        end
    elseif(l==3)
        N = d(3) ;
        [m, n] = factor_out(N);
        for k=1:N
            I = image_list(:,:,k);
            subplot(m,n,k);
            imshow(I);
            set(gca,'xtick',[],'ytick',[])
        end  
    end     
    hold off
end 

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-07-02
    • 2021-11-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-12-25
    • 2019-03-04
    相关资源
    最近更新 更多