ITK  4.13.0
Insight Segmentation and Registration Toolkit
itkScalarToRGBColormapImageFilter.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 itkScalarToRGBColormapImageFilter_h
19 #define itkScalarToRGBColormapImageFilter_h
20 
21 #include "itkImageToImageFilter.h"
22 
23 #include "itkColormapFunction.h"
24 
25 namespace itk
26 {
76 template< typename TInputImage, typename TOutputImage >
77 class ITK_TEMPLATE_EXPORT ScalarToRGBColormapImageFilter:
78  public ImageToImageFilter< TInputImage, TOutputImage >
79 {
80 public:
86 
88  itkNewMacro(Self);
89 
92 
94  typedef TInputImage InputImageType;
95  typedef typename InputImageType::ConstPointer InputImagePointer;
96  typedef typename InputImageType::RegionType InputImageRegionType;
97  typedef typename InputImageType::PixelType InputImagePixelType;
98  typedef TOutputImage OutputImageType;
99  typedef typename OutputImageType::Pointer OutputImagePointer;
100  typedef typename OutputImageType::RegionType OutputImageRegionType;
101  typedef typename OutputImageType::PixelType OutputImagePixelType;
102 
105 
107  itkSetObjectMacro(Colormap, ColormapType);
108  itkGetModifiableObjectMacro(Colormap, ColormapType);
110 
112  typedef enum { Red, Green, Blue, Grey, Hot, Cool, Spring, Summer,
113  Autumn, Winter, Copper, Jet, HSV, OverUnder } ColormapEnumType;
114 
115  void SetColormap(ColormapEnumType);
116 
120  itkSetMacro(UseInputImageExtremaForScaling, bool);
121  itkGetConstMacro(UseInputImageExtremaForScaling, bool);
122  itkBooleanMacro(UseInputImageExtremaForScaling);
124 
125 protected:
127  virtual ~ScalarToRGBColormapImageFilter() ITK_OVERRIDE {}
128 
129  void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE;
130 
133  virtual void GenerateOutputInformation() ITK_OVERRIDE
134  {
135  Superclass::GenerateOutputInformation();
136  OutputImageType* output = this->GetOutput();
138 
139  if ( !output )
140  {
141  return;
142  }
143  if ( output->GetNumberOfComponentsPerPixel() != 3 )
144  {
145  output->SetNumberOfComponentsPerPixel( 3 );
146  }
147  }
148 
161  void ThreadedGenerateData(const OutputImageRegionType & outputRegionForThread,
162  ThreadIdType threadId) ITK_OVERRIDE;
163 
165  void BeforeThreadedGenerateData() ITK_OVERRIDE;
166 
167 private:
168  ITK_DISALLOW_COPY_AND_ASSIGN(ScalarToRGBColormapImageFilter);
169 
170 private:
171  typename ColormapType::Pointer m_Colormap;
172 
173  bool m_UseInputImageExtremaForScaling;
174 };
175 } // end namespace itk
176 
177 #ifndef ITK_MANUAL_INSTANTIATION
178 #include "itkScalarToRGBColormapImageFilter.hxx"
179 #endif
180 
181 #endif
Base class for all process objects that output image data.
Function object which maps a scalar value into an RGB colormap value.
ImageToImageFilter< TInputImage, TOutputImage > Superclass
Implements pixel-wise intensity-&gt;rgb mapping operation on one image.
OutputImageType::PixelType OutputImagePixelType
unsigned int ThreadIdType
Definition: itkIntTypes.h:159
Function::ColormapFunction< InputImagePixelType, OutputImagePixelType > ColormapType
InputImageType::PixelType InputImagePixelType
Base class for filters that take an image as input and produce an image as output.
Control indentation during Print() invocation.
Definition: itkIndent.h:49
TOutputImage OutputImageType