Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
itkDistanceMapFilter.txx
Go to the documentation of this file.
1 /*===================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center,
6 Division of Medical and Biological Informatics.
7 All rights reserved.
8 
9 This software is distributed WITHOUT ANY WARRANTY; without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE.
12 
13 See LICENSE.txt or http://www.mitk.org for details.
14 
15 ===================================================================*/
16 #ifndef _itkDistanceMapFilter_txx
17 #define _itkDistanceMapFilter_txx
18 
19 #include "itkDistanceMapFilter.h"
20 
21 #include <itkSignedMaurerDistanceMapImageFilter.h>
22 
23 
24 namespace itk
25 {
26 
27  template< class TInputImage, class TOutputImage >
28  DistanceMapFilter<TInputImage, TOutputImage>::DistanceMapFilter()
29  {
30 
31  }
32 
33  template< class TInputImage, class TOutputImage >
34  DistanceMapFilter<TInputImage, TOutputImage>::~DistanceMapFilter()
35  {
36 
37 
38  }
39 
40 
41 
42 
43  template< class TInputImage, class TOutputImage >
44  void DistanceMapFilter<TInputImage, TOutputImage>::GenerateData()
45  {
46 
47 
48  typedef itk::SignedMaurerDistanceMapImageFilter<InputImageType, OutputImageType> DistanceFilterType;
49  typename DistanceFilterType::Pointer dFilter = DistanceFilterType::New();
50  dFilter->SetInput(this->GetInput());
51  dFilter->SetUseImageSpacing(true);
52  dFilter->SetSquaredDistance(false);
53  dFilter->SetInsideIsPositive(true);
54  dFilter->Update();
55 
56  typename OutputImageType::Pointer outputImg = dFilter->GetOutput();
57 
58  typedef itk::ImageRegionIterator<OutputImageType> ImageIteratorType;
59 
60  ImageIteratorType outIt(outputImg, outputImg->GetRequestedRegion());
61  outIt.GoToBegin();
62  while(!outIt.IsAtEnd())
63  {
64  typename OutputImageType::PixelType p = outIt.Get();
65  p *= -1;
66  outIt.Set(p);
67  ++outIt;
68  }
69 
70  Superclass::SetNthOutput( 0, outputImg );
71 
72  }
73 
74 
75 
76 
77 
78 }
79 #endif // _itkDistanceMapFilter_txx