Separating intersecting blobs on an image

6 views (last 30 days)
I am doing a project in Digital Image Processing where I am segmenting images which have multiple cells, many times these cells touch. I have succeeded in separating the background as shown in attached image "BW200.png". I want to separate them, so I tried using the Watershed algorithm(refer attached image "watershed200.png"), but the algorithm is segmenting the image too much and I must be able to know which slices to merge to get the desired cell. So I was wondering if there was a way to identify the centroids of the blobs in the image using which I can find out the approximate shape of each blob and merge the appropriate slices on the watershed. The final goal is to obtain something like the attached image "separated.png"(Coloured in photoshop). What do you suggest I do?
imshow(imread('separated.png'))

Accepted Answer

Matt J
Matt J on 21 Apr 2025
Edited: Matt J on 22 Apr 2025
This uses some tools downloadable from,
load BWimage
BW=imresize(BW,'Output',[500,500]);
BW0=BW;
BW=~bwlalphaclose(~BW,20);
BW=bwareafilt( imfill(BW,'holes') ,5); %5 is the number of principal, large blobs
L=bwlabel(BW);
L=geodesic(BW0,L).*BW0;
L(BW0 & ~ L) = max(L(:))+1; %Assign a common label to small left-over blobs
h=imshow(labeloverlay(uint8(BW0)*255,L)); shg
function nearest=geodesic(BW,L)
%Finds the geodesically nearest blob to any true pixels in BW
%not yet labeled in L.
M=max(L(:));
D = nan([size(L),M]);
for i=1:M
D(:,:,i) = bwdistgeodesic(BW,L==i);
end
[val,nearest]=min(D,[],3);
nearest(val==inf)=0;
end
  5 Comments
Matt J
Matt J on 23 Apr 2025
Edited: Matt J on 23 Apr 2025
Maybe once you've done the initial segmentations above, you can subsegment the central blob with the same routine, but with a larger alpha radius.
When successfuly segmented, the central blob always seems to have an Eccentricity of less than 0.5, and otherwise jumps significantly. So maybe you can use that as a criterion to subsegment.
load L
regionprops('table',(L==3),'Eccentricity')
ans = table
Eccentricity ____________ 0.43298
regionprops('table',(L==3)+(L==4),'Eccentricity')
ans = table
Eccentricity ____________ 0.65189
Mukunda
Mukunda on 23 Apr 2025
Thats a great idea, will be trying it, will update you when I do

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!