Image Component Library (ICL)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
icl::cv::MeanShiftTracker Class Reference

#include <MeanShiftTracker.h>

List of all members.

Public Types

enum  kernelType { epanechnikov, gauss }
 An enumeration for the different kernel types. More...

Public Member Functions

 MeanShiftTracker (kernelType type, int bandwidth, float stdDev=1)
 Constructor with only the most needed parameters.
void setKernel (kernelType type, int bandwidth, float stdDev=1)
 sets new kernel type (with params)
int getKernel () const
 returns current kernel type
const core::Img32fgetKernelImage () const
 returns current kernel image
int getBandwidth () const
 Returns current kernel bandwidth.
const utils::Point32f step (const core::Img32f &weigthImage, const utils::Point32f &initialPoint, int maxCycles=-1, float convergenceCriterion=1.0, bool *converged=0)
 This function returns a new center after the MeanShift algorithm is applied.

Static Public Member Functions

static core::Img32f generateEpanechnikov (int bandwidth)
 Generates an Epanechnikov Kernel.
static core::Img32f generateGauss (int bandwidth, float stdDev)
 Generates a Gauss Kernel.

Private Member Functions

utils::Point32f applyMeanShiftStep (const core::Img32f &image, const utils::Point32f &pos)
 Applies a single step of the mean shift algorithm.

Private Attributes

int m_bandwidth
 The bandwidth of the kernel; equals diameter / 2.
kernelType m_kernelType
 The kerneltype; displayed as int.
core::Img32f m_kernelImage
 An internal representation of the kernel used.

Detailed Description

MeanShiftTracker

The MeanShiftTracker is a tracking component using the MeanShift algorithm.

Given a, preferably formatGrey, so called weightImage, it can find a distribution maxima of the feature tracked in the workingImage. The workingImage must contain weights for each pixel, determing the likelihood of the pixel belonging to the feature being tracked. High values correspond to a high likelihood.

The MeanShiftTracker uses the MeanShift algorithm for tracking blobs in realtime. It is an efficient technique for tracking 2D blobs through an image. Given a, preferably formatGrey, weightImage, it can find a distribution maxima of the feature tracked. The weightImage must contain weights for each pixel, determing the likelihood of the pixel belonging to the blob. High values correspond to a high likelihood. The Meanshift algorithm is resistent to camera movements, partial covering, scaling and noise. The Meanshift algorithm is also useful in image segmentation.

The MeanShift algorithm

As stated above, the MeanShiftTracker uses the MeanShift algorithm to find the new center of the blob being tracked. This is the MeanShift algorithm:

\[P_n = \frac{\sum_{A_h}k(A_h-P_o)w(A_h)P_o}{\sum_{A_h} | k(A_h-P_o) w(A_h)|} \]

, where $P_n $ is the new center of the blob, $P_o $ is the previous center, where the algorithm starts, $k() $ is the kernel function, $w() $ is the weight function and $A_h $ are all pixels located in a squarish region of the size 2*bandwidth around $P_o $.

The Bandwidth

The Bandwidth is the only parameter for this algorithm. It is half the length of the squarish mask containing all pixels $A$. Choosing a correct size for this mask is essential. It should approximatly cover the blob being tracked.

The Kernel

The Kernel determines how much each pixel $A$ contributes to the outcome of the formula. Using different kernels changes the speed and precision of the algorithm. So far, the Epanechnikov kernel, which is used as the default kernel for this algorithm, due to its good performance, and a Gauss kernel have been implemented.

The weightImage

This implementation of the Meanshift algorithm does not work with the original image. Only a one-channel image, having the same size and using the same coordinate system as the original image, is needed. In this image, all pixels, that belong to the blob must have high values.

ToDo

Add other kernels. Add functionality to open any image as kernel image. Performance tweaking.


Member Enumeration Documentation

An enumeration for the different kernel types.

Enumerator:
epanechnikov 
gauss 

Constructor & Destructor Documentation

icl::cv::MeanShiftTracker::MeanShiftTracker ( kernelType  type,
int  bandwidth,
float  stdDev = 1 
)

Constructor with only the most needed parameters.

The basic constructor with only the most needed parameters.

Parameters:
typeThe desired kernel type
bandwidthThe desired kernel bandwidth
stdDevprofiles the standard deviation.

Member Function Documentation

Applies a single step of the mean shift algorithm.

Parameters:
imageimage with which the mean shift step will be performed
posstart original position
Returns:
new center

Generates an Epanechnikov Kernel.

Parameters:
bandwidthkernel bandwidth
static core::Img32f icl::cv::MeanShiftTracker::generateGauss ( int  bandwidth,
float  stdDev 
) [static]

Generates a Gauss Kernel.

Generates the internal m_opKernelImage using the Gauss profile

Parameters:
bandwidthkernel bandwidth
stdDevprofiles the standard deviation.

Returns current kernel bandwidth.

int icl::cv::MeanShiftTracker::getKernel ( ) const [inline]

returns current kernel type

returns current kernel image

void icl::cv::MeanShiftTracker::setKernel ( kernelType  type,
int  bandwidth,
float  stdDev = 1 
)

sets new kernel type (with params)

Parameters:
typekernel type
bandwidthnew bandwidth
stdDevprofiles the standard deviation.
const utils::Point32f icl::cv::MeanShiftTracker::step ( const core::Img32f weigthImage,
const utils::Point32f initialPoint,
int  maxCycles = -1,
float  convergenceCriterion = 1.0,
bool *  converged = 0 
)

This function returns a new center after the MeanShift algorithm is applied.

Parameters:
weigthImagegray level input image
initialPointstarting point for meanshift loop
maxCyclesA treshold for the maximum iteration coutn if (-1, 10000 is used as upper limit)
convergenceCriterionposition difference (in pixels) of consecutive steps that is used as threshold for mean shift loop
convergedif a non-NULL pointer is given here, the reference boolean is used to notify the caller whether actually maxCycles iteration steps were used or the convergence criterion was reached

Member Data Documentation

The bandwidth of the kernel; equals diameter / 2.

An internal representation of the kernel used.

An image of the kernel used for the MeanShift. Stored is only the second quadrant of the image, as the values are the same for absolute coordinates.

The kerneltype; displayed as int.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines