eLynx SDK
v3.3.0 C++ image processing API reference |
00001 //============================================================================ 00002 // ColorSpace.h Image.Component package 00003 //============================================================================ 00004 // http://www.brucelindbloom.com/ 00005 // http://www.kleocolor.com/en/sommaire.php 00006 // http://www.aim-dtp.net/aim/technology/color-spaces_faq/color-space.faq.txt 00007 // http://www.tsi.enst.fr/tsi/enseignement/ressources/mti/correl_couleur/ 00008 // http://www.easyrgb.com/math.php?MATH=M1#text1 00009 // http://www.cs.rit.edu/~ncs/color/a_spaces.html 00010 //---------------------------------------------------------------------------- 00011 // Copyright (C) 2006 by eLynx project 00012 // 00013 // This library is free software; you can redistribute it and/or 00014 // modify it under the terms of the GNU Library General Public 00015 // License as published by the Free Software Foundation; either 00016 // version 2 of the License, or (at your option) any later version. 00017 // 00018 // This library is distributed in the hope that it will be useful, 00019 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00020 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00021 // See the GNU Library General Public License for more details. 00022 //---------------------------------------------------------------------------- 00023 #ifndef __ColorSpace_h__ 00024 #define __ColorSpace_h__ 00025 00026 #include <elx/image/Pixels.h> 00027 00028 namespace eLynx { 00029 namespace Image { 00030 00032 enum ETristimulus 00033 { 00034 TV_A_2, 00035 TV_C_2, 00036 TV_D50_2, 00037 TV_D55_2, 00038 TV_D65_2, 00039 TV_D75_2, 00040 TV_F2_2, 00041 TV_F7_2, 00042 TV_F11_2, 00043 00044 TV_A_10, 00045 TV_C_10, 00046 TV_TD50_10, 00047 TV_D55_10, 00048 TV_D65_10, 00049 TV_D75_10, 00050 TV_F2_10, 00051 TV_F7_10, 00052 TV_F11_10, 00053 00054 TV_Default = TV_D65_10 00055 }; 00056 ExportedByImage extern const double g_TristimulusLut[1 + TV_F11_10][3]; 00057 00058 //---------------------------------------------------------------------------- 00059 // Pre-calculated CIE Lookup tables 00060 //---------------------------------------------------------------------------- 00061 class ExportedByImage CIELut 00062 { 00063 public: 00064 static void Init(); 00065 00066 template <typename T> 00067 static float GetXYZ2Lab(T iValue); 00068 00069 template <typename T> 00070 static float GetRGB2XYZ(T iValue); 00071 00072 private: 00073 static bool _sbInit; 00074 00075 static float _slutXYZ2Lab_ub[0x100]; 00076 static float _slutXYZ2Lab_us[0x10000]; 00077 00078 public: 00079 static uint8 _slutRGB2XYZ_ub[0x100][9]; 00080 static uint16 _slutRGB2XYZ_us[0x10000][9]; 00081 }; 00082 00083 template<typename T> 00084 ExportedByImage 00085 T elxGetHue(double iHue); 00086 00087 template<typename T> 00088 ExportedByImage 00089 T elxGetSaturation(double iSaturation); 00090 00091 template<class Pixel> 00092 ExportedByImage 00093 void elxColorize(Pixel& ioPixel, typename Pixel::type iHue, typename Pixel::type iSaturation); 00094 00095 template<class Pixel> 00096 ExportedByImage 00097 void elxDesaturate(Pixel& ioPixel, double iFactor); 00098 00099 template<class Pixel> 00100 ExportedByImage 00101 void elxDesaturate(Pixel& ioPixel, double iFactor, uint32 iChannelMask); 00102 00103 template<class Pixel> 00104 ExportedByImage 00105 void elxAdjustHueSaturation(Pixel& ioPixel, double iHue, double iSaturation); 00106 00107 template<typename T> 00108 ExportedByImage 00109 void elxRGBToHLS(const PixelRGB<T>& iPixel, T& oHue, T& oLuminance, T& oSaturation); 00110 00111 template<typename T> 00112 ExportedByImage 00113 void elxHLSToRGB(T iHue, T iLuminance, T iSaturation, PixelRGB<T>& oPixel); 00114 00115 template <typename T> 00116 ExportedByImage 00117 void elxRGBToLab(const PixelRGB<T>& iPixelRGB, 00118 PixelLab<typename ResolutionTypeTraits<T>::Floating_type>& oPixelLab); 00119 00120 } // namespace Image 00121 } // namespace eLynx 00122 00123 #endif // __ColorSpace_h__