00001 /*========================================================================= 00002 00003 Program: Insight Segmentation & Registration Toolkit 00004 Module: $RCSfile: itkLabelMapFilter.h,v $ 00005 Language: C++ 00006 Date: $Date: 2009-05-16 22:19:30 $ 00007 Version: $Revision: 1.2 $ 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 00026 namespace itk 00027 { 00028 00048 template <class TInputImage, class TOutputImage> 00049 class ITK_EXPORT LabelMapFilter : public ImageToImageFilter<TInputImage, TOutputImage> 00050 { 00051 public: 00053 typedef LabelMapFilter Self; 00054 typedef ImageToImageFilter<TInputImage, TOutputImage> Superclass; 00055 typedef SmartPointer<Self> Pointer; 00056 typedef SmartPointer<const Self> ConstPointer; 00057 00058 00060 itkTypeMacro(LabelMapFilter,ImageToImageFilter); 00061 00063 itkNewMacro(Self); 00064 00066 typedef TInputImage InputImageType; 00067 typedef typename InputImageType::Pointer InputImagePointer; 00068 typedef typename InputImageType::ConstPointer InputImageConstPointer; 00069 typedef typename InputImageType::RegionType InputImageRegionType; 00070 typedef typename InputImageType::PixelType InputImagePixelType; 00071 typedef typename InputImageType::LabelObjectType LabelObjectType; 00072 00073 typedef TOutputImage OutputImageType; 00074 typedef typename OutputImageType::Pointer OutputImagePointer; 00075 typedef typename OutputImageType::ConstPointer OutputImageConstPointer; 00076 typedef typename OutputImageType::RegionType OutputImageRegionType; 00077 typedef typename OutputImageType::PixelType OutputImagePixelType; 00078 00080 itkStaticConstMacro(InputImageDimension, unsigned int, 00081 TInputImage::ImageDimension); 00082 itkStaticConstMacro(OutputImageDimension, unsigned int, 00083 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 private: 00118 LabelMapFilter(const Self&); //purposely not implemented 00119 void operator=(const Self&); //purposely not implemented 00120 00121 typename InputImageType::LabelObjectContainerType::const_iterator m_LabelObjectIterator; 00122 00123 ProgressReporter * m_Progress; 00124 00125 }; 00126 00127 } // end namespace itk 00128 00129 #ifndef ITK_MANUAL_INSTANTIATION 00130 #include "itkLabelMapFilter.txx" 00131 #endif 00132 00133 #endif 00134