FilterOps.H File Reference

#include "Util/Promotions.H"
#include "Image/Convolutions.H"
#include "Image/LowPass.H"
Include dependency graph for FilterOps.H:

Go to the source code of this file.

Functions

template<class T >
Image< typename promote_trait
< T, float >::TP > 
correlation (const Image< T > &src, const Image< float > &filter)
 template matching correlation
template<class T >
Image< typename promote_trait
< T, float >::TP > 
templMatch (const Image< T > &src, const Image< float > &filter, int method=0)
template<class T >
Image< typename promote_trait
< T, float >::TP > 
spatialPoolMax (const Image< T > &src, const int si, const int sj, const int sti, const int stj)
 Spatial pooling taking the max value over a neighborhood.
template<class T >
float featurePoolHmax (const Image< T > &img1, const Image< T > &img2, const Image< T > &img3, const Image< T > &img4, const int si, const int sj, const float s2t)
 Feature/spatial pooling for the S2 layer of Hmax.
template<class T_or_RGB >
Image< typename promote_trait
< T_or_RGB, float >::TP > 
orientedFilter (const Image< T_or_RGB > &src, const float k, const float theta, const float intensity=1.0, const bool usetab=false)
 Oriented filter along theta (deg), spatial freq k.
template<class T >
Image< T > centerSurround (const Image< T > &center, const Image< T > &surround, const bool absol=false)
 Compute center-surround difference, taking the abs if absol==true.
template<class T >
void centerSurround (const Image< T > &center, const Image< T > &surround, Image< T > &pos, Image< T > &neg)
 Compute center-surround difference, without clamping or rectifying.
template<class T >
Image< typename promote_trait
< T, float >::TP > 
doubleOpp (const Image< T > &cplus, const Image< T > &cminus, const Image< T > &splus, const Image< T > &sminus)
 compute double-opponent response
template<class T >
void avgOrient (const Image< T > &src, Image< float > &orient, Image< float > &strength)
 Compute average orientation and strength using steerable filters.
template<class T >
Image< T > energyNorm (const Image< T > &img)
 Divide image by the local image energy, then subtract overall mean.
template<class T >
Image< T > junctionFilterFull (const Image< T > &i0, const Image< T > &i45, const Image< T > &i90, const Image< T > &i135, const bool r[8], const int dx=6, const int dy=6, const bool useEuclidDiag=true)
 Compute response of a junction detector filter.
template<class T >
Image< T > junctionFilterPartial (const Image< T > &i0, const Image< T > &i45, const Image< T > &i90, const Image< T > &i135, const bool r[8], const int dx=6, const int dy=6, const bool useEuclidDiag=false)
 Compute response of a junction detector filter, partial implementation.
template<class T >
Image< T > MSTFilterFull (const Image< T > &i0, const Image< T > &i45, const Image< T > &i90, const Image< T > &i135, const bool r[8], const int dx=6, const int dy=6, const bool useEuclidDiag=true)
 Compute response of a MST detector filter.
template<class T >
Image< T > MSTFilterPartial (const Image< T > &i0, const Image< T > &i45, const Image< T > &i90, const Image< T > &i135, const bool r[8], const int dx=6, const int dy=6, const bool useEuclidDiag=false)
 Compute response of a MST detector filter, partial implementation.
template<class T >
Image< typename promote_trait
< T, float >::TP > 
gradientmag (const Image< T > &input)
 Compute the magnitude of the gradient of an image.
template<class T >
Image< typename promote_trait
< T, float >::TP > 
gradientori (const Image< T > &input)
 Compute the orientation of the gradient of an image.
template<class T >
void gradient (const Image< T > &input, Image< typename promote_trait< T, float >::TP > &mag, Image< typename promote_trait< T, float >::TP > &ori)
 Compute the magnitude and orientation of the gradient.
template<class T >
void gradientSobel (const Image< T > &input, Image< typename promote_trait< T, float >::TP > &mag, Image< typename promote_trait< T, float >::TP > &ori, int kernelSize=3)
 Compute the magnitude and orientation of the gradient using the sobel op.
Image< float > nonMaxSuppr (const Image< float > &mag, const Image< float > &ori)
 Compute the non maximal suppression (edge thinning).
template<class T_or_RGB >
Image< T_or_RGB > shuffleImage (const Image< T_or_RGB > &img)
 shuffle the contents of an image using Fisher-Yates shuffle

Detailed Description

Filtering operations on Image

Definition in file FilterOps.H.


Function Documentation

template<class T >
void avgOrient ( const Image< T > &  src,
Image< float > &  orient,
Image< float > &  strength 
) [inline]

Compute average orientation and strength using steerable filters.

Definition at line 473 of file FilterOps.C.

