【发布时间】:2019-09-30 13:22:55
【问题描述】:
我有一张如下图:
我正在应用代码中的某种阈值。我可以像下面这样分离蓝色对象:
但是,现在我在分离这些蓝色对象时遇到了问题。我应用了分水岭(我不知道我做对了还是错了)但没有成功,所以我需要帮助来分离这些连接的对象。
我尝试使用的代码如下所示:
RGB=imread('testImage.jpg');
RGB = im2double(RGB);
cform = makecform('srgb2lab', 'AdaptedWhitePoint', whitepoint('D65'));
I = applycform(RGB,cform);
channel1Min = 12.099;
channel1Max = 36.044;
channel2Min = -9.048;
channel2Max = 48.547;
channel3Min = -53.996;
channel3Max = 15.471;
BW = (I(:,:,1) >= channel1Min ) & (I(:,:,1) <= channel1Max) & ...
(I(:,:,2) >= channel2Min ) & (I(:,:,2) <= channel2Max) & ...
(I(:,:,3) >= channel3Min ) & (I(:,:,3) <= channel3Max);
maskedRGBImage = RGB;
maskedRGBImage(repmat(~BW,[1 1 3])) = 0;
figure
imshow(maskedRGBImage)
【问题讨论】:
标签: matlab image-processing image-segmentation