DSPRelated.com
Forums

Problems with using bwlabels with a coin counter

Started by matthew joyce April 6, 2006
Thanks to those who helped me with inverting the black
and white image

>> I = imread('H:\image\simple.png');
J = rgb2gray(I);
figure, imshow(I), figure, imshow(J);
level = graythresh(J);
BW = im2bw(J,level);
BW=~BW;
imshow(BW)
>> BW1 = imfill(BW,'holes');
imshow(BW1)

The next step that I want to do is use the bwlabel
function. The problem that im having with it though is
that I dont think im getting the right labels for the
coin objects. I've tried using it on the coins.png
example that comes with matlab and it does it
correctly, matrixs of 1-10 and there are 10 coins but
when I do it on my image I get serveral of 8 and 13..?
I need to get the labels so I can calculate the area
of each label and then calculate the total of the
coins.

im just using the syntax L=bwlabel(BW1)

This might just be im inability to understand what i'm
getting back so any help would be great thanks