
How to trace the boundary of each object in a binary image?
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I have a binary image like the following image. I want to plot the border of each object with different color. As far as I know, I need to use bwtraceboundary. But, I don't know how to choose the starting point that has to be parsed in the second input argument of bwtraceboundary. Any help is appreciated. Thanks.

0 Commenti
Risposta accettata
Matt J
il 5 Set 2018
Modificato: Matt J
il 5 Set 2018
If your shapes are all solid blobs with no holes or narrow necks, then there are simpler ways than bwtraceboundary:
B=A-imerode(A,ones(3))>0;
reg=regionprops(B,'PixelList');
colors={'g','r','m','y','c'};
imagesc(A); colormap(gray(256));
hold on
for i=1:numel(reg)
plot(reg(i).PixelList(:,1), reg(i).PixelList(:,2),['.' colors{i}]);
end
hold off

4 Commenti
Matt J
il 5 Set 2018
You're welcome, but please Accept-click the answer to certify that it solved your problem.
Più risposte (0)
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!