ITK  4.1.0
Insight Segmentation and Registration Toolkit
itkLabelMapToBinaryImageFilter.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 __itkLabelMapToBinaryImageFilter_h
00019 #define __itkLabelMapToBinaryImageFilter_h
00020 
00021 #include "itkLabelMapFilter.h"
00022 #include "itkBarrier.h"
00023 
00024 namespace itk
00025 {
00045 template< class TInputImage, class TOutputImage >
00046 class ITK_EXPORT LabelMapToBinaryImageFilter:
00047   public LabelMapFilter< TInputImage, TOutputImage >
00048 {
00049 public:
00051   typedef LabelMapToBinaryImageFilter                 Self;
00052   typedef LabelMapFilter< TInputImage, TOutputImage > Superclass;
00053   typedef SmartPointer< Self >                        Pointer;
00054   typedef SmartPointer< const Self >                  ConstPointer;
00055 
00057   typedef TInputImage                              InputImageType;
00058   typedef TOutputImage                             OutputImageType;
00059   typedef typename InputImageType::Pointer         InputImagePointer;
00060   typedef typename InputImageType::ConstPointer    InputImageConstPointer;
00061   typedef typename InputImageType::RegionType      InputImageRegionType;
00062   typedef typename InputImageType::PixelType       InputImagePixelType;
00063   typedef typename InputImageType::LabelObjectType LabelObjectType;
00064 
00065   typedef typename OutputImageType::Pointer      OutputImagePointer;
00066   typedef typename OutputImageType::ConstPointer OutputImageConstPointer;
00067   typedef typename OutputImageType::RegionType   OutputImageRegionType;
00068   typedef typename OutputImageType::PixelType    OutputImagePixelType;
00069   typedef typename OutputImageType::IndexType    IndexType;
00070 
00072   itkStaticConstMacro(InputImageDimension, unsigned int, TInputImage::ImageDimension);
00073   itkStaticConstMacro(OutputImageDimension, unsigned int, TOutputImage::ImageDimension);
00075 
00077   itkNewMacro(Self);
00078 
00080   itkTypeMacro(LabelMapToBinaryImageFilter, ImageToImageFilter);
00081 
00086   itkSetMacro(BackgroundValue, OutputImagePixelType);
00087   itkGetConstMacro(BackgroundValue, OutputImagePixelType);
00089 
00094   itkSetMacro(ForegroundValue, OutputImagePixelType);
00095   itkGetConstMacro(ForegroundValue, OutputImagePixelType);
00097 
00100   void SetBackgroundImage(const OutputImageType *input)
00101   {
00102     // Process object is not const-correct so the const casting is required.
00103     this->SetNthInput( 1, const_cast< OutputImageType * >( input ) );
00104   }
00105 
00106   OutputImageType * GetBackgroundImage()
00107   {
00108     return static_cast< OutputImageType * >( const_cast< DataObject * >( this->ProcessObject::GetInput(1) ) );
00109   }
00110 
00112   void SetInput1(const InputImageType *input)
00113   {
00114     this->SetInput(input);
00115   }
00116 
00118   void SetInput2(const OutputImageType *input)
00119   {
00120     this->SetBackgroundImage(input);
00121   }
00122 
00123 protected:
00124   LabelMapToBinaryImageFilter();
00125   ~LabelMapToBinaryImageFilter() {}
00126 
00130   void GenerateInputRequestedRegion();
00131 
00133   void EnlargeOutputRequestedRegion( DataObject *itkNotUsed(output) );
00134 
00135   virtual void BeforeThreadedGenerateData();
00136 
00137   virtual void ThreadedGenerateData(const OutputImageRegionType & outputRegionForThread, ThreadIdType threadId);
00138 
00139   virtual void ThreadedProcessLabelObject(LabelObjectType *labelObject);
00140 
00141   void PrintSelf(std::ostream & os, Indent indent) const;
00142 
00143 private:
00144   LabelMapToBinaryImageFilter(const Self &); //purposely not implemented
00145   void operator=(const Self &);              //purposely not implemented
00146 
00147   OutputImagePixelType m_BackgroundValue;
00148   OutputImagePixelType m_ForegroundValue;
00149 
00150   typename Barrier::Pointer m_Barrier;
00151 }; // end of class
00152 } // end namespace itk
00153 
00154 #ifndef ITK_MANUAL_INSTANTIATION
00155 #include "itkLabelMapToBinaryImageFilter.hxx"
00156 #endif
00157 
00158 #endif
00159