References Image< T >::begin(), Image< T >::beginw(), CONV_BOUNDARY_ZERO, Image< T >::getDims(), Image< T >::getSize(), NO_INIT, sepFilter(), sqrt(), and squareOf().

template<class T >
void centerSurround ( const Image< T > &  center,
const Image< T > &  surround,
Image< T > &  pos,
Image< T > &  neg 
) [inline]

Compute center-surround difference, without clamping or rectifying.

To the (hires) center will be substracted a (lowres) surround. Image sizes must be int multiples. This is implemented in a different function from centerSurround() as it returns two images, for the positive and negative values of the difference

Definition at line 409 of file FilterOps.C.

References Image< T >::begin(), Image< T >::beginw(), Image< T >::getDims(), Image< T >::getHeight(), Image< T >::getWidth(), inplaceAttenuateBorders(), Dims::max(), NO_INIT, and Image< T >::resize().

template<class T >
Image<T> centerSurround ( const Image< T > &  center,
const Image< T > &  surround,
const bool  absol = false 
) [inline]

Compute center-surround difference, taking the abs if absol==true.

To the (hires) center will be substracted a (lowres) surround. Image sizes must be int multiples. CAUTION: values will be clamped to the range of your template type.

Parameters:
absol if true, take the absolute value of the difference (otherwise, negative values are clamped to zero).

Definition at line 343 of file FilterOps.C.

References Image< T >::begin(), Image< T >::getDims(), Image< T >::getHeight(), Image< T >::getWidth(), inplaceAttenuateBorders(), and NO_INIT.

Referenced by centerSurround(), centerSurroundDiff(), centerSurroundDiffSingleOpponent(), centerSurroundSingleOpponent(), SaliencyMT::computeCMAP(), BeoSubSaliency::computeCMAP(), computeCMAP(), doubleOpp(), and BeobotBrainMT::threadCompute().

template<class T >
Image<typename promote_trait<T, float>::TP> correlation ( const Image< T > &  src,
const Image< float > &  filter 
) [inline]

template matching correlation

Definition at line 57 of file FilterOps.C.

References ASSERT, Image< T >::begin(), Image< T >::beginw(), Image< T >::getHeight(), Image< T >::getWidth(), Image< T >::initialized(), and NO_INIT.

Referenced by templMatch().

template<class T >
Image<typename promote_trait<T, float>::TP> doubleOpp ( const Image< T > &  cplus,
const Image< T > &  cminus,
const Image< T > &  splus,
const Image< T > &  sminus 
) [inline]

compute double-opponent response

(cplus - cminus) [-] (splus - sminus) where [-] is subtraction of two images of possibly different sizes, followed by absolute value. The result will have the size of the larger (center) image.

Definition at line 453 of file FilterOps.C.

References ASSERT, centerSurround(), and Image< T >::isSameSize().

template<class T >
Image<T> energyNorm ( const Image< T > &  img  )  [inline]

Divide image by the local image energy, then subtract overall mean.

Definition at line 540 of file FilterOps.C.

References lowPass9(), mean(), and sqrt().

Referenced by buildPyrGabor(), and doEnergyNorm().

template<class T >
float featurePoolHmax ( const Image< T > &  img1,
const Image< T > &  img2,
const Image< T > &  img3,
const Image< T > &  img4,
const int  si,
const int  sj,
const float  s2t 
) [inline]

Feature/spatial pooling for the S2 layer of Hmax.

Definition at line 195 of file FilterOps.C.

References ASSERT, Image< T >::begin(), Image< T >::getHeight(), Image< T >::getWidth(), Image< T >::isSameSize(), and min().

Referenced by Hmax::getC2().

template<class T >
void gradient ( const Image< T > &  input,
Image< typename promote_trait< T, float >::TP > &  mag,
Image< typename promote_trait< T, float >::TP > &  ori 
) [inline]

Compute the magnitude and orientation of the gradient.

This is just an efficient combination of gradientmag() and gradientori()

Definition at line 1363 of file FilterOps.C.

References Image< T >::begin(), Image< T >::getDims(), Image< T >::getHeight(), Image< T >::getWidth(), and sqrt().

template<class T >
Image<typename promote_trait<T, float>::TP> gradientmag ( const Image< T > &  input  )  [inline]

Compute the magnitude of the gradient of an image.

This is an approximation to the gradient magnitude as used in the SIFT code. output(x, y) = sqrt([input(x+1, y) - input(x-1, y)]^2 + [input(x, y+1) - input(x, y-1)]^2)

Definition at line 1277 of file FilterOps.C.

References Image< T >::begin(), Image< T >::getDims(), Image< T >::getHeight(), Image< T >::getWidth(), NO_INIT, and sqrt().

Referenced by SpectralResidualChannel::getOutput().

template<class T >
Image<typename promote_trait<T, float>::TP> gradientori ( const Image< T > &  input  )  [inline]

