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

MathOps.H File Reference


Detailed Description

Mathematical operations on Image

Definition in file MathOps.H.

#include "Image/Image.H"
#include "Util/Promotions.H"
#include <vector>

Include dependency graph for MathOps.H:

This graph shows which files directly or indirectly include this file:

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) for each color channel, clamping to zero all neg. 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>
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>
Image< T > overlay (const Image< T > &top, const Image< T > &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.
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.
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.


Function Documentation

template<class T>
Image<T> abs const Image< T > &  a  ) 
 

Take absolute value of every pixel.

Definition at line 252 of file MathOps.C.

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

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.

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

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

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 721 of file MathOps.H.

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

template<class T>
Image<T> average const Image< T > &  b,
const Image< T > &  c
 

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

Definition at line 477 of file MathOps.C.

References ASSERT, Image< T >::begin(), Image< T >::beginw(), Image< T >::endw(), Image< T >::getDims(), GVX_TRACE, Image< T >::isSameSize(), NO_INIT, and lobot::stop().

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.

Definition at line 496 of file MathOps.C.

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

template<class T>
Image<T> binaryReverse const Image< T > &  a,
const T  val
 

Returns (val - a).

Definition at line 459 of file MathOps.C.

References Image< T >::begin(), Image< T >::beginw(), Image< T >::endw(), Image< T >::getDims(), GVX_TRACE, NO_INIT, and lobot::stop().

Referenced by SingleChannel::getRawCSmap(), SimulationViewerCompress::getTraj(), highlightRegions(), VisualBufferStd::inhibit(), VisualBufferStd::input(), learningCoeff(), and main().

template<class T>
Point2D<int> centroid const Image< T > &  img  ) 
 

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 1374 of file MathOps.C.

References centroid(), and GVX_TRACE.

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

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 1350 of file MathOps.C.

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

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) 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.

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

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 813 of file MathOps.C.

References base, Image< T >::beginw(), Image< T >::endw(), Image< T >::getVal(), i, LINFO, Image< T >::resize(), Image< T >::setVal(), sqrt(), x, and y.

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
 

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

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).

Definition at line 2292 of file MathOps.C.

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

Referenced by infoMeasure().

template<class T>
double distance const Image< T > &  img1,
const Image< T > &  img2,
const Image< float > &  weight
 

Returns weighted Euclidean distance between two images.

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

template<class T>
double distance const Image< T > &  img1,
const Image< T > &  img2
 

Returns Euclidean distance between two images.

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

Definition at line 671 of file MathOps.C.

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

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

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

template<class T>
int emptyArea const Image< T > &  src  ) 
 

Tells how many pixels are zero.

Definition at line 2284 of file MathOps.C.

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

Referenced by Image_xx_emptyArea_xx_1().

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

Take exponential of all pixels.

Definition at line 1249 of file MathOps.C.

References Image< T >::begin(), Image< T >::beginw(), Image< T >::end(), exp(), Image< T >::getDims(), GVX_TRACE, NO_INIT, src, and lobot::stop().

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 706 of file MathOps.H.

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

Referenced by compute_centroids(), countParticles(), lobot::extricate(), generateImage(), histogram(), Image_xx_blurAndDecY_xx_1(), Image_xx_fft_xx_1(), Image_xx_svd_lapack_xx_2(), md5_update(), InferotemporalCortexI::run(), sha1_update(), sha256_update(), and BackpropNetwork::train().

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

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)

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.

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

References Image< T >::begin(), Image< T >::beginw(), diff(), Image< T >::end(), Image< T >::endw(), exp(), Image< T >::getHeight(), Image< T >::getWidth(), rutz::max(), rutz::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
 

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

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.

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 972 of file MathOps.C.

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

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

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

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.

Only pixels with non-zero mask value are considered.

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.

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

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.

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

template<class T>
void getMinMax const Image< T > &  src,
T &  mini,
T &  maxi
 

Get min and max values.

Definition at line 1848 of file MathOps.C.

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

