ITK  6.0.0
Insight Toolkit
itkColorTable.h
Go to the documentation of this file.
1/*=========================================================================
2 *
3 * Copyright NumFOCUS
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 * https://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>
27namespace itk
28{
39template <typename TComponent>
40class ITK_TEMPLATE_EXPORT ColorTable : public Object
41{
42public:
43 ITK_DISALLOW_COPY_AND_MOVE(ColorTable);
44
50
52 itkNewMacro(Self);
53
55 itkOverrideGetNameOfClassMacro(ColorTable);
56
62 void
64
69 void
70 UseGrayColors(unsigned int n = 256);
71
77 void
78 UseHeatColors(unsigned int n = 256);
79
84 void
85 UseRandomColors(unsigned int n = 256);
86
88 itkGetConstMacro(NumberOfColors, unsigned int);
89
92 GetColor(unsigned int c);
93
98 bool
99 SetColor(unsigned int c, TComponent r, TComponent g, TComponent b, const char * name = "UserDefined");
100 bool
101 SetColor(unsigned int c, RGBPixel<TComponent> pixel, const char * name = "UserDefined");
107 TComponent
108 GetColorComponent(unsigned int c, char rgb);
109
111 std::string
112 GetColorName(unsigned int c);
113
117 unsigned int
118 GetClosestColorTableId(TComponent r, TComponent g, TComponent b);
119
120protected:
121 ColorTable() = default;
122 void
123 PrintSelf(std::ostream & os, Indent indent) const override;
124
125private:
126 using ColorNameVectorType = std::vector<std::string>;
127 using ColorVectorType = std::vector<RGBPixel<TComponent>>;
128
129 void
131
132 unsigned int m_NumberOfColors{ 0 };
133
134 ColorNameVectorType m_ColorName{};
136};
137} // namespace itk
138
139#ifndef ITK_MANUAL_INSTANTIATION
140# include "itkColorTable.hxx"
141#endif
142
143#endif
Define a color table for image visualisation.
Definition: itkColorTable.h:41
ColorTable()=default
bool SetColor(unsigned int c, TComponent r, TComponent g, TComponent b, const char *name="UserDefined")
std::vector< std::string > ColorNameVectorType
void PrintSelf(std::ostream &os, Indent indent) const override
RGBPixel< TComponent > GetColor(unsigned int c)
void UseHeatColors(unsigned int n=256)
void UseGrayColors(unsigned int n=256)
TComponent GetColorComponent(unsigned int c, char rgb)
void UseDiscreteColors()
std::string GetColorName(unsigned int c)
bool SetColor(unsigned int c, RGBPixel< TComponent > pixel, const char *name="UserDefined")
unsigned int GetClosestColorTableId(TComponent r, TComponent g, TComponent b)
void UseRandomColors(unsigned int n=256)
std::vector< RGBPixel< TComponent > > ColorVectorType
Control indentation during Print() invocation.
Definition: itkIndent.h:50
Base class for most ITK classes.
Definition: itkObject.h:62
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....