00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef __itkColorTable_h
00018 #define __itkColorTable_h
00019
00020 #include <itkObject.h>
00021 #include <itkRGBPixel.h>
00022 #include <itkObjectFactory.h>
00023
00024 namespace itk
00025 {
00032 template<class TPixel>
00033 class ITK_EXPORT ColorTable : public Object
00034 {
00035 public:
00037 typedef ColorTable Self;
00038 typedef Object Superclass;
00039 typedef SmartPointer<Self> Pointer;
00040 typedef SmartPointer<const Self> ConstPointer;
00041
00043 itkNewMacro(Self);
00044
00046 itkTypeMacro(ColorTable,Object);
00047
00051 void UseDiscreteColors(void);
00052
00056 void UseGrayColors(unsigned int n=256);
00057 void UseHeatColors(unsigned int n=256);
00058 void UseRandomColors(unsigned int n=256);
00060
00062 void useDiscrete(void){UseDiscreteColors();};
00063 void useGray(unsigned int n=256){UseGrayColors(n);}
00064 void useHeat(unsigned int n=256){UseHeatColors(n);}
00066
00067 itkGetConstMacro(NumberOfColors, unsigned int);
00068 unsigned int size(void);
00069
00070 RGBPixel<TPixel>* GetColor(unsigned int colorId);
00071 RGBPixel<TPixel>* color(unsigned int c);
00072
00073 bool SetColor(unsigned int c, TPixel r, TPixel g, TPixel b,
00074 const char * name="UserDefined");
00075
00078 TPixel GetColorComponent(unsigned int colorId, char rgb);
00079 TPixel color(unsigned int c, char rgb);
00080 char * GetColorName(unsigned int colorId);
00081 char * colorName(unsigned int c);
00083
00084 unsigned int GetClosestColorTableId(TPixel r, TPixel g, TPixel b);
00085
00086 protected:
00087 ColorTable();
00088 void PrintSelf(std::ostream & os, Indent indent) const;
00089 virtual ~ColorTable();
00090
00091 unsigned int m_NumberOfColors;
00092 RGBPixel<TPixel> * m_Color;
00093 char ** m_ColorName;
00094
00095 private:
00096 ColorTable(const Self&);
00097 void operator=(const Self&);
00098 void DeleteColors();
00099 };
00100
00101
00102 }
00103
00104
00105 #define ITK_TEMPLATE_ColorTable(_, EXPORT, x, y) namespace itk { \
00106 _(1(class EXPORT ColorTable< ITK_TEMPLATE_1 x >)) \
00107 namespace Templates { typedef ColorTable< ITK_TEMPLATE_1 x > \
00108 ColorTable##y; } \
00109 }
00110
00111 #if ITK_TEMPLATE_EXPLICIT
00112 # include "Templates/itkColorTable+-.h"
00113 #endif
00114
00115 #if ITK_TEMPLATE_TXX
00116 # include "itkColorTable.txx"
00117 #endif
00118
00119 #endif
00120