ITK  4.0.0
Insight Segmentation and Registration Toolkit
itkLabelMapFilter.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 /*=========================================================================
00019  *
00020  *  Portions of this file are subject to the VTK Toolkit Version 3 copyright.
00021  *
00022  *  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
00023  *
00024  *  For complete copyright, license and disclaimer of warranty information
00025  *  please refer to the NOTICE file at the top of the ITK source tree.
00026  *
00027  *=========================================================================*/
00028 #ifndef __itkLabelMapFilter_h
00029 #define __itkLabelMapFilter_h
00030 
00031 #include "itkImageToImageFilter.h"
00032 #include "itkProgressReporter.h"
00033 #include "itkFastMutexLock.h"
00034 
00035 namespace itk
00036 {
00057 template< class TInputImage, class TOutputImage >
00058 class ITK_EXPORT LabelMapFilter:
00059   public
00060   ImageToImageFilter< TInputImage, TOutputImage >
00061 {
00062 public:
00064   typedef LabelMapFilter                                  Self;
00065   typedef ImageToImageFilter< TInputImage, TOutputImage > Superclass;
00066   typedef SmartPointer< Self >                            Pointer;
00067   typedef SmartPointer< const Self >                      ConstPointer;
00068 
00070   itkTypeMacro(LabelMapFilter, ImageToImageFilter);
00071 
00073   itkNewMacro(Self);
00074 
00076   typedef TInputImage                              InputImageType;
00077   typedef typename InputImageType::Pointer         InputImagePointer;
00078   typedef typename InputImageType::ConstPointer    InputImageConstPointer;
00079   typedef typename InputImageType::RegionType      InputImageRegionType;
00080   typedef typename InputImageType::PixelType       InputImagePixelType;
00081   typedef typename InputImageType::LabelObjectType LabelObjectType;
00082 
00083   typedef TOutputImage                           OutputImageType;
00084   typedef typename OutputImageType::Pointer      OutputImagePointer;
00085   typedef typename OutputImageType::ConstPointer OutputImageConstPointer;
00086   typedef typename OutputImageType::RegionType   OutputImageRegionType;
00087   typedef typename OutputImageType::PixelType    OutputImagePixelType;
00088 
00090   itkStaticConstMacro(InputImageDimension, unsigned int, TInputImage::ImageDimension);
00091   itkStaticConstMacro(OutputImageDimension, unsigned int, TOutputImage::ImageDimension);
00093 
00097   void GenerateInputRequestedRegion();
00098 
00100   void EnlargeOutputRequestedRegion( DataObject * itkNotUsed(output) );
00101 protected:
00102   LabelMapFilter();
00103   ~LabelMapFilter();
00105 
00106   virtual void BeforeThreadedGenerateData();
00107 
00108   virtual void AfterThreadedGenerateData();
00109 
00110   virtual void ThreadedGenerateData(const OutputImageRegionType & outputRegionForThread, ThreadIdType threadId);
00111 
00112   virtual void ThreadedProcessLabelObject(LabelObjectType *labelObject);
00113 
00118   virtual InputImageType * GetLabelMap()
00119   {
00120     return static_cast< InputImageType * >( const_cast< DataObject * >( this->ProcessObject::GetInput(0) ) );
00121   }
00122 
00123   typename FastMutexLock::Pointer m_LabelObjectContainerLock;
00124 
00125 private:
00126   LabelMapFilter(const Self &); //purposely not implemented
00127   void operator=(const Self &); //purposely not implemented
00128 
00129   typename InputImageType::Iterator m_LabelObjectIterator;
00130 
00131   ProgressReporter *m_Progress;
00132 };
00133 } // end namespace itk
00134 
00135 #ifndef ITK_MANUAL_INSTANTIATION
00136 #include "itkLabelMapFilter.hxx"
00137 #endif
00138 
00139 #endif
00140