ColorSpace.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /**
  2. * @file ColorSpace.h
  3. * @brief color space conversion routines
  4. * @author Michael Koch
  5. * @date 07/28/2008
  6. */
  7. #ifndef COLORSPACEINCLUDE
  8. #define COLORSPACEINCLUDE
  9. #include "core/image/ImageT.h"
  10. #include "core/vector/VectorT.h"
  11. #include "core/vector/MatrixT.h"
  12. #include "core/image/MultiChannelImageT.h"
  13. namespace OBJREC {
  14. /** @brief color space conversion routines */
  15. class ColorSpace
  16. {
  17. protected:
  18. public:
  19. enum {
  20. COLORSPACE_RGB = 0,
  21. COLORSPACE_HSL,
  22. COLORSPACE_LAB,
  23. COLORSPACE_LMS,
  24. COLORSPACE_OPP,
  25. NUM_COLORSPACES
  26. };
  27. //bad position choose better one
  28. static void ColorImagetoMultiChannelImage( const NICE::ColorImage &imgrgb, NICE::MultiChannelImageT<double> &genimg );
  29. /** convert RGB to hsl*/
  30. static NICE::MultiChannelImageT<double> rgbtohsl( const NICE::MultiChannelImageT<double> &imgrgb );
  31. /** convert hsl to RGB*/
  32. static NICE::MultiChannelImageT<double> hsltorgb( const NICE::MultiChannelImageT<double> &imghsl );
  33. /** convert RGB to LAB*/
  34. static NICE::MultiChannelImageT<double> rgbtolab( const NICE::MultiChannelImageT<double> &imgrgb );
  35. /** convert LAB to RGB*/
  36. static NICE::MultiChannelImageT<double> labtorgb( const NICE::MultiChannelImageT<double> &imglab );
  37. /** convert RGB to LMS*/
  38. static NICE::MultiChannelImageT<double> rgbtolms( const NICE::MultiChannelImageT<double> &imgrgb );
  39. template<class SrcPixelType, class DstPixelType>
  40. static void convert( NICE::MultiChannelImageT<DstPixelType> & dst,
  41. const NICE::MultiChannelImageT<SrcPixelType> & src,
  42. int dstColorSpace = COLORSPACE_HSL,
  43. int srcColorSpace = COLORSPACE_RGB,
  44. double dstM = 255.0,
  45. double srcM = 255.0 );
  46. };
  47. } // namespace
  48. #include "ColorSpace.tcc"
  49. #endif