00001 /* 00002 * Copyright (c) 2009-2010 Jose-Luis Lisani <joseluis.lisani@uib.es> 00003 * All rights reserved. 00004 * 00005 * This program is free software: you can redistribute it and/or modify 00006 * it under the terms of the GNU General Public License as published by 00007 * the Free Software Foundation, either version 3 of the License, or 00008 * (at your option) any later version. 00009 * 00010 * This program is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 * GNU General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU General Public License 00016 * along with this program. If not, see <http://www.gnu.org/licenses/>. 00017 */ 00018 00019 00020 #ifndef COLORFILTERING_IPOL_H 00021 #define COLORFILTERING_IPOL_H 00022 00023 00043 struct paramColorFilter { 00044 int rneigh; //distance defining the neighborhood of a color point 00045 //(neighbors are RGB points at L1-distance below rneigh) 00046 int rsim; //distance defining a small neighborhood around each color point, 00047 //it is used to accelerate the algorithm. 00048 //It must be much smaller than rneigh, typically rsim=rneigh/3 00049 int nneighmin; //minimum number of neighbors needed to compute a local line 00050 //or plane in the vicinity of a color point 00051 float eitmax; //stop criterion of the algorithm. The algorithm is iterated 00052 //until the average difference of corresponding colors in two 00053 //consecutive iterations is below eitmax 00054 unsigned char option; //project points to lines (option=1) 00055 //or planes (option=2) 00056 unsigned char ignore000; //if set to 1, do not take into account pixels with 00057 //(0,0,0) RGB value (eventually discarded for 00058 //computation in a preprocessing step) 00059 }; 00060 00061 struct paramColorFilter *new_colorfiltering_parameters(int rneigh, int rsim, 00062 int nneighmin, 00063 float eitmax, 00064 unsigned char option, 00065 unsigned char ignore000); 00066 00067 void delete_colorfiltering_parameters(struct paramColorFilter *param); 00068 00069 //option=1 -> project to line 00070 //option=2 -> project to plane 00071 //option=3 -> project to line if weight1 >= weightMin, else project to plane 00072 int colorfiltering(unsigned char *R, unsigned char *G, unsigned char *B, 00073 unsigned char *outR, unsigned char *outG, 00074 unsigned char *outB, 00075 int w, int h, struct paramColorFilter *param); 00076 00077 float ***RGBdensities(unsigned char *R, unsigned char *G, unsigned char *B, 00078 int w, int h, int rdst, float hdst, float &maxdst); 00079 00080 void delete_RGBdensities(float ***dsts); 00081 00082 void removeisolatedRGB(unsigned char *R, unsigned char *G, unsigned char *B, 00083 unsigned char *outR, unsigned char *outG, 00084 unsigned char *outB, 00085 int w, int h, int r, int nmin, int &nRGB, 00086 int &nisolatedRGB, 00087 int &nisolatedpixels); 00088 00089 #endif 00090