Compute the orientation of the gradient of an image.

This is an approximation to the gradient orientation as used in the SIFT code. output(x, y) = atan2(input(x, y+1) - input(x, y-1), input(x+1, y) - input(x-1, y)). Result is in radians. A value of 0 corresponds to a purely horizontal rightward gradient, other values relating to that in a clockwise manner.

Definition at line 1320 of file FilterOps.C.

References Image< T >::begin(), Image< T >::getDims(), Image< T >::getHeight(), Image< T >::getWidth(), and NO_INIT.

template<class T >
void gradientSobel ( const Image< T > &  input,
Image< typename promote_trait< T, float >::TP > &  mag,
Image< typename promote_trait< T, float >::TP > &  ori,
int  kernelSize = 3 
) [inline]

Compute the magnitude and orientation of the gradient using the sobel op.

Definition at line 1407 of file FilterOps.C.

References ASSERT, Image< T >::begin(), Image< T >::getDims(), Image< T >::getHeight(), Image< T >::getWidth(), and sqrt().

Referenced by HistogramOfGradients::calculateGradient(), and ColorHist::createFeatureVector().

template<class T >
Image<T> junctionFilterFull ( const Image< T > &  i0,
const Image< T > &  i45,
const Image< T > &  i90,
const Image< T > &  i135,
const bool  r[8],
const int  dx = 6,
const int  dy = 6,
const bool  useEuclidDiag = true 
) [inline]

Compute response of a junction detector filter.

In the full implementation here, the junction filter responds only if the relevant features are present and the irrelevant features are absent.

Parameters:
i0 image filtered by a 0deg (horisontal) Gabor filter
i45 image filtered by a 45deg Gabor filter
i90 image filtered by a 90deg (vertical) Gabor filter
i135 image filtered by a 135deg Gabor filter
r boolean array of which features are considered relevant to the junction. The first element is for the horizontal (i0) feature at (x+dx, y), the second for the 45deg (i45) feature at (x+dx, y-dy), and so on, going counterclockwise:

: 3 2 1 : \ | / : 4 -- o -- 0 : / | \ : 5 6 7

Parameters:
dx horizontal distance from current pixel at which the presence or absence of a given feature should be checked for.
dy vertical distance from current pixel at which the presence or absence of a given feature should be checked for.

Definition at line 562 of file FilterOps.C.

References ASSERT, Image< T >::begin(), Image< T >::getDims(), Image< T >::getHeight(), Image< T >::getWidth(), Image< T >::isSameSize(), max(), sqrt(), and ZEROS.

Referenced by JunctionChannel::doInput().

template<class T >
Image<T> junctionFilterPartial ( const Image< T > &  i0,
const Image< T > &  i45,
const Image< T > &  i90,
const Image< T > &  i135,
const bool  r[8],
const int  dx = 6,
const int  dy = 6,
const bool  useEuclidDiag = false 
) [inline]

Compute response of a junction detector filter, partial implementation.

In the partial implementation here, the junction filter responds when the relevant features are present, without consideration of what the values of the irrelevant features might be.

Parameters:
i0 image filtered by a 0deg (horisontal) Gabor filter
i45 image filtered by a 45deg Gabor filter
i90 image filtered by a 90deg (vertical) Gabor filter
i135 image filtered by a 135deg Gabor filter
r boolean array of which features are considered relevant to the junction. The first element is for the horizontal (i0) feature at (x+dx, y), the second for the 45deg (i45) feature at (x+dx, y-dy), and so on, going counterclockwise:

: 3 2 1 : \ | / : 4 -- o -- 0 : / | \ : 5 6 7

Parameters:
dx horizontal distance from current pixel at which the presence or absence of a given feature should be checked for.
dy vertical distance from current pixel at which the presence or absence of a given feature should be checked for.

Definition at line 751 of file FilterOps.C.

References ASSERT, Image< T >::begin(), fastSqrt(), Image< T >::getDims(), Image< T >::getHeight(), Image< T >::getWidth(), Image< T >::isSameSize(), and ZEROS.

Referenced by JunctionChannel::doInput().

template<class T >
Image<T> MSTFilterFull ( const Image< T > &  i0,
const Image< T > &  i45,
const Image< T > &  i90,
const Image< T > &  i135,
const bool  r[8],
const int  dx = 6,
const int  dy = 6,
const bool  useEuclidDiag = true 
) [inline]

Compute response of a MST detector filter.

In the full implementation here, the MST filter responds only if the relevant features are present and the irrelevant features are absent.

Parameters:
i0 image filtered by a 0deg (horisontal) Gabor filter
i45 image filtered by a 45deg Gabor filter
i90 image filtered by a 90deg (vertical) Gabor filter
i135 image filtered by a 135deg Gabor filter
r boolean array of which features are considered relevant to the MST. The first element is for the horizontal (i0) feature at (x+dx, y), the second for the 45deg (i45) feature at (x+dx, y-dy), and so on, going counterclockwise:

