MathOps.H File Reference

#include "Image/Image.H"
#include "Util/Promotions.H"
#include "Image/Pixels.H"
#include <vector>
Include dependency graph for MathOps.H:

Go to the source code of this file.

Functions

template<class T , class F >
fill (Image< T > &x, F func)
 fill with a generating function: x = func() for each x in image
template<class T , class F >
apply (Image< T > &x, F func)
 apply a function in-place: x = func(x) for each x in image
template<class T2 , class T , class F >
Image< T2 > transform (const Image< T > &x, F func)
 apply a function out-of-place: y = func(x) for x in input, y in output
template<class T >
double sum (const Image< T > &a)
 Returns the sum of all input pixels.
template<class T >
double mean (const Image< T > &a)
 Get the average of all input pixels.
template<class T >
double stdev (const Image< T > &a)
 compute standard deviation of pixel values over image
template<class T >
Range< T > rangeOf (const Image< T > &img)
 Get the min/max range of the input pixels.
template<class T >
Image< T > remapRange (const Image< T > &img, const Range< T > &from, const Range< T > &to)
 Linearly remap pixels from the source to dest dynamic ranges.
template<class T >
Image< T > squared (const Image< T > &a)
 Square each element of the input image.
template<class T >
Image< typename promote_trait
< T, float >::TP > 
toPower (const Image< T > &a, double pow)
 Raise each element of the input image to the given power.
template<class T >
Image< typename promote_trait
< T, float >::TP > 
toPowerRegion (const Image< T > &a, double pow, std::vector< Point2D< int > > region)
 Raise pixels in given region of an input image to the given power. Pass a vector of 2D points that define the region of the image that you want to enhance.
template<class T >
Image< T > abs (const Image< T > &a)
 Take absolute value of every pixel.
template<class T >
Image< typename promote_trait
< T, float >::TP > 
hmaxActivation (const Image< T > &a, const float sigma)
 Compute exp(pixel / (2 * sigma^2)) for every pixel.
template<class T_or_RGB >
Image< T_or_RGB > absDiff (const Image< T_or_RGB > &b, const Image< T_or_RGB > &c)
 Returns abs(b - c) for each color channel.
template<class T_or_RGB >
Image< T_or_RGB > clampedDiff (const Image< T_or_RGB > &b, const Image< T_or_RGB > &c)
 Returns (b - c), clamping to zero all negative values.
template<class T >
Image< T > binaryReverse (const Image< T > &a, const T val)
 Returns (val - a).
template<class T >
Image< T > average (const Image< T > &b, const Image< T > &c)
 Returns (b + c) / 2, clean & prevents overflows.
template<class T >
Image< T > averageWeighted (Image< T > &a, const Image< T > &b, T *aWeight)
 Returns (a*w + b) / 2, the weighted average between images.
template<class T_or_RGB >
Image< T_or_RGB > takeMax (const Image< T_or_RGB > &a, const Image< T_or_RGB > &b)
 Returns max(a, b), element by element.
template<class T >
void takeLinkedMax (const Image< T > &a1, const Image< T > &a2, const Image< T > &b1, const Image< T > &b2, Image< T > &aout, Image< T > &bout)
 Take element-wise max of a1,a2 and use that to choose b1,b2, storing a[12] result into aout and b[12] result into bout.
template<class T >
Image< T > takeMin (const Image< T > &a, const Image< T > &b)
 Returns min(a, b), element by element.
template<class T_or_RGB >
Image< T_or_RGB > quadEnergy (const Image< T_or_RGB > &img1, const Image< T_or_RGB > &img2)
 Compute energy for quadrature pair (sqrt(img1^2 + img2^2)).
template<class T >
double RMSerr (const Image< T > &arr1, const Image< T > &arr2)
 RMS error between arr1 and arr2.
template<class T_or_RGB >
Image< T_or_RGB > overlay (const Image< T_or_RGB > &top, const Image< T_or_RGB > &bottom, const float trans)
 Create transparency overlay of two images.
template<class T >
float sumXY (const Image< T > &img, std::vector< float > &sumX, std::vector< float > &sumY)
 sum pixels along the X and Y axes (sumX, sumY) and in total (return value)
template<class T >
double distance (const Image< T > &img1, const Image< T > &img2)
 Returns Euclidean distance between two images.
template<class T >
double distance (const Image< T > &img1, const Image< T > &img2, const Image< float > &weight)
 Returns weighted Euclidean distance between two images.
double corrcoef (const Image< float > &img1, const Image< float > &img2)
 Returns the correlation coefficient r^2 of the two images.
template<class T >
double corrpatch (const Image< T > &img1, const Point2D< int > &topleft1, const Dims &patchdims, const Image< T > &img2, const Point2D< int > &topleft2, const double eps=1.0e-20)
 Returns the cross-correlation coefficient r between two patches.
template<class T >
void corrEigenMatrix (const std::vector< std::vector< Image< T > > > &baseImages, Image< T > &baseCorr, Image< T > &baseMean, Image< T > &baseSTD, Image< T > &baseSS, uint &baseN, bool returnR=false)
 return correlation matrix and means for input samples
template<class T >
void getLikelyhoodImage (const std::vector< Image< T > > &baseImages, const Image< T > &baseCorr, const Image< T > &baseMean, const bool returnLogLikelyhood, Image< T > &likelyhoodImage, Image< T > &nonNormalizedLImage)
 Given an eigen matrix and mean matrix, compute a likelyhood image.
template<class T >
Image< T > getNormalizedBayesImage (const Image< T > classImage1, const Image< T > classImage2, const bool usingLogLikelyhood, const T beta, const T classPrior1=1.0, const T classPrior2=1.0, const T bias=1.0)
 Take in two likelyhood images and compute bayes p between them.
template<class T >
Image< T > getPearsonRMatrix (const Image< T > &eigenMatrix, const Image< T > &STDMatrix)
 Take in an image of correlation and standard deviation, give r.
template<class T >
void getAugmentedBeliefBayesImage (const Image< T > &bayesImage, const Image< T > &beliefImage1, const Image< T > &beliefImage2, const T medianPoint, Image< T > &beliefImage, Image< T > &beliefValue)
 Augment the bayes image with some beliefs.
template<class T >
double pSNR (const Image< T > &img1, const Image< T > &img2)
 Returns peak signal-to-noise ratio.
template<class T >
double pSNR (const Image< T > &img1, const Image< T > &img2, const Image< float > &weight)
 Returns weighted peak signal-to-noise ratio.
template<class T >
Image< typename promote_trait
< T, float >::TP > 
sqrt (const Image< T > &img)
 Take square root of all elements.
template<class T >
Image< typename promote_trait
< T, float >::TP > 
inverse (const Image< T > &img, const T eps)
 Take inverse of all elements > eps in abs, 0 otherwise.
template<class T >
Image< typename promote_trait
< T, float >::TP > 
exp (const Image< T > &img)
 Take exponential of all pixels.
template<class T >
Image< typename promote_trait
< T, float >::TP > 
negexp (const Image< T > &img)
 Take negative exponential of all pixels, that is exp(-x).
template<class T >
Image< typename promote_trait
< T, float >::TP > 
log (const Image< T > &img)
 Take natural logarithm of all pixels.
template<class T >
Image< typename promote_trait
< T, float >::TP > 
log10 (const Image< T > &img)
 Take base-10 logarithm of all pixels.
template<class T >
bool getCentroidFirstLast (std::vector< T > vect, float &centroid, int &first, int &last)
 determine the first and last non-zero values and the centroid
template<class T >
Point2D< int > centroid (const Image< T > &img, Rectangle &boundingBox, float &cenX, float &cenY)
 determine the centroid of all the points in the image