template<class T>
void getMinMaxAvg const Image< T > &  src,
T &  mini,
T &  maxi,
T &  avg
 

Get min, max and average values.

Definition at line 1927 of file MathOps.C.

References ASSERT, Image< T >::begin(), Image< T >::end(), Image< T >::getSize(), GVX_TRACE, Image< T >::initialized(), and lobot::stop().

Referenced by NssScorer::accum(), ComplexChannel::combineOutputs(), SimulationViewerStats::computeAGStats(), MichelsonChannel::doInput(), SimulationViewerCompress::getTraj(), imgcompare(), main(), dummy_namespace_to_avoid_gcc411_bug_ContourChannel_C::printStats(), SimulationViewerStats::save1(), SimulationViewerNerdCam::saveResults(), segmentColor(), CINNIC::viewNeuronTemplate(), and SimulationViewerNerdCam::writeStatusPage().

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.

Definition at line 2023 of file MathOps.C.

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

Referenced by SimulationViewerStats::saveAGMaskStats(), SimulationViewerStats::saveCompat(), ContourChannel::saveStats(), and SingleChannel::saveStats().

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.

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 1065 of file MathOps.C.

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

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

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.

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 1113 of file MathOps.C.

References Image< T >::getHeight(), Image< T >::getVal(), Image< T >::getWidth(), i, LFATAL, 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
 

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

Definition at line 263 of file MathOps.C.

References Image< T >::begin(), Image< T >::beginw(), exp(), Image< T >::getDims(), Image< T >::getSize(), GVX_TRACE, i, 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
 

a += b * coeff

Definition at line 1635 of file MathOps.C.

References ASSERT, Image< T >::begin(), Image< T >::beginw(), Image< T >::end(), Image< T >::getDims(), GVX_TRACE, Image< T >::initialized(), Image< T >::isSameSize(), NO_INIT, and lobot::stop().

Referenced by SoxChannel::getNonlinearResponse(), and SaliencyMapFast::integrate().

template<class T_or_RGB>
void inplaceAttenuateBorders Image< T_or_RGB > &  a,
int  size
 

Progressive attenuation of borders by "size" pixels.

template<class T>
void inplaceClamp Image< T > &  dst,
const T  cmin,
const T  cmax
 

Saturate values < cmin to cmin and > cmax to cmax.

Definition at line 2109 of file MathOps.C.

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

Referenced by contrastModulate(), countClusters(), SimEventShapeEstimatorOutput::cumSmoothMask(), XWindow::drawImage(), SimulationViewerNerdCam::drawMegaCombo(), SimulationViewerStd::drawMegaCombo(), greyWorldNormalize(), TaskRelevanceMapKillStatic::inputFrame(), TaskRelevanceMapKillN::integrate(), main(), maxNormalizeFancy(), SimEventShapeEstimatorOutput::negCumSmoothMask(), BPnnet::normalizeWeights(), and warp3Dmap().

template<class T>
void inplaceLowThresh Image< T > &  dst,
const T  thresh,
const T  val = T()
 

Cut values < thresh and replace them by val.

Definition at line 2229 of file MathOps.C.

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

Referenced by doLowThresh(), SimulationViewerNerdCam::drawMaskOutline(), SimulationViewerStd::drawMaskOutline(), foveate(), SimulationViewerCompress::getTraj(), VisualBufferStd::input(), intgDoLowThresh(), and main().

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.

Definition at line 2243 of file MathOps.C.

References abs(), Image< T >::beginw(), Image< T >::endw(), GVX_TRACE, LERROR, and lobot::stop().

Referenced by doLowThreshAbs(), and intgDoLowThreshAbs().

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.

Definition at line 2132 of file MathOps.C.

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

template<class T>
void inplaceNormalize Image< T > &  dst,
const T  nmin,
const T  nmax
 

Normalize values between nmin and nmax.

Definition at line 2123 of file MathOps.C.

References GVX_TRACE, and inplaceNormalize().

template<class T>
void inplaceRectify Image< T > &  dst  ) 
 

