Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
DistTransform.hh
1 /*
2 This file is part of the BIAS library (Basic ImageAlgorithmS).
3 
4 Copyright (C) 2003-2009 (see file CONTACT for details)
5  Multimediale Systeme der Informationsverarbeitung
6  Institut fuer Informatik
7  Christian-Albrechts-Universitaet Kiel
8 
9 
10 BIAS is free software; you can redistribute it and/or modify
11 it under the terms of the GNU Lesser General Public License as published by
12 the Free Software Foundation; either version 2.1 of the License, or
13 (at your option) any later version.
14 
15 BIAS is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU Lesser General Public License for more details.
19 
20 You should have received a copy of the GNU Lesser General Public License
21 along with BIAS; if not, write to the Free Software
22 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 */
24 #ifndef __BIAS_DISTTRANS_HH__
25 #define __BIAS_DISTTRANS_HH__
26 #include <Base/Common/BIASpragmaStart.hh>
27 
28 // std includes
29 #include <vector>
30 
31 // BIAS includes
32 #include <Base/Image/Image.hh>
33 #include <Base/Math/Vector2.hh>
34 #include "FilterBase.hh"
35 #include "FilterNToN.hh"
36 
37 namespace BIAS {
38  /** @class DistTransform
39  @brief Class for calculating the distance transform.
40 
41  Generates an image where for all pixels the distance to the step of
42  pixels with zero value in the input image is calculated. The Borgefor
43  distance is used to measure distances (diagonal step has distance 4,
44  horizontal/vertical step has distance 3).
45 
46  @author Dennis Herzog, Jan. 2005, edited by grest
47  */
48  template <class InputStorageType, class OutputStorageType>
49  class BIASFilter_EXPORT DistTransform
50  : public FilterNToN<InputStorageType, OutputStorageType>
51  {
52 
53  public:
54  DistTransform();
56  virtual ~DistTransform() {}
57 
58  /** @brief Calculates the distanceImage from source image src.
59  Converts the given image to a distance transformed image (the Borgefor
60  distance is used, that means one step in diagonal direction has a
61  distance of 4 other steps have distances of 3); <br>
62  The pixel set, to which the distance is calculated
63  has to be marked as zero valued pixels, e.g. grey value zero or
64  SetZeroLevel().
65  @author herzog
66  @param img input and output image
67  */
68  virtual int Filter(const Image<InputStorageType>& src,
70 
71  virtual int FilterInt(const Image<InputStorageType>& src,
73 
74  virtual int FilterFloat(const Image<InputStorageType>& src,
76 
79 
80  void SetZeroLevel(InputStorageType value) { zeroLevel_=value;}
81 
82  protected:
83  void MakeDistanceImage_(BIAS::Image<OutputStorageType>& img);
84  void InitDistanceImage_(BIAS::Image<OutputStorageType>& img);
85  InputStorageType zeroLevel_;
86 
87  virtual void GetBordersValid_(int &border_x, int& border_y) const;
88  };
89 
90 }
91 
92 #include <Base/Common/BIASpragmaEnd.hh>
93 
94 #endif
virtual FilterNToN< InputStorageType, OutputStorageType > * Clone() const
void SetZeroLevel(InputStorageType value)
Class for calculating the distance transform.
base class for simple n-&gt;n filter implementations
Definition: FilterNToN.hh:43
virtual ~DistTransform()
InputStorageType zeroLevel_