Connected Components of an Image or Matrix

IMAGE_COMPONENTS is a C++ library which seeks to count and label the connected nonzero/nonblack components in an image or integer vector, matrix or 3D block.


The computer code and data files described and made available on this web page are distributed under the GNU LGPL license.


IMAGE_COMPONENTS is available in a C version and a C++ version and a FORTRAN90 version and a MATLAB version.

Related Data and Programs:

IMAGE_DENOISE, a C++ library which applies simple filtering techniques to remove noise from an image.

IMAGE_EDGE, a C++ library which demonstrates a simple procedure for edge detection in images.

REGION, a FORTRAN90 library which reads 3D MRI voxel data, and groups the voxels into connected regions;


  1. Jonas Gomes, Luiz Velho,
    Image Processing for Computer Graphics,
    Springer, 1997,
    ISBN: 0387948546,
    LC: T385.G65.
  2. William Pratt,
    Digital Image Processing,
    Second Edition,
    Wiley, 1991,
    ISBN13: 978-0471857662,
    LC: TA1632.P7.

Source Code:

Examples and Tests:

List of Routines:

You can go up one level to the C++ source codes.

Last revised on 01 March 2011.