ITK  5.3.0
Insight Toolkit
itkScalarToRGBColormapImageFilter.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  * 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 itkScalarToRGBColormapImageFilter_h
19 #define itkScalarToRGBColormapImageFilter_h
20 
21 #include "itkImageToImageFilter.h"
22 #include "itkColormapFunction.h"
23 #include "ITKColormapExport.h"
24 
25 namespace itk
26 {
32 {
33 public:
38  {
39  Red,
40  Green,
41  Blue,
42  Grey,
43  Hot,
44  Cool,
45  Spring,
46  Summer,
47  Autumn,
48  Winter,
49  Copper,
50  Jet,
51  HSV,
52  OverUnder
53  };
54 };
55 #if !defined(ITK_LEGACY_REMOVE)
56 using RGBColormapFilterEnum = ScalarToRGBColormapImageFilterEnums::RGBColormapFilter;
57 using RGBColormapFilterEnumType = ScalarToRGBColormapImageFilterEnums::RGBColormapFilter;
58 // We need to expose the enum values at the class level
59 // for backwards compatibility
60 static constexpr RGBColormapFilterEnum Red = RGBColormapFilterEnum::Red;
61 static constexpr RGBColormapFilterEnum Green = RGBColormapFilterEnum::Green;
62 static constexpr RGBColormapFilterEnum Blue = RGBColormapFilterEnum::Blue;
63 static constexpr RGBColormapFilterEnum Grey = RGBColormapFilterEnum::Grey;
64 static constexpr RGBColormapFilterEnum Hot = RGBColormapFilterEnum::Hot;
65 static constexpr RGBColormapFilterEnum Cool = RGBColormapFilterEnum::Cool;
66 static constexpr RGBColormapFilterEnum Spring = RGBColormapFilterEnum::Spring;
67 static constexpr RGBColormapFilterEnum Summer = RGBColormapFilterEnum::Summer;
68 static constexpr RGBColormapFilterEnum Autumn = RGBColormapFilterEnum::Autumn;
69 static constexpr RGBColormapFilterEnum Winter = RGBColormapFilterEnum::Winter;
70 static constexpr RGBColormapFilterEnum Copper = RGBColormapFilterEnum::Copper;
71 static constexpr RGBColormapFilterEnum Jet = RGBColormapFilterEnum::Jet;
72 static constexpr RGBColormapFilterEnum HSV = RGBColormapFilterEnum::HSV;
73 static constexpr RGBColormapFilterEnum OverUnder = RGBColormapFilterEnum::OverUnder;
74 #endif
75 
76 extern ITKColormap_EXPORT std::ostream &
78 
129 template <typename TInputImage, typename TOutputImage>
130 class ITK_TEMPLATE_EXPORT ScalarToRGBColormapImageFilter : public ImageToImageFilter<TInputImage, TOutputImage>
131 {
132 public:
133  ITK_DISALLOW_COPY_AND_MOVE(ScalarToRGBColormapImageFilter);
135 
141 
143  itkNewMacro(Self);
144 
147 
149  using InputImageType = TInputImage;
150  using InputImagePointer = typename InputImageType::ConstPointer;
152  using InputImagePixelType = typename InputImageType::PixelType;
153  using OutputImageType = TOutputImage;
154  using OutputImagePointer = typename OutputImageType::Pointer;
156  using OutputImagePixelType = typename OutputImageType::PixelType;
157 
159 
161 #if !defined(ITK_LEGACY_REMOVE)
162 
163  using ColormapEnumType = RGBColormapFilterEnum;
164 #endif
165 
166 #if !defined(ITK_LEGACY_REMOVE)
167  // We need to expose the enum values at the class level
168  // for backwards compatibility
169  static constexpr RGBColormapFilterEnum Red = RGBColormapFilterEnum::Red;
170  static constexpr RGBColormapFilterEnum Green = RGBColormapFilterEnum::Green;
171  static constexpr RGBColormapFilterEnum Blue = RGBColormapFilterEnum::Blue;
172  static constexpr RGBColormapFilterEnum Grey = RGBColormapFilterEnum::Grey;
173  static constexpr RGBColormapFilterEnum Hot = RGBColormapFilterEnum::Hot;
174  static constexpr RGBColormapFilterEnum Cool = RGBColormapFilterEnum::Cool;
175  static constexpr RGBColormapFilterEnum Spring = RGBColormapFilterEnum::Spring;
176  static constexpr RGBColormapFilterEnum Summer = RGBColormapFilterEnum::Summer;
177  static constexpr RGBColormapFilterEnum Autumn = RGBColormapFilterEnum::Autumn;
178  static constexpr RGBColormapFilterEnum Winter = RGBColormapFilterEnum::Winter;
179  static constexpr RGBColormapFilterEnum Copper = RGBColormapFilterEnum::Copper;
180  static constexpr RGBColormapFilterEnum Jet = RGBColormapFilterEnum::Jet;
181  static constexpr RGBColormapFilterEnum HSV = RGBColormapFilterEnum::HSV;
182  static constexpr RGBColormapFilterEnum OverUnder = RGBColormapFilterEnum::OverUnder;
183 #endif
184 
186  itkSetObjectMacro(Colormap, ColormapType);
187  itkGetModifiableObjectMacro(Colormap, ColormapType);
189 
190  void SetColormap(RGBColormapFilterEnum);
191 
195  itkSetMacro(UseInputImageExtremaForScaling, bool);
196  itkGetConstMacro(UseInputImageExtremaForScaling, bool);
197  itkBooleanMacro(UseInputImageExtremaForScaling);
199 
200 protected:
202  ~ScalarToRGBColormapImageFilter() override = default;
203 
204  void
205  PrintSelf(std::ostream & os, Indent indent) const override;
206 
209  void
211  {
212  Superclass::GenerateOutputInformation();
213  OutputImageType * output = this->GetOutput();
215 
216  if (!output)
217  {
218  return;
219  }
220  if (output->GetNumberOfComponentsPerPixel() != 3)
221  {
222  output->SetNumberOfComponentsPerPixel(3);
223  }
224  }
225 
238  void
239  DynamicThreadedGenerateData(const OutputImageRegionType & outputRegionForThread) override;
240 
242  void
243  BeforeThreadedGenerateData() override;
244 
245 private:
246 private:
248 
250 };
251 } // end namespace itk
252 
253 #ifndef ITK_MANUAL_INSTANTIATION
254 # include "itkScalarToRGBColormapImageFilter.hxx"
255 #endif
256 
257 #endif
itk::ScalarToRGBColormapImageFilterEnums::RGBColormapFilter::Red
itk::uint8_t
::uint8_t uint8_t
Definition: itkIntTypes.h:29
itk::ImageSource::OutputImagePointer
typename OutputImageType::Pointer OutputImagePointer
Definition: itkImageSource.h:91
itk::ScalarToRGBColormapImageFilterEnums::RGBColormapFilter::Green
itk::operator<<
std::ostream & operator<<(std::ostream &os, const Array< TValue > &arr)
Definition: itkArray.h:218
itk::ScalarToRGBColormapImageFilterEnums::RGBColormapFilter::Grey
itk::ScalarToRGBColormapImageFilter
Implements pixel-wise intensity->rgb mapping operation on one image.
Definition: itkScalarToRGBColormapImageFilter.h:130
itk::ScalarToRGBColormapImageFilter::m_Colormap
ColormapType::Pointer m_Colormap
Definition: itkScalarToRGBColormapImageFilter.h:247
itk::ScalarToRGBColormapImageFilterEnums::RGBColormapFilter
RGBColormapFilter
Definition: itkScalarToRGBColormapImageFilter.h:37
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::ScalarToRGBColormapImageFilterEnums::RGBColormapFilter::Hot
itk::Function::ColormapFunction
Function object which maps a scalar value into an RGB colormap value.
Definition: itkColormapFunction.h:45
itk::ScalarToRGBColormapImageFilterEnums::RGBColormapFilter::Jet
itk::ScalarToRGBColormapImageFilterEnums::RGBColormapFilter::Autumn
itk::ScalarToRGBColormapImageFilter::m_UseInputImageExtremaForScaling
bool m_UseInputImageExtremaForScaling
Definition: itkScalarToRGBColormapImageFilter.h:249
itk::ScalarToRGBColormapImageFilterEnums::RGBColormapFilter::Winter
itk::ImageToImageFilter::InputImagePixelType
typename InputImageType::PixelType InputImagePixelType
Definition: itkImageToImageFilter.h:133
itk::ImageToImageFilter
Base class for filters that take an image as input and produce an image as output.
Definition: itkImageToImageFilter.h:108
itk::ImageSource
Base class for all process objects that output image data.
Definition: itkImageSource.h:67
itk::ScalarToRGBColormapImageFilterEnums
Contains all enum classes for ScalarToRGBColormapImageFilter class.
Definition: itkScalarToRGBColormapImageFilter.h:31
itk::ImageToImageFilter::InputImagePointer
typename InputImageType::Pointer InputImagePointer
Definition: itkImageToImageFilter.h:130
itk::GTest::TypedefsAndConstructors::Dimension2::RegionType
ImageBaseType::RegionType RegionType
Definition: itkGTestTypedefsAndConstructors.h:54
itk::ImageToImageFilter::InputImageType
TInputImage InputImageType
Definition: itkImageToImageFilter.h:129
itkImageToImageFilter.h
itk::ScalarToRGBColormapImageFilterEnums::RGBColormapFilter::Copper
itk::ScalarToRGBColormapImageFilterEnums::RGBColormapFilter::HSV
itkColormapFunction.h
itk::ImageSource::OutputImageRegionType
typename OutputImageType::RegionType OutputImageRegionType
Definition: itkImageSource.h:92
itk::ScalarToRGBColormapImageFilter::GenerateOutputInformation
void GenerateOutputInformation() override
Definition: itkScalarToRGBColormapImageFilter.h:210
RGBColormapFilter
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itk::ProcessObject
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
Definition: itkProcessObject.h:138
itk::ScalarToRGBColormapImageFilterEnums::RGBColormapFilter::Blue
itk::ImageSource::OutputImagePixelType
typename OutputImageType::PixelType OutputImagePixelType
Definition: itkImageSource.h:93
itk::ScalarToRGBColormapImageFilterEnums::RGBColormapFilter::Summer
itk::ScalarToRGBColormapImageFilterEnums::RGBColormapFilter::OverUnder
itk::ScalarToRGBColormapImageFilterEnums::RGBColormapFilter::Spring
itk::ImageToImageFilter::InputImageRegionType
typename InputImageType::RegionType InputImageRegionType
Definition: itkImageToImageFilter.h:132
itk::ScalarToRGBColormapImageFilterEnums::RGBColormapFilter::Cool
itk::ImageSource::OutputImageType
TOutputImage OutputImageType
Definition: itkImageSource.h:90