template<class T >
Point2D< int > centroid (const Image< T > &img)
 determine the center of mass of all the points in the image
template<class T >
Image< T > squash (const Image< T > &src, const T oldmin, const T newmin, const T oldmid, const T newmid, const T oldmax, const T newmax)
 Apply a squashing function to the pixel values.
template<class T >
Image< T > squash (const Image< T > &src, const T newmin, const T oldmid, const T newmid, const T newmax)
 Apply a squashing function to the pixel values.
template<class T >
Image< T > squash (const Image< T > &src, const T oldmid, const T newmid)
 Apply a squashing function to the pixel values.
template<class T , class T_or_RGB >
Image< T_or_RGB > thresholdedMix (const Image< T > &mask, const T &thresh, const Image< T_or_RGB > &lower, const Image< T_or_RGB > &higher)
 Mix between two images based on comparing mask values to a threshold.
Image< float > logSig (const Image< float > &ima, float o, float b)
 take the logistic sigmoid 1/(1+e^x(...)) over the image
template<class T_or_RGB >
Image< T_or_RGB > scramble (const Image< T_or_RGB > &ima)
 randomly scramble image pixels
int32 findMonteMap (Image< float > &ima, std::vector< Point2D< int > > *coords, int decimation, float bias)
 take in an image and return it's statistically most relevent points
int32 makeSparceMap (std::vector< Point2D< int > > *coords, std::vector< Point2D< int > * > *cmap, std::vector< Point2D< int > > *Oldcoords, std::vector< bool > *keep, int inPoints, int outPoints)
 Take in a vector and decimate it according how many points you want back.
template<class T >
void inplaceAddWeighted (Image< T > &a, const Image< T > &b, const float coeff)
 a += b * coeff
template<class T >
void inplaceSquare (Image< T > &a)
 a = a*a
void inplaceReplaceVal (Image< byte > &dest, const byte &from, const byte &to)
 Replace all occurences of a value 'from' by another value 'to'.
template<class T_or_RGB >
void inplaceAttenuateBorders (Image< T_or_RGB > &a, int size)
 Progressive attenuation of borders by "size" pixels.
template<class T_or_RGB >
void inplaceSetBorders (Image< T_or_RGB > &a, const int size, const T_or_RGB value=T_or_RGB())
 Set borders of "size" pixels to given value.
void inplaceSpeckleNoise (Image< byte > &dest, const float thresh, const int size, const byte noise_color, bool random_color=false)
 Add speckle noise to array; thresh = 1 for 100% noise.
template<class T >
Image< typename promote_trait
< T, float >::TP > 
addPowerNoise (const Image< T > &src, double beta)
float getLocalMax (const Image< float > &src, const Point2D< int > &center, const int radius)
 Get a sample which is the max value within a circular aperture.
float getLocalAvg (const Image< float > &src, const Point2D< int > &center, const int radius)
 Get a sample which is the average value within a circular aperture.
template<class T >
void getMinMax (const Image< T > &src, T &mini, T &maxi)
 Get min and max values.
template<class T >
void getMaskedMinMax (const Image< T > &src, const Image< byte > &mask, T &min_in, T &max_in, T &min_out, T &max_out)
 Get min and max values inside and outside a mask.
template<class T >
void getMinMaxAvg (const Image< T > &src, T &mini, T &maxi, T &avg)
 Get min, max and average values.
template<class T >
void getMaskedMinMaxAvg (const Image< T > &src, const Image< byte > &mask, T &mi, T &ma, T &avg)
 Get min, max, avg within a binary mask.
template<class T >
void getMaskedMinMaxSumArea (const Image< T > &src, const Image< float > &mask, T &mi, T &ma, typename promote_trait< T, float >::TP &sum, typename promote_trait< T, float >::TP &area)
 Get min, max, sum and area values from a continuously-masked image.
template<class T >
void getMinMaxAvgEtc (const Image< T > &src, T &xmini, T &xmaxi, T &xavg, T &xstd, ushort &minPosX, ushort &minPosY, ushort &maxPosX, ushort &maxPosY, uint &pixCount)
 Get min, max, average std deviation and some other stats.
template<class T >
bool isFinite (const Image< T > &src)
 Check wether all pixels have finite values.
template<class T >
void findMax (const Image< T > &src, Point2D< int > &p, T &maxval)
 find point of max activity and also what that max activity is
template<class T >
void findMin (const Image< T > &src, Point2D< int > &p, T &minval)
 find point of min activity and also what that min activity is
template<class T >
void inplaceClamp (Image< T > &dst, const T cmin, const T cmax)
 Saturate values < cmin to cmin and > cmax to cmax.
template<class T >
void inplaceNormalize (Image< T > &dst, const T nmin, const T nmax)
 Normalize values between nmin and nmax.
template<class T >
void inplaceNormalize (Image< T > &dst, const T nmin, const T nmax, T &oldmin, T &oldmax)
 Normalize values between nmin and nmax, also return oldmin and oldmax.
template<class T >
bool isLocalMax (const Image< T > &src, const Point2D< int > &p)
 Return true if point p is a local maximum.
template<class T >
void inplaceRectify (Image< T > &dst)
 Saturate values < 0.
template<class T >
void splitPosNeg (const Image< T > &src, Image< T > &pos, Image< T > &neg)
 Put all values >= 0 into pos and the negated of all vals <= 0 into neg.
template<class T >
void inplaceLowThresh (Image< T > &dst, const T thresh, const T val=T())
 Cut values < thresh and replace them by val.
template<class T >
void inplaceLowThreshAbs (Image< T > &dst, const T thresh, const T val=T())
 Cut values whose abs is < thresh and replace them by val.
template<class T >
void inplaceSigmoid (Image< T > &dst, const float g, const float h, const float s)
 Pass image through sigmoid: f(x) = x^g / (s + x^h).
template<class T >
int emptyArea (const Image< T > &src)
 Tells how many pixels are zero.
template<class T >
int countThresh (const Image< T > &src, const T thresh, const bool absol=true)
 Counts how many pixels are > thresh (in absolute value if absol true).
Image< float > meanRow (const Image< float > &inp)
 Return a row vector containing the within-column mean of each input column.
Image< float > stdevRow (const Image< float > &inp)
 Return a row vector containing the within-column standard deviation of each input column.
Image< float > addRow (const Image< float > &M, const Image< float > &v)
 Return the result of adding vector v to each row of matrix M.
Image< float > subtractRow (const Image< float > &M, const Image< float > &v)
 Return the result of subtracting vector v from each row of matrix M.
Image< float > multiplyRow (const Image< float > &M, const Image< float > &v)
 Return the result of multiplying each row of matrix M by vector v.
Image< float > divideRow (const Image< float > &M, const Image< float > &v)
 Return the result of dividing each row of matrix M by vector v.
std::vector< Point2D< int > > approxPolyDP (std::vector< Point2D< int > > &points, float tol)
 Approximate a polyline with a simpler polyline using the Douglas-Peucker algorithm.
void recursePolyDP (float tol, std::vector< Point2D< int > > &v, int j, int k, std::vector< int > &mk)
std::vector< Point2D< float > > approximateHull (std::vector< Point2D< float > > points, int accuracy)
 Approximate 2D hull algorithm using the BFP algorithm.

Detailed Description

Mathematical operations on Image

Definition in file MathOps.H.


Function Documentation

template<class T >
Image<T> abs ( const Image< T > &  a  )  [inline]
template<class T_or_RGB >
Image<T_or_RGB> absDiff ( const Image< T_or_RGB > &  b,
const Image< T_or_RGB > &  c 
) [inline]
template<class T >
Image<typename promote_trait<T,float>::TP> addPowerNoise ( const Image< T > &  src,
double  beta 
) [inline]

