ITK
4.1.0
Insight Segmentation and Registration Toolkit
|
00001 /*========================================================================= 00002 * 00003 * Copyright Insight Software Consortium 00004 * 00005 * Licensed under the Apache License, Version 2.0 (the "License"); 00006 * you may not use this file except in compliance with the License. 00007 * You may obtain a copy of the License at 00008 * 00009 * http://www.apache.org/licenses/LICENSE-2.0.txt 00010 * 00011 * Unless required by applicable law or agreed to in writing, software 00012 * distributed under the License is distributed on an "AS IS" BASIS, 00013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00014 * See the License for the specific language governing permissions and 00015 * limitations under the License. 00016 * 00017 *=========================================================================*/ 00018 #ifndef __itkScalarToRGBColormapImageFilter_h 00019 #define __itkScalarToRGBColormapImageFilter_h 00020 00021 #include "itkImageToImageFilter.h" 00022 00023 #include "itkColormapFunction.h" 00024 00025 namespace itk 00026 { 00076 template< class TInputImage, class TOutputImage > 00077 class ITK_EXPORT ScalarToRGBColormapImageFilter: 00078 public ImageToImageFilter< TInputImage, TOutputImage > 00079 { 00080 public: 00082 typedef ScalarToRGBColormapImageFilter Self; 00083 typedef ImageToImageFilter< TInputImage, TOutputImage > Superclass; 00084 typedef SmartPointer< Self > Pointer; 00085 typedef SmartPointer< const Self > ConstPointer; 00086 00088 itkNewMacro(Self); 00089 00091 itkTypeMacro(ScalarToRGBColormapImageFilter, ImageToImageFilter); 00092 00094 typedef TInputImage InputImageType; 00095 typedef typename InputImageType::ConstPointer InputImagePointer; 00096 typedef typename InputImageType::RegionType InputImageRegionType; 00097 typedef typename InputImageType::PixelType InputImagePixelType; 00098 typedef TOutputImage OutputImageType; 00099 typedef typename OutputImageType::Pointer OutputImagePointer; 00100 typedef typename OutputImageType::RegionType OutputImageRegionType; 00101 typedef typename OutputImageType::PixelType OutputImagePixelType; 00102 00103 typedef Function::ColormapFunction< InputImagePixelType, 00104 OutputImagePixelType > ColormapType; 00105 00109 itkSetObjectMacro(Colormap, ColormapType); 00110 itkGetObjectMacro(Colormap, ColormapType); 00112 00116 typedef enum { Red, Green, Blue, Grey, Hot, Cool, Spring, Summer, 00117 Autumn, Winter, Copper, Jet, HSV, OverUnder } ColormapEnumType; 00118 00119 void SetColormap(ColormapEnumType); 00120 00126 itkSetMacro(UseInputImageExtremaForScaling, bool); 00127 itkGetConstMacro(UseInputImageExtremaForScaling, bool); 00128 itkBooleanMacro(UseInputImageExtremaForScaling); 00129 protected: 00130 ScalarToRGBColormapImageFilter(); 00131 virtual ~ScalarToRGBColormapImageFilter() {} 00133 00134 void PrintSelf(std::ostream & os, Indent indent) const; 00135 00136 virtual void GenerateOutputInformation() 00137 { 00138 // this methods is overloaded so that if the output image is a 00139 // VectorImage then the correct number of components are set. 00140 00141 Superclass::GenerateOutputInformation(); 00142 OutputImageType* output = this->GetOutput(); 00143 00144 if ( !output ) 00145 { 00146 return; 00147 } 00148 if ( output->GetNumberOfComponentsPerPixel() != 3 ) 00149 { 00150 output->SetNumberOfComponentsPerPixel( 3 ); 00151 } 00152 } 00153 00165 void ThreadedGenerateData(const OutputImageRegionType & outputRegionForThread, 00166 ThreadIdType threadId); 00167 00169 void BeforeThreadedGenerateData(); 00170 00171 private: 00172 ScalarToRGBColormapImageFilter(const Self &); //purposely not implemented 00173 void operator=(const Self &); //purposely not implemented 00174 00175 typename ColormapType::Pointer m_Colormap; 00176 00177 bool m_UseInputImageExtremaForScaling; 00178 }; 00179 } // end namespace itk 00180 00181 #ifndef ITK_MANUAL_INSTANTIATION 00182 #include "itkScalarToRGBColormapImageFilter.hxx" 00183 #endif 00184 00185 #endif 00186