
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> | |
| F | fill (Image< T > &x, F func) |
| fill with a generating function: x = func() for each x in image | |
| template<class T, class F> | |
| 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 ¢roid, 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 > ¢er, 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. | |
|
||||||||||
|
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(). |
|
||||||||||||||||
|
Returns abs(b - c) for each color channel.
|
|
||||||||||||
|
Return the result of adding vector v to each row of matrix M.
|
|
||||||||||||||||
|
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(). |
|
||||||||||||||||
|
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(). |
|
||||||||||||||||||||
|
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(). |
|
||||||||||||||||
|
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(). |
|
||||||||||
|
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. |
|
||||||||||||||||||||||||
|
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
Definition at line 1350 of file MathOps.C. References getCentroidFirstLast(), GVX_TRACE, sumXY(), and Rectangle::tlbrI(). |
|
||||||||||||||||
|
Returns (b - c) for each color channel, clamping to zero all neg. values.
|
|
||||||||||||
|
Returns the correlation coefficient r^2 of the two images.
|
|
||||||||||||||||||||||||||||||||||||
|
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
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(). |
|
||||||||||||||||||||||||||||||||
|
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.
|
|
||||||||||||||||||||
|
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(). |
|
||||||||||||||||||||
|
Returns weighted Euclidean distance between two images. Returns sqrt(sum_over_pixels(weight[i] * (img1[i] - img2[i])^2)) |
|
||||||||||||||||
|
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(). |
|
||||||||||||
|
Return the result of dividing each row of matrix M by vector v.
|
|
||||||||||
|
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(). |
|
||||||||||
|
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(). |
|
||||||||||||||||
|
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(). |
|
||||||||||||||||||||
|
find point of max activity and also what that max activity is
|
|
||||||||||||||||||||
|
find point of min activity and also what that min activity is
|
|
||||||||||||||||||||
|
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.
|
|
||||||||||||||||||||||||||||||||
|
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.
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(). |
|
||||||||||||||||||||||||
|
determine the first and last non-zero values and the centroid
|
|
||||||||||||||||||||||||||||||||
|
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
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(). |
|
||||||||||||||||
|
Get a sample which is the max value within a circular aperture. This only works for monochromatic images.
|
|
||||||||||||||||||||||||||||||||
|
Get min and max values inside and outside a mask. Only pixels with non-zero mask value are considered. |
|
||||||||||||||||||||||||||||
|
Get min, max, avg within a binary mask. Only the pixels where mask is non-zero are considered. |
|
||||||||||||||||||||||||||||||||
|
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. |
|
||||||||||||||||||||
|
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(). |
|
||||||||||||||||||||||||
|
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(). |
|
||||||||||||||||||||||||||||||||||||||||||||||||
|
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(). |
|
||||||||||||||||||||||||||||||||||||
|
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)
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(). |
|
||||||||||||||||
|
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
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(). |
|
||||||||||||||||
|
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(). |
|
||||||||||||||||||||
|
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(). |
|
||||||||||||||||
|
Progressive attenuation of borders by "size" pixels.
|
|
||||||||||||||||||||
|
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(). |
|
||||||||||||||||||||
|
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(). |
|
||||||||||||||||||||
|
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(). |
|
||||||||||||||||||||||||||||
|
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(). |
|
||||||||||||||||||||
|
Normalize values between nmin and nmax.
Definition at line 2123 of file MathOps.C. References GVX_TRACE, and inplaceNormalize(). |
|
||||||||||
|
||||||||||||||||
|
Replace all occurences of a value 'from' by another value 'to'.
|
|
||||||||||||||||||||
|
Set borders of "size" pixels to given value. Default value is T's default, which should be T's representation of zero. |
|
||||||||||||||||||||||||
|
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(). |
|
||||||||||||||||||||||||
|
Add speckle noise to array; thresh = 1 for 100% noise.
|
|
||||||||||
|
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(). |
|
||||||||||||||||
|
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(). |
|
||||||||||
|
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(). |
|
||||||||||||||||
|
Return true if point p is a local maximum. We just check that the value at p is >= the values of its 4 neighbors |
|
||||||||||
|
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(). |
|
||||||||||
|
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(). |
|
||||||||||||||||
|
take the logistic sigmoid 1/(1+e^x(...)) over the image This is a standard logistic sigmoid with offset o and slope b
|
|
||||||||||||||||||||||||||||
|
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.
|
|
||||||||||
|
Get the average of all input pixels.
Definition at line 107 of file MathOps.C. References ASSERT, Image< T >::getSize(), GVX_TRACE, and sum. |
|
|
Return a row vector containing the within-column mean of each input column.
|
|
||||||||||||
|
Return the result of multiplying each row of matrix M by vector v.
|
|
||||||||||
|
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(). |
|
||||||||||||||||||||
|
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(). |
|
||||||||||||||||||||
|
Returns weighted peak signal-to-noise ratio. This is like the other pSNR() except that it uses the weighted version of distance() internally |
|
||||||||||||||||
|
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(). |
|
||||||||||||||||
|
Compute energy for quadrature pair (sqrt(img1^2 + img2^2)).
|
|
||||||||||
|
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. |
|
||||||||||||||||||||
|
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(). |
|
||||||||||||||||
|
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(). |
|
||||||||||
|
randomly scramble image pixels
|
|
||||||||||||||||||||
|
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(). |
|
||||||||||
|
||||||||||
|
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(). |
|
||||||||||||||||||||
|
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(). |
|
||||||||||||||||||||||||||||
|
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(). |
|
||||||||||||||||||||||||||||||||||||
|
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(). |
|
||||||||||
|
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(). |
|
|
Return a row vector containing the within-column standard deviation of each input column.
|
|
||||||||||||
|
Return the result of subtracting vector v from each row of matrix M.
|
|
||||||||||
|
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. |
|
||||||||||||||||||||
|
sum pixels along the X and Y axes (sumX, sumY) and in total (return value)
|
|
||||||||||||||||
|
Returns max(a, b), element by element.
|
|
||||||||||||||||
|
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(). |
|
||||||||||||||||||||||||
|
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. |
|
||||||||||||||||
|
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(). |
|
||||||||||||||||||||
|
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.
|
|
||||||||||||||||
|
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(). |
1.4.4