vil_blob_finder Class Reference

#include <vil_blob_finder.h>

List of all members.


Detailed Description

Finds connected regions in a boolean image.

Class to iterate through image, finding boundaries of all regions (connected true pixels).

Can deal with both 4-connected and 8-connected regions.

Note that the usual use of the class copies the boolean image input, then erases the true pixels as it goes through finding the blobs (in order to avoid finding the same blob twice). If the image is expendable, then the deep copy can be avoided using set_work_image(im). In this case the supplied image (im) will be erased as the blob finder goes about it's humble task.

Where a blob has holes, only the outside of the blob is located. The algorithm will locate nested blobs (ie a blob within a hole inside another blob).

  vcl_vector<int> bi,bj;
  vil_blob_finder finder(bool_image);
  while (finder.next_4con_region(bi,bj))
  {
    vcl_cout<<"Blob boundary length: "<<bi.size()<<vcl_endl;
  }

Alternatively we can get the internal pixels (including the boundary) of each blob. A region is represented as a vcl_vector<vil_chord>, a set of rows of pixels which make up all the pixels in the region.

  vcl_vector<vil_chord> region;
  vil_blob_finder finder(bool_image);
  while (finder.next_4con_region(region))
  {
    vcl_cout<<"Blob area: "<<vil_area(region)<<vcl_endl;
  }
This is useful when we have holes and wish to represent the region more completely than just using its external boundary.

Definition at line 52 of file vil_blob_finder.h.


Public Member Functions

 vil_blob_finder ()
 Default constructor.
 vil_blob_finder (const vil_image_view< bool > &image)
 Construct to work on image (takes deep copy).
void set_image (const vil_image_view< bool > &image)
 Define image to work on (deep copy taken).
void set_work_image (vil_image_view< bool > &image)
 Define image to work on and use as workspace.
bool next_4con_region (vcl_vector< int > &bi, vcl_vector< int > &bj)
 Get boundary pixels of next blob in current image.
bool next_4con_region (vcl_vector< vil_chord > &region)
 Get pixels of next blob in current image.
void longest_4con_boundary (vcl_vector< int > &bi, vcl_vector< int > &bj)
 Get longest blob boundary in current image.
unsigned largest_4con_region (vcl_vector< vil_chord > &region)
 Get largest blob region in current image.
unsigned n_4con_regions (const vil_image_view< bool > &image)
 Get number of blobs in given image.
bool next_8con_region (vcl_vector< int > &bi, vcl_vector< int > &bj)
 Get boundary pixels of next blob in current image.
bool next_8con_region (vcl_vector< vil_chord > &region)
 Get pixels of next blob in current image.
void longest_8con_boundary (vcl_vector< int > &bi, vcl_vector< int > &bj)
 Get longest blob boundary in current image.
unsigned largest_8con_region (vcl_vector< vil_chord > &region)
 Get largest blob region in current image.
unsigned n_8con_regions (const vil_image_view< bool > &image)
 Get number of blobs in given image.

Private Attributes

vil_image_view< bool > image_
 Workspace (may be view of external image).
unsigned int i_
 Current point of interest.
unsigned int j_

Constructor & Destructor Documentation

vil_blob_finder::vil_blob_finder (  ) 

Default constructor.

Definition at line 12 of file vil_blob_finder.cxx.

vil_blob_finder::vil_blob_finder ( const vil_image_view< bool > &  image  ) 

Construct to work on image (takes deep copy).

Definition at line 16 of file vil_blob_finder.cxx.


Member Function Documentation

void vil_blob_finder::set_image ( const vil_image_view< bool > &  image  ) 

Define image to work on (deep copy taken).

Definition at line 23 of file vil_blob_finder.cxx.

void vil_blob_finder::set_work_image ( vil_image_view< bool > &  image  ) 

Define image to work on and use as workspace.

Image will be erased during process. Avoids the deep copy in set_image()

Image will be erased during process. Avoids the copy in set_image()

Definition at line 31 of file vil_blob_finder.cxx.

