ITK  4.1.0
Insight Segmentation and Registration Toolkit
itkDanielssonDistanceMapImageFilter.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 __itkDanielssonDistanceMapImageFilter_h
00019 #define __itkDanielssonDistanceMapImageFilter_h
00020 
00021 #include "itkImageToImageFilter.h"
00022 #include "itkImageRegionIteratorWithIndex.h"
00023 
00024 namespace itk
00025 {
00058 template< class TInputImage,
00059   class TOutputImage,
00060   class TVoronoiImage = TInputImage >
00061 class ITK_EXPORT DanielssonDistanceMapImageFilter:
00062   public ImageToImageFilter< TInputImage, TOutputImage >
00063 {
00064 public:
00066   typedef DanielssonDistanceMapImageFilter                Self;
00067   typedef ImageToImageFilter< TInputImage, TOutputImage > Superclass;
00068   typedef SmartPointer< Self >                            Pointer;
00069   typedef SmartPointer< const Self >                      ConstPointer;
00070 
00071   typedef DataObject::Pointer                             DataObjectPointer;
00072 
00074   itkNewMacro(Self);
00075 
00077   itkTypeMacro(DanielssonDistanceMapImageFilter, ImageToImageFilter);
00078 
00080   typedef   TInputImage InputImageType;
00081 
00083   typedef typename InputImageType::PixelType InputPixelType;
00084 
00086   typedef typename InputImageType::RegionType RegionType;
00087 
00089   typedef typename RegionType::IndexType IndexType;
00090 
00092   typedef typename InputImageType::OffsetType OffsetType;
00093 
00095   typedef typename InputImageType::SpacingType      SpacingType;
00096   typedef typename InputImageType::SpacingValueType SpacingValueType;
00097 
00099   typedef typename RegionType::SizeType SizeType;
00100 
00102   typedef typename SizeType::SizeValueType SizeValueType;
00103 
00106   typedef   TOutputImage OutputImageType;
00107 
00109   typedef typename OutputImageType::PixelType OutputPixelType;
00110 
00111   typedef TVoronoiImage                         VoronoiImageType;
00112   typedef typename VoronoiImageType::Pointer    VoronoiImagePointer;
00113   typedef typename VoronoiImageType::PixelType  VoronoiPixelType;
00114 
00116   itkStaticConstMacro(InputImageDimension, unsigned int,
00117                       InputImageType::ImageDimension);
00118 
00120   typedef Image< OffsetType,
00121                  itkGetStaticConstMacro(InputImageDimension) > VectorImageType;
00122 
00124   typedef typename InputImageType::ConstPointer InputImagePointer;
00125 
00127   typedef typename OutputImageType::Pointer OutputImagePointer;
00128 
00130   typedef typename VectorImageType::Pointer VectorImagePointer;
00131 
00133   itkSetMacro(SquaredDistance, bool);
00134 
00136   itkGetConstReferenceMacro(SquaredDistance, bool);
00137 
00139   itkBooleanMacro(SquaredDistance);
00140 
00146   itkSetMacro(InputIsBinary, bool);
00147 
00149   itkGetConstReferenceMacro(InputIsBinary, bool);
00150 
00152   itkBooleanMacro(InputIsBinary);
00153 
00155   itkSetMacro(UseImageSpacing, bool);
00156 
00158   itkGetConstReferenceMacro(UseImageSpacing, bool);
00159 
00161   itkBooleanMacro(UseImageSpacing);
00162 
00168   VoronoiImageType * GetVoronoiMap(void);
00169 
00178   OutputImageType * GetDistanceMap(void);
00179 
00181   VectorImageType * GetVectorDistanceMap(void);
00182 
00184   typedef ProcessObject::DataObjectPointerArraySizeType DataObjectPointerArraySizeType;
00185   using Superclass::MakeOutput;
00186   virtual DataObjectPointer MakeOutput( DataObjectPointerArraySizeType idx );
00187 
00188 #ifdef ITK_USE_CONCEPT_CHECKING
00189   itkStaticConstMacro(OutputImageDimension, unsigned int,
00190                       TOutputImage::ImageDimension);
00191   itkStaticConstMacro(VoronoiImageDimension, unsigned int,
00192                       TVoronoiImage::ImageDimension);
00193 
00195   itkConceptMacro( InputOutputSameDimensionCheck,
00196                    ( Concept::SameDimension< InputImageDimension, OutputImageDimension > ) );
00197   itkConceptMacro( InputVoronoiSameDimensionCheck,
00198                    ( Concept::SameDimension< InputImageDimension, VoronoiImageDimension > ) );
00199   itkConceptMacro( DoubleConvertibleToOutputCheck,
00200                    ( Concept::Convertible< double, OutputPixelType > ) );
00201   itkConceptMacro( InputConvertibleToOutputCheck,
00202                    ( Concept::Convertible< InputPixelType,
00203                                            OutputPixelType > ) );
00204 
00206 #endif
00207 protected:
00208   DanielssonDistanceMapImageFilter();
00209   virtual ~DanielssonDistanceMapImageFilter() {}
00210   void PrintSelf(std::ostream & os, Indent indent) const;
00212 
00214   void GenerateData();
00215 
00217   void PrepareData();
00218 
00220   void ComputeVoronoiMap();
00221 
00223   void UpdateLocalDistance(VectorImageType *,
00224                            const IndexType &,
00225                            const OffsetType &);
00226 
00227 private:
00228   DanielssonDistanceMapImageFilter(const Self &); //purposely not implemented
00229   void operator=(const Self &);                   //purposely not implemented
00230 
00231   bool m_SquaredDistance;
00232   bool m_InputIsBinary;
00233   bool m_UseImageSpacing;
00234 }; // end of DanielssonDistanceMapImageFilter class
00235 } //end namespace itk
00236 
00237 #ifndef ITK_MANUAL_INSTANTIATION
00238 #include "itkDanielssonDistanceMapImageFilter.hxx"
00239 #endif
00240 
00241 #endif
00242