Transforms.C File Reference

#include "Image/Transforms.H"
#include "Image/CutPaste.H"
#include "Image/Image.H"
#include "Image/MathOps.H"
#include "Image/Pixels.H"
#include "Image/Rectangle.H"
#include "Util/Assert.H"
#include "Util/log.H"
#include <algorithm>
#include <cmath>
#include <vector>
#include <cstdio>
#include "inst/Image/Transforms.I"
Include dependency graph for Transforms.C:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define SEGOBJ_START   0.9
#define SEGOBJ_STEP   0.05
#define SEGOBJ_MINA   0.005
#define SEGOBJ_EXPL   1.05
#define ALGORITHM   CHAMFER34
#define BGNOISELEVEL   0.00001

Functions

template<class T >
Image< bytesegmentObject (const Image< T > &src, const Point2D< int > &seed)
 Segment object using an adaptive thresholding & region growing method.
template<class T >
int segmentLandmark (const Image< T > &src, const Point2D< int > &seed, Image< byte > &target, double &activity, double &standout, float &area_percentage)
 Segment landmark using an adaptive thresholding & region growing method.
template<class T >
Image< bytecontour2D (const Image< T > &src, const byte onval, const byte offval)
 Compute 2D 4-neighbor contours of binary objects in image.
template<class T >
Image< T > chamfer34 (const Image< T > &src, const T dmax)
 3/4-chamfer distance transform; object = non 0
template<class T >
Image< T > saliencyChamfer34 (const Image< T > &src, const T dmax)
 3/4-chamfer saliency distance transform; object = non 0
template<class T >
Image< typename promote_trait
< T, float >::TP > 
dct (const Image< T > &src, const int offx, const int offy, const int size)
 Computes 2D discrete cosine transform.
template<class T >
float infoFFT (const Image< T > &src, const float eps, const Rectangle &rect)
 FFT-based information measure.
template<class T >
Image< float > infoFFT (const Image< T > &src, const float eps)
 FFT-based information measure.
double learningCoeff (const Image< float > &featureMap, const Image< byte > &targetDMap, const bool softmask, const int in_thresh, const int out_thresh)
 Examine local maxes in/out of targets and compute a learning weight.
template<class T >
Image< T > scaleBlock (const Image< T > &src, const Dims newDims)
template<class T >
int floodClean (const Image< T > &src, Image< T > &dest, const Point2D< int > &seed, const T thresh, const T val, int numConn)
 Floods object >= thresh with val from seed and returns area.
template<class T >
int floodCleanBB (const Image< T > &src, Image< T > &dest, const Point2D< int > &seed, const T thresh, const T val, Rectangle &bbox)
 same as floodClean, only finds the bounding box of the region in addition
template<class T >
Image< float > distDegrade (const Image< T > &src, const Point2D< int > &foa, const float area)
 degrades a binary image mask s.t. it decays away from the FOA
template<class T >
Image< bytesegmentObjectClean (const Image< T > &src, const Point2D< int > &seed, int numConn)
 same as segmentObject, only with floodClean and different parameters
template<class T >
Image< T > highThresh (const Image< T > &src, const T thresh, const T val)
 set all values >= thresh to val in src and return the result
template<class T_or_RGB >
Image< T_or_RGB > replaceVals (const Image< T_or_RGB > &src, const T_or_RGB from, const T_or_RGB to, const T_or_RGB other)
 replace all values "from" with "to" and all other values with "other"
template<class T_or_RGB >
Image< T_or_RGB > replaceVals (const Image< T_or_RGB > &src, const T_or_RGB from, const T_or_RGB to)
 replace all values "from" with "to" and leave all other values in place
template<class T_or_RGB >
Image< T_or_RGB > composite (const Image< T_or_RGB > &fg, const Image< T_or_RGB > &bg, const T_or_RGB transparent)
 Composite of the non-transparent pixels of fg on top of bg.
template<class T_or_RGB >
Image< T_or_RGB > createMask (const Image< T_or_RGB > &fg, const Image< bool > mask, const T_or_RGB transparent=T_or_RGB())
 Create a mask of an object and transparent pixels in desired area.
