Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

FilterOps.C File Reference


Detailed Description

Filtering operations on Image

Definition in file FilterOps.C.

#include "Image/FilterOps.H"
#include "Image/Image.H"
#include "Image/Kernels.H"
#include "Image/MathOps.H"
#include "Image/Pixels.H"
#include "Util/Assert.H"
#include "Util/MathFunctions.H"
#include "Util/Promotions.H"
#include "Util/log.H"
#include "rutz/trace.h"
#include <algorithm>
#include <cmath>
#include <limits>
#include "inst/Image/FilterOps.I"

Include dependency graph for FilterOps.C:

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<class T>
Image< typename promote_trait<
T, float >::TP > 
templMatch (const Image< T > &src, const Image< float > &filter, int method)
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.
void trigtab_init ()
template<class T>
Image< typename promote_trait<
T, float >::TP > 
orientedFilter (const Image< T > &src, const float k, const float theta, const float intensity, const bool usetab)
template<class T>
Image< T > centerSurround (const Image< T > &center, const Image< T > &surround, const bool absol)
 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)
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 DstItr, class SrcItr>
void JFILT (DstItr dptr, SrcItr sptr, const int w, const int jmax, const int imax)
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 DstItr, class SrcItr>
void MSTFILT (DstItr dptr, SrcItr sptr, const int w, const int jmax, const int imax)
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)
 Compute the magnitude and orientation of the gradient using the sobel op.
template<class T>
Image< T > shuffleImage (const Image< T > &img)

Variables

pthread_once_t trigtab_init_once = PTHREAD_ONCE_INIT
const int TRIGTAB_SIZE = 256
double sintab [TRIGTAB_SIZE]
double costab [TRIGTAB_SIZE]


Function Documentation

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.

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 423 of file FilterOps.C.

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.

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 357 of file FilterOps.C.

Referenced by centerSurround(), centerSurroundDiff(), centerSurroundDiffSingleOpponent(), centerSurroundSingleOpponent(), ComputeCMAP(), computeCMAP(), BeoSubSaliency::computeCMAP(), SaliencyMT::computeCMAP(), doubleOpp(), CMap_i::getBiasCMAP(), RegSaliency::postChannel(), BeobotBrainMT::threadCompute(), and roRetina< T >::update().

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

(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 467 of file FilterOps.C.

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

template<class T>
Image<T> energyNorm const Image< T > &  img  ) 
 

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

Definition at line 554 of file FilterOps.C.

References GVX_TRACE, 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
 

Feature/spatial pooling for the S2 layer of Hmax.

Definition at line 209 of file FilterOps.C.

References ASSERT, Image< T >::begin(), Image< T >::getHeight(), Image< T >::getWidth(), GVX_TRACE, h, Image< T >::isSameSize(), rutz::min(), w, x, and y.

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
 

Compute the magnitude and orientation of the gradient.

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

Definition at line 1377 of file FilterOps.C.

References Image< T >::begin(), Image< T >::getDims(), Image< T >::getHeight(), Image< T >::getWidth(), GVX_TRACE, h, i, sqrt(), src, and w.

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

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 1291 of file FilterOps.C.

References Image< T >::begin(), Image< T >::beginw(), Image< T >::getDims(), Image< T >::getHeight(), Image< T >::getWidth(), GVX_TRACE, h, i, NO_INIT, sqrt(), src, and w.

Referenced by SpectralResidualChannel::getOutput(), and Image_xx_gradientmag_xx_1().

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

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 1334 of file FilterOps.C.

References Image< T >::begin(), Image< T >::beginw(), Image< T >::getDims(), Image< T >::getHeight(), Image< T >::getWidth(), GVX_TRACE, h, i, NO_INIT, src, and w.

Referenced by Image_xx_gradientori_xx_1().

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
 

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

Definition at line 1421 of file FilterOps.C.

References ASSERT, Image< T >::begin(), Image< T >::getDims(), Image< T >::getHeight(), Image< T >::getWidth(), GVX_TRACE, h, i, sqrt(), src, and w.

Referenced by Geons3D::calcGeonLikelihood(), TwoHalfDSketch::calcSketchLikelihood(), ObjRec::edgesLiklyProb(), V1::evolveCanny(), V1::evolveSobel(), Geons3D::getDebugImage(), ObjRecSPM::getSiftDescriptor(), ObjRec::initialProposal(), and main().

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.

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 576 of file FilterOps.C.

References ASSERT, Image< T >::begin(), Image< T >::beginw(), Image< T >::getDims(), Image< T >::getHeight(), Image< T >::getWidth(), GVX_TRACE, h, i, Image< T >::isSameSize(), rutz::max(), lobot::round(), sqrt(), w, 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
 

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 765 of file FilterOps.C.

References ASSERT, Image< T >::begin(), Image< T >::beginw(), fastSqrt(), Image< T >::getDims(), Image< T >::getHeight(), Image< T >::getWidth(), GVX_TRACE, h, i, Image< T >::isSameSize(), JFILT(), lobot::round(), w, 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
 

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 894 of file FilterOps.C.

References ASSERT, Image< T >::begin(), Image< T >::beginw(), Image< T >::getDims(), Image< T >::getHeight(), Image< T >::getWidth(), GVX_TRACE, h, i, Image< T >::isSameSize(), rutz::max(), lobot::round(), sqrt(), w, 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
 

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 1142 of file FilterOps.C.

References ASSERT, Image< T >::begin(), Image< T >::beginw(), fastSqrt(), Image< T >::getDims(), Image< T >::getHeight(), Image< T >::getWidth(), GVX_TRACE, h, i, Image< T >::isSameSize(), MSTFILT(), lobot::round(), w, and ZEROS.

Referenced by MSTChannel::doInput().

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.

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

Definition at line 171 of file FilterOps.C.

References Image< T >::begin(), Image< T >::beginw(), Image< T >::getHeight(), Image< T >::getWidth(), GVX_TRACE, h, i, rutz::min(), NO_INIT, source, and w.

Referenced by Hmax::getC1().


Generated on Mon Nov 23 15:48:25 2009 for iLab Neuromorphic Vision Toolkit by  doxygen 1.4.4