Saturate values < 0.

Definition at line 2197 of file MathOps.C.

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

Referenced by Context::combineBuTd(), SaliencyMapTrivial::depress(), SaliencyMapFast::depress(), DisparityChannel::doInput(), ObjDetChannel::doInput(), doRectify(), V2::evolve2(), ImageSpring< T >::getStats(), SurpriseMap< T >::initModels(), intgDoRectify(), intgMaxNormalizeNone(), intgMaxNormalizeStd(), maxNormalizeFancy(), maxNormalizeFancyFast(), maxNormalizeFancyLandmark(), maxNormalizeNone(), maxNormalizeStd(), DisparityChannel::normalizeDispMap(), VisualCortexSurprise::postProcessOutputMap(), rectify(), SurpriseMap< T >::surprise(), SurpriseMapFFT< T >::surprise(), and Context::testFrame().

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 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.

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
 

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

Definition at line 2269 of file MathOps.C.

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

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.

template<class T>
void inplaceSquare Image< T > &  a  ) 
 

a = a*a

Definition at line 1664 of file MathOps.C.

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

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

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.

Definition at line 1238 of file MathOps.C.

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

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

template<class T>
bool isFinite const Image< T > &  src  ) 
 

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 2060 of file MathOps.C.

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

template<class T>
bool isLocalMax const Image< T > &  src,
const Point2D< int > &  p
 

Return true if point p is a local maximum.

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

template<class T>
Image<typename promote_trait<T,float>::TP> log const Image< T > &  img  ) 
 

Take natural logarithm of all pixels.

Definition at line 1275 of file MathOps.C.

References Image< T >::begin(), Image< T >::beginw(), Image< T >::endw(), Image< T >::getDims(), GVX_TRACE, log(), NO_INIT, and lobot::stop().

template<class T>
Image<typename promote_trait<T,float>::TP> log10 const Image< T > &  img  ) 
 

Take base-10 logarithm of all pixels.

Definition at line 1292 of file MathOps.C.

References Image< T >::begin(), Image< T >::beginw(), Image< T >::endw(), Image< T >::getDims(), GVX_TRACE, log10(), NO_INIT, and lobot::stop().

Referenced by Image_xx_log10_xx_1(), V2::lineSegmentDetection(), lobot::log(), log10(), V2::nfa(), Pixels_xx_math_functions_xx_9(), pSNR(), pSNRcolor(), TwoHalfDSketch::vanishingPoints(), and rutz::error::what().

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

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

template<class T>
double mean const Image< T > &  a  ) 
 

Get the average of all input pixels.

Definition at line 107 of file MathOps.C.

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

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

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

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

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

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).

Definition at line 1262 of file MathOps.C.

References Image< T >::begin(), Image< T >::beginw(), Image< T >::end(), exp(), Image< T >::getDims(), GVX_TRACE, NO_INIT, src, and lobot::stop().

template<class T>
Image<T> overlay const Image< T > &  top,
const Image< T > &  bottom,
const float  trans
 

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

Definition at line 613 of file MathOps.C.

References ASSERT, Image< T >::begin(), Image< T >::beginw(), Image< T >::endw(), Image< T >::getDims(), GVX_TRACE, Image< T >::isSameSize(), NO_INIT, and lobot::stop().

Referenced by Image_xx_overlay_xx_1().

template<class T>
double pSNR const Image< T > &  img1,
const Image< T > &  img2,
const Image< float > &  weight
 

Returns weighted peak signal-to-noise ratio.

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

template<class T>
double pSNR const Image< T > &  img1,
const Image< T > &  img2
 

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 1204 of file MathOps.C.

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

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>
Range<T> rangeOf const Image< T > &  img  ) 
 

Get the min/max range of the input pixels.

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

Definition at line 136 of file MathOps.C.

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

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.

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 144 of file MathOps.C.

References Image< T >::begin(), Image< T >::beginw(), Image< T >::endw(), Image< T >::getDims(), GVX_TRACE, Range< T >::min(), NO_INIT, Range< T >::range(), and lobot::stop().

