File Exchange Pick of the Week

November 6th, 2009

Segmenting Coins…a Tutorial on Blob Analysis

Many of us who have used or participated in comp.soft-sys.matlab over the years--particularly those of us who have had occasion to solve image processing problems--have come to appreciate Image Analyst's thoughts on relevant matters.

Recently, Image Analyst had occasion to share his first file through the File Exchange--a demo tutorial on blob analysis. In a nice, well-documented bit of code, IA steps us through an approach to segmenting, and determining the properties of, some objects in an image. In this case, the image is a sample ('coins.png') that ships with the Image Processing Toolbox.

IA's code shows how one might segment objects of interest (coins) from the background, then use regionprops (my favorite IPT function!) to differentiate nickels from dimes, and dull dimes from shiny ones:

This is a nice demo--very informative, and certainly worth a read. Two thoughts: 1) IA's code uses bwlabel to calculate a connected components matrix of the image as a precursor to calling regionprops. As of R2009a, the new IPT function bwconncomp replaces bwlabel as the preferred approach; it uses significantly less memory, and can be markedly faster! Also, 2) IA shows how one can extract the specific pixels (PixelIdxList) associated with each object of interest, then calculate statistics on those pixel intensities to differentiate shiny from dull objects. Note that the fourth syntax of regionprops in the documentation enables one to avoid this step, and instead to operate directly on the original intensity image. Using this syntax, one can calculate directly the MIN, MAX, or MEAN intensitities--or even the weighted centroids-- of each blob in the image.

Nice work, Image Analyst!

Comments?


Get the MATLAB code

Published with MATLAB® 7.9

Leave a Reply

Wrap code fragments inside <pre> tags, like this:

<pre class="code">
a = magic(3);
sum(a)
</pre>

If you have a "<" character in your code, either follow it with a space or replace it with "&lt;" (including the semicolon).


Bob, Brett & Jiro share their favorite user-contributed submissions from the File Exchange.

  • Doug: Ben, The name is in the name field as you saw in the video: files(1).name will give you just the name of the...
  • Ben: Hey, Thank you for the tutorial but I must ask, once you have the files required in the array, how do you parse...
  • jiro: Nisa, I’m not familiar with the Psychtoolbox. It’s not a toolbox developed by the MathWorks. As far...
  • nisa: Hi, I have just started to learn to use mathlab can this myaa codes be used with mathlab 7.5.0(R2007b)using...
  • Doug: @Rupa, Could you do this algorithm and then remove the two points and run again? Not efficient, but could be...
  • Doug: From the convhull doc http://www.mathworks .com/access/helpdesk /help/techdoc/ref/co nvhull.html xx = -1:.05:1;...
  • Mark: Very nice function, indeed, thanks for that. But why does’t MATLAB freeze the colormaps for subplots...
  • Steve L: MAuricio, From the description it sounds like the features variable is a cell array that itself contains a...
  • Fred: Doug, I have a set of coordinates for the perimeter of an object in random order. I want to plot these using...
  • Rupa: Hi, sorry to digress but I have a similar problem, I think. I would like to find the three (or n) smallest...

These postings are the author's and don't necessarily represent the opinions of The MathWorks.