【问题标题】:overlaping binary image on the RGB image MATLAB在 RGB 图像 MATLAB 上重叠二值图像
【发布时间】:2011-09-15 08:44:09
【问题描述】:

我能够将二进制图像与原始 RGB 图像重叠。通过以下代码。

inImage = imresize(imread('1.jpg'),0.25);
%imwrite(inImage,'original.jpg');
inImage = skyremoval(inImage);
greyImage = rgb2gray(inImage);


thresh1 = 200;
whiteLayer = greyImage > thresh1;


thresh2 = 125;
lightgreyLayer = greyImage > thresh2 & greyImage <= thresh1;



layer1 = whiteLayer*200;
layer2 = lightgreyLayer*125;


G = layer1 + layer2;
% figure,imshow(G);


se = strel('disk', 15);
Io = imopen(G, se);
figure,imshow(Io);

f = find(Io==0);

 mask(:,:,1) = f;  % For the red plane
%  mask(:,:,2) = f;  % For the green plane
%  mask(:,:,3) = f;  % For the blue plane

inImage(mask)=0;
I = inImage;
figure,imshow(I);

以下是图片。 Here。第一个是从原始图像派生的二进制图像,第二个是原始图像,第三个是二进制图像和 rgb 图像重叠后的结果,由上面给出的代码。正如您所看到的,我面临的问题是除了道路以外的部分是青色的,我想要的是不是黑色的部分。我该怎么做?

如果您能提供帮助,请更改我的代码。谢谢。

【问题讨论】:

    标签: image matlab binary overlap


    【解决方案1】:

    您不需要find 命令,因为您可以使用二进制图像进行索引。

    代替

    f = find(Io==0);
    
     mask(:,:,1) = f;  % For the red plane
    %  mask(:,:,2) = f;  % For the green plane
    %  mask(:,:,3) = f;  % For the blue plane
    
    inImage(mask)=0;
    I = inImage;
    figure,imshow(I);
    

    你可以写

    mask = repmat(Io==0,1,1,3); %# 1 wherever mask is false
    I = inImage;
    I(mask) = 0;
    figure,imshow(I);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-12-20
      • 1970-01-01
      • 2018-02-14
      • 2015-08-15
      • 1970-01-01
      • 2022-08-19
      • 2020-12-05
      相关资源
      最近更新 更多