ITK  4.1.0
Insight Segmentation and Registration Toolkit
itkSignedDanielssonDistanceMapImageFilter.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 __itkSignedDanielssonDistanceMapImageFilter_h
00019 #define __itkSignedDanielssonDistanceMapImageFilter_h
00020 
00021 #include "itkDanielssonDistanceMapImageFilter.h"
00022 #include "itkSubtractImageFilter.h"
00023 
00024 //Simple functor to invert an image for Outside Danielsson distance map
00025 namespace itk
00026 {
00027 namespace Functor
00028 {
00029 template< class InputPixelType >
00030 class InvertIntensityFunctor
00031 {
00032 public:
00033   InputPixelType operator()(InputPixelType input) const
00034   {
00035     if ( input )
00036       {
00037       return NumericTraits< InputPixelType >::Zero;
00038       }
00039     else
00040       {
00041       return NumericTraits< InputPixelType >::One;
00042       }
00043   }
00044 };
00045 }
00046 }
00047 
00048 namespace itk
00049 {
00087 template< class TInputImage,
00088           class TOutputImage,
00089           class TVoronoiImage = TInputImage >
00090 class ITK_EXPORT SignedDanielssonDistanceMapImageFilter:
00091   public ImageToImageFilter< TInputImage, TOutputImage >
00092 {
00093 public:
00095   typedef SignedDanielssonDistanceMapImageFilter          Self;
00096   typedef ImageToImageFilter< TInputImage, TOutputImage > Superclass;
00097   typedef SmartPointer< Self >                            Pointer;
00098   typedef SmartPointer< const Self >                      ConstPointer;
00099 
00101   itkNewMacro(Self);
00102 
00104   itkTypeMacro(SignedDanielssonDistanceMapImageFilter, ImageToImageFilter);
00105 
00107   typedef   TInputImage InputImageType;
00108 
00111   typedef   TOutputImage OutputImageType;
00112 
00114   typedef typename InputImageType::RegionType RegionType;
00115 
00117   typedef typename RegionType::IndexType IndexType;
00118 
00120   typedef typename InputImageType::OffsetType OffsetType;
00121 
00123   typedef typename InputImageType::PixelType PixelType;
00124 
00126   typedef typename RegionType::SizeType SizeType;
00127 
00129   itkStaticConstMacro(InputImageDimension, unsigned int,
00130                       InputImageType::ImageDimension);
00131 
00133   typedef Image< OffsetType,
00134                  itkGetStaticConstMacro(InputImageDimension) > VectorImageType;
00135 
00137   typedef typename InputImageType::ConstPointer InputImagePointer;
00138 
00140   typedef typename OutputImageType::Pointer OutputImagePointer;
00141 
00143   typedef typename VectorImageType::Pointer VectorImagePointer;
00144 
00145   typedef TVoronoiImage                         VoronoiImageType;
00146   typedef typename VoronoiImageType::Pointer    VoronoiImagePointer;
00147   typedef typename VoronoiImageType::PixelType  VoronoiPixelType;
00148 
00150   typedef typename Superclass::DataObjectPointer DataObjectPointer;
00151 
00153   itkSetMacro(SquaredDistance, bool);
00154 
00156   itkGetConstReferenceMacro(SquaredDistance, bool);
00157 
00159   itkBooleanMacro(SquaredDistance);
00160 
00162   itkSetMacro(UseImageSpacing, bool);
00163 
00165   itkGetConstReferenceMacro(UseImageSpacing, bool);
00166 
00168   itkBooleanMacro(UseImageSpacing);
00169 
00172   itkSetMacro(InsideIsPositive, bool);
00173 
00176   itkGetConstReferenceMacro(InsideIsPositive, bool);
00177 
00181   itkBooleanMacro(InsideIsPositive);
00182 
00188   VoronoiImageType * GetVoronoiMap(void);
00189 
00198   OutputImageType * GetDistanceMap(void);
00199 
00201   VectorImageType * GetVectorDistanceMap(void);
00202 
00204   typedef ProcessObject::DataObjectPointerArraySizeType DataObjectPointerArraySizeType;
00205   using Superclass::MakeOutput;
00206   virtual DataObjectPointer MakeOutput(DataObjectPointerArraySizeType idx);
00207 
00208 #ifdef ITK_USE_CONCEPT_CHECKING
00209 
00210   itkConceptMacro( IntConvertibleToInputCheck,
00211                    ( Concept::Convertible< int, PixelType > ) );
00212   itkConceptMacro( InputHasNumericTraitsCheck,
00213                    ( Concept::HasNumericTraits< PixelType > ) );
00214 
00216 #endif
00217 protected:
00218   SignedDanielssonDistanceMapImageFilter();
00219   virtual ~SignedDanielssonDistanceMapImageFilter() {}
00220   void PrintSelf(std::ostream & os, Indent indent) const;
00222 
00224   void GenerateData();
00225 
00226 private:
00227   SignedDanielssonDistanceMapImageFilter(const Self &); //purposely not
00228                                                         // implemented
00229   void operator=(const Self &);                         //purposely not
00230 
00231   // implemented
00232 
00233   bool m_SquaredDistance;
00234   bool m_UseImageSpacing;
00235   bool m_InsideIsPositive; // ON is treated as inside pixels
00236 };                         // end of SignedDanielssonDistanceMapImageFilter
00237                            // class
00238 } //end namespace itk
00239 
00240 #ifndef ITK_MANUAL_INSTANTIATION
00241 #include "itkSignedDanielssonDistanceMapImageFilter.hxx"
00242 #endif
00243 
00244 #endif
00245