ITK  4.1.0
Insight Segmentation and Registration Toolkit
itkSignedMaurerDistanceMapImageFilter.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 __itkSignedMaurerDistanceMapImageFilter_h
00019 #define __itkSignedMaurerDistanceMapImageFilter_h
00020 
00021 #include "itkImageToImageFilter.h"
00022 
00023 namespace itk
00024 {
00061 template< class TInputImage, class TOutputImage >
00062 class ITK_EXPORT SignedMaurerDistanceMapImageFilter:
00063   public ImageToImageFilter< TInputImage, TOutputImage >
00064 {
00065 public:
00066 
00068   itkStaticConstMacro(InputImageDimension, unsigned int,
00069                       TInputImage::ImageDimension);
00070   itkStaticConstMacro(OutputImageDimension, unsigned int,
00071                       TOutputImage::ImageDimension);
00072   itkStaticConstMacro(ImageDimension, unsigned int,
00073                       TOutputImage::ImageDimension);
00075 
00077   typedef TInputImage                           InputImageType;
00078   typedef typename InputImageType::ConstPointer InputImageConstPointer;
00079 
00080   typedef TOutputImage                          OutputImageType;
00081   typedef typename OutputImageType::Pointer     OutputImagePointer;
00082 
00084   typedef SignedMaurerDistanceMapImageFilter  Self;
00085   typedef ImageToImageFilter<
00086     InputImageType,
00087     OutputImageType >                         Superclass;
00088 
00089   typedef SmartPointer< Self >                Pointer;
00090   typedef SmartPointer< const Self >          ConstPointer;
00091 
00093   itkNewMacro(Self);
00094 
00096   itkTypeMacro(SignedMaurerDistanceMapImageFilter,
00097                ImageToImageFilter);
00098 
00099   typedef typename InputImageType::RegionType   InputRegionType;
00100   typedef typename OutputImageType::RegionType  OutputRegionType;
00101 
00103   typedef typename InputImageType::PixelType  InputPixelType;
00104   typedef typename OutputImageType::PixelType OutputPixelType;
00105 
00106   typedef typename InputImageType::SizeType       InputSizeType;
00107   typedef typename InputImageType::SizeValueType  InputSizeValueType;
00108   typedef typename OutputImageType::SizeType      OutputSizeType;
00109   typedef typename OutputImageType::SizeValueType OutputSizeValueType;
00110 
00111   typedef typename InputImageType::IndexType        InputIndexType;
00112   typedef typename InputImageType::IndexValueType   InputIndexValueType;
00113   typedef typename OutputImageType::IndexType       OutputIndexType;
00114   typedef typename OutputImageType::IndexValueType  OutputIndexValueType;
00115 
00116   typedef typename InputImageType::SpacingType  InputSpacingType;
00117   typedef typename OutputImageType::SpacingType OutputSpacingType;
00118   typedef typename OutputImageType::RegionType  OutputImageRegionType;
00119 
00121   itkSetMacro(SquaredDistance, bool);
00122 
00124   itkGetConstReferenceMacro(SquaredDistance, bool);
00125 
00127   itkBooleanMacro(SquaredDistance);
00128 
00131   itkSetMacro(InsideIsPositive, bool);
00132 
00135   itkGetConstReferenceMacro(InsideIsPositive, bool);
00136 
00140   itkBooleanMacro(InsideIsPositive);
00141 
00143   itkSetMacro(UseImageSpacing, bool);
00144 
00146   itkGetConstReferenceMacro(UseImageSpacing, bool);
00147 
00149   itkBooleanMacro(UseImageSpacing);
00150 
00155   itkSetMacro(BackgroundValue, InputPixelType);
00156   itkGetConstReferenceMacro(BackgroundValue, InputPixelType);
00157 protected:
00159 
00160   SignedMaurerDistanceMapImageFilter();
00161 
00162   virtual ~SignedMaurerDistanceMapImageFilter();
00163 
00164   void PrintSelf(std::ostream & os, Indent indent) const;
00165 
00166   void GenerateData();
00167 
00168   unsigned int SplitRequestedRegion(unsigned int i, unsigned int num,
00169     OutputImageRegionType & splitRegion);
00170 
00171   void ThreadedGenerateData(const OutputImageRegionType & outputRegionForThread,
00172                             ThreadIdType threadId);
00173 
00174 private:
00175 
00176   SignedMaurerDistanceMapImageFilter(const Self &); //purposely not implemented
00177   void operator=(const Self &);                     //purposely not implemented
00178 
00179   void Voronoi(unsigned int, OutputIndexType );
00180   bool Remove(OutputPixelType, OutputPixelType, OutputPixelType,
00181               OutputPixelType, OutputPixelType, OutputPixelType);
00182 
00183   InputPixelType   m_BackgroundValue;
00184   InputSpacingType m_Spacing;
00185 
00186   unsigned int m_CurrentDimension;
00187 
00188   bool m_InsideIsPositive;
00189   bool m_UseImageSpacing;
00190   bool m_SquaredDistance;
00191 };
00192 } // end namespace itk
00193 
00194 #ifndef ITK_MANUAL_INSTANTIATION
00195 #include "itkSignedMaurerDistanceMapImageFilter.hxx"
00196 #endif
00197 
00198 #endif
00199