LTI-Lib latest version v1.9 - last update 10 Apr 2010

lti::boundingBox< T > Class Template Reference

Generate an image containing a region of another one specified through a contour-instance, or compute the "best" rectLocation that contains the specified region. More...

#include <ltiBoundingBox.h>

Inheritance diagram for lti::boundingBox< T >:
Inheritance graph
[legend]
Collaboration diagram for lti::boundingBox< T >:
Collaboration graph
[legend]

List of all members.

Classes

class  parameters
 the parameters for the class boundingBox More...

Public Member Functions

 boundingBox ()
 boundingBox (const boundingBox &other)
virtual ~boundingBox ()
virtual const char * getTypeName () const
bool apply (matrix< T > &srcdest, const areaPoints &obj) const
bool apply (const matrix< T > &src, const areaPoints &obj, matrix< T > &dest) const
bool apply (const matrix< T > &src, const areaPoints &obj, matrix< T > &dest, rectLocation &loc) const
bool apply (const areaPoints &obj, rectLocation &loc) const
bool apply (const ioPoints &obj, rectLocation &loc) const
bool apply (const pointList &obj, rectLocation &loc) const
boundingBoxcopy (const boundingBox &other)
virtual functorclone () const
const parametersgetParameters () const

Protected Member Functions

void calculatePositions (const areaPoints &obj, point &destSize, point &delta) const
void computeLocation (const pointList &pts, rectLocation &loc) const
bool computeLocationFromCH (const pointList &convexHull, rectLocation &loc) const

Detailed Description

template<class T>
class lti::boundingBox< T >

Generate an image containing a region of another one specified through a contour-instance, or compute the "best" rectLocation that contains the specified region.

After segmenting the biggest object on an image or channel, it is usually desirable to get a new image with the extracted object only. This class will allow to generate such an image. The position of the desired object will be indicated by the area points of a contour object.

Type T of the template specify the type of the matrix to be used (for images this will be rgbPixel and for channels float).

Example:

 lti::loadBMP loader;
 lti::image img,biggestObject;
 lti::channel8 mask;

 loader.load("img/leo040801_00_019.bmp",img); // load an image

 lti::regionGrowing segmenter;  // functor for segmentation

 segmenter.apply(img,mask);     // get a mask to differentiate background
                                // and object.

 // get the biggest object on the mask
 lti::objectsFromMask ofm;
 std::list<areaPoints> objs;
 ofm.apply(mask,objs); // the first object on "objs" is the biggest one
                       // on the mask!
 // get a new image with the biggest object only
 lti::boundingBox<image::value_type> bbox;
 lti::boundingBox<image::value_type>::parameters bboxParam;
 bboxParam.borderSize = 5; // the border will have 5 pixels (each side!)
 bboxParam.centerOfGravity = false;
 bbox.apply(img,objs.front(),biggestObject);

Constructor & Destructor Documentation

template<class T>
lti::boundingBox< T >::boundingBox (  ) 

default constructor

template<class T>
lti::boundingBox< T >::boundingBox ( const boundingBox< T > &  other  ) 

copy constructor

Parameters:
other the object to be copied
template<class T>
virtual lti::boundingBox< T >::~boundingBox (  )  [virtual]

destructor


Member Function Documentation

template<class T>
bool lti::boundingBox< T >::apply ( const pointList obj,
rectLocation loc 
) const

computes the oriented rectangular bounding box for the given point list, and leaves the result as a rectLocation.

Parameters:
obj point list the object description
loc the rectangular location will represent the smallest rectangular region that contains all points of the list.
Returns:
true if successful, false otherwise.
template<class T>
bool lti::boundingBox< T >::apply ( const ioPoints obj,
rectLocation loc 
) const

computes the oriented rectangular bounding box for the given io points, and leaves the result as a rectLocation.

Parameters:
obj io points with the object description
loc the rectangular location will represent the smallest rectangular region that contains all points of the io points obj.
Returns:
true if successful, false otherwise.
template<class T>
bool lti::boundingBox< T >::apply ( const areaPoints obj,
rectLocation loc 
) const

computes the oriented rectangular bounding box for the given area points, and leaves the result as a rectLocation.

Parameters:
obj areaPoints with the object description
loc the rectangular location will represent the smallest rectangular region that contains all points of the areaPoints obj.
Returns:
true if successful, false otherwise.
template<class T>
bool lti::boundingBox< T >::apply ( const matrix< T > &  src,
const areaPoints obj,
matrix< T > &  dest,
rectLocation loc 
) const

Take the object specified by the area points on the given contour, and create a new image with only the object and a border of the specified size on the srcdest.

Parameters:
src matrix with the source data.
obj the areaPoints list which specifies which points of the image belong to the object. The boundary must be calculated before calling this member (i.e. you need to call obj.computeBoundary()). This is not done automatically, because many functors (like lti::objectsFromMask) compute the bounding box directly and computing it twice can cost too much time!
dest matrix where the destination data will be stored.
loc a rectangular location that indicates the smallest rectangular region that contains the hole object
Returns:
true if successful, false otherwise
template<class T>
bool lti::boundingBox< T >::apply ( const matrix< T > &  src,
const areaPoints obj,
matrix< T > &  dest 
) const

Take the object specified by the area points on the given contour, and create a new image with only the object and a border of the specified size on the srcdest.

Parameters:
src matrix with the source data.
obj the areaPoints list which specifies which points of the image belong to the object. The boundary must be calculated before calling this member (i.e. you need to call obj.computeBoundary()). This is not done automatically, because many functors (like lti::objectsFromMask) compute the bounding box directly and computing it twice can cost too much time!
dest matrix where the destination data will be stored.
Returns:
true if successful, false otherwise
template<class T>
bool lti::boundingBox< T >::apply ( matrix< T > &  srcdest,
const areaPoints obj 
) const

Take the object specified by the area points, and create a new image with only the object and a border of the specified size on the srcdest.

Parameters:
srcdest matrix with the source data. The result will be left here too.
obj a contour which specifies which points of the image belong to the object. Only the area points, center and boundary points
Returns:
true if successful, false otherwise
template<class T>
void lti::boundingBox< T >::calculatePositions ( const areaPoints obj,
point destSize,
point delta 
) const [protected]

calculate the source box of the source image, the size of the destination image, and the position of the box on the destination image.

Parameters:
obj the area points of the object. It is assumed that the boundary of the object is up to date. (see lti::pointList::updateBoundary())
destSize size of the destination image
delta translation vector of the area points to the new image.
template<class T>
virtual functor* lti::boundingBox< T >::clone (  )  const [virtual]

returns a pointer to a clone of this functor.

Reimplemented from lti::segmentation.

template<class T>
void lti::boundingBox< T >::computeLocation ( const pointList pts,
rectLocation loc 
) const [protected]

compute the location given the angle in the location.

template<class T>
bool lti::boundingBox< T >::computeLocationFromCH ( const pointList convexHull,
rectLocation loc 
) const [protected]

location from the convex hull

template<class T>
boundingBox& lti::boundingBox< T >::copy ( const boundingBox< T > &  other  ) 

copy data of "other" functor.

Parameters:
other the functor to be copied
Returns:
a reference to this functor object

Reimplemented from lti::segmentation.

template<class T>
const parameters& lti::boundingBox< T >::getParameters (  )  const

returns used parameters

Reimplemented from lti::functor.

template<class T>
virtual const char* lti::boundingBox< T >::getTypeName (  )  const [virtual]

returns the name of this type ("boundingBox")

Reimplemented from lti::segmentation.


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

Generated on Sat Apr 10 15:27:04 2010 for LTI-Lib by Doxygen 1.6.1