ITK  4.13.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 ITK_TEMPLATE_EXPORT 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();
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 private:
115  typedef std::vector< std::string > ColorNameVectorType;
116  typedef std::vector< RGBPixel< TPixel > > ColorVectorType;
117 
118  ITK_DISALLOW_COPY_AND_ASSIGN(ColorTable);
119 
120  void DeleteColors();
121 
122  unsigned int m_NumberOfColors;
123 
126 };
127 } // namespace itk
128 
129 #ifndef ITK_MANUAL_INSTANTIATION
130 #include "itkColorTable.hxx"
131 #endif
132 
133 #endif
ColorTable Self
Definition: itkColorTable.h:44
SmartPointer< Self > Pointer
Definition: itkColorTable.h:46
unsigned int m_NumberOfColors
std::vector< std::string > ColorNameVectorType
ColorVectorType m_Color
SmartPointer< const Self > ConstPointer
Definition: itkColorTable.h:47
Define a color table for image visualisation.
Definition: itkColorTable.h:40
Control indentation during Print() invocation.
Definition: itkIndent.h:49
std::vector< RGBPixel< TPixel > > ColorVectorType
Base class for most ITK classes.
Definition: itkObject.h:59
ColorNameVectorType m_ColorName