latest version v1.9 - last update 10 Apr 2010 |
00001 /* 00002 * Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 00003 * Lehrstuhl fuer Technische Informatik, RWTH-Aachen, Germany 00004 * 00005 * This file is part of the LTI-Computer Vision Library (LTI-Lib) 00006 * 00007 * The LTI-Lib is free software; you can redistribute it and/or 00008 * modify it under the terms of the GNU Lesser General Public License (LGPL) 00009 * as published by the Free Software Foundation; either version 2.1 of 00010 * the License, or (at your option) any later version. 00011 * 00012 * The LTI-Lib is distributed in the hope that it will be 00013 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty 00014 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 * GNU Lesser General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU Lesser General Public 00018 * License along with the LTI-Lib; see the file LICENSE. If 00019 * not, write to the Free Software Foundation, Inc., 59 Temple Place - 00020 * Suite 330, Boston, MA 02111-1307, USA. 00021 */ 00022 00023 00024 /*---------------------------------------------------------------- 00025 * project ....: LTI Digital Image/Signal Processing Library 00026 * file .......: ltiSplitImageToCIELuv.h 00027 * authors ....: Pablo Alvarado, Stefan Syberichs, Thomas Rusert 00028 * organization: LTI, RWTH Aachen 00029 * creation ...: 19.04.99 00030 * revisions ..: $Id: ltiSplitImageToCIELuv.h,v 1.6 2007/11/17 21:28:39 alvarado Exp $ 00031 */ 00032 00033 #ifndef _LTI_SPLIT_IMAGE_TO_CIELUV_H_ 00034 #define _LTI_SPLIT_IMAGE_TO_CIELUV_H_ 00035 00036 #include "ltiSplitImage.h" 00037 00038 namespace lti { 00039 00040 /** 00041 * Split image in its L\f$^*\f$u\f$^*\f$v\f$^*\f$ channels. 00042 * 00043 * The following is an excerpt of 00044 * <a href="http://www.cs.rit.edu/~ncs/color/t_convert.html">this page</a> 00045 * 00046 * CIE 1976 \f$L^*u^*v^*\f$ (CIELUV) is 00047 * based directly on CIE XYZ and is another attempt to linearize the 00048 * perceptibility of color differences. The non-linear relations for 00049 * \f$L^*\f$, \f$u^*\f$, and \f$v^*\f$ are given below: 00050 * 00051 * \f$L^*\f$ = 116 * (Y/Yn)1/3 - 16<br> 00052 * \f$u^*\f$ = 13L<sup>*</sup> * ( u' - un' )<br> 00053 * \f$v^*\f$ = 13L<sup>*</sup> * ( v' - vn' )<br> 00054 * 00055 * The quantities un' and vn' refer to the reference white of the 00056 * light source; for the \f$2^\circ\f$ observer and illuminant C, 00057 * un' = 0.2009, 00058 * vn' = 0.4610 [ 1 ]. Equations for u' and v' are given below: 00059 * 00060 * u' = 4X / (X + 15Y + 3Z) = 4x / ( -2x + 12y + 3 )<br> 00061 * v' = 9Y / (X + 15Y + 3Z) = 9y / ( -2x + 12y + 3 )<br> 00062 * 00063 * The transformation from (u',v') to (x,y) is: 00064 * 00065 * x = 27u' / ( 18u' - 48v' + 36 )<br> 00066 * y = 12v' / ( 18u' - 48v' + 36 )<br> 00067 * 00068 * The transformation from CIELUV to XYZ is performed as following: 00069 * 00070 * u' = u / ( 13\f$L^*\f$) + un<br> 00071 * v' = v / ( 13\f$L^*\f$ ) + vn<br> 00072 * Y = (( \f$L^*\f$ + 16 ) / 116 )3<br> 00073 * X = - 9Yu' / (( u' - 4 ) v' - u'v' )<br> 00074 * Z = ( 9Y - 15v'Y - v'X ) / 3v' 00075 * 00076 * 00077 * The \f$L^*\f$ value with these definitions will be between 0 and 100. 00078 * This functor ensure that the outputs will be put into the usual values in 00079 * the LTI-Lib, i.e. for channels the outputs will be normalized by 100, so 00080 * that the luminance channel will be between 0 and 1.0. The u channel will 00081 * get values between -0.865731 to 1.72906 and the v channel from -1.30445 to 00082 * 1.16047. 00083 * 00084 * For channel8 outputs this color space doesn't make much sense, since some 00085 * values are negative. 00086 * 00087 * @ingroup gColor 00088 */ 00089 class splitImageToCIELuv : public splitImage { 00090 public: 00091 /** 00092 * default constructor. 00093 * Initializes (only once) the lut for the cubic root, with 2048 entries. 00094 */ 00095 splitImageToCIELuv(); 00096 00097 /** 00098 * returns the name of this type 00099 */ 00100 virtual const char* getTypename() const; 00101 00102 /** 00103 * returns a pointer to a clone of the functor 00104 */ 00105 virtual functor* clone() const; 00106 00107 /** 00108 * on-copy 00109 * Note that the output channels will contain values outside the interval 00110 * 0.0-1.0. 00111 */ 00112 virtual bool apply(const image& img, 00113 channel& c1, 00114 channel& c2, 00115 channel& c3) const; 00116 00117 /** 00118 * on-copy 00119 * Note that the output values will contain values outside the interval 00120 * 0.0-1.0. 00121 */ 00122 virtual bool apply(const rgbPixel& pixel, 00123 float& c1, 00124 float& c2, 00125 float& c3) const; 00126 00127 protected: 00128 00129 /** 00130 * on-copy 00131 * Do not use this method yet! The output channels will contain invalid 00132 * data due to underflows and overflows of the channel valid value range! 00133 */ 00134 virtual bool apply(const image& img, 00135 channel8& c1, 00136 channel8& c2, 00137 channel8& c3) const; 00138 00139 /** 00140 * on-copy 00141 * Do not use this method yet! The output values will contain invalid 00142 * data due to underflows and overflows of the valid value range! 00143 */ 00144 virtual bool apply(const rgbPixel& pixel, 00145 ubyte& c1, 00146 ubyte& c2, 00147 ubyte& c3) const; 00148 00149 /** 00150 * look-up-table for cubic root 00151 */ 00152 static const float* lut; 00153 /** 00154 * size of the lut for cubic root 00155 */ 00156 static const int lutSize; 00157 }; 00158 00159 } // namespace lti 00160 #endif