libidx
|
00001 /*************************************************************************** 00002 * Copyright (C) 2009 by Pierre Sermanet * 00003 * pierre.sermanet@gmail.com * 00004 * All rights reserved. 00005 * 00006 * Redistribution and use in source and binary forms, with or without 00007 * modification, are permitted provided that the following conditions are met: 00008 * * Redistributions of source code must retain the above copyright 00009 * notice, this list of conditions and the following disclaimer. 00010 * * Redistributions in binary form must reproduce the above copyright 00011 * notice, this list of conditions and the following disclaimer in the 00012 * documentation and/or other materials provided with the distribution. 00013 * * Redistribution under a license not approved by the Open Source 00014 * Initiative (http://www.opensource.org) must display the 00015 * following acknowledgement in all advertising material: 00016 * This product includes software developed at the Courant 00017 * Institute of Mathematical Sciences (http://cims.nyu.edu). 00018 * * The names of the authors may not be used to endorse or promote products 00019 * derived from this software without specific prior written permission. 00020 * 00021 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED 00022 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 00023 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00024 * DISCLAIMED. IN NO EVENT SHALL ThE AUTHORS BE LIABLE FOR ANY 00025 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 00026 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00027 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 00028 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00029 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00030 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00031 ***************************************************************************/ 00032 00033 #ifndef COLOR_SPACES_H_ 00034 #define COLOR_SPACES_H_ 00035 00036 #include "defines.h" 00037 #include "idx.h" 00038 00039 namespace ebl { 00040 00041 extern idx<double> rgb_yuv; 00042 extern idx<double> yuv_rgb; 00043 00045 // RGB -> YUV 00046 00054 template<class T> 00055 void rgb_to_yuv(idx<T> &rgb, idx<T> &yuv); 00056 00059 template<class T> 00060 void rgb_to_yuv_1D(idx<T> &rgb, idx<T> &yuv); 00061 00064 template<class T> 00065 idx<T> rgb_to_yuv(idx<T> &rgb); 00066 00070 template<class T> 00071 void rgb_to_y(idx<T> &rgb, idx<T> &y); 00072 00075 template<class T> 00076 void rgb_to_y_1D(idx<T> &rgb, idx<T> &y); 00077 00079 // BGR -> YUV 00080 00084 template<class T> 00085 void bgr_to_y(idx<T> &bgr, idx<T> &y); 00086 00089 template<class T> 00090 void bgr_to_yuv_1D(idx<T> &bgr, idx<T> &yuv); 00091 00094 template<class T> 00095 void bgr_to_y_1D(idx<T> &bgr, idx<T> &y); 00096 00098 // YUV -> RGB 00099 00103 template<class T> 00104 void yuv_to_rgb(idx<T> &yuv, idx<T> &rgb); 00105 00108 template<class T> 00109 idx<T> yuv_to_rgb(idx<T> &yuv); 00110 00112 void YUVGlobalNormalization(idx<float> &yuv); 00113 00115 // HSV 00116 00117 EXPORT void PIX_RGB_TO_HSV_COMMON(double H, double S, double V, 00118 double &R, double &G, double &B, bool NORM); 00119 00120 EXPORT void PIX_HSV_TO_RGB_COMMON(double H, double S, double V, 00121 double &R, double &G, double &B); 00122 00123 00124 template<class T> 00125 void rgb_to_h_1D(idx<T> &rgb, idx<T> &h); 00126 00130 template<class T> 00131 void rgb_to_hsv(idx<T> &rgb, idx<T> &hsv); 00132 00135 template<class T> 00136 idx<T> rgb_to_hsv(idx<T> &rgb); 00137 00141 template<class T> 00142 void hsv_to_rgb(idx<T> &hsv, idx<T> &rgb); 00143 00146 template<class T> 00147 idx<T> hsv_to_rgb(idx<T> &hsv); 00148 00150 // HSV3 00151 00152 EXPORT void PIX_HSV3_TO_RGB_COMMON(double H, double S, double V, 00153 double &R, double &G, double &B); 00157 template<class T> 00158 void rgb_to_hsv3(idx<T> &rgb, idx<T> &hsv3, 00159 double threshold1, double threshold2); 00160 00163 template<class T> 00164 idx<T> rgb_to_hsv3(idx<T> &rgb, double threshold1, double threshold2); 00165 00169 template<class T> 00170 void hsv3_to_rgb(idx<T> &hsv3, idx<T> &rgb); 00171 00174 template<class T> 00175 idx<T> hsv3_to_rgb(idx<T> &hsv3); 00176 00178 // YH3 00179 00183 template<class T> 00184 void rgb_to_yh3(idx<T> &rgb, idx<T> &yh3, double threshold1 = .10, 00185 double threshold2 = .15); 00186 00189 template<class T> 00190 idx<T> rgb_to_yh3(idx<T> &rgb, double threshold1 = .10, 00191 double threshold2 = .15); 00192 00196 template<class T> 00197 void h3_to_rgb(idx<T> &h3, idx<T> &rgb); 00198 00201 template<class T> 00202 idx<T> h3_to_rgb(idx<T> &h3); 00203 00205 // H2sv 00206 00207 void PIX_HSV_TO_H2SV1_COMMON(double H, double &H1, double &H2); 00208 00209 template<class T> 00210 void rgb_to_h2sv_1D(idx<T> &rgb, idx<T> &h2sv); 00211 00212 template<class T> 00213 void rgb_to_h2sv(idx<T> &rgb, idx<T> &h2sv); 00214 00216 // VpH2SV 00217 00218 template<class T> 00219 void rgb_to_vph2sv(idx<T> &rgb, idx<T> &vph2sv, double s, int n); 00220 00221 } // end namespace ebl 00222 00223 #include "color_spaces.hpp" 00224 00225 #endif /* COLOR_SPACES_H_ */