template<class T_or_RGB >
Image< T_or_RGB > mosaic (const Image< T_or_RGB > &fg, const Image< T_or_RGB > *bg, const T_or_RGB *transvalues, const uint Nimages)
template<class T_or_RGB >
Image< T_or_RGB > alphaBlend (const Image< T_or_RGB > &fg, const Image< T_or_RGB > &bg, const double alpha, const T_or_RGB transparent)
 apply a translucent layer (also called alpha blending)
template<class T >
Image< bytemakeBinary (const Image< T > &src, const T &threshold, const byte lowVal, const byte highVal)
 make a binary version of the source image
template<class T >
Image< bytemakeBinary2 (const Image< T > &src, const T &lowThresh, const T &highThresh, const byte lowVal, const byte highVal)
 make a binary version of the source image
template<class T_or_RGB >
void pasteImage (Image< T_or_RGB > &background, const Image< T_or_RGB > &foreground, const T_or_RGB &transparent, const Point2D< int > location, float opacity)
template<class T >
void inplacePasteGabor (Image< T > &dst, const Image< T > &gabor, const Point2D< int > &pos, const T background)
 Paste a gabor into an image area. Account for overlap.
template<class T >
int flood (const Image< T > &src, Image< T > &dest, const Point2D< int > &seed, const T thresh, const T val)
 Floods object >= thresh with val from seed and returns area.
template<class T >
int countParticles (const Image< T > &src, const T thresh)
 How many particles >= thresh ?
template<class T >
void inplaceAddBGnoise (Image< T > &src, const float range)
 Add background noise to image.
template<class T >
void inplaceAddBGnoise2 (Image< T > &src, const float range)
 Add background noise to image.

Detailed Description

Transformations on Image

Definition in file Transforms.C.


Function Documentation

template<class T_or_RGB >
Image<T_or_RGB> alphaBlend ( const Image< T_or_RGB > &  fg,
const Image< T_or_RGB > &  bg,
const double  alpha,
const T_or_RGB  transparent 
) [inline]

apply a translucent layer (also called alpha blending)

Definition at line 1446 of file Transforms.C.

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

Referenced by SimulationViewerEyeRegion::getTraj().

template<class T >
Image<T> chamfer34 ( const Image< T > &  src,
const T  dmax 
) [inline]
template<class T_or_RGB >
Image<T_or_RGB> composite ( const Image< T_or_RGB > &  fg,
const Image< T_or_RGB > &  bg,
const T_or_RGB  transparent 
) [inline]
template<class T >
Image<byte> contour2D ( const Image< T > &  src,
const byte  onval = 255,
const byte  offval = 0 
) [inline]

Compute 2D 4-neighbor contours of binary objects in image.

Points on the contour will be given value onval, and points not on the contour will have offval.

Definition at line 210 of file Transforms.C.

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

Referenced by SimulationViewerNerdCam::drawMaskOutline(), SimulationViewerStd::drawMaskOutline(), and SimulationViewerCompress::getTraj().

template<class T >
int countParticles ( const Image< T > &  src,
const T  thresh 
) [inline]

How many particles >= thresh ?

Definition at line 1650 of file Transforms.C.

References fill(), flood(), Image< T >::getHeight(), Image< T >::getVal(), Image< T >::getWidth(), and Point2D< T >::i.

template<class T_or_RGB >
Image<T_or_RGB> createMask ( const Image< T_or_RGB > &  fg,
const Image< bool >  mask,
const T_or_RGB  transparent = T_or_RGB() 
) [inline]

Create a mask of an object and transparent pixels in desired area.

Definition at line 1382 of file Transforms.C.

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

template<class T >
Image<typename promote_trait<T, float>::TP> dct ( const Image< T > &  src,
const int  offx,
const int  offy,
const int  size 
) [inline]

Computes 2D discrete cosine transform.

of square image patch size*size at offset (offx, offy)

Definition at line 525 of file Transforms.C.

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

Referenced by infoMeasure().

template<class T >
Image<float> distDegrade ( const Image< T > &  src,
const Point2D< int > &  foa,
const float  area 
) [inline]

degrades a binary image mask s.t. it decays away from the FOA

