Table of contents

  1. Blob extraction library
    1. Download
    2. Build intructions
    3. Documentation
    4. Examples

Blob extraction library

A library to perform binary images connected component labelling. It also provides functions to manipulate, filter and extract results from the extracted blobs.

Download

The library is distributed in a single zip file. The file is located in the Opencv yahoo groups, Files section, in the file cvBlobsLib_OpenCv_v4.zip.

Build intructions

CvBlobsLib has been developed using Microsoft Visual C++ (6.0) and also can be used in .NET. A Linux makefile is expected, but there is no expected date.

CvBlobsLib is distributed in a static library (.lib). To use it, it is needed to build the .lib file and later use that lib file in the desired project. To build the .lib file, simply open the MSVC++ project and build it (debug or release version).

To build the project where the library is to be used follow this steps (MSVC++ 6.0):

- In "Project/Settings/C++/Preprocessor/Additional Include directories" add the directory where the blob library is stored

- In "Project/Settings/Link/Input/Additional library path" add the directory where the blob library is stored and in "Object/Library modules" add the cvblobslib.lib file

- Include the file "BlobResult.h" where you want to use blob variables.

- In "Project/Settings/C++/Precompiled Headers" select "Not use precompiled headers" (Thanks Brendan)

NOTE: Verify that in the project where the cvblobslib.lib is used, the MFC Runtime Libraries are not mixed:

1. Check in "Project->Settings->C/C++->Code Generation->Use run-time library" of your project and set it to

2 Check in "Project->Settings->General" how it uses the MFC. It should be "Use MFC in a shared DLL".

NOTE: The library can be compiled and used in .NET using this steps, but the menu options may differ a little

NOTE2: In the .NET version, the character sets must be equal in the .lib and in the project. [OpenCV yahoo group: Msg 35500]

Documentation

The documentation is included in source files and also can be build usingDoxygen.

The main classes are: CBlobResult and CBlob. CBlobResult stores a set of blobs and CBlob stores a single blob.

To buid a CBlobResult, just use the its image constructor on a input 1-channel image. This, will fill the CBlobResult with all the blobs of the image (see NOTE3). The blobs from the CBlobResult object can be filtered using the Filter method. The criteria to include or discard blobs is any object from classes derived from COperadorBlob (area, perimeter, gray level, etc, or new classes created by users ).

NOTE3: The are two extra blobs extracted from any image: the background and a blob with area 0. This blob with zero area corresponds to a helper external frame for the blob extraction process, the background can be discarded using the mean gray level (255 or 0, depending on the blob colour ).

Examples

/** Example of extracting and filtering the blobs of an image */ 

// object that will contain blobs of inputImage 
CBlobResult blobs;

// Extract the blobs using a threshold of 100 in the image
blobs = CBlobResult( inputImage, NULL, 100, true );

// create a file with some of the extracted features
blobs.PrintBlobs( "c:\\tmp\\blobs.txt" );

// discard the blobs with less area than 5000 pixels
// ( the criteria to filter can be any class derived from COperadorBlob ) 
blobs.Filter( blobs, B_INCLUDE, CBlobGetArea(), B_GREATER, 5000 );

// create a file with filtered results
blobs.PrintBlobs( "c:\\tmp\\filteredBlobs.txt" );

// object with the blob with most perimeter in the image
// ( the criteria to select can be any class derived from COperadorBlob )
CBlob blobWithBiggestPerimeter, CBlob blobWithLessArea;

// from the filtered blobs, get the blob with biggest perimeter
blobs.GetNthBlob( CBlobGetPerimeter(), 0, blobWithBiggestPerimeter );

// get the blob with less area
blobs.GetNthBlob( CBlobGetArea(), blobs.GetNumBlobs() - 1, blobWithLessArea );

// build an output image equal to the input but with 3 channels (to draw the coloured blobs)
IplImage *outputImage;
outputImage = cvCreateImage( cvSize( inputImage->width, inputImage->height ), IPL_DEPTH_8U, 3 );
cvMerge( inputImage, inputImage, inputImage, NULL, outputImage );

// plot the selected blobs in a output image
blobWithBiggestPerimeter.FillBlob( outputImage, CV_RGB( 255, 0, 0 ));
blobWithLessArea.FillBlob( outputImage, CV_RGB( 0, 255, 0 ));

cvBlobsLib (last edited 2006-04-12 13:35:53 by vyra03)

SourceForge.net Logo