ITK  4.1.0
Insight Segmentation and Registration Toolkit
itkIsoContourDistanceImageFilter.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 __itkIsoContourDistanceImageFilter_h
00019 #define __itkIsoContourDistanceImageFilter_h
00020 
00021 #include "itkImageToImageFilter.h"
00022 #include "itkNarrowBand.h"
00023 #include "itkNeighborhoodIterator.h"
00024 #include "itkBarrier.h"
00025 
00026 namespace itk
00027 {
00056 template< class TInputImage, class TOutputImage >
00057 class ITK_EXPORT IsoContourDistanceImageFilter:
00058   public ImageToImageFilter< TInputImage, TOutputImage >
00059 {
00060 public:
00062   typedef IsoContourDistanceImageFilter                   Self;
00063   typedef ImageToImageFilter< TInputImage, TOutputImage > Superclass;
00064   typedef SmartPointer< Self >                            Pointer;
00065   typedef SmartPointer< const Self >                      ConstPointer;
00066 
00068   itkNewMacro(Self);
00069 
00071   itkTypeMacro(IsoContourDistanceImageFilter, ImageToImageFilter);
00072 
00074   typedef typename Superclass::InputImageType  InputImageType;
00075   typedef typename Superclass::OutputImageType OutputImageType;
00076 
00079   itkStaticConstMacro(ImageDimension, unsigned int,
00080                       TInputImage::ImageDimension);
00081   itkStaticConstMacro(OutputImageDimension, unsigned int,
00082                       TOutputImage::ImageDimension);
00084 
00087   typedef typename OutputImageType::PixelType  PixelType;
00088   typedef typename InputImageType::PixelType   InputPixelType;
00089   typedef typename OutputImageType::RegionType OutputImageRegionType;
00090 
00091   typedef typename InputImageType::SizeType   InputSizeType;
00092   typedef typename OutputImageType::SizeType  SizeType;
00093 
00094   typedef typename InputImageType::IndexType  InputIndexType;
00095   typedef typename OutputImageType::IndexType IndexType;
00096 
00097   typedef typename InputImageType::SpacingType InputSpacingType;
00098 
00100   typedef BandNode< IndexType, PixelType >       BandNodeType;
00101   typedef NarrowBand< BandNodeType >             NarrowBandType;
00102   typedef typename NarrowBandType::Pointer       NarrowBandPointer;
00103   typedef typename NarrowBandType::RegionType    RegionType;
00104   typedef typename NarrowBandType::ConstIterator ConstBandIterator;
00105   typedef typename NarrowBandType::Iterator      BandIterator;
00106 
00109   itkSetMacro(LevelSetValue, InputPixelType);
00110   itkGetConstMacro(LevelSetValue, InputPixelType);
00112 
00115   itkSetMacro(FarValue, PixelType);
00116   itkGetConstMacro(FarValue, PixelType);
00118 
00121   itkSetMacro(NarrowBanding, bool);
00122   itkGetConstMacro(NarrowBanding, bool);
00123   itkBooleanMacro(NarrowBanding);
00125 
00127   void SetNarrowBand(NarrowBandType *ptr);
00128 
00129   NarrowBandPointer GetNarrowBand() const
00130   { return m_NarrowBand; }
00131 
00132 #ifdef ITK_USE_CONCEPT_CHECKING
00133 
00134   itkConceptMacro( InputEqualityComparableCheck,
00135                    ( Concept::EqualityComparable< InputPixelType > ) );
00136   itkConceptMacro( OutputEqualityComparableCheck,
00137                    ( Concept::EqualityComparable< PixelType > ) );
00138   itkConceptMacro( SameDimensionCheck,
00139                    ( Concept::SameDimension< ImageDimension, OutputImageDimension > ) );
00140   itkConceptMacro( DoubleConvertibleToOutputCheck,
00141                    ( Concept::Convertible< double, PixelType > ) );
00142   itkConceptMacro( InputConvertibleToOutputCheck,
00143                    ( Concept::Convertible< InputPixelType, PixelType > ) );
00144   itkConceptMacro( OutputAdditiveOperatorsCheck,
00145                    ( Concept::AdditiveOperators< PixelType > ) );
00146   itkConceptMacro( InputOStreamWritableCheck,
00147                    ( Concept::OStreamWritable< InputPixelType > ) );
00148   itkConceptMacro( OutputOStreamWritableCheck,
00149                    ( Concept::OStreamWritable< PixelType > ) );
00150 
00152 #endif
00153 protected:
00154   IsoContourDistanceImageFilter();
00155   ~IsoContourDistanceImageFilter(){}
00156   void PrintSelf(std::ostream & os, Indent indent) const;
00158 
00159   void ThreadedGenerateData(const OutputImageRegionType & outputRegionForThread,
00160                             ThreadIdType threadId);
00161 
00162   void ThreadedGenerateDataFull(const OutputImageRegionType & outputRegionForThread,
00163                                 ThreadIdType threadId);
00164 
00165   void ThreadedGenerateDataBand(const OutputImageRegionType & outputRegionForThread,
00166                                 ThreadIdType threadId);
00167 
00168   void BeforeThreadedGenerateData();
00169 
00170   virtual void GenerateInputRequestedRegion();
00171 
00172   virtual void EnlargeOutputRequestedRegion(DataObject *);
00173 
00174   typedef ConstNeighborhoodIterator< InputImageType > InputNeighbordIteratorType;
00175   typedef NeighborhoodIterator< OutputImageType >     OutputNeighborhoodIteratorType;
00176 
00177   void ComputeValue( const InputNeighbordIteratorType& inNeigIt,
00178                      OutputNeighborhoodIteratorType& outNeigIt,
00179                      unsigned int center,
00180                      const std::vector< OffsetValueType >& stride );
00181 
00182 private:
00183   IsoContourDistanceImageFilter(const Self &); //purposely not implemented
00184   void operator=(const Self &);                //purposely not implemented
00185 
00186   InputPixelType m_LevelSetValue;
00187   PixelType      m_FarValue;
00188 
00189   InputSpacingType m_Spacing;
00190 
00191   bool                      m_NarrowBanding;
00192   NarrowBandPointer         m_NarrowBand;
00193   std::vector< RegionType > m_NarrowBandRegion;
00194 
00196   typename Barrier::Pointer m_Barrier;
00197 };
00198 } // namespace itk
00199 
00200 #ifndef ITK_MANUAL_INSTANTIATION
00201 #include "itkIsoContourDistanceImageFilter.hxx"
00202 #endif
00203 
00204 #endif
00205