Add power-law noise to array Beta is a power-law factor T must be either a float or a double

Definition at line 1870 of file MathOps.C.

References Image< T >::beginw(), Image< T >::getHeight(), Image< T >::getWidth(), FourierInvEngine< T >::ifft(), and NO_INIT.

Image<float> addRow ( const Image< float > &  M,
const Image< float > &  v 
)

Return the result of adding vector v to each row of matrix M.

Definition at line 2493 of file MathOps.C.

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

template<class T , class F >
F apply ( Image< T > &  x,
func 
) [inline]

apply a function in-place: x = func(x) for each x in image

returns a copy of the functor object after having been called

Definition at line 739 of file MathOps.H.

References Image< T >::beginw(), and Image< T >::endw().

std::vector<Point2D<float> > approximateHull ( std::vector< Point2D< float > >  points,
int  accuracy 
)

Approximate 2D hull algorithm using the BFP algorithm.

Definition at line 2728 of file MathOps.C.

References B, Point2D< T >::i, max(), and min().

std::vector<Point2D<int> > approxPolyDP ( std::vector< Point2D< int > > &  points,
float  tol 
)

Approximate a polyline with a simpler polyline using the Douglas-Peucker algorithm.

Definition at line 2608 of file MathOps.C.

template<class T >
Image<T> average ( const Image< T > &  b,
const Image< T > &  c 
) [inline]

Returns (b + c) / 2, clean & prevents overflows.

Definition at line 480 of file MathOps.C.

References ASSERT, Image< T >::begin(), Image< T >::getDims(), Image< T >::isSameSize(), and NO_INIT.

Referenced by cimg_library::CImg< charT >::variance_mean().

template<class T >
Image<T> averageWeighted ( Image< T > &  a,
const Image< T > &  b,
T *  aWeight 
) [inline]

Returns (a*w + b) / 2, the weighted average between images.

Definition at line 499 of file MathOps.C.

References ASSERT, Image< T >::begin(), Image< T >::beginw(), Image< T >::endw(), and Image< T >::isSameSize().

template<class T >
Image<T> binaryReverse ( const Image< T > &  a,
const T  val 
) [inline]
template<class T >
Point2D<int> centroid ( const Image< T > &  img  )  [inline]

determine the center of mass of all the points in the image

The centroid is rounded to integer pixel positions. When there are no values > 0 in the img, (-1,-1) is returned

Definition at line 1417 of file MathOps.C.

References centroid().

template<class T >
Point2D<int> centroid ( const Image< T > &  img,
Rectangle boundingBox,
float &  cenX,
float &  cenY 
) [inline]

determine the centroid of all the points in the image

The centroid is rounded to integer pixel positions. When there are no values > 0 in the img, (-1,-1) is returned

Parameters:
boundingBox the bounding box of the object(s) contained in the image is returned
cenX returns the float value of the centroid along the x axis
cenY returns the float value of the centroid along the y axis
Returns:
the centroid rounded to integer coordinates

Definition at line 1393 of file MathOps.C.

References getCentroidFirstLast(), sumXY(), and Rectangle::tlbrI().

Referenced by centroid(), VisualBufferStd::findMostInterestingTarget(), and Beobot::highLevel().

template<class T_or_RGB >
Image<T_or_RGB> clampedDiff ( const Image< T_or_RGB > &  b,
const Image< T_or_RGB > &  c 
) [inline]

Returns (b - c), clamping to zero all negative values.

Returns (b - c) for each color channel, clamping to zero all neg. values

double corrcoef ( const Image< float > &  img1,
const Image< float > &  img2 
)

Returns the correlation coefficient r^2 of the two images.

Definition at line 749 of file MathOps.C.

References ASSERT, Image< T >::begin(), Image< T >::end(), Image< T >::getSize(), Image< T >::initialized(), Image< T >::isSameSize(), and squareOf().

template<class T >
void corrEigenMatrix ( const std::vector< std::vector< Image< T > > > &  baseImages,
Image< T > &  baseCorr,
Image< T > &  baseMean,
Image< T > &  baseSTD,
Image< T > &  baseSS,
uint baseN,
bool  returnR = false 
) [inline]

return correlation matrix and means for input samples

This class will take a set of images and produce the eigen / correlation matrices. The input provided consists of a set of images:

(1) An image for each feature dimension (2) Multiple sets of (1) for each frame sample

That is, you provide a cardinal set of images that contains multiple image frames as well as feature maps for each frame.

This class returns an image that is the eigen matrix given the samples you have provided. It also returns the mean values per dimension. The usefulness of this is that one can compute and fit a gaussian to the data. This can be used for instance in likelyhood estimation.

The return eigen matrix is either a basic covariance matrix with un-normalized values useful for likelyhood estimation OR you can opt to have it normalize the matrix by the product of the standard deviations. This gives a pearson r correlation coefficent.

note on input: The set is a nest vector of images. It should be of the form in c++ notation

baseImages[frames][features]

Thus, the first nesting should index each frame while the second should index each feature image.

We compute covariance using an augmented method from Hayes 5th Ed. 1991

Parameters:
baseImages The set of all input images
baseCorr a return image that is the eigen matrix
baseMean a return image that is the set of means
baseSTD a return image that is the set of independant standard dev.
baseSS a return image that contains the sum of squares
baseN a return uint that is the total sample size
returnR Should we return the normalized R or the eigen matrix

Definition at line 856 of file MathOps.C.

References Image< T >::beginw(), Image< T >::endw(), Image< T >::getVal(), Image< T >::resize(), Image< T >::setVal(), and sqrt().

Referenced by ScaleRemoveSurprise< FLOAT >::SRScomputeBayesFeatureBias().

template<class T >
double corrpatch ( const Image< T > &  img1,
const Point2D< int > &  topleft1,
const Dims patchdims,
const Image< T > &  img2,
const Point2D< int > &  topleft2,
const double  eps = 1.0e-20 
) [inline]

Returns the cross-correlation coefficient r between two patches.

Note that the computations done here differ from what is done in corrcoeff, in that a signed correlation coefficient is returned (between -1 and 1), and we add a convention that if both patches have zero variance then the correlation is 1. If only one patch has zero variance then the correlation is zero. Current implementation requires that the patch fits within both image bounds, and assumes a small patch size so that it will not attempt to use a faster FFT-based implementation which can save time with larger patches.

Parameters:
img1 first image
topleft1 coordinates of top-left corner of patch in img1
patchdims dimensions of patch
img2 second image
topleft2 coordinates of top-left corner of patch in img2
eps epsilon used to determine whether patch variance is zero

Definition at line 803 of file MathOps.C.

References ASSERT, Image< T >::begin(), Image< T >::getWidth(), Dims::h(), Point2D< T >::i, Image< T >::rectangleOk(), sqrt(), Dims::sz(), and Dims::w().

Referenced by TcorrChannel::getOutput().

template<class T >
int countThresh ( const Image< T > &  src,
const T  thresh,
const bool  absol = true 
) [inline]

Counts how many pixels are > thresh (in absolute value if absol true).

Definition at line 2417 of file MathOps.C.

References Image< T >::begin(), and Image< T >::end().

Referenced by infoMeasure().

template<class T >
double distance ( const Image< T > &  img1,
const Image< T > &  img2,
const Image< float > &  weight 
) [inline]

Returns weighted Euclidean distance between two images.

Returns sqrt(sum_over_pixels(weight[i] * (img1[i] - img2[i])^2))

Definition at line 730 of file MathOps.C.

References ASSERT, Image< T >::begin(), Image< T >::end(), Image< T >::isSameSize(), and sqrt().

