所以我有一种情况,我试图分割两个相同颜色的标记,但它们是重叠的。我最终得到的是一个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;
答案 0 :(得分:0)
如果您可以假设某些标记的形状(例如椭圆形),那么您可以使用边缘像素并使用RANSAC将它们拟合为椭圆。一旦你有一个合适的,你就可以删除那个椭圆并重复,直到你没有剩下的有意义的标记像素。