#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"
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) |
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 > | |
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 > ¢er, 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 > ¢er, 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) |
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 > | |
Image< T > | shuffleImage (const Image< T > &img) |
Filtering operations on Image
Definition in file FilterOps.C.
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().
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().
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.
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().
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().
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().
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().
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().
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().
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().
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.
void gradientSobel | ( | const Image< T > & | input, | |
Image< typename promote_trait< T, float >::TP > & | mag, | |||
Image< typename promote_trait< T, float >::TP > & | ori, | |||
int | kernelSize | |||
) | [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().
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.
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
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().
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.
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
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().
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.
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
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().
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.
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
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().
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().
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.
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().