template<class T >
double distance ( const Image< T > &  img1,
const Image< T > &  img2 
) [inline]

Returns Euclidean distance between two images.

Returns sqrt(sum_over_pixels((img1[i] - img2[i])^2))

Definition at line 714 of file MathOps.C.

References ASSERT, Image< T >::begin(), Image< T >::end(), Image< T >::isSameSize(), and sqrt().

Referenced by ImageSpring< T >::computeStiff(), ImageSpring< T >::getStatsDist(), ArmPlanner::gibbsControl(), main(), Localization::predict(), pSNR(), pSNRcolor(), and updateTemplate().

Image<float> divideRow ( const Image< float > &  M,
const Image< float > &  v 
)

Return the result of dividing each row of matrix M by vector v.

Definition at line 2577 of file MathOps.C.

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

template<class T >
int emptyArea ( const Image< T > &  src  )  [inline]

Tells how many pixels are zero.

Definition at line 2409 of file MathOps.C.

References Image< T >::begin(), and Image< T >::end().

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

Take exponential of all pixels.

Definition at line 1292 of file MathOps.C.

References Image< T >::begin(), Image< T >::end(), exp(), Image< T >::getDims(), and NO_INIT.

Referenced by AlphaDecoder::AlphaDecoder(), SingleOpponentChannel::centerSurround(), SingleChannel::centerSurround(), RecurBayes::classify(), Bayes::classify(), Bayes::classifyRange(), cMapLeftBiasProc(), TaskRelevanceMapGistClassify::computeGistDist(), distDegrade(), dogFilter(), dogFilterHmax(), MultiColorBandChannel::doInput(), IntensityBandChannel::doInput(), cimg_library::CImg< charT >::draw_gaussian(), cimg_library::CImg< charT >::exp(), exp(), fixationMask(), gaborFilter(), gaborFilter2(), gaborFilter3(), gamma(), covEstimate< T >::gauss(), stats< T >::gauss(), gauss(), RecurBayes::gauss(), Bayes::gauss(), gaussian(), gaussian2D(), getAugmentedBeliefBayesImage(), Geons3D::getEdgeProb(), UKF::getLikelihood(), getLikelyhoodImage(), SoxChannel::getNonlinearResponse(), getNormalizedBayesImage(), Geons3D::getSurfaceProb(), hmaxActivation(), hueDistance(), logsig(), logsig2(), longRangeExcFilter(), negexp(), lobot::OccGrid::occupied(), poisson(), cimg_library::cimg::prand(), RemoveSurprise< PIXTYPE, BETATYPE, FLOAT >::RScreateSepFilters(), SurpriseControl< PIXTYPE, BETATYPE, FLOAT >::SCcreateSepFilters(), FovealTransform::setup(), segmentImageMerge2::SIMPgauss(), tansig(), BeobotControl::toSpeedSigmoid(), HMM< T >::train(), HippocampusI::updateParticleObservation(), and HippocampusI::updateParticleSlamObservation().

template<class T , class F >
F fill ( Image< T > &  x,
func 
) [inline]

fill with a generating function: x = func() for each x in image

returns a copy of the functor object after having been called

Definition at line 724 of file MathOps.H.

References Image< T >::beginw(), Image< T >::endw(), Image< T >::getDims(), Image< T >::isShared(), and NO_INIT.

Referenced by countParticles(), lobot::PointMatrix::PointMatrix(), and lobot::TTIEstimator::update().

template<class T >
void findMax ( const Image< T > &  src,
Point2D< int > &  p,
T &  maxval 
) [inline]
template<class T >
void findMin ( const Image< T > &  src,
Point2D< int > &  p,
T &  minval 
) [inline]
int32 findMonteMap ( Image< float > &  ima,
std::vector< Point2D< int > > *  coords,
int  decimation,
float  bias 
)

take in an image and return it's statistically most relevent points

Input an image to find a monte carlo like map. This will in essence cut out about half the pixels in a simple quick fashion by applying the formula: select if -> pow(pixelValue,bias) > minVal+(maxVal*rand()/RAND_MAX+1.0) The bias is used to scew the distribution using an exponent if no bias is given, this method will work more efficently by skipping the exponent computation over each pixel.

Parameters:
ima This is the input probability map
coords this is a pointer to a vector which will hold selected coords
bais this scews the probability map by pow(pixVal,bias)

Definition at line 1560 of file MathOps.C.

References ASSERT, Image< T >::beginw(), Image< T >::endw(), Image< T >::getSize(), and Image< T >::getWidth().

template<class T >
void getAugmentedBeliefBayesImage ( const Image< T > &  bayesImage,
const Image< T > &  beliefImage1,
const Image< T > &  beliefImage2,
const T  medianPoint,
Image< T > &  beliefImage,
Image< T > &  beliefValue 
) [inline]

Augment the bayes image with some beliefs.

The belief images should be from 0 to 1 where 0 signifies complete belief in the reliability of class1 results while 0 signifies absolutly no reliability. This basicially takes the product of the two as the final augmented belief.

Using the median point, beliefs can be contracted to single values for instance, if the input bayes image ranges from 0 to 2, if the median is specified as 1, then values below 1 will tend to 1 as beleifs decrease while values above 1, will tend to 1 as beliefs decrease.

Parameters:
bayesImage An image from getNormalizedBayesImage
beliefImage1 the belief for class image 1
beliefImage2 the belief for class image 2
medianPoint a middle point values are squashed to
beliefImage The augemented belief image
beliefValue a record of the beleif products

Definition at line 1185 of file MathOps.C.

References Image< T >::begin(), Image< T >::beginw(), Image< T >::end(), Image< T >::endw(), exp(), Image< T >::getHeight(), Image< T >::getWidth(), max(), min(), and Image< T >::resize().

Referenced by ScaleRemoveSurprise< FLOAT >::SRScomputeBayesFeatureCurrent().

template<class T >
bool getCentroidFirstLast ( std::vector< T >  vect,
float &  centroid,
int &  first,
int &  last 
) [inline]

determine the first and last non-zero values and the centroid

Parameters:
vect a vector of numbers
centroid returns the centroid of vect
first returns the position of the first non-zero value in vect
last returns the position of the last non-zero value in vect
Returns:
true if we actually found all these values, false if vect only contains zeros

Definition at line 1352 of file MathOps.C.

References sum().

Referenced by centroid(), and BitObject::reset().

template<class T >
void getLikelyhoodImage ( const std::vector< Image< T > > &  baseImages,
const Image< T > &  baseCorr,
const Image< T > &  baseMean,
const bool  returnLogLikelyhood,
Image< T > &  likelyhoodImage,
Image< T > &  nonNormalizedLImage 
) [inline]

Given an eigen matrix and mean matrix, compute a likelyhood image.

In this function we take in an image and the statistics of an exemplar image set. We then use this to find a likelyhood image which is how much each pixel in the input image is like the exempler based on probability. High return values mean that a pixel has a high probability of belonging to the exemplar class.

Basically, we compute P(x|C) for each pixel assuming baseImages as the samples and baseCorr as the eigen matrix that describes the distribution of the original sample. This computes P from the multi-variate gaussian. The results can be taken and fed into getNormalized bayes image with the results from a second class to give a true bayes P for each pixel belonging to one class or the other.

Note: the non-normalized likelhood image is usefull for certain things but should not be used in deriving the direct bayed probability

Parameters:
baseImage the image set you wish to find the likelyhood over
baseCorr The eigen matrix correlation from the training set
baseMean The set of mean values from the training set
returnLogLikelyhood Keep numbers sane and return log not e^
likelyhoodImage this is the returned likelyhood image
nonNormalizedLImage this is a non-normalized likelyhood image

Definition at line 1015 of file MathOps.C.