Definition at line 1230 of file Transforms.C.

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

template<class T >
int flood ( const Image< T > &  src,
Image< T > &  dest,
const Point2D< int > &  seed,
const T  thresh,
const T  val 
) [inline]
template<class T >
int floodClean ( const Image< T > &  src,
Image< T > &  dest,
const Point2D< int > &  seed,
const T  thresh,
const T  val,
int  numdirs = 8 
) [inline]

Floods object >= thresh with val from seed and returns area.

a clean version of Image::flood - problems solved: correct boundary checking, allow for thresh = 0.

Parameters:
dest if dest is not initialized, it will be initialized to ZEROS. ATTENTION: If you want to have the old behavior of dest being initialized to src, you have to this explicitely before calling floodClean

Definition at line 1110 of file Transforms.C.

References ASSERT, Image< T >::coordsOk(), Image< T >::getDims(), Image< T >::getVal(), Image< T >::initialized(), Image< T >::resize(), Image< T >::setVal(), and ZEROS.

Referenced by segmentObjectClean().

template<class T >
int floodCleanBB ( const Image< T > &  src,
Image< T > &  dest,
const Point2D< int > &  seed,
const T  thresh,
const T  val,
Rectangle bbox 
) [inline]
template<class T >
Image<T> highThresh ( const Image< T > &  src,
const T  thresh,
const T  val 
) [inline]

set all values >= thresh to val in src and return the result

Definition at line 1312 of file Transforms.C.

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

Referenced by EntropyChannel::doInput().

template<class T >
Image<float> infoFFT ( const Image< T > &  src,
const float  eps 
) [inline]

FFT-based information measure.

Definition at line 867 of file Transforms.C.

References Image< T >::getDims(), Image< T >::getHeight(), Image< T >::getVal(), Image< T >::getWidth(), and NO_INIT.

template<class T >
float infoFFT ( const Image< T > &  src,
const float  eps,
const Rectangle rect 
) [inline]

FFT-based information measure.

Definition at line 856 of file Transforms.C.

References getMinMax(), and infoFFT().

Referenced by infoFFT().

template<class T >
void inplaceAddBGnoise ( Image< T > &  dst,
const float  range 
) [inline]

Add background noise to image.

Range should be max value for any image of the type to which we add noise

Definition at line 1673 of file Transforms.C.

References inplaceAddBGnoise2().

Referenced by RawVisualCortex::combineOutputs(), BeoSubSaliency::computeCMAP(), computeCMAP(), ObjDetChannel::doInput(), SingleChannel::postProcessMap(), and BeobotBrainMT::threadCompute().

template<class T >
void inplaceAddBGnoise2 ( Image< T > &  dst,
const float  range 
) [inline]

Add background noise to image.

Range should be max value for any image of the type to which we add noise similar to addBGnoise, but eliminates BNG.. constant

Definition at line 1683 of file Transforms.C.

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

Referenced by inplaceAddBGnoise().

template<class T >
void inplacePasteGabor ( Image< T > &  dst,
const Image< T > &  gabor,
const Point2D< int > &  pos,
const T  background 
) [inline]

Paste a gabor into an image area. Account for overlap.

this is a simple extention to paste, but it tests for gabor overlap and attempts rectify similar to solution for MakeSnake by taking the pixel value furthest from the background value

Parameters:
background This is the color of the image background

Definition at line 1546 of file Transforms.C.

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

double learningCoeff ( const Image< float > &  featureMap,
const Image< byte > &  targetDMap,
const bool  softmask = false,
const int  in_thresh = 20,
const int  out_thresh = 255 
)

Examine local maxes in/out of targets and compute a learning weight.

Valid ranges for in_thresh and out_thresh are 0..255, plus: use -1 for in_thresh to learn from the background only, or use -1 for out_thresh to learn from the target only.

Definition at line 1015 of file Transforms.C.

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

template<class T >
Image<byte> makeBinary ( const Image< T > &  src,
const T &  threshold,
const byte  lowVal = byte(0),
const byte  highVal = byte(255) 
) [inline]

make a binary version of the source image

Parameters:
src source image
threshold the threshold used for binarization
lowVal value for all points <= threshold
highVal value for all points > threshold

Definition at line 1472 of file Transforms.C.

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

Referenced by VisualBufferStd::findMostInterestingTarget(), and main().

template<class T >
Image<byte> makeBinary2 ( const Image< T > &  src,
const T &  lowThresh,
const T &  highThresh,
const byte  lowVal = byte(0),
const byte  highVal = byte(255) 
) [inline]

make a binary version of the source image

Parameters:
src source image
highThresh the threshold used for binarization
lowThresh the threshold used for binarization
lowVal value for all points <= threshold
highVal value for all points > threshold

Definition at line 1485 of file Transforms.C.

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

template<class T_or_RGB >
Image<T_or_RGB> mosaic ( const Image< T_or_RGB > &  fg,
const Image< T_or_RGB > *  bg,
const T_or_RGB *  transvalues,
const uint  Nimages 
) [inline]

Mosaic mapping of transparent pixels of fg into multiple bg's Equivalent to several simultaneous composite operations

Definition at line 1408 of file Transforms.C.

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

template<class T_or_RGB >
void pasteImage ( Image< T_or_RGB > &  background,
const Image< T_or_RGB > &  foreground,
const T_or_RGB &  transparent,
const Point2D< int >  location,
float  opacity = 1.0F 
) [inline]

paste foreground into background image at location as the upper-left corner in the background frame

Parameters:
transparent pixels with this value are not replaced in background

Definition at line 1502 of file Transforms.C.

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

Referenced by VisualEventSet::drawTokens(), TestImages::generateScene(), BitObject::getObjectMask(), VisualBufferStd::input(), and main().

template<class T_or_RGB >
Image<T_or_RGB> replaceVals ( const Image< T_or_RGB > &  src,
const T_or_RGB  from,
const T_or_RGB  to 
) [inline]

replace all values "from" with "to" and leave all other values in place

Definition at line 1343 of file Transforms.C.

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

template<class T_or_RGB >
Image<T_or_RGB> replaceVals ( const Image< T_or_RGB > &  src,
const T_or_RGB  from,
const T_or_RGB  to,
const T_or_RGB  other 
) [inline]

replace all values "from" with "to" and all other values with "other"

Definition at line 1328 of file Transforms.C.

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

Referenced by VisualEventSet::drawTokens(), extractBitObjects(), and BitObject::getObjectMask().

template<class T >
Image<T> saliencyChamfer34 ( const Image< T > &  src,
const T  dmax 
) [inline]

3/4-chamfer saliency distance transform; object = non 0

* reset borders */

Definition at line 376 of file Transforms.C.

References ASSERT, Image< T >::beginw(), Image< T >::getDims(), Image< T >::getHeight(), Image< T >::getSize(), Image< T >::getWidth(), Dims::h(), Image< T >::initialized(), and Dims::w().

template<class T >
int segmentLandmark ( const Image< T > &  src,
const Point2D< int > &  seed,
Image< byte > &  target,
double &  activity,
double &  standout,
float &  area_percentage 
) [inline]

Segment landmark using an adaptive thresholding & region growing method.

Returns an image that masks the landmark

Parameters:
activity is a measure of mean activity in the landmark
standout is a measure of how much the landmark stands out from the rest of the image
area is the percentage area of landmark

Definition at line 101 of file Transforms.C.

References area(), ASSERT, flood(), Image< T >::getSize(), Image< T >::getVal(), Point2D< T >::i, Image< T >::initialized(), and sum().

Referenced by findPeaks(), goodness_map(), and maxNormalizeLandmark().

template<class T >
Image<byte> segmentObject ( const Image< T > &  src,
const Point2D< int > &  center 
) [inline]

Segment object using an adaptive thresholding & region growing method.

Returns an image that masks the object (see Itti et al, J Neuroimaging, 2001)

Definition at line 64 of file Transforms.C.

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

template<class T >
Image<byte> segmentObjectClean ( const Image< T > &  src,
const Point2D< int > &  seed,
int  numConn 
) [inline]

same as segmentObject, only with floodClean and different parameters

Definition at line 1259 of file Transforms.C.

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

Generated on Sun May 8 08:13:02 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3