Image Component Library (ICL)
|
#include <MeanShiftTracker.h>
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. More... | |
void | setKernel (kernelType type, int bandwidth, float stdDev=1) |
sets new kernel type (with params) More... | |
int | getKernel () const |
returns current kernel type More... | |
const core::Img32f & | getKernelImage () const |
returns current kernel image More... | |
int | getBandwidth () const |
Returns current kernel bandwidth. More... | |
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. More... | |
Static Public Member Functions | |
static core::Img32f | generateEpanechnikov (int bandwidth) |
Generates an Epanechnikov Kernel. More... | |
static core::Img32f | generateGauss (int bandwidth, float stdDev) |
Generates a Gauss Kernel. More... | |
Private Member Functions | |
utils::Point32f | applyMeanShiftStep (const core::Img32f &image, const utils::Point32f &pos) |
Applies a single step of the mean shift algorithm. More... | |
Private Attributes | |
int | m_bandwidth |
The bandwidth of the kernel; equals diameter / 2. More... | |
kernelType | m_kernelType |
The kerneltype; displayed as int. More... | |
core::Img32f | m_kernelImage |
An internal representation of the kernel used. More... | |
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.
As stated above, the MeanShiftTracker uses the MeanShift algorithm to find the new center of the blob being tracked. This is the MeanShift algorithm:
, where is the new center of the blob, is the previous center, where the algorithm starts, is the kernel function, is the weight function and are all pixels located in a squarish region of the size 2*bandwidth around .
The Bandwidth is the only parameter for this algorithm. It is half the length of the squarish mask containing all pixels . Choosing a correct size for this mask is essential. It should approximatly cover the blob being tracked.
The Kernel determines how much each pixel 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.
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.
Add other kernels. Add functionality to open any image as kernel image. Performance tweaking.
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.
type | The desired kernel type |
bandwidth | The desired kernel bandwidth |
stdDev | profiles the standard deviation. |
|
private |
Applies a single step of the mean shift algorithm.
image | image with which the mean shift step will be performed |
pos | start original position |
|
static |
Generates an Epanechnikov Kernel.
bandwidth | kernel bandwidth |
|
static |
Generates a Gauss Kernel.
Generates the internal m_opKernelImage using the Gauss profile
bandwidth | kernel bandwidth |
stdDev | profiles the standard deviation. |
|
inline |
Returns current kernel bandwidth.
|
inline |
returns current kernel type
|
inline |
returns current kernel image
void icl::cv::MeanShiftTracker::setKernel | ( | kernelType | type, |
int | bandwidth, | ||
float | stdDev = 1 |
||
) |
sets new kernel type (with params)
type | kernel type |
bandwidth | new bandwidth |
stdDev | profiles 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.
weigthImage | gray level input image |
initialPoint | starting point for meanshift loop |
maxCycles | A treshold for the maximum iteration coutn if (-1, 10000 is used as upper limit) |
convergenceCriterion | position difference (in pixels) of consecutive steps that is used as threshold for mean shift loop |
converged | if 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 |
|
private |
The bandwidth of the kernel; equals diameter / 2.
|
private |
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.
|
private |
The kerneltype; displayed as int.