CVR-Lib last update 20 Sep 2009

cvr::integralImage Class Reference
[Linear filtering]

Class integralImage. More...

#include <cvrIntegralImage.h>

Inheritance diagram for cvr::integralImage:

Inheritance graph
[legend]
Collaboration diagram for cvr::integralImage:

Collaboration graph
[legend]

List of all members.

Classes

class  parameters
 The parameters for the class integralImage. More...

Public Member Functions

 integralImage ()
 integralImage (const eBoundaryType boundaryType)
 integralImage (const parameters &par)
 integralImage (const integralImage &other)
virtual ~integralImage ()
bool apply (const matrix< ubyte > &src, matrix< int32 > &dest) const
bool apply (const fmatrix &src, fmatrix &dest) const
integralImagecopy (const integralImage &other)
integralImageoperator= (const integralImage &other)
virtual const std::string & name () const
virtual integralImageclone () const
virtual integralImagenewInstance () const
const parametersgetParameters () const
bool updateParameters ()
Convenience window sums with boundary considerations.
This methods used the computed integral image to produce the sum of elements of the originary channel falling inside a given window.

These methods are relatively slow, since they check if a part of the window falls outside the image and take the necessary measures depending on the boundary type selected. The methods are designed to produce valid results if and only if at least a part of the window falls over the image.

If in your application you know for sure that the window falls completely inside the image, and at least with one pixel free on the top and left boundaries, then you may want to use the unchecked internalSum() methods.

The NoBoundary type will return 0 if any part of the given window falls outside the image.

You have to ensure that the from arguments correspond to the top-left corner or the window, and that the to arguments correspond to the bottom-right one.

Warning:
Invalid results are provided if the complete window falls outside the image. You must ensure that the image is not empty when you call these methods.


int32 sum (const matrix< int32 > &intImage, const irectangle &rect) const
int32 sum (const matrix< int32 > &intImage, const ipoint &from, const ipoint &to) const
int32 sum (const matrix< int32 > &intImage, const int fromX, const int fromY, const int toX, const int toY) const
float sum (const fmatrix &intImage, const irectangle &rect) const
float sum (const fmatrix &intImage, const ipoint &from, const ipoint &to) const
float sum (const matrix< float > &intImage, const int fromX, const int fromY, const int toX, const int toY) const
Convenience window sums without boundary considerations.
These methods use the computed integral image to produce the sum of elements of the originary channel falling inside a given window.

They are relatively fast, since they assume that the complete window falls into the image and at least one pixel border has been left on the top and on the left. If this is not the case, you have to use the sum() methods instead.

Warning:
If this condition is not met, the debug version will report an assert when accessing the matrix at invalid indices, and the release version probably will crash due to a segmentation fault.
This method is used when you know for sure that the window falls completely inside the image, and leaves at least one pixel free on the top and left boundaries.

int32 internalSum (const matrix< int32 > &intImage, const irectangle &rect) const
int32 internalSum (const matrix< int32 > &intImage, const ipoint &from, const ipoint &to) const
int32 internalSum (const matrix< int32 > &intImage, const int fromX, const int fromY, const int toX, const int toY) const
float internalSum (const fmatrix &intImage, const irectangle &rect) const
float internalSum (const fmatrix &intImage, const ipoint &from, const ipoint &to) const
float internalSum (const matrix< float > &intImage, const int fromX, const int fromY, const int toX, const int toY) const


Detailed Description

Class integralImage.

The integral image, (which in the CVR-Lib should it be better called the integral channel, but for consistency with the literature we leave it as is) is the image $I_\Sigma(x,y)$ obtained from the channel $I(x,y)$ with the following convention:

\[ I_\Sigma(x,y) = \sum_{i=0}^{x}\sum_{j=0}^{y} I(i,j) \]

From this integral image, the computation of any sum of intensities over any upright, rectangular area can be done with only four additions, independent of the area size.

The computation of the integral image is very efficient. It needs just one pass of the orignal image to be obtained, with just two additions per pixel.

The class provides a collection of useful methods to compute the sum of elements in a rectangular window, for which the parameter boundaryType makes a lot of sense.

See also:
integralImage::parameters.

Constructor & Destructor Documentation

cvr::integralImage::integralImage (  ) 

Default constructor.

cvr::integralImage::integralImage ( const eBoundaryType  boundaryType  ) 

Construct with the given boundary type.

cvr::integralImage::integralImage ( const parameters par  ) 

Construct a functor using the given parameters.

cvr::integralImage::integralImage ( const integralImage other  ) 

Copy constructor.

Parameters:
other the object to be copied

virtual cvr::integralImage::~integralImage (  )  [virtual]

Destructor.


Member Function Documentation

bool cvr::integralImage::apply ( const fmatrix src,
fmatrix dest 
) const

Compute the integral image of an fmatrix.

Parameters:
src fmatrix with the source data.
dest fmatrix where the result will be left.
Returns:
true if apply successful or false otherwise.

bool cvr::integralImage::apply ( const matrix< ubyte > &  src,
matrix< int32 > &  dest 
) const

Compute the integral image of a ubyte matrix.

Parameters:
src matrix<ubyte> with the source data.
dest matrix<ubyte> where the result will be left.
Returns:
true if apply successful or false otherwise.

virtual integralImage* cvr::integralImage::clone (  )  const [virtual]

Returns a pointer to a clone of this functor.

Implements cvr::functor.

integralImage& cvr::integralImage::copy ( const integralImage other  ) 

Copy data of "other" functor.

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

const parameters& cvr::integralImage::getParameters (  )  const

Returns used parameters.

Reimplemented from cvr::parametersManager.

float cvr::integralImage::internalSum ( const matrix< float > &  intImage,
const int  fromX,
const int  fromY,
const int  toX,
const int  toY 
) const [inline]

Convenience method to use the computed integral image to produce the sum of the results in the provided rectangle.

Parameters:
intImage an integral image computed with apply()
fromX initial x coordinate of area to be summed.
fromY initial y coordinate of area to be summed.
toX final x coordinate of area to be summed.
toY final y coordinate of area to be summed.
Returns:
the computed sum

float cvr::integralImage::internalSum ( const fmatrix intImage,
const ipoint from,
const ipoint to 
) const [inline]

Convenience method to use the computed integral image to produce the sum of the results in the provided rectangle.

Parameters:
intImage an integral image computed with apply()
from initial point of area to be summed.
to final point of area to be summed.
Returns:
the computed sum

float cvr::integralImage::internalSum ( const fmatrix intImage,
const irectangle rect 
) const [inline]

Convenience method to use the computed integral image to produce the sum of the results in the provided rectangle.

Parameters:
intImage an integral image computed with apply()
rect the delimiter of a window whose pixels have to be sumed.
Returns:
the computed sum

int32 cvr::integralImage::internalSum ( const matrix< int32 > &  intImage,
const int  fromX,
const int  fromY,
const int  toX,
const int  toY 
) const [inline]

Convenience method to use the computed integral image to produce the sum of the results in the provided rectangle.

Parameters:
intImage an integral image computed with apply()
fromX initial x coordinate of area to be summed.
fromY initial y coordinate of area to be summed.
toX final x coordinate of area to be summed.
toY final y coordinate of area to be summed.
Returns:
the computed sum

int32 cvr::integralImage::internalSum ( const matrix< int32 > &  intImage,
const ipoint from,
const ipoint to 
) const [inline]

Convenience method to use the computed integral image to produce the sum of the results in the provided rectangle.

Parameters:
intImage an integral image computed with apply()
from initial point of area to be summed.
to final point of area to be summed.
Returns:
the computed sum

int32 cvr::integralImage::internalSum ( const matrix< int32 > &  intImage,
const irectangle rect 
) const [inline]

Convenience method to use the computed integral image to produce the sum of the results in the provided rectangle.

Parameters:
intImage an integral image computed with apply()
rect the delimiter of a window whose pixels have to be sumed.

virtual const std::string& cvr::integralImage::name (  )  const [virtual]

Returns the complete name of the functor class.

Implements cvr::functor.

virtual integralImage* cvr::integralImage::newInstance (  )  const [virtual]

Returns a pointer to a new instance of this functor.

Implements cvr::functor.

integralImage& cvr::integralImage::operator= ( const integralImage other  ) 

Alias for copy member.

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

float cvr::integralImage::sum ( const matrix< float > &  intImage,
const int  fromX,
const int  fromY,
const int  toX,
const int  toY 
) const [inline]

Convenience method to use the computed integral image to produce the sum of the results in the provided rectangle.

Parameters:
intImage an integral image computed with apply()
fromX initial x coordinate of area to be summed.
fromY initial y coordinate of area to be summed.
toX final x coordinate of area to be summed.
toY final y coordinate of area to be summed.
Returns:
the computed sum

float cvr::integralImage::sum ( const fmatrix intImage,
const ipoint from,
const ipoint to 
) const [inline]

Convenience method to use the computed integral image to produce the sum of the results in the provided rectangle.

Parameters:
intImage an integral image computed with apply()
from initial point of area to be summed.
to final point of area to be summed.
Returns:
the computed sum

float cvr::integralImage::sum ( const fmatrix intImage,
const irectangle rect 
) const [inline]

Convenience method to use the computed integral image to produce the sum of the results in the provided rectangle.

Parameters:
intImage an integral image computed with apply()
rect the delimiter of a window whose pixels have to be sumed.
Returns:
the computed sum

int32 cvr::integralImage::sum ( const matrix< int32 > &  intImage,
const int  fromX,
const int  fromY,
const int  toX,
const int  toY 
) const [inline]

Convenience method to use the computed integral image to produce the sum of the results in the provided rectangle.

Parameters:
intImage an integral image computed with apply()
fromX initial x coordinate of area to be summed.
fromY initial y coordinate of area to be summed.
toX final x coordinate of area to be summed.
toY final y coordinate of area to be summed.
Returns:
the computed sum

int32 cvr::integralImage::sum ( const matrix< int32 > &  intImage,
const ipoint from,
const ipoint to 
) const [inline]

Convenience method to use the computed integral image to produce the sum of the results in the provided rectangle.

Parameters:
intImage an integral image computed with apply()
from initial point of area to be summed.
to final point of area to be summed.
Returns:
the computed sum

int32 cvr::integralImage::sum ( const matrix< int32 > &  intImage,
const irectangle rect 
) const [inline]

Convenience method to use the computed integral image to produce the sum of the results in the provided rectangle.

Parameters:
intImage an integral image computed with apply()
rect the delimiter of a window whose pixels have to be sumed.

bool cvr::integralImage::updateParameters (  )  [virtual]

Update parameters.

Reimplemented from cvr::parametersManager.


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

Generated on Sun Sep 20 22:08:47 2009 for CVR-Lib by Doxygen 1.5.8