ITK  4.1.0
Insight Segmentation and Registration Toolkit
itkLabelToRGBImageFilter.h
Go to the documentation of this file.
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 __itkLabelToRGBImageFilter_h
00019 #define __itkLabelToRGBImageFilter_h
00020 
00021 #include "itkUnaryFunctorImageFilter.h"
00022 #include "itkLabelToRGBFunctor.h"
00023 
00024 namespace itk
00025 {
00048 template< class TLabelImage, typename  TOutputImage >
00049 class ITK_EXPORT LabelToRGBImageFilter:
00050   public
00051   UnaryFunctorImageFilter< TLabelImage, TOutputImage,
00052                            Functor::LabelToRGBFunctor<
00053                              typename TLabelImage::PixelType,
00054                              typename TOutputImage::PixelType >   >
00055 {
00056 public:
00058   typedef LabelToRGBImageFilter      Self;
00059   typedef SmartPointer< Self >       Pointer;
00060   typedef SmartPointer< const Self > ConstPointer;
00061 
00062   typedef UnaryFunctorImageFilter< TLabelImage, TOutputImage,
00063                                    Functor::LabelToRGBFunctor<
00064                                      typename TLabelImage::PixelType,
00065                                      typename TOutputImage::PixelType >   >  Superclass;
00066 
00067   typedef TOutputImage OutputImageType;
00068   typedef TLabelImage  LabelImageType;
00069 
00070   typedef typename TOutputImage::PixelType                     OutputPixelType;
00071   typedef typename TLabelImage::PixelType                      LabelPixelType;
00072   typedef typename NumericTraits< OutputPixelType >::ValueType OutputPixelValueType;
00073 
00075   itkTypeMacro(LabelToRGBImageFilter, UnaryFunctorImageFilter);
00076 
00078   itkNewMacro(Self);
00079 
00081   itkSetMacro(BackgroundValue, LabelPixelType);
00082   itkGetConstReferenceMacro(BackgroundValue, LabelPixelType);
00084 
00086   itkSetMacro(BackgroundColor, OutputPixelType);
00087   itkGetConstReferenceMacro(BackgroundColor, OutputPixelType);
00089 
00091   void ResetColors();
00092 
00094   unsigned int GetNumberOfColors() const;
00095 
00097   typedef typename OutputPixelType::ComponentType ComponentType;
00098 
00100   void AddColor(ComponentType r, ComponentType g, ComponentType b);
00101 
00102 protected:
00103   LabelToRGBImageFilter();
00104   virtual ~LabelToRGBImageFilter() {}
00105 
00107   void BeforeThreadedGenerateData(void);
00108 
00110   void PrintSelf(std::ostream & os, Indent indent) const;
00111 
00112   void GenerateOutputInformation();
00113 
00114 private:
00115   LabelToRGBImageFilter(const Self &); //purposely not implemented
00116   void operator=(const Self &);        //purposely not implemented
00117 
00118   OutputPixelType m_BackgroundColor;
00119   LabelPixelType  m_BackgroundValue;
00120 };
00121 } // end namespace itk
00122 
00123 #ifndef ITK_MANUAL_INSTANTIATION
00124 #include "itkLabelToRGBImageFilter.hxx"
00125 #endif
00126 
00127 #endif
00128