Steve on Image Processing with MATLAB

Image processing concepts, algorithms, and MATLAB

Connected component labeling – Part 1

Several people have asked recently about how bwlabel works, so I plan to write about it here during the next several weeks.

bwlabel implements an operation known as connected component labeling, or sometimes blob labeling. So, what is a connected component, and what does it mean to label it?

Let's start by looking at a simple binary image:

bw = imread('https://blogs.mathworks.com/images/steve/119/binary.png');
imshow(bw)

What do you see? Most people would probably say that they see four round objects (or blobs). (Actually, if you look closely
at the lower right object, you can see a picture of Cleve Moler from his grad school days. No, just kidding.)

In MATLAB, this image is represented as a simple matrix. It has 74,536 elements. 17,871 of the elements have the value 1;
the rest have the value 0. Here are a few of these matrix values:

showPixelValues(bw, [173, 162])

How do we get from 17,871 foreground pixels to four objects? Well, some of the pixels are obviously "connected" to each other.
We want to identify all the groups of interconnected foreground pixels. This process is called connected component labeling.
(If you are interested in a more precise definition of a connected component, see section 9.4 of Digital Image Processing Using MATLAB.)

In subsequent posts I'll write about several methods you might use to find connected components, including the particular
methods used by bwlabel and its multidimensional cousin bwlabeln. I'll also explain how the exact definition of a pixel's neighborhood affects the results.

Published with MATLAB® 7.4

|
  • print
  • send email

Comments

To leave a comment, please click here to sign in to your MathWorks Account or create a new one.