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

ImageSpring< T > Class Template Reference

#include <Beobot/ImageSpring.H>

Inheritance diagram for ImageSpring< T >:

Inheritance graph
[legend]
Collaboration diagram for ImageSpring< T >:

Collaboration graph
[legend]
List of all members.

Detailed Description

template<class T>
class ImageSpring< T >

This class is some sort of self organizing map used for clustering.

All the pixels are linked by springs whose stiffness depends on the difference between them

Definition at line 53 of file ImageSpring.H.

Public Member Functions

 ImageSpring (const int width, const int height, const int nbNeighbors)
 Constructor that only allocates memory for given size.
 ImageSpring ()
 Constructor for uninitialized image (useful for arrays of Images).
 ImageSpring (const ImageSpring< T > &A)
 Copy constructor.
void init (const int width, const int height, const int nbNeighbors)
 init function
void init (const T *a, const float *posX, const float *posY, const float **stiff, const int width, const int height, const int nbNeighbors)
 init function, to copy another ImageSpring
 ~ImageSpring ()
 Destructor.
void freeMem ()
 Free memory and switch to uninitialized state.
void initClustering (bool initPosMasses)
 initialize 'stiff' and 'pos'
void computeStiff (void)
 compute the stiffness of the spring between the masses
void computePos (const float dt)
 updates the positions of the masses
void getStats (void)
 computes mean and stdev (**heuristic**)
void getStatsDist (void)
 computes meanDist and stdevDist (**heuristic**)
void getXY (const int index, Point2D< int > &pt) const
 returns (X,Y) given an index=X+w*Y (see posX)
void getIndex (const Point2D< int > point, int &index) const
 returns the index=X+w*Y (see posX)
int getNbNeighbors (void) const
 returns the number of neighbors
float getDistanceMasses (const int index1, const int index2) const
 distance between the 2 masses
bool getNeighbor (const int index, const int n, int &indexNeighbor) const
 computes the index of the nth neighbor of "index"
void getPositions (Image< PixRGB< byte > > &img, const int zoom=16)
 Get position of masses and strength of springs (for debug).
void getClusteredImage (const Image< PixRGB< byte > > &scene, Image< PixRGB< byte > > &clusteredImage, Point2D< int > &supposedTrackCentroid, const Point2D< int > &previousTrackCentroid)
 get clustered image and track centroid position


Constructor & Destructor Documentation

template<class T>
ImageSpring< T >::ImageSpring const int  width,
const int  height,
const int  nbNeighbors
[inline]
 

Constructor that only allocates memory for given size.

Definition at line 197 of file ImageSpring.H.

References ImageSpring< T >::init().

template<class T>
ImageSpring< T >::ImageSpring  )  [inline]
 

Constructor for uninitialized image (useful for arrays of Images).

Use init() later to initialize

Definition at line 206 of file ImageSpring.H.

template<class T>
ImageSpring< T >::ImageSpring const ImageSpring< T > &  A  )  [inline]
 

Copy constructor.

Definition at line 211 of file ImageSpring.H.

References ASSERT, Image< T >::getArrayPtr(), Image< T >::getHeight(), Image< T >::getWidth(), ImageSpring< T >::init(), Image< T >::initialized(), ImageSpring< T >::nbNeighbors, and ImageSpring< T >::stiff.

template<class T>
ImageSpring< T >::~ImageSpring  )  [inline]
 

Destructor.

Definition at line 222 of file ImageSpring.H.

References ImageSpring< T >::freeMem().


Member Function Documentation

template<class T>
void ImageSpring< T >::computePos const float  dt  ) 
 

updates the positions of the masses

based on simple mechanics

Definition at line 172 of file ImageSpring.C.

References gamma(), Image< T >::getHeight(), ImageSpring< T >::getIndex(), ImageSpring< T >::getNeighbor(), Image< T >::getSize(), Image< T >::getWidth(), n, x, Y, and y.

Referenced by BeobotVisualCortex::iterateSprings().

template<class T>
void ImageSpring< T >::computeStiff void   ) 
 

compute the stiffness of the spring between the masses

based on the color-distance between pixels

Definition at line 139 of file ImageSpring.C.

References distance(), ImageSpring< T >::getNeighbor(), Image< T >::getSize(), Image< T >::getVal(), ImageSpring< T >::getXY(), and n.

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

template<class T>
void ImageSpring< T >::freeMem  )  [inline]
 

Free memory and switch to uninitialized state.

Reimplemented from Image< T >.

Definition at line 227 of file ImageSpring.H.

References Image< T >::freeMem(), Image< T >::getSize(), and Dlist::index().

Referenced by ImageSpring< T >::init(), and ImageSpring< T >::~ImageSpring().

template<class T>
void ImageSpring< T >::getClusteredImage const Image< PixRGB< byte > > &  scene,
Image< PixRGB< byte > > &  clusteredImage,
Point2D< int > &  supposedTrackCentroid,
const Point2D< int > &  previousTrackCentroid
 

get clustered image and track centroid position

