Go to the source code of this file.
Classes | |
struct | paramColorFilter |
Data structure containing the parameters of the filtering algorithm. More... | |
Functions | |
struct paramColorFilter * | new_colorfiltering_parameters (int rneigh, int rsim, int nneighmin, float eitmax, unsigned char option, unsigned char ignore000) |
Organize input parameters in a data structure. | |
void | delete_colorfiltering_parameters (struct paramColorFilter *param) |
Delete input parameters data structure. | |
int | colorfiltering (unsigned char *R, unsigned char *G, unsigned char *B, unsigned char *outR, unsigned char *outG, unsigned char *outB, int w, int h, struct paramColorFilter *param) |
Main function implementing the color filtering algorithm (LLP algorithm). | |
float *** | RGBdensities (unsigned char *R, unsigned char *G, unsigned char *B, int w, int h, int rdst, float hdst, float &maxdst) |
Compute the density of the colors of an image. | |
void | delete_RGBdensities (float ***dsts) |
Delete data structure containing density values. | |
void | removeisolatedRGB (unsigned char *R, unsigned char *G, unsigned char *B, unsigned char *outR, unsigned char *outG, unsigned char *outB, int w, int h, int r, int nmin, int &nRGB, int &nisolatedRGB, int &nisolatedpixels) |
Filter out "isolated" colors in RGB space, that is, colors with a small number of neighbors. |
int colorfiltering | ( | unsigned char * | R, | |
unsigned char * | G, | |||
unsigned char * | B, | |||
unsigned char * | outR, | |||
unsigned char * | outG, | |||
unsigned char * | outB, | |||
int | w, | |||
int | h, | |||
struct paramColorFilter * | param | |||
) |
Main function implementing the color filtering algorithm (LLP algorithm).
Algorithm description (LLP algorithm)
Image colors are considered as points in a 3D space, namely the color cube. The algorithm replaces each RGB color in the cube by its projection onto a line (or plane) locally defined. This line (or plane) is the one that better fits the spatial distribution of the colors in a neighborhood of the considered RGB point, and it is computed by Principal Components Analysis (PCA). Only points with a large enough number of neighboring colors are projected. The process is iterated until the average error between corresponding colors in consecutive iterations is below a threshold.
[in] | R,G,B | pointers to red, green and blue channels of the input image |
[out] | outR,outG,outB | pointers to red, green and blue channels of the output image |
[in] | w,h | width and height of the input (and output) images |
[in] | param | data structure with the parameters of the algorithm: |
param.rneigh | radius of local neighborhood for computation of lines or planes | |
param.nneighmin | minimum number of neighbors (number of different colors) needed to compute lines or planes | |
param.rsim | speed up factor, the same line or plane computed for a given RGB point is used for its neighbors at L1-distance rsim | |
param.eitmax | stop criterion of the algorithm. The algorithm is iterated until the average difference of corresponding colors in two consecutive iterations is below eitmax | |
param.option | 1 project to line, 2 project to plane | |
param.ignore000 | if TRUE ignore (0,0,0) color points (eventually belonging to pixels discarded in a pre-processing step) |
Definition at line 1017 of file colorfilteringIPOL.cpp.
void delete_colorfiltering_parameters | ( | struct paramColorFilter * | param | ) |
Delete input parameters data structure.
Definition at line 1151 of file colorfilteringIPOL.cpp.
void delete_RGBdensities | ( | float *** | dsts | ) |
Delete data structure containing density values.
Definition at line 1247 of file colorfilteringIPOL.cpp.
struct paramColorFilter* new_colorfiltering_parameters | ( | int | rneigh, | |
int | rsim, | |||
int | nneighmin, | |||
float | eitmax, | |||
unsigned char | option, | |||
unsigned char | ignore000 | |||
) | [read] |
Organize input parameters in a data structure.
[in] | rneigh | distance defining the neighborhood of a color point (neighbors are RGB points at L1-distance below rneigh) |
[in] | rsim | distance defining a small neighborhood around each color point, it is used to speed up the algorithm. It must be much smaller than rneigh, typically rsim=rneigh/3 |
[in] | nneighmin | minimum number of neighbors needed to compute a local line or plane in the vicinity of a color point |
[in] | eitmax | stop criterion of the algorithm. The algorithm is iterated until the average difference of corresponding colors in two consecutive iterations is below eitmax |
[in] | option | project points to lines (option=1) or planes (option=2) |
[in] | ignore000 | if set to 1, do not take into account pixels with (0,0,0) RGB value (eventually discarded for computation in a preprocessing step) |
Definition at line 1129 of file colorfilteringIPOL.cpp.
void removeisolatedRGB | ( | unsigned char * | R, | |
unsigned char * | G, | |||
unsigned char * | B, | |||
unsigned char * | outR, | |||
unsigned char * | outG, | |||
unsigned char * | outB, | |||
int | w, | |||
int | h, | |||
int | r, | |||
int | nmin, | |||
int & | nRGB, | |||
int & | nisolatedRGB, | |||
int & | nisolatedpixels | |||
) |
Filter out "isolated" colors in RGB space, that is, colors with a small number of neighbors.
The result is an image identical to the original, except at the pixels with "isolated" colors, whose value has been replace by (0, 0, 0). The number of neighbors of a pixel is the number of color points at L1-distance below some threshold. Each color appears in the list of neighbors as many times as it is present in the image (i.e. the frequency of the color is taken into account in the computations).
[in] | R,G,B | color channels of the input image |
[out] | outR,outG,outB | color channels of the output image |
[in] | w,h | dimensions of input and output images |
[in] | r | radius of the neighborhood around each color point |
[in] | nmin | threshold for the minimum number of neighboring color points needed to decide that a color is not "isolated" |
[out] | nRGB | number of colors in input image |
[out] | nisolatedRGB | number of "isolated" colors |
[out] | nisolatedpixels | number of pixel with "isolated" color |
Definition at line 1284 of file colorfilteringIPOL.cpp.
float*** RGBdensities | ( | unsigned char * | R, | |
unsigned char * | G, | |||
unsigned char * | B, | |||
int | w, | |||
int | h, | |||
int | rdst, | |||
float | hdst, | |||
float & | maxdst | |||
) |
Compute the density of the colors of an image.
The density of a color C (in RGB space) is defined as
where is the set of neighbors of C is the Euclidean distance between colors C and C' in RGB space and is a weighting parameter
The set of neighbors of a color C is composed of all the colors at L1-distance below some threshold . Each color appears in the set of neighbors as many times as it is present in the image (i.e. the frequency of the color is taken into account in the computations). Tipically the weighting parameter is so the weight of the furthest neighbors is
[in] | R,G,B | color channels of the image |
[in] | w,h | dimensions of the image |
[in] | rdst | radius of the neighbor around each color point |
[in] | hdst | weighting parameter |
[out] | maxdst | maximum density value |
Definition at line 1186 of file colorfilteringIPOL.cpp.