ITK  5.2.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 
130 template <typename TInputImage, typename TOutputImage>
131 class ITK_TEMPLATE_EXPORT ScalarToRGBColormapImageFilter : public ImageToImageFilter<TInputImage, TOutputImage>
132 {
133 public:
134  ITK_DISALLOW_COPY_AND_MOVE(ScalarToRGBColormapImageFilter);
136 
142 
144  itkNewMacro(Self);
145 
148 
150  using InputImageType = TInputImage;
151  using InputImagePointer = typename InputImageType::ConstPointer;
153  using InputImagePixelType = typename InputImageType::PixelType;
154  using OutputImageType = TOutputImage;
155  using OutputImagePointer = typename OutputImageType::Pointer;
157  using OutputImagePixelType = typename OutputImageType::PixelType;
158 
160 
162 #if !defined(ITK_LEGACY_REMOVE)
163 
164  using ColormapEnumType = RGBColormapFilterEnum;
165 #endif
166 
167 #if !defined(ITK_LEGACY_REMOVE)
168  // We need to expose the enum values at the class level
169  // for backwards compatibility
170  static constexpr RGBColormapFilterEnum Red = RGBColormapFilterEnum::Red;
171  static constexpr RGBColormapFilterEnum Green = RGBColormapFilterEnum::Green;
172  static constexpr RGBColormapFilterEnum Blue = RGBColormapFilterEnum::Blue;
173  static constexpr RGBColormapFilterEnum Grey = RGBColormapFilterEnum::Grey;
174  static constexpr RGBColormapFilterEnum Hot = RGBColormapFilterEnum::Hot;
175  static constexpr RGBColormapFilterEnum Cool = RGBColormapFilterEnum::Cool;
176  static constexpr RGBColormapFilterEnum Spring = RGBColormapFilterEnum::Spring;
177  static constexpr RGBColormapFilterEnum Summer = RGBColormapFilterEnum::Summer;
178  static constexpr RGBColormapFilterEnum Autumn = RGBColormapFilterEnum::Autumn;
179  static constexpr RGBColormapFilterEnum Winter = RGBColormapFilterEnum::Winter;
180  static constexpr RGBColormapFilterEnum Copper = RGBColormapFilterEnum::Copper;
181  static constexpr RGBColormapFilterEnum Jet = RGBColormapFilterEnum::Jet;
182  static constexpr RGBColormapFilterEnum HSV = RGBColormapFilterEnum::HSV;
183  static constexpr RGBColormapFilterEnum OverUnder = RGBColormapFilterEnum::OverUnder;
184 #endif
185 
187  itkSetObjectMacro(Colormap, ColormapType);
188  itkGetModifiableObjectMacro(Colormap, ColormapType);
190 
191  void SetColormap(RGBColormapFilterEnum);
192 
196  itkSetMacro(UseInputImageExtremaForScaling, bool);
197  itkGetConstMacro(UseInputImageExtremaForScaling, bool);
198  itkBooleanMacro(UseInputImageExtremaForScaling);
200 
201 protected:
203  ~ScalarToRGBColormapImageFilter() override = default;
204 
205  void
206  PrintSelf(std::ostream & os, Indent indent) const override;
207 
210  void
212  {
213  Superclass::GenerateOutputInformation();
214  OutputImageType * output = this->GetOutput();
216 
217  if (!output)
218  {
219  return;
220  }
221  if (output->GetNumberOfComponentsPerPixel() != 3)
222  {
223  output->SetNumberOfComponentsPerPixel(3);
224  }
225  }
226 
239  void
240  DynamicThreadedGenerateData(const OutputImageRegionType & outputRegionForThread) override;
241 
243  void
244  BeforeThreadedGenerateData() override;
245 
246 private:
247 private:
249 
251 };
252 } // end namespace itk
253 
254 #ifndef ITK_MANUAL_INSTANTIATION
255 # include "itkScalarToRGBColormapImageFilter.hxx"
256 #endif
257 
258 #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:213
itk::ScalarToRGBColormapImageFilterEnums::RGBColormapFilter::Grey
itk::ScalarToRGBColormapImageFilter
Implements pixel-wise intensity->rgb mapping operation on one image.
Definition: itkScalarToRGBColormapImageFilter.h:131
itk::ScalarToRGBColormapImageFilter::m_Colormap
ColormapType::Pointer m_Colormap
Definition: itkScalarToRGBColormapImageFilter.h:248
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:46
itk::ScalarToRGBColormapImageFilterEnums::RGBColormapFilter::Jet
itk::ScalarToRGBColormapImageFilterEnums::RGBColormapFilter::Autumn
itk::ScalarToRGBColormapImageFilter::m_UseInputImageExtremaForScaling
bool m_UseInputImageExtremaForScaling
Definition: itkScalarToRGBColormapImageFilter.h:250
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:211
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