00001 /*========================================================================= 00002 00003 Program: Insight Segmentation & Registration Toolkit 00004 Module: $RCSfile: itkLabelMapFilter.h,v $ 00005 Language: C++ 00006 Date: $Date: 2009-08-15 16:50:00 $ 00007 Version: $Revision: 1.5 $ 00008 00009 Copyright (c) Insight Software Consortium. All rights reserved. 00010 See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. 00011 00012 Portions of this code are covered under the VTK copyright. 00013 See VTKCopyright.txt or http://www.kitware.com/VTKCopyright.htm for details. 00014 00015 This software is distributed WITHOUT ANY WARRANTY; without even 00016 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00017 PURPOSE. See the above copyright notices for more information. 00018 00019 =========================================================================*/ 00020 #ifndef __itkLabelMapFilter_h 00021 #define __itkLabelMapFilter_h 00022 00023 #include "itkImageToImageFilter.h" 00024 #include "itkProgressReporter.h" 00025 #include "itkFastMutexLock.h" 00026 00027 namespace itk 00028 { 00029 00049 template <class TInputImage, class TOutputImage> 00050 class ITK_EXPORT LabelMapFilter : 00051 public 00052 ImageToImageFilter<TInputImage, TOutputImage> 00053 { 00054 public: 00056 typedef LabelMapFilter Self; 00057 typedef ImageToImageFilter<TInputImage, TOutputImage> Superclass; 00058 typedef SmartPointer<Self> Pointer; 00059 typedef SmartPointer<const Self> ConstPointer; 00060 00062 itkTypeMacro(LabelMapFilter,ImageToImageFilter); 00063 00065 itkNewMacro(Self); 00066 00068 typedef TInputImage InputImageType; 00069 typedef typename InputImageType::Pointer InputImagePointer; 00070 typedef typename InputImageType::ConstPointer InputImageConstPointer; 00071 typedef typename InputImageType::RegionType InputImageRegionType; 00072 typedef typename InputImageType::PixelType InputImagePixelType; 00073 typedef typename InputImageType::LabelObjectType LabelObjectType; 00074 00075 typedef TOutputImage OutputImageType; 00076 typedef typename OutputImageType::Pointer OutputImagePointer; 00077 typedef typename OutputImageType::ConstPointer OutputImageConstPointer; 00078 typedef typename OutputImageType::RegionType OutputImageRegionType; 00079 typedef typename OutputImageType::PixelType OutputImagePixelType; 00080 00082 itkStaticConstMacro(InputImageDimension, unsigned int, TInputImage::ImageDimension); 00083 itkStaticConstMacro(OutputImageDimension, unsigned int, TOutputImage::ImageDimension); 00085 00089 void GenerateInputRequestedRegion(); 00090 00092 void EnlargeOutputRequestedRegion(DataObject *itkNotUsed(output)); 00093 00094 protected: 00095 LabelMapFilter(); 00096 ~LabelMapFilter(); 00097 00098 virtual void BeforeThreadedGenerateData(); 00099 00100 virtual void AfterThreadedGenerateData(); 00101 00102 virtual void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, int threadId ); 00103 00104 virtual void ThreadedProcessLabelObject( LabelObjectType * labelObject ); 00105 00110 virtual InputImageType * GetLabelMap() 00111 { 00112 return static_cast<InputImageType*>(const_cast<DataObject *>(this->ProcessObject::GetInput(0))); 00113 } 00114 00115 typename FastMutexLock::Pointer m_LabelObjectContainerLock; 00116 00117 typedef typename InputImageType::LabelObjectContainerType LabelObjectContainerType; 00118 typedef typename LabelObjectContainerType::const_iterator LabelObjectContainerConstIterator; 00119 00120 private: 00121 LabelMapFilter(const Self&); //purposely not implemented 00122 void operator=(const Self&); //purposely not implemented 00123 00124 LabelObjectContainerConstIterator m_LabelObjectIterator; 00125 00126 ProgressReporter * m_Progress; 00127 00128 }; 00129 00130 } // end namespace itk 00131 00132 #ifndef ITK_MANUAL_INSTANTIATION 00133 #include "itkLabelMapFilter.txx" 00134 #endif 00135 00136 #endif 00137