ITK  4.6.0
Insight Segmentation and Registration Toolkit
itkColorTable.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 #ifndef __itkColorTable_h
19 #define __itkColorTable_h
20 
21 #include "itkObject.h"
22 #include "itkRGBPixel.h"
23 #include "itkObjectFactory.h"
24 
25 #include <string>
26 #include <vector>
27 namespace itk
28 {
39 template< typename TPixel >
40 class ColorTable:public Object
41 {
42 public:
44  typedef ColorTable Self;
45  typedef Object Superclass;
48 
50  itkNewMacro(Self);
51 
53  itkTypeMacro(ColorTable, Object);
54 
60  void UseDiscreteColors(void);
61 
66  void UseGrayColors(unsigned int n = 256);
67 
73  void UseHeatColors(unsigned int n = 256);
74 
79  void UseRandomColors(unsigned int n = 256);
80 
82  itkGetConstMacro(NumberOfColors, unsigned int);
83 
85  RGBPixel< TPixel > GetColor(unsigned int colorId);
86 
91  bool SetColor(unsigned int c, TPixel r, TPixel g, TPixel b,
92  const char *name = "UserDefined");
93  bool SetColor(unsigned int c, RGBPixel<TPixel> pixel,
94  const char *name = "UserDefined");
96 
100  TPixel GetColorComponent(unsigned int colorId, char rgb);
101 
103  std::string GetColorName(unsigned int colorId);
104 
108  unsigned int GetClosestColorTableId(TPixel r, TPixel g, TPixel b);
109 
110 protected:
111  ColorTable();
112  virtual void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE;
113 
114  unsigned int m_NumberOfColors;
115 
116  std::vector<std::string> m_ColorName;
117  std::vector<RGBPixel< TPixel > > m_Color;
118 
119 private:
120  ColorTable(const Self &); //purposely not implemented
121  void operator=(const Self &); //purposely not implemented
122 
123  void DeleteColors();
124 };
125 } // namespace itk
126 
127 #ifndef ITK_MANUAL_INSTANTIATION
128 #include "itkColorTable.hxx"
129 #endif
130 
131 #endif
ColorTable Self
Definition: itkColorTable.h:44
std::vector< RGBPixel< TPixel > > m_Color
SmartPointer< Self > Pointer
Definition: itkColorTable.h:46
TPixel GetColorComponent(unsigned int colorId, char rgb)
unsigned int GetClosestColorTableId(TPixel r, TPixel g, TPixel b)
virtual void PrintSelf(std::ostream &os, Indent indent) const ITK_OVERRIDE
unsigned int m_NumberOfColors
SmartPointer< const Self > ConstPointer
Definition: itkColorTable.h:47
bool SetColor(unsigned int c, TPixel r, TPixel g, TPixel b, const char *name="UserDefined")
void UseDiscreteColors(void)
Define a color table for image visualisation.
Definition: itkColorTable.h:40
Control indentation during Print() invocation.
Definition: itkIndent.h:49
void UseRandomColors(unsigned int n=256)
void UseHeatColors(unsigned int n=256)
std::string GetColorName(unsigned int colorId)
void operator=(const Self &)
Base class for most ITK classes.
Definition: itkObject.h:57
RGBPixel< TPixel > GetColor(unsigned int colorId)
void UseGrayColors(unsigned int n=256)
std::vector< std::string > m_ColorName