bool vil_blob_finder::next_4con_region ( vcl_vector< int > &  bi,
vcl_vector< int > &  bj 
)

Get boundary pixels of next blob in current image.

Uses four connected boundary representation. Return false if no more regions

Uses four connected boundary representation. Return false if no more regions

Definition at line 60 of file vil_blob_finder.cxx.

bool vil_blob_finder::next_4con_region ( vcl_vector< vil_chord > &  region  ) 

Get pixels of next blob in current image.

Uses 4 connected representation. Return false if no more regions

Uses four connected boundary representation. Return false if no more regions

Definition at line 83 of file vil_blob_finder.cxx.

void vil_blob_finder::longest_4con_boundary ( vcl_vector< int > &  bi,
vcl_vector< int > &  bj 
)

Get longest blob boundary in current image.

Assumes image has been initialised, and that next_4con_region not yet called. Erases internal image during this call, so any subsequent calls will not work.

bi,bj empty if no blobs found.

Assumes image has been initialised, and that next_4con_region not yet called. Erases internal image during this call, so any subsequent calls will not work.

Definition at line 130 of file vil_blob_finder.cxx.

unsigned vil_blob_finder::largest_4con_region ( vcl_vector< vil_chord > &  region  ) 

Get largest blob region in current image.

Assumes image has been initialised, and that next_8con_region not yet called. Erases internal image during this call, so any subsequent calls will not work.

region empty if no blobs found. Returns area of largest region

Definition at line 217 of file vil_blob_finder.cxx.

unsigned vil_blob_finder::n_4con_regions ( const vil_image_view< bool > &  image  ) 

Get number of blobs in given image.

Overrides any internal state

Definition at line 145 of file vil_blob_finder.cxx.

bool vil_blob_finder::next_8con_region ( vcl_vector< int > &  bi,
vcl_vector< int > &  bj 
)

Get boundary pixels of next blob in current image.

Uses 8 connected boundary representation. Return false if no more regions

Uses four connected boundary representation. Return false if no more regions

Definition at line 160 of file vil_blob_finder.cxx.

bool vil_blob_finder::next_8con_region ( vcl_vector< vil_chord > &  region  ) 

Get pixels of next blob in current image.

Uses 8 connected representation. Return false if no more regions

Uses 8 connected boundary representation. Return false if no more regions

Definition at line 106 of file vil_blob_finder.cxx.

void vil_blob_finder::longest_8con_boundary ( vcl_vector< int > &  bi,
vcl_vector< int > &  bj 
)

Get longest blob boundary in current image.

Assumes image has been initialised, and that next_8con_region not yet called. Erases internal image during this call, so any subsequent calls will not work.

bi,bj empty if no blobs found.

Assumes image has been initialised, and that next_8con_region not yet called. Erases internal image during this call, so any subsequent calls will not work.

Definition at line 184 of file vil_blob_finder.cxx.

unsigned vil_blob_finder::largest_8con_region ( vcl_vector< vil_chord > &  region  ) 

Get largest blob region in current image.

Assumes image has been initialised, and that next_8con_region not yet called. Erases internal image during this call, so any subsequent calls will not work.

region empty if no blobs found. Returns area of largest region

Definition at line 199 of file vil_blob_finder.cxx.

unsigned vil_blob_finder::n_8con_regions ( const vil_image_view< bool > &  image  ) 

Get number of blobs in given image.

Overrides any internal state

Definition at line 235 of file vil_blob_finder.cxx.


Member Data Documentation

Workspace (may be view of external image).

Definition at line 56 of file vil_blob_finder.h.

unsigned int vil_blob_finder::i_ [private]

Current point of interest.

Definition at line 59 of file vil_blob_finder.h.

unsigned int vil_blob_finder::j_ [private]

Definition at line 59 of file vil_blob_finder.h.


The documentation for this class was generated from the following files:

Generated on Sun Nov 22 06:18:58 2009 for core/vil by  doxygen 1.5.5