GJK_nD
 All Classes Files Functions Typedefs Friends Pages
Public Types | Public Member Functions | List of all members
Utils::BoundariesExtractor Class Reference

A utility class to extract the boundaries of a binary image. More...

#include <BoundariesExtractor.hpp>

Public Types

typedef std::pair< size_t, size_t > Coordinates
 The coordinates type of each pixel of the contour. More...
 
typedef std::vector< CoordinatesCurve
 The type of a contour. More...
 
typedef png::image
< png::gray_pixel > 
Image
 The type of images to work with. More...
 

Public Member Functions

 BoundariesExtractor (const Image *image=0)
 
void setImage (const Image *image)
 
std::vector< CurveextractBoundaries ()
 
std::vector< CurveextractBoundaries (const Image &image)
 

Detailed Description

A utility class to extract the boundaries of a binary image.

The BoundariesExtractor class expects a binary image with a black background (i.e. with a pixel value of 0) and a non-black foreground (i.e. pixels value that are different from 0 are considered as foreground). The boundaries of each 4-connected component of the image are extracted and returned as a set of Curve which are an ordered set of coordinates.

...
png::image<png::gray_pixel> image(inputFile);
// set the image to work with
be.setImage(&image);
// do the contour tracking
std::vector<Curve> contours = be.extractBoundaries();
// this 2 steps could be replaced by a call to
// std::vector<Curve> contours = be.extractBoundaries(image);
// print the pixels' coordinates of each contour curve
for (std::vector<Curve>::const_iterator curveItor = contours.begin();
curveItor != contours.end(); ++curveItor) {
std::cout << "Curve: ";
for(Curve::const_iterator coordItor = curveItor->begin();
coordItor != curveItor->end(); ++coordItor) {
std::cout << "(" << coordItor->first << "," << coordItor->second << ") ";
}
std::cout << std::endl;
}

Member Typedef Documentation

typedef std::pair<size_t, size_t> Utils::BoundariesExtractor::Coordinates

The coordinates type of each pixel of the contour.

The type of a contour.

typedef png::image<png::gray_pixel> Utils::BoundariesExtractor::Image

The type of images to work with.

Constructor & Destructor Documentation

Utils::BoundariesExtractor::BoundariesExtractor ( const Image image = 0)
inline

Create a new BoundariesExtractor to extract the contour of each 4-connected component of the image.

Member Function Documentation

std::vector< BoundariesExtractor::Curve > Utils::BoundariesExtractor::extractBoundaries ( )

Extract the boundaries of the image associated to this instance of BoundariesExctractor.

Returns
the different contours as a set of 8-connected curves.
std::vector<Curve> Utils::BoundariesExtractor::extractBoundaries ( const Image image)
inline

Extract the boundaries of the image.

Returns
the different contours as a set of 8-connected curves
void Utils::BoundariesExtractor::setImage ( const Image image)
inline

Associate the image to this BoundariesExtractor instance.


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