: 3 2 1 : \ | / : 4 -- o -- 0 : / | \ : 5 6 7

Parameters:
dx horizontal distance from current pixel at which the presence or absence of a given feature should be checked for.
dy vertical distance from current pixel at which the presence or absence of a given feature should be checked for.

Definition at line 880 of file FilterOps.C.

References ASSERT, Image< T >::begin(), Image< T >::getDims(), Image< T >::getHeight(), Image< T >::getWidth(), Image< T >::isSameSize(), max(), sqrt(), and ZEROS.

Referenced by MSTChannel::doInput().

template<class T >
Image<T> MSTFilterPartial ( const Image< T > &  i0,
const Image< T > &  i45,
const Image< T > &  i90,
const Image< T > &  i135,
const bool  r[8],
const int  dx = 6,
const int  dy = 6,
const bool  useEuclidDiag = false 
) [inline]

Compute response of a MST detector filter, partial implementation.

In the partial implementation here, the MST filter responds when the relevant features are present, without consideration of what the values of the irrelevant features might be.

Parameters:
i0 image filtered by a 0deg (horisontal) Gabor filter
i45 image filtered by a 45deg Gabor filter
i90 image filtered by a 90deg (vertical) Gabor filter
i135 image filtered by a 135deg Gabor filter
r boolean array of which features are considered relevant to the MST. The first element is for the horizontal (i0) feature at (x+dx, y), the second for the 45deg (i45) feature at (x+dx, y-dy), and so on, going counterclockwise:

: 3 2 1 : \ | / : 4 -- o -- 0 : / | \ : 5 6 7

Parameters:
dx horizontal distance from current pixel at which the presence or absence of a given feature should be checked for.
dy vertical distance from current pixel at which the presence or absence of a given feature should be checked for.

Definition at line 1128 of file FilterOps.C.

References ASSERT, Image< T >::begin(), fastSqrt(), Image< T >::getDims(), Image< T >::getHeight(), Image< T >::getWidth(), Image< T >::isSameSize(), and ZEROS.

Referenced by MSTChannel::doInput().

Image<float> nonMaxSuppr ( const Image< float > &  mag,
const Image< float > &  ori 
)

Compute the non maximal suppression (edge thinning).

Definition at line 1506 of file FilterOps.C.

References Image< T >::coordsOk(), Image< T >::getHeight(), Image< T >::getVal(), Image< T >::getWidth(), and Image< T >::setVal().

template<class T_or_RGB >
Image<typename promote_trait<T_or_RGB, float>::TP> orientedFilter ( const Image< T_or_RGB > &  src,
const float  k,
const float  theta,
const float  intensity = 1.0,
const bool  usetab = false 
) [inline]

Oriented filter along theta (deg), spatial freq k.

This filter works on the difference between the image and itself low-passed. It modulates this difference by a complex sinusoid, and then low-passes the real and imaginary parts, and finally takes the modulus. This method is by Greenspan et al. (1994). CAUTION: *you* must provide as input (i.e., in "this") the difference between an image and itself low-pass filtered. CAUTION: results are possibly bad with the integer versions. Use float.

Parameters:
usetab Whether to use trig lookup tables internally to get sin and cos values. This may give up to a 2x speedup, at the cost of some minor loss of precision,

Referenced by orientedFilterSet().

template<class T_or_RGB >
Image<T_or_RGB> shuffleImage ( const Image< T_or_RGB > &  img  )  [inline]

shuffle the contents of an image using Fisher-Yates shuffle

template<class T >
Image<typename promote_trait<T, float>::TP> spatialPoolMax ( const Image< T > &  src,
const int  si,
const int  sj,
const int  sti,
const int  stj 
) [inline]

Spatial pooling taking the max value over a neighborhood.

Compute max over a rectangle of size (si, sj) starting at positions that increment in steps (sti, stj)

Definition at line 157 of file FilterOps.C.

References Image< T >::begin(), Image< T >::beginw(), Image< T >::getHeight(), Image< T >::getWidth(), min(), and NO_INIT.

template<class T >
Image<typename promote_trait<T, float>::TP> templMatch ( const Image< T > &  src,
const Image< float > &  filter,
int  method = 0 
) [inline]

template matching useing opencv defaults to correlation if no openCV installed defaults to CV_TM_SQDIFF

Definition at line 126 of file FilterOps.C.

References ASSERT, correlation(), Image< T >::getHeight(), Image< T >::getWidth(), Image< T >::initialized(), and NO_INIT.

Referenced by SingleChannel::combineSubMaps().

Generated on Sun May 8 08:12:41 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3