ImageSpring< T > Class Template Reference

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

#include <Beobot/ImageSpring.H>

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

List of all members.

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

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.


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]
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  )  [inline]

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(), and Y.

Referenced by BeobotVisualCortex::iterateSprings().

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

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(), and ImageSpring< T >::getXY().

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 >::getSize().

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 
) [inline]
template<class T >
float ImageSpring< T >::getDistanceMasses ( const int  index1,
const int  index2 
) const [inline]

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(), and Point2D< T >::i.

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(), and Point2D< T >::i.

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 
) [inline]

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

Definition at line 225 of file ImageSpring.C.

References drawDisk(), Image< T >::getHeight(), ImageSpring< T >::getNeighbor(), Image< T >::getSize(), and Image< T >::getWidth().

Referenced by BeobotVisualCortex::getPositions().

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

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 >::getSize(), Image< T >::getVal(), Image< T >::initialized(), inplaceRectify(), inplaceSquare(), inverse(), randomUpToNotIncluding(), and sqrt().

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

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

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 >::getSize(), Image< T >::getVal(), Image< T >::initialized(), 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(), and Point2D< T >::i.

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(), Image< T >::resize(), and Image< T >::size().

template<class T >
void ImageSpring< T >::init ( const int  width,
const int  height,
const int  nbNeighbors 
) [inline]
template<class T >
void ImageSpring< T >::initClustering ( bool  initPosMasses  )  [inline]

The documentation for this class was generated from the following files:
Generated on Sun May 8 08:43:22 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3