References Image< T >::begin(), Image< T >::beginw(), clamped_convert(), exp(), Image< T >::getHeight(), Image< T >::getVal(), Image< T >::getWidth(), log(), matrixInv(), matrixMult(), Image< T >::resize(), Image< T >::setVal(), sqrt(), sum(), transpose(), and vmMult().

Referenced by ScaleRemoveSurprise< FLOAT >::SRScomputeBayesFeatureCurrent().

float getLocalAvg ( const Image< float > &  src,
const Point2D< int > &  center,
const int  radius 
)

Get a sample which is the average value within a circular aperture.

This only works for monochromatic images.

Parameters:
center coordinates of the center of the aperture
radius radius of the aperture, in pixels

Definition at line 1949 of file MathOps.C.

References ASSERT, Image< T >::coordsOk(), Image< T >::getVal(), Point2D< T >::i, and Image< T >::initialized().

float getLocalMax ( const Image< float > &  src,
const Point2D< int > &  center,
const int  radius 
)

Get a sample which is the max value within a circular aperture.

This only works for monochromatic images.

Parameters:
center coordinates of the center of the aperture
radius radius of the aperture, in pixels

Definition at line 1927 of file MathOps.C.

References ASSERT, Image< T >::coordsOk(), Image< T >::getVal(), Point2D< T >::i, and Image< T >::initialized().

template<class T >
void getMaskedMinMax ( const Image< T > &  src,
const Image< byte > &  mask,
T &  min_in,
T &  max_in,
T &  min_out,
T &  max_out 
) [inline]

Get min and max values inside and outside a mask.

Only pixels with non-zero mask value are considered.

Definition at line 1989 of file MathOps.C.

References ASSERT, Image< T >::begin(), Image< T >::end(), Image< T >::initialized(), and Image< T >::isSameSize().

Referenced by OptimalGainsFinder::visitComplexChannel(), and OptimalGainsFinder::visitSingleChannel().

template<class T >
void getMaskedMinMaxAvg ( const Image< T > &  src,
const Image< byte > &  mask,
T &  mi,
T &  ma,
T &  avg 
) [inline]

Get min, max, avg within a binary mask.

Only the pixels where mask is non-zero are considered.

Definition at line 2071 of file MathOps.C.

References area(), ASSERT, Image< T >::begin(), Image< T >::end(), Image< T >::initialized(), Image< T >::isSameSize(), and sum().

Referenced by OptimalGainsFinder::visitComplexChannel(), and OptimalGainsFinder::visitSingleChannel().

template<class T >
void getMaskedMinMaxSumArea ( const Image< T > &  src,
const Image< float > &  mask,
T &  mi,
T &  ma,
typename promote_trait< T, float >::TP &  sum,
typename promote_trait< T, float >::TP &  area 
) [inline]

Get min, max, sum and area values from a continuously-masked image.

The sum is the weighted sum of src by mask. Area is the sum of all non-zero mask values.

Definition at line 2109 of file MathOps.C.

References ASSERT, Image< T >::begin(), Image< T >::end(), Image< T >::initialized(), and Image< T >::isSameSize().

template<class T >
void getMinMax ( const Image< T > &  src,
T &  mini,
T &  maxi 
) [inline]

Get min and max values.

Definition at line 1973 of file MathOps.C.

References ASSERT, Image< T >::begin(), Image< T >::end(), and Image< T >::initialized().

Referenced by addNoise(), ComplexChannel::combineOutputs(), RawVisualCortex::combineOutputs(), IntegerRawVisualCortex::combineOutputsInt(), IntegerComplexChannel::combineOutputsInt(), SingleChannel::combineSubMaps(), GistEstimatorFFT::computeGistFeatureVector(), ContourBoundaryDetector::displayGradImage(), ForegroundDetectionChannel::doInput(), SimulationViewerStd::drawMegaCombo(), BeoLRF::evolve(), Beobot2GistSalMasterI::evolve(), featureClusterVision< FLOAT >::fCVmixChannels(), VisualBufferStd::findMostInterestingTarget(), VisualBufferStd::findMostInterestingTargetLocMax(), formatMapForDisplay(), HmaxFL::getC2(), RawVisualCortex::getChannelOutputMap(), Graph::getMaxDirectedDistance(), Graph::getMaxUndirectedDistance(), TopologicalMap::getNodeSegmentMaxDistance(), SpectralResidualChannel::getOutput(), IntegerRawVisualCortex::getOutput(), VisualCortexEyeMvt::getOutput(), SingleChannel::getRawCSmap(), IntegerSimpleChannel::getRawCSmapInt(), SimulationViewerStd::getTraj(), infoFFT(), SurpriseMap< T >::initModels(), inplaceNormalize(), TaskRelevanceMapKillStatic::inputFrame(), TaskRelevanceMapKillN::integrate(), TaskRelevanceMapTigs2::integrate(), TaskRelevanceMapGistClassify::integrate(), TaskRelevanceMapTigs::integrate(), main(), maxNormalize(), maxNormalizeFancy(), maxNormalizeFancyFast(), maxNormalizeFancyLandmark(), maxNormalizeStdev(), DisparityChannel::normalizeDispMap(), normalizeRGPolarAuto(), normalizeScaleRainbow(), BPnnet::normalizeWeights(), normalizeWithScale(), normalizMAP(), SingleChannel::postProcessMap(), SimulationViewerStd::prepMapForDisplay(), BeoSubSaliency::run(), SurpriseControl< PIXTYPE, BETATYPE, FLOAT >::SCcomputeLocalBias(), SurpriseControl< PIXTYPE, BETATYPE, FLOAT >::SCinputMaskImage(), squash(), SurpriseMapFFT< T >::surprise(), BeobotBrainMT::threadCompute(), Beobot2_GistSalLocalizerMasterI::updateMessage(), Raster::VisuFloat(), and Raster::VisuGray().

template<class T >
void getMinMaxAvg ( const Image< T > &  src,
T &  mini,
T &  maxi,
T &  avg 
) [inline]
template<class T >
void getMinMaxAvgEtc ( const Image< T > &  src,
T &  xmini,
T &  xmaxi,
T &  xavg,
T &  xstd,
ushort minPosX,
ushort minPosY,
ushort maxPosX,
ushort maxPosY,
uint pixCount 
) [inline]
template<class T >
Image<T> getNormalizedBayesImage ( const Image< T >  classImage1,
const Image< T >  classImage2,
const bool  usingLogLikelyhood,
const T  beta,
const T  classPrior1 = 1.0,
const T  classPrior2 = 1.0,
const T  bias = 1.0 
) [inline]

Take in two likelyhood images and compute bayes p between them.

The idea here is to compute the true bayesian probability of membership in one image or another given the likelyhood computed in getLikelyhoodImage. Here we compute the p(C|x) for two classes.

The idea here is to compute the likelyhood that a pixel belongs to one class v. another in an input image. You must input two likelyhood images of the form P(x|C) (as computed in getLikelyhoodImage). Also, you may input the prior probability P(C) if P(C1) is not P(C2). Otherwise, it is assumed P(C1) = P(C2).

The return image has the P for each pixel being in class 1 v. class 2 to get the result the other way, compute 1 - P (pretty easy).

To compute this, we perform P(C|x) = g(a) where:

a = ln((P(x|C1)*P(C1))/(P(x|C2)*P(C2)))

g(a) = 1/(1 + exp(-a))

This is known as logistic discrimination (Bishop 1995)

Parameters:
classImage1 the likelyhood image of class 1
classImage2 the likelyhood image of class 2 set to true if using log rather than e^ likelyhood
classPrior1 the prior of class 1 (sample numbers)
classPrior2 the prior of class 2 (sample numbers)
bias This is a simple bias if desired, P(x)' = P(x)*bias

