The C++ interface for meanshift. More...

array meanshift (const array &image, const float space, const float color, const int iter=5)
 Meanshift filtering. More...
 

Detailed Description

The C++ interface for meanshift.

A meanshift filter is an edge-preserving smoothing filter commonly used in object tracking and image segmentation.

This filter replaces each pixel in the image with the mean of the values within a given given color and spatial radius. The meanshift filter is an iterative algorithm that continues until a maxium number of iterations is met or until the value of the means no longer changes.

Function Documentation

array af::meanshift ( const array &  image,
const float  space,
const float  color,
const int  iter = 5 
)

Meanshift filtering.

// meanshift filter an image with color values [0-1]
float sigma_space = 3.f;
float sigma_color = 0.2f;
int iterations = 5;
array img_out = meanshift(img_in, sigma_space, sigma_color, iterations);
// meanshift filter an image with color values [0-255]
float sigma_space = 3.f;
float sigma_color = 0.2f * 255.f;
int iterations = 5;
array img_out = meanshift(img_in, sigma_space, sigma_color, iterations);
Parameters
[in]imageinput image
[in]spaceradius in pixels, area for filtering. note: internally space *= 1.5
[in]colordifference in color allowed, range depends on values in image
[in]itermaximum number of iterations for convergence (default=5, max=100)
Note
color range depends on values in the image if image is [0-1], scale color from [0-1]; if image is [0-255], scale color from [0-255];