【问题标题】:Segmenting/Differentiating between two objects of the same color but overlapped在相同颜色但重叠的两个对象之间进行分割/区分
【发布时间】:2015-11-12 00:22:24
【问题描述】:

所以我有一种情况,我试图分割两个相同颜色的标记,但它们是重叠的。我最终得到的是一个blob而不是两个blob。任何人都可以提出解决方案吗?

图片如下:

有没有办法区分这两个绿色标记,以便它们在我的分割图像上显示为两个不同的对象?

以下是分段的代码: [bw,maskedRGBImage] = createMask(RGB_image);

r = maskedRGBImage(:,:,1); %red layer
g = maskedRGBImage(:,:,2); %green layer
b = maskedRGBImage(:,:,3); %blue layer

justGreen = g - r/2-b/2;

bw = justGreen>10; %anything above 50 in green goes in bw


bw2 = imfill(bw,'holes'); %fill the holes in the image bw and save it in bw

bw3 = bwlabel(bw2,8); %label the differnet parts of the image wid an integer value

bw3 = imfill(bw3,'holes');


s = regionprops(bw3,{'centroid','area','Perimeter','EquivDiameter'}); %using 

%%%%%%Create Mask code%%%%%%%%
% Convert RGB image to chosen color space
I = rgb2ycbcr(RGB);

% Define thresholds for channel 1 based on histogram settings
channel1Min = 0.000;
channel1Max = 188.000;

% Define thresholds for channel 2 based on histogram settings
channel2Min = 0.000;
channel2Max = 132.000;

% Define thresholds for channel 3 based on histogram settings
channel3Min = 0.000;
channel3Max = 123.000;

% Create mask based on chosen histogram thresholds
BW = (I(:,:,1) >= channel1Min ) & (I(:,:,1) <= channel1Max) & ...
(I(:,:,2) >= channel2Min ) & (I(:,:,2) <= channel2Max) & ...
(I(:,:,3) >= channel3Min ) & (I(:,:,3) <= channel3Max);

% Initialize output masked image based on input image.
maskedRGBImage = RGB;

% Set background pixels where BW is false to zero.
maskedRGBImage(repmat(~BW,[1 1 3])) = 0;

【问题讨论】:

    标签: matlab image-processing computer-vision image-segmentation


    【解决方案1】:

    如果您可以假设标记的形状(例如椭圆),那么您可以使用边缘像素并使用 RANSAC 将它们拟合到椭圆。一旦你有一个很好的拟合,你可以删除那个椭圆并重复,直到你没有留下任何重要的标记像素。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-03-10
      • 1970-01-01
      • 2019-09-25
      • 2013-10-21
      • 1970-01-01
      • 2015-03-11
      • 2019-03-19
      • 1970-01-01
      相关资源
      最近更新 更多