Referenced by BackpropLearner::getBiasMap(), Image_xx_remapRange_xx_1(), and main().

template<class T>
double RMSerr const Image< T > &  arr1,
const Image< T > &  arr2
 

RMS error between arr1 and arr2.

Definition at line 595 of file MathOps.C.

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

Referenced by FeatureExtractor::extract(), BackpropLearner::getBiasMap(), LeastSquaresLearner::getBiasMap(), Image_xx_blurAndDecY_xx_1(), Image_xx_fft_xx_1(), Image_xx_svd_gsl_xx_1(), Image_xx_svd_lapack_xx_1(), Image_xx_svd_lapack_xx_2(), main(), and BackpropNetwork::train().

template<class T_or_RGB>
Image<T_or_RGB> scramble const Image< T_or_RGB > &  ima  ) 
 

randomly scramble image pixels

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.

Definition at line 2212 of file MathOps.C.

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

Referenced by main().

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

Take square root of all elements.

Definition at line 1225 of file MathOps.C.

References Image< T >::begin(), Image< T >::beginw(), Image< T >::end(), Image< T >::getDims(), GVX_TRACE, NO_INIT, sqrt(), src, and lobot::stop().

Referenced by GSlocalizer::actionUpdateBelief(), Beobot2_GistSalLocalizerMasterI::actionUpdateBelief(), avgOrient(), blas_dnrm2(), LandmarkDB::build(), MotionEnergyPyrBuilder< T >::buildHorizontalMotionLevel(), MotionEnergyPyrBuilder< T >::buildVerticalMotionLevel(), Contour::calcLineLikelihood(), cartesian(), checkDataLength(), cMapLeftBiasProc(), compBhattHist(), compEquHist(), compProbHist(), GAPopulation::compute_sigma(), AttentionGateStd::computeFeatureDistance(), FrictionSaccadeController::computeWhenNewDecision(), convolveHmax(), WeightFilter::convolveHmax(), corrEigenMatrix(), corrpatch(), count_pixels(), create_givens(), cuda_global_dogFilterHmax(), cudaDogFilter(), cudaGaborFilter3(), cudaGaussian(), cudaMaxNormalizeFancy(), cvRunHaarClassifierCascade(), GistEstimatorGen::diffGist(), GistEstimatorStd::diffGist(), PsychoDisplay::displayMovingDotBackground(), PsychoDisplay::displaySmoothPursuitCalibration(), Point3D< T >::distance(), distance(), Point2D< T >::distance(), LineSegment2D::distance(), Point< T, DIMS >::distance(), V1::EdgeState::distance(), V4::GeonState::distance(), V4d::NAFState::distance(), dogFilter(), dogFilterHmax(), IntensityBandChannel::doInput(), MultiColorBandChannel::doInput(), PN03contrastChannel::doInput(), doSqrt(), drawDiskCheckTarget(), drawEllipse(), drawRectOR(), ViewPort::drawSphereShadow(), energyNorm(), SupplementaryMotorAreaI::evolve(), MovementControllerI::evolve(), SMap::evolve(), V2::evolve2(), fastSqrt(), featureClusterVision< FLOAT >::fCVgetImageBaseStats(), featureClusterVision< FLOAT >::fCVgetImageComplexStats(), featureClusterVision< FLOAT >::fCVprocessOutSaccadeData(), fillCubicRadiant(), fillLinearRadiant(), fillQuadricRadiant(), find_eigenvectors_2x2_positive_semi_def_real_matrix(), findDirection(), ContourNeuronCreate< TC2 >::FindDistance(), V2::findLines(), stats< T >::findS(), gaborFilter(), gaborFilter2(), gaborFilter3(), gaborFilterRGB(), gasdev(), Bayes::gauss(), RecurBayes::gauss(), stats< T >::gauss(), covEstimate< T >::gauss(), gaussian(), gaussian2D(), SearchArray::generateBackground(), HippocampusI::get3Dpos(), V2::get_theta(), ImageSpring< T >::getClusteredImage(), BeoSubCross::getCrossCenter(), BeoSubCross::getCrossDir(), covEstimate< T >::getD(), BeoSubDB::getDirections(), getDistance(), ImageSpring< T >::getDistanceMasses(), stats< T >::getErrorGGC_2AFC(), getGeomRelProb(), IT::getGeonDistance(), V4::getGeonLikelihood(), segmentImage::getHSVvalue(), ArmPlanner::getIK2(), Scorbot::getIKArmPos(), SearchArray::getImage(), getLikelyhoodImage(), FeatureVector::getMag(), getMag(), getMinMaxAvgEtc(), IT::getObjectLikelihood(), covEstimate< T >::getP(), V4d::getParticleLikelihood(), BeoSubPipe::getPipeDir(), VisualObjectMatch::getSalScore(), ImageSpring< T >::getStats(), ImageSpring< T >::getStatsDist(), getSwpe(), gradient(), gradientmag(), gradientSobel(), Scorbot::gravityComp(), houghTransform(), CudaDevices::initDevice(), HmaxFL::initFilters(), insertLocalVar(), WinnerTakeAllTempNote::integrate(), LineSegment2D::intersects(), iorHelper(), isolateRed(), joinLogampliPhase(), junctionFilterFull(), Vector2D::length(), V2::lineSegmentDetection(), V2::ll_angle(), LogPolarTransform::LogPolarTransform(), longRangeExcFilter(), BeoSubCanny::magnitude_x_y(), magnitude_x_y(), main(), BeoSubCanny::make_gaussian_kernel(), make_gaussian_kernel(), makeImageArray(), Landmark::matchSalientFeatures(), maxNormalizeFancy(), maxNormalizeFancyFast(), maxNormalizeFancyLandmark(), MSTFilterFull(), multiScaleBatchFilter(), SOFM::Neighborhood(), NPclassify2< FLOAT >::NPclassifySpaceKmeans(), NPclassify2< FLOAT >::NPgaussKernel(), GSlocalizer::objectUpdateBelief(), Beobot2_GistSalLocalizerMasterI::objectUpdateBelief(), omniCorrectGen(), omniCorrectSp(), Hmax::origGetC2(), PixDKL< T >::PixDKL(), Pixels_xx_math_functions_xx_4(), CINNICstatsRun::polatSagi2AFC(), Util::ProbabilityDistribution(), SOFM::Propagate(), SOFM::propagate(), BeoSubCross::pruneLines(), quadEnergy(), Localization::resample(), covEstimate< T >::returnCovSlice(), RMSerr(), rotate(), RemoveSurprise< PIXTYPE, BETATYPE, FLOAT >::RScreateSepFilters(), CINNICstatsRun::runStandardStats(), ColorTracker::runTracker(), StimAnalyzer::SAcompImages(), StimAnalyzer::SAfinalStats(), sample(), ScaleSpace::ScaleSpace(), SurpriseControl< PIXTYPE, BETATYPE, FLOAT >::SCcreateSepFilters(), segmentColor(), segmentImageMerge::setCameraPosition(), SurpriseMapFFT< T >::setFFTModels(), CorticalTransform::setup(), setupGaborMask(), segmentImage2::SIgetHSVvalue(), segmentImageMC::SIgetValue(), segmentImageMC2::SIgetValue(), segmentImageMerge2::SIMPgauss(), segmentImageMerge2::SIMsetCameraPosition(), segmentImageTrackMC::SITdrawBlobTrack(), segmentImageTrackMC::SITdrawBlobTrackMerged(), sqrt(), squashQuadrangle(), ScaleRemoveSurprise< FLOAT >::SRSsetAntiWeightsInteract(), stdev(), stdevRow(), submain(), SurpriseModelGG::surprise(), BeoSub::TaskA(), testBiasedSceneALOI(), testSceneALOI(), trackPoint(), transform_ellipse_parameters(), HippocampusI::updateParticleMotion(), HippocampusI::updateParticleObservation(), HippocampusI::updateParticleSlamObservation(), Util::vectorTo(), IT::voteForFeature(), V4::voteForFeature(), V4d::voteForFeature(), and watershed().