Definition at line 1108 of file MathOps.C.

References Image< T >::begin(), Image< T >::beginw(), Image< T >::end(), exp(), Image< T >::getHeight(), Image< T >::getWidth(), log(), and Image< T >::resize().

Referenced by ScaleRemoveSurprise< FLOAT >::SRScomputeBayesFeatureCurrent().

template<class T >
Image<T> getPearsonRMatrix ( const Image< T > &  eigenMatrix,
const Image< T > &  STDMatrix 
) [inline]

Take in an image of correlation and standard deviation, give r.

You can use this function to give r from an already existing eigen matrix for instance, one computed from corrEigenMatrix. Thus, you can post hoc compute r if you opted not to when using corrEigenMatrix. This function just basically normalizes the eigen matrix by the standard deviation to give a true pearson r correlation matrix

Parameters:
eigenMatrix The input eigen correlation matrix
STDMatrix The input independant standard deviations

Definition at line 1156 of file MathOps.C.

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

Referenced by ScaleRemoveSurprise< FLOAT >::SRScomputeBayesFeatureBias(), and ScaleRemoveSurprise< FLOAT >::SRSopenBayesFeatureBias().

template<class T >
Image<typename promote_trait<T,float>::TP> hmaxActivation ( const Image< T > &  a,
const float  sigma 
) [inline]

Compute exp(pixel / (2 * sigma^2)) for every pixel.

Definition at line 266 of file MathOps.C.

References Image< T >::begin(), exp(), Image< T >::getDims(), Image< T >::getSize(), and NO_INIT.

Referenced by Hmax::getC2(), and Hmax::origGetC2().

template<class T >
void inplaceAddWeighted ( Image< T > &  a,
const Image< T > &  b,
const float  coeff 
) [inline]
template<class T_or_RGB >
void inplaceAttenuateBorders ( Image< T_or_RGB > &  a,
int  size 
) [inline]
template<class T >
void inplaceClamp ( Image< T > &  dst,
const T  cmin,
const T  cmax 
) [inline]
template<class T >
void inplaceLowThresh ( Image< T > &  dst,
const T  thresh,
const T  val = T() 
) [inline]
template<class T >
void inplaceLowThreshAbs ( Image< T > &  dst,
const T  thresh,
const T  val = T() 
) [inline]

Cut values whose abs is < thresh and replace them by val.

Definition at line 2368 of file MathOps.C.

References abs(), Image< T >::beginw(), and Image< T >::endw().

Referenced by doLowThreshAbs().

template<class T >
void inplaceNormalize ( Image< T > &  dst,
const T  nmin,
const T  nmax,
T &  oldmin,
T &  oldmax 
) [inline]

Normalize values between nmin and nmax, also return oldmin and oldmax.

Definition at line 2257 of file MathOps.C.

References Image< T >::beginw(), Image< T >::clear(), Image< T >::endw(), getMinMax(), and Image< T >::initialized().

template<class T >
void inplaceNormalize ( Image< T > &  dst,
const T  nmin,
const T  nmax 
) [inline]
template<class T >
void inplaceRectify ( Image< T > &  dst  )  [inline]
void inplaceReplaceVal ( Image< byte > &  dest,
const byte from,
const byte to 
)

Replace all occurences of a value 'from' by another value 'to'.

Definition at line 1725 of file MathOps.C.

References Image< T >::beginw(), and Image< T >::endw().

Referenced by VisualBufferStd::findMostInterestingTarget().

template<class T_or_RGB >
void inplaceSetBorders ( Image< T_or_RGB > &  a,
const int  size,
const T_or_RGB  value = T_or_RGB() 
) [inline]

Set borders of "size" pixels to given value.

Default value is T's default, which should be T's representation of zero.

template<class T >
void inplaceSigmoid ( Image< T > &  dst,
const float  g,
const float  h,
const float  s 
) [inline]

Pass image through sigmoid: f(x) = x^g / (s + x^h).

Definition at line 2394 of file MathOps.C.

References Image< T >::beginw(), and Image< T >::endw().

Referenced by VisualCortexSurprise::postProcessOutputMap().

void inplaceSpeckleNoise ( Image< byte > &  dest,
const float  thresh,
const int  size,
const byte  noise_color,
bool  random_color = false 
)

Add speckle noise to array; thresh = 1 for 100% noise.

Definition at line 1838 of file MathOps.C.

References ASSERT, Image< T >::getHeight(), Image< T >::getWidth(), Image< T >::initialized(), randomDouble(), and Image< T >::setVal().

template<class T >
void inplaceSquare ( Image< T > &  a  )  [inline]

a = a*a

Definition at line 1707 of file MathOps.C.

References Image< T >::beginw(), and Image< T >::endw().

Referenced by ImageSpring< T >::getStats().

template<class T >
Image<typename promote_trait<T,float>::TP> inverse ( const Image< T > &  img,
const T  eps 
) [inline]

Take inverse of all elements > eps in abs, 0 otherwise.

Definition at line 1281 of file MathOps.C.

References Image< T >::begin(), Image< T >::end(), Image< T >::getDims(), NO_INIT, and transform().

Referenced by ImageSpring< T >::getStats().

template<class T >
bool isFinite ( const Image< T > &  src  )  [inline]

Check wether all pixels have finite values.

This relies on isFinite() being defined for your pixel type T. In Types.H we define it for the canonical types, and you can use these canonical definitions to define it for more complex types (see, for example, the definition in Pixels.H).

Definition at line 2185 of file MathOps.C.

References ASSERT, Image< T >::begin(), Image< T >::end(), Image< T >::initialized(), and isFinite().

Referenced by LineSegment2D::intersects(), and isFinite().

template<class T >
bool isLocalMax ( const Image< T > &  src,
const Point2D< int > &  p 
) [inline]

Return true if point p is a local maximum.

We just check that the value at p is >= the values of its 4 neighbors

Definition at line 2301 of file MathOps.C.

References Image< T >::begin(), Image< T >::coordsOk(), Image< T >::getHeight(), Image< T >::getWidth(), and Point2D< T >::i.

Referenced by WinnerTakeAllGreedy::integrate().

template<class T >
Image<typename promote_trait<T,float>::TP> log ( const Image< T > &  img  )  [inline]
template<class T >
Image<typename promote_trait<T,float>::TP> log10 ( const Image< T > &  img  )  [inline]
Image<float> logSig ( const Image< float > &  ima,
float  o,
float  b 
)

take the logistic sigmoid 1/(1+e^x(...)) over the image

This is a standard logistic sigmoid with offset o and slope b

Parameters:
ima the input image
o Offset for this sigmoid
b Slope for this sigmoid

Definition at line 1528 of file MathOps.C.

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

int32 makeSparceMap ( std::vector< Point2D< int > > *  coords,
std::vector< Point2D< int > * > *  cmap,
std::vector< Point2D< int > > *  Oldcoords,
std::vector< bool > *  keep,
int  inPoints,
int  outPoints 
)

Take in a vector and decimate it according how many points you want back.

In essence this will decimate a list of coordinates attempting to create a list of the size in outPoints. Thus, if you have list of 23890 points and want a list of 300 points, this will take every nth point and create a list of about this size.

Parameters:
coords This is the list of input coordinates
cmap This is the final list of coordinates after decimation
inPoints this is the input list size
outPoints this is how many points you would like out

Definition at line 1616 of file MathOps.C.

References ASSERT, Image< T >::begin(), and Image< T >::size().

template<class T >
double mean ( const Image< T > &  a  )  [inline]

Get the average of all input pixels.

Definition at line 110 of file MathOps.C.

