Functions for Meanshift algorithm.
More...
#include "ms.h"
#include <stack>
#include "../ra/TransitiveClosure.h"
|
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...
|
|
Functions for Meanshift algorithm.
- Author
- Damir Demirović damir.nosp@m..dem.nosp@m.irovi.nosp@m.c@un.nosp@m.tz.ba
◆ AddToStack()
void AddToStack |
( |
std::stack< MSPoint > & |
stack, |
|
|
int |
i, |
|
|
int |
j |
|
) |
| |
Function AddToStack add point to the stack.
- Parameters
-
i | x coordinate of the point |
j | y 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
-
image | input image for Meanshift algorithm |
filtered_luv | output image filtered with Meanshift algorithm |
labels | labels |
width | width of the image |
height | height of the image |
spatial_radius | spatial radius |
color_radius | range radius |
minRegion | minimal region for merging |
num_iters | initial 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
-
image | in L*u*v colorspace, |
width | width of the image |
height | height of the image |
labels | contain labels |
modePoints | data about mode points |
mode | data about mode |
color_radius | range 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
-
image | input image |
width | width of the image |
height | height of the image |
spatial_radius | spatial radius |
color_radius | range radius |
initIters | initial 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
-
image | in L*u*v colorspace, |
width | width of the image |
height | height of the image |
labels | contain labels |
color_radius | range radius |
minRegion | minimal region for merging |
- Returns
- regCount Number of segmented regions