template<class T>
Image<T> squared const Image< T > &  a  ) 
 

Square each element of the input image.

Definition at line 166 of file MathOps.C.

References Image< T >::begin(), Image< T >::beginw(), Image< T >::endw(), Image< T >::getDims(), GVX_TRACE, NO_INIT, and lobot::stop().

Referenced by dogFilterHmax(), DisparityChannel::doInput(), V1::evolveGabor(), getLocalSalPt(), SpectralResidualChannel::getOutput(), Image_xx_squared_xx_1(), Hmax::initFilters(), HmaxFL::initFilters(), ObjRecSPM::ObjRecSPM(), Ganglion::setBias(), and ObjRec::start2().

template<class T>
Image<T> squash const Image< T > &  src,
const T  oldmid,
const T  newmid
 

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 1452 of file MathOps.C.

References getMinMax(), GVX_TRACE, and squash().

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.

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

Definition at line 1439 of file MathOps.C.

References getMinMax(), GVX_TRACE, 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
 

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 1384 of file MathOps.C.

References Image< T >::begin(), Image< T >::beginw(), e, Image< T >::end(), Image< T >::getDims(), GVX_TRACE, LERROR, NO_INIT, src, and lobot::stop().

template<class T>
double stdev const Image< T > &  a  ) 
 