References ASSERT, Image< T >::getSize(), and sum().

Image<float> meanRow ( const Image< float > &  inp  ) 

Return a row vector containing the within-column mean of each input column.

Definition at line 2442 of file MathOps.C.

References ASSERT, Image< T >::getHeight(), Image< T >::getWidth(), Point2D< T >::i, and ZEROS.

Referenced by stdevRow().

Image<float> multiplyRow ( const Image< float > &  M,
const Image< float > &  v 
)

Return the result of multiplying each row of matrix M by vector v.

Definition at line 2549 of file MathOps.C.

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

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

Take negative exponential of all pixels, that is exp(-x).

Definition at line 1305 of file MathOps.C.

References Image< T >::begin(), Image< T >::end(), exp(), Image< T >::getDims(), and NO_INIT.

template<class T_or_RGB >
Image<T_or_RGB> overlay ( const Image< T_or_RGB > &  top,
const Image< T_or_RGB > &  bottom,
const float  trans 
) [inline]

Create transparency overlay of two images.

by laying top over bottom with transparency of top set to trans. A new image will be returned (use 0 to 100 for percent transparency). NOTE: top and bottom must be the same size! this function only works for grey scale images

template<class T >
double pSNR ( const Image< T > &  img1,
const Image< T > &  img2,
const Image< float > &  weight 
) [inline]

Returns weighted peak signal-to-noise ratio.

This is like the other pSNR() except that it uses the weighted version of distance() internally

Definition at line 1257 of file MathOps.C.

References distance(), Image< T >::getSize(), and log10().

template<class T >
double pSNR ( const Image< T > &  img1,
const Image< T > &  img2 
) [inline]

Returns peak signal-to-noise ratio.

pSNR is computed as 10.log_10(255^2/sigma^2) where sigma^2=/N.sum(x1_i - x2_i)^2 and is a measure of distortion between two images

Definition at line 1247 of file MathOps.C.

References distance(), Image< T >::getSize(), and log10().

template<class T_or_RGB >
Image<T_or_RGB> quadEnergy ( const Image< T_or_RGB > &  img1,
const Image< T_or_RGB > &  img2 
) [inline]

Compute energy for quadrature pair (sqrt(img1^2 + img2^2)).

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

Get the min/max range of the input pixels.

This provides similar functionality to Image<T>::getMinMax().

Definition at line 139 of file MathOps.C.

References Image< T >::begin(), and Image< T >::end().

template<class T >
Image<T> remapRange ( const Image< T > &  img,
const Range< T > &  from,
const Range< T > &  to 
) [inline]

Linearly remap pixels from the source to dest dynamic ranges.

This is similar to, but more general than, Image<T>::normalize(). In effect, Image<T>::normalize() always assumes that the source range is the image's own min/max range. In contrast, remapRange() allows one to find the global min/max across a range of images, and then use that as the source range while normalizing each the images using that range.

Definition at line 147 of file MathOps.C.

References Image< T >::begin(), Image< T >::getDims(), Range< T >::min(), NO_INIT, and Range< T >::range().

template<class T >
double RMSerr ( const Image< T > &  arr1,
const Image< T > &  arr2 
) [inline]

RMS error between arr1 and arr2.

Definition at line 638 of file MathOps.C.

References ASSERT, Image< T >::begin(), Image< T >::end(), Image< T >::getSize(), Image< T >::initialized(), Image< T >::isSameSize(), and sqrt().

template<class T_or_RGB >
Image<T_or_RGB> scramble ( const Image< T_or_RGB > &  ima  )  [inline]

randomly scramble image pixels

template<class T >
void splitPosNeg ( const Image< T > &  src,
Image< T > &  pos,
Image< T > &  neg 
) [inline]

Put all values >= 0 into pos and the negated of all vals <= 0 into neg.

Definition at line 2337 of file MathOps.C.

References Image< T >::begin(), Image< T >::beginw(), Image< T >::end(), Image< T >::getDims(), NO_INIT, and Image< T >::resize().

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

Take square root of all elements.

Definition at line 1268 of file MathOps.C.

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

Referenced by Beobot2_GistSalLocalizerMasterI::actionUpdateBelief(), GSlocalizer::actionUpdateBelief(), angle(), avgOrient(), LandmarkDB::build(), JunctionHOG::calculateJunctionHistogram(), cartesian(), GeometricHashing::changeBasis(), cMapLeftBiasProc(), GAPopulation::compute_sigma(), AttentionGateStd::computeFeatureDistance(), FrictionSaccadeController::computeWhenNewDecision(), convolveHmax(), corrEigenMatrix(), corrpatch(), GistEstimatorGen::diffGist(), RawGistEstimatorStd::diffGist(), PsychoDisplay::displayMovingDotBackground(), PsychoDisplay::displaySmoothPursuitCalibration(), Point2D< T >::distance(), distance(), Point3D< T >::distance(), Point2D< T >::distanceToLine(), dogFilter(), dogFilterHmax(), PN03contrastChannel::doInput(), MultiColorBandChannel::doInput(), IntensityBandChannel::doInput(), doSqrt(), cimg_library::CImg< charT >::draw_plasma(), cimg_library::CImg< charT >::draw_spline(), drawDiskCheckTarget(), ViewPort3D::drawExtrudedContour(), ViewPort3D::drawPatch(), energyNorm(), MovementControllerI::evolve(), fastSqrt(), featureClusterVision< FLOAT >::fCVgetImageBaseStats(), featureClusterVision< FLOAT >::fCVgetImageComplexStats(), ContourNeuronCreate< TC2 >::FindDistance(), stats< T >::findS(), fixationMask(), gaborFilter(), gaborFilter2(), gaborFilter3(), gasdev(), covEstimate< T >::gauss(), stats< T >::gauss(), RecurBayes::gauss(), Bayes::gauss(), gaussian(), gaussian2D(), cimg_library::CImg< charT >::get_matrix_at(), Graph::getAngle(), ImageSpring< T >::getClusteredImage(), covEstimate< T >::getD(), BeoSubDB::getDirections(), ImageSpring< T >::getDistanceMasses(), getEllipseFromCov(), stats< T >::getErrorGGC_2AFC(), segmentImage::getHSVvalue(), Scorbot::getIKArmPos(), UKF::getLikelihood(), getLikelyhoodImage(), FeatureVector::getMag(), HOG::getMaxGradient(), getMinMaxAvgEtc(), ParticleTracker::getObservation(), covEstimate< T >::getP(), VisualObjectMatch::getSalScore(), ImageSpring< T >::getStats(), ImageSpring< T >::getStatsDist(), getTensorEigen(), getTensorMag(), gradient(), gradientmag(), gradientSobel(), cimg_library::cimg::grand(), Scorbot::gravityComp(), WinnerTakeAllTempNote::integrate(), LineSegment2D::intersects(), junctionFilterFull(), Vector2D::length(), longRangeExcFilter(), cimg_library::CImg< charT >::magnitude(), Point2D< T >::magnitude(), Point3D< T >::magnitude(), main(), makeImageArray(), Landmark::matchSalientFeatures(), maxNormalizeFancy(), maxNormalizeFancyFast(), maxNormalizeFancyLandmark(), MSTFilterFull(), multiScaleBatchFilter(), cimg_library::CImg< charT >::noise(), cimg_library::CImg< charT >::normalize(), HistogramOfGradients::normalizeFeatureVector(), NPclassify2< FLOAT >::NPclassifySpaceKmeans(), NPclassify2< FLOAT >::NPgaussKernel(), Beobot2_GistSalLocalizerMasterI::objectUpdateBelief(), GSlocalizer::objectUpdateBelief(), omniCorrectGen(), omniCorrectSp(), Hmax::origGetC2(), CINNICstatsRun::polatSagi2AFC(), cimg_library::CImg< charT >::pow(), cimg_library::cimg::prand(), cimg_library::CImg< charT >::print(), cimg_library::CImg< charT >::PSNR(), Localization::resample(), RMSerr(), cimg_library::CImg< charT >::rotation_matrix(), RemoveSurprise< PIXTYPE, BETATYPE, FLOAT >::RScreateSepFilters(), CINNICstatsRun::runStandardStats(), StimAnalyzer::SAcompImages(), StimAnalyzer::SAfinalStats(), ScaleSpace::ScaleSpace(), SurpriseControl< PIXTYPE, BETATYPE, FLOAT >::SCcreateSepFilters(), segmentImageMerge::setCameraPosition(), TensorField::setMax(), FovealTransform::setup(), segmentImage2::SIgetHSVvalue(), segmentImageMC2::SIgetValue(), segmentImageMC::SIgetValue(), segmentImageMerge2::SIMPgauss(), segmentImageMerge2::SIMsetCameraPosition(), segmentImageTrackMC::SITdrawBlobTrack(), segmentImageTrackMC::SITdrawBlobTrackMerged(), cimg_library::CImg< charT >::sphere3d(), cimg_library::CImg< charT >::sqrt(), sqrt(), ScaleRemoveSurprise< FLOAT >::SRSsetAntiWeightsInteract(), stdev(), stdevRow(), SurpriseModelGG::surprise(), trackPoint(), HippocampusI::updateParticleMotion(), HippocampusI::updateParticleObservation(), HippocampusI::updateParticleSlamObservation(), and cimg_library::CImg< charT >::variance_mean().

