From: Mathew Thomas on
Hey all!!

If there are two objects with the same coordinate value (either x or y), how does bwlabel work in labelling the objects.... for eg...

O
O

Now if bwlabel is going columnwise from top to bottom....how will it label it 1 and 2

Thanks for any help!!!

Matt
From: ImageAnalyst on
On Oct 13, 1:34 pm, "Mathew Thomas" <mathe...(a)gmail.com> wrote:
> Hey all!!
>
> If there are two objects with the same coordinate value (either x or y), how does bwlabel work in labelling the objects.... for eg...
>
>                                 O
>                                 O
>
> Now if bwlabel is going columnwise from top to bottom....how will it label it 1 and 2
>
> Thanks for any help!!!
>
> Matt

------------------------------------------------------------------------------------------------------
Hey Matt!!!
Try it and see. What I've found is exactly what you said: Going down
columns and going over rows from upper left to lower right. So in
your example, the top blob would be #1 and the bottom one would be #2
Here's some code for you:

labeledImage = bwlabel(binaryImage, 8); % Label each blob so we
can make measurements of it
% Get all the blob properties.
blobMeasurements = regionprops(labeledImage, 'all');
numberOfBlobs = size(blobMeasurements, 1);
for k = 1 : numberOfBlobs % Loop through all blobs.
blobCentroid = blobMeasurements(k).Centroid; % Get centroid.
% Write blob number over blob at its centroid.
text(blobCentroid(1), blobCentroid(2), num2str(k));
end

From: Mathew Thomas on
Hey,

Thank you for helping out...very useful...

Mathew