compute standard deviation of pixel values over image

Definition at line 116 of file MathOps.C.

References ASSERT, Image< T >::begin(), Image< T >::end(), Image< T >::getSize(), GVX_TRACE, mean(), sqrt(), lobot::stop(), and sum.

Referenced by NssScorer::accum(), Beobot2GistSalMasterI::evolve(), fillEyeData(), fillMouthData(), fillNoseData(), getGeomRelProb(), getNSS(), KLScorer::getScoreString(), getSubSum2(), main(), maxNormalizeStdev(), maxNormalizeStdev0(), normalize(), CudaHmax::printCorners(), Hmax::printCorners(), StatsOutputSeries::Impl::printStatsRGB(), GSnavResult::read(), GSnav_M_Result::read(), SimulationViewerStats::save1(), setupGaborMask(), Context::testFrame(), train(), Beobot2_GistSalLocalizerMasterI::updateMessage(), and SimulationViewerNerdCam::writeStatusPage().

Image<float> stdevRow const Image< float > &  inp  ) 
 

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

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

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

template<class T>
double sum const Image< T > &  a  ) 
 

Returns the sum of all input pixels.

Definition at line 65 of file MathOps.C.

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

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)

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

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>
Image<T> takeMin const Image< T > &  a,
const Image< T > &  b
 

Returns min(a, b), element by element.

Definition at line 549 of file MathOps.C.

References ASSERT, Image< T >::begin(), Image< T >::beginw(), Image< T >::endw(), Image< T >::getDims(), GVX_TRACE, Image< T >::isSameSize(), rutz::min(), NO_INIT, and lobot::stop().

Referenced by BitObject::doesIntersect(), ImageCacheMinMax< T >::getMin(), and SimulationViewerCompress::getTraj().

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.

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.

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.

Definition at line 216 of file MathOps.C.

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

Referenced by SoxChannel::getNonlinearResponse(), Image_xx_toPower_xx_1(), Image_xx_toPower_xx_2(), main(), 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
 

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 T2, class T, class F>
Image< T2 > transform const Image< T > &  x,
func
[inline]
 

apply a function out-of-place: y = func(x) for x in input, y in output

Definition at line 732 of file MathOps.H.

References Image< T >::begin(), Image< T >::beginw(), Image< T >::endw(), Image< T >::getDims(), NO_INIT, and lobot::stop().


Generated on Sun Nov 22 13:44:08 2009 for iLab Neuromorphic Vision Toolkit by  doxygen 1.4.4