template<class T >
Image<T> squared ( const Image< T > &  a  )  [inline]

Square each element of the input image.

Definition at line 169 of file MathOps.C.

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

Referenced by dogFilterHmax(), DisparityChannel::doInput(), doSquared(), SpectralResidualChannel::getOutput(), and ObjRec::start2().

template<class T >
Image<T> squash ( const Image< T > &  src,
const T  oldmid,
const T  newmid 
) [inline]

Apply a squashing function to the pixel values.

In this specialization of the general form of squash(), the old min/max are computed using getMinMax(), and the new min/max will be kept equal to the old ones, so that there is no overall change in range (unless your mid-point is outside that range).

Definition at line 1495 of file MathOps.C.

References getMinMax(), and squash().

template<class T >
Image<T> squash ( const Image< T > &  src,
const T  newmin,
const T  oldmid,
const T  newmid,
const T  newmax 
) [inline]

Apply a squashing function to the pixel values.

In this specialization of the general form of squash(), the old min/max are computed using getMinMax().

Definition at line 1482 of file MathOps.C.

References getMinMax(), and squash().

template<class T >
Image<T> squash ( const Image< T > &  src,
const T  oldmin,
const T  newmin,
const T  oldmid,
const T  newmid,
const T  oldmax,
const T  newmax 
) [inline]

Apply a squashing function to the pixel values.

The squashing function is a 4th-order polynomial with sigmoidal shape. Denoting by x a pixel value in the original image and by y=f(x) the transformed pixel value that will be put in the result image, the contraints on the polynomial are: 1) f(oldmin)=newmin, 2) f(oldmax)=newmax, 3) f(oldmid)=newmid, 4) f'(oldmin)=0, and 5) f'(oldmax)=0. So, typically, the polynomial will have horizontal slope at both ends of the input range, and will remap the old min/max to the new min/max while also remapping a user-chosen mid-point oldmid to newmid. Playing with this mid-point allows the user to give more emphasis to higher or lower values while remapping. This is the full form, but two simplified forms are also available that will compute some of the arguments here from the input image. Because the main use of this function is when oldmin is the true minimum value of the input image, and oldmax its true maximum, here we will not waste time checking for input values outside this range, and their remapped values are unclear as the polynomial is unconstrained outside the input range. Internal remapping is done using floats, and results are converted back (with possible clamping) to the same type as the original image, so that this function may be efficiently used to do contrast adjustments in Image<byte> data.

Definition at line 1427 of file MathOps.C.

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

Referenced by VisualBufferStd::input(), and squash().

template<class T >
double stdev ( const Image< T > &  a  )  [inline]
Image<float> stdevRow ( const Image< float > &  inp  ) 

Return a row vector containing the within-column standard deviation of each input column.

Definition at line 2464 of file MathOps.C.

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

Image<float> subtractRow ( const Image< float > &  M,
const Image< float > &  v 
)

Return the result of subtracting vector v from each row of matrix M.

Definition at line 2521 of file MathOps.C.

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

template<class T >
double sum ( const Image< T > &  a  )  [inline]

Returns the sum of all input pixels.

Definition at line 68 of file MathOps.C.

References Image< T >::begin(), and Image< T >::end().

template<class T >
float sumXY ( const Image< T > &  img,
std::vector< float > &  sumX,
std::vector< float > &  sumY 
) [inline]

sum pixels along the X and Y axes (sumX, sumY) and in total (return value)

Parameters:
img is a w x h size image
sumX will return a vector of length w with the sum over the rows of img
sumY will return a vector of length h with the sum over the columns

Definition at line 684 of file MathOps.C.

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

Referenced by centroid(), and BitObject::reset().

template<class T >
void takeLinkedMax ( const Image< T > &  a1,
const Image< T > &  a2,
const Image< T > &  b1,
const Image< T > &  b2,
Image< T > &  aout,
Image< T > &  bout 
) [inline]

Take element-wise max of a1,a2 and use that to choose b1,b2, storing a[12] result into aout and b[12] result into bout.

Definition at line 553 of file MathOps.C.

References ASSERT, Image< T >::begin(), Image< T >::beginw(), Image< T >::endw(), and Image< T >::isSameSize().

Referenced by HistogramOfGradients::calculateGradient().

template<class T_or_RGB >
Image<T_or_RGB> takeMax ( const Image< T_or_RGB > &  a,
const Image< T_or_RGB > &  b 
) [inline]
template<class T >
Image<T> takeMin ( const Image< T > &  a,
const Image< T > &  b 
) [inline]
template<class T , class T_or_RGB >
Image<T_or_RGB> thresholdedMix ( const Image< T > &  mask,
const T &  thresh,
const Image< T_or_RGB > &  lower,
const Image< T_or_RGB > &  higher 
) [inline]

Mix between two images based on comparing mask values to a threshold.

On every pixel, if mask >= thresh, the returned value is taken from higher, otherwise it is taken from lower. All three of lower, highr and mask must have same dims.

Referenced by SimulationViewerCompress::getTraj().

template<class T >
Image<typename promote_trait<T,float>::TP> toPower ( const Image< T > &  a,
double  pow 
) [inline]

Raise each element of the input image to the given power.

Definition at line 219 of file MathOps.C.

References Image< T >::begin(), Image< T >::end(), Image< T >::getDims(), NO_INIT, and transform().

Referenced by SoxChannel::getNonlinearResponse(), and SurpriseMap< T >::surprise().

template<class T >
Image<typename promote_trait<T,float>::TP> toPowerRegion ( const Image< T > &  a,
double  pow,
std::vector< Point2D< int > >  region 
) [inline]

Raise pixels in given region of an input image to the given power. Pass a vector of 2D points that define the region of the image that you want to enhance.

Definition at line 230 of file MathOps.C.

References Image< T >::begin(), Image< T >::getDims(), Image< T >::getVal(), NO_INIT, and Image< T >::setVal().

template<class T2 , class T , class F >
Image< T2 > transform ( const Image< T > &  x,
func 
) [inline]
Generated on Sun May 8 08:42:42 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3