User`s guide
CountingObjectsinanImage
CountingObjectsinanImage
In this ex ample, you im port an intensity imag e of a wheel from the MATLAB
workspace and convert it to binary. Then, using the Opening and Label blocks,
you count the number of spokes in the wheel. You can use similar techniques
to count objects in other intensity imag es. However, you might need to use
additional morphological operators and different structuring elements:
1 Define an intensity image in the MATLAB workspace. To read in an
intensity image from a PNG file, at the M ATLAB command prom pt, type
I= imread('testpat 1.pn g');
I
is a 256-by-256 matrix of 8-bit unsigned integers.
2 To view the image this matrix represents, at the MATLAB command
prompt, type
imshow(I)
6-3