Meanshift  1.0
Functions
ms.cpp File Reference

Functions for Meanshift algorithm. More...

#include "ms.h"
#include <stack>
#include "../ra/TransitiveClosure.h"
Include dependency graph for ms.cpp:

Functions

void AddToStack (std::stack< MSPoint > &stack, int i, int j)
 Function AddToStack add point to the stack. More...
 
uchar * MeanShift (uchar *image, uchar *filtered_luv, int **labels, int width, int height, int spatial_radius, double color_radius, int minRegion, int num_iters)
 Function MeanShift runs two phases of Mean shift algorithm Filter and Segment using Meanshift algorithm The main program for Meanshift Meanshift algorithm: First phase is image filtering. Filtered image is in L*u*v colorspace Second phase is image segmentation. More...
 
uchar * MS_Filter (uchar *image, int width, int height, int spatial_radius, double color_radius, int initIters)
 Function MS_Filter filter image usign Meanshift algorithm using a circular flat kernel and color distance in L*u*v colorspace. More...
 
int MS_Segment (uchar *image, int width, int height, int **labels, double color_radius, int minRegion)
 Function MS_Segment segments the image using Meanshift algorithm. More...
 
int MS_Cluster (uchar *image, int width, int height, int **labels, int *modePoints, float *mode, double color_radius)
 Function MS_Cluster cluster the image using Meanshift. More...
 

Detailed Description

Functions for Meanshift algorithm.

Author
Damir Demirović damir.nosp@m..dem.nosp@m.irovi.nosp@m.c@un.nosp@m.tz.ba

Function Documentation

◆ AddToStack()

void AddToStack ( std::stack< MSPoint > &  stack,
int  i,
int  j 
)

Function AddToStack add point to the stack.

Parameters
ix coordinate of the point
jy coordinate of the point

◆ MeanShift()

uchar* MeanShift ( uchar *  image,
uchar *  filtered_luv,
int **  labels,
int  width,
int  height,
int  spatial_radius,
double  color_radius,
int  minRegion,
int  num_iters 
)

Function MeanShift runs two phases of Mean shift algorithm Filter and Segment using Meanshift algorithm The main program for Meanshift Meanshift algorithm: First phase is image filtering. Filtered image is in L*u*v colorspace Second phase is image segmentation.

Parameters
imageinput image for Meanshift algorithm
filtered_luvoutput image filtered with Meanshift algorithm
labelslabels
widthwidth of the image
heightheight of the image
spatial_radiusspatial radius
color_radiusrange radius
minRegionminimal region for merging
num_itersinitial number of iterations
Returns
segmented image

◆ MS_Cluster()

int MS_Cluster ( uchar *  image,
int  width,
int  height,
int **  labels,
int *  modePoints,
float *  mode,
double  color_radius 
)

Function MS_Cluster cluster the image using Meanshift.

Parameters
imagein L*u*v colorspace,
widthwidth of the image
heightheight of the image
labelscontain labels
modePointsdata about mode points
modedata about mode
color_radiusrange radius
Returns
regCount number of regions

◆ MS_Filter()

uchar* MS_Filter ( uchar *  image,
int  width,
int  height,
int  spatial_radius,
double  color_radius,
int  initIters 
)

Function MS_Filter filter image usign Meanshift algorithm using a circular flat kernel and color distance in L*u*v colorspace.

Based on implementation from https://imagej.nih.gov/ij/plugins/download/Mean_Shift.java

For each pixel of the image and the set ot the neighboring pixels within the specified spatial radius and color distance is determined. For this set of neighbor pixels, the new spatial center an the new color mean values are calculated. These new values will serve as the new center for the next iteration. This procedure will iterate until the spatial and color means will stop changing or the maximal number of iterations is achieved.

Parameters
imageinput image
widthwidth of the image
heightheight of the image
spatial_radiusspatial radius
color_radiusrange radius
initItersinitial number of iterations
Returns
luv Meanshift filtered image in L*u*v colorspace.

◆ MS_Segment()

int MS_Segment ( uchar *  image,
int  width,
int  height,
int **  labels,
double  color_radius,
int  minRegion 
)

Function MS_Segment segments the image using Meanshift algorithm.

Parameters
imagein L*u*v colorspace,
widthwidth of the image
heightheight of the image
labelscontain labels
color_radiusrange radius
minRegionminimal region for merging
Returns
regCount Number of segmented regions