Definition at line 289 of file ImageSpring.C.

References drawCross(), Image< T >::getHeight(), Image< T >::getVal(), Image< T >::getWidth(), Point2D< T >::i, Point2D< T >::j, rutz::max(), NO_INIT, PixRGB< T >::set(), Image< T >::setVal(), sqrt(), squareOf(), x, y, and ZEROS.

Referenced by BeobotVisualCortex::getClusteredImage().

template<class T>
float ImageSpring< T >::getDistanceMasses const int  index1,
const int  index2
const
 

distance between the 2 masses

Definition at line 220 of file ImageSpring.C.

References sqrt(), and squareOf().

template<class T>
void ImageSpring< T >::getIndex const Point2D< int >  point,
int &  index
const [inline]
 

returns the index=X+w*Y (see posX)

Definition at line 293 of file ImageSpring.H.

References Image< T >::getWidth(), Point2D< T >::i, and Point2D< T >::j.

Referenced by ImageSpring< T >::computePos(), and ImageSpring< T >::getNeighbor().

template<class T>
int ImageSpring< T >::getNbNeighbors void   )  const [inline]
 

returns the number of neighbors

Definition at line 351 of file ImageSpring.H.

template<class T>
bool ImageSpring< T >::getNeighbor const int  index,
const int  n,
int &  indexNeighbor
const [inline]
 

computes the index of the nth neighbor of "index"

returns true iif the neighbor is in the image

Definition at line 298 of file ImageSpring.H.

References ASSERT, Image< T >::coordsOk(), ImageSpring< T >::getIndex(), ImageSpring< T >::getXY(), Point2D< T >::i, Point2D< T >::j, and LFATAL.

Referenced by ImageSpring< T >::computePos(), ImageSpring< T >::computeStiff(), ImageSpring< T >::getPositions(), and ImageSpring< T >::getStatsDist().

template<class T>
void ImageSpring< T >::getPositions Image< PixRGB< byte > > &  img,
const int  zoom = 16
 

Get position of masses and strength of springs (for debug).

Definition at line 225 of file ImageSpring.C.

References drawDisk(), drawLine(), Image< T >::getHeight(), ImageSpring< T >::getNeighbor(), Image< T >::getSize(), i, n, and pp.

Referenced by BeobotVisualCortex::getPositions().

template<class T>
void ImageSpring< T >::getStats void   ) 
 

computes mean and stdev (**heuristic**)

this function is a heuristic because it will only consider nbHeuristic pixels at random

Definition at line 57 of file ImageSpring.C.

References ASSERT, Image< T >::getVal(), inplaceRectify(), inplaceSquare(), inverse(), n, randomUpToNotIncluding(), and sqrt().

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

template<class T>
void ImageSpring< T >::getStatsDist void   ) 
 

computes meanDist and stdevDist (**heuristic**)

weight must be defined this function is an heuristic because it will only consider nbHeuristic pairs of pixels at random

Definition at line 88 of file ImageSpring.C.

References ASSERT, distance(), ImageSpring< T >::getNeighbor(), Image< T >::getVal(), n, randomUpToNotIncluding(), sqrt(), and squareOf().

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

template<class T>
void ImageSpring< T >::getXY const int  index,
Point2D< int > &  pt
const [inline]
 

returns (X,Y) given an index=X+w*Y (see posX)

Definition at line 288 of file ImageSpring.H.

References Image< T >::getWidth(), Point2D< T >::i, and Point2D< T >::j.

Referenced by ImageSpring< T >::computeStiff(), and ImageSpring< T >::getNeighbor().

template<class T>
void ImageSpring< T >::init const T *  a,
const float *  posX,
const float *  posY,
const float **  stiff,
const int  width,
const int  height,
const int  nbNeighbors
[inline]
 

init function, to copy another ImageSpring

Definition at line 242 of file ImageSpring.H.

References ImageSpring< T >::freeMem(), Image< T >::getSize(), Dlist::index(), Image< T >::resize(), and Image< T >::size().

template<class T>
void ImageSpring< T >::init const int  width,
const int  height,
const int  nbNeighbors
[inline]
 

init function

Definition at line 270 of file ImageSpring.H.

References ImageSpring< T >::freeMem(), Image< T >::getSize(), Dlist::index(), Image< T >::resize(), and Image< T >::size().

Referenced by ImageSpring< T >::ImageSpring(), and BeobotVisualCortex::init().

template<class T>
void ImageSpring< T >::initClustering bool  initPosMasses  ) 
 

initialize 'stiff' and 'pos'

Definition at line 121 of file ImageSpring.C.

References ImageSpring< T >::computeStiff(), Image< T >::getHeight(), ImageSpring< T >::getStats(), ImageSpring< T >::getStatsDist(), Image< T >::getWidth(), x, and y.

Referenced by BeobotVisualCortex::initSprings().


The documentation for this class was generated from the following files:
Generated on Mon Nov 23 15:50:25 2009 for iLab Neuromorphic Vision Toolkit by  doxygen 1.4.4