Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
GradientSimple.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 
25 
26 #ifndef __GradientSimple_hh__
27 #define __GradientSimple_hh__
28 
29 #include "FilterNTo2N.hh"
30 
31 #include <Base/Math/Vector3.hh>
32 #include "Convolution.hh"
33 
34 
35 namespace BIAS {
36 
37  /** @class GradientSimple
38  @ingroup g_filter
39  @brief simple gradient calculation
40  gx(x,y) = I(x+1,y) - I(x-1,y)
41  gy(x,y) = I(x,y+1) - I(x,y-1)
42 
43  weights (not filter mask, ->reflection!) are
44  - -1
45  - WE: -1 0 1 NS: 0
46  - 1
47 
48  The main interface Filter dispatches: If there is a fast version, it
49  is called, otherwise Filter calls the generic convolution.
50  @author koeser 04/2005 */
51  template <class InputStorageType, class OutputStorageType>
52  class BIASFilter_EXPORT GradientSimple : public FilterNTo2N<InputStorageType,
53  OutputStorageType>
54  {
55  public:
56  GradientSimple(bool BuildPCM = false);
58  virtual ~GradientSimple();
59 
60  /** returns a 2 channel image containing gx and gy
61  @author woelk 12/2004, untested */
62  virtual int Filter(const Image<InputStorageType>& src,
64 
65  virtual int Filter(const Image<InputStorageType>& src,
68 
69  virtual int Filter(const Image<InputStorageType>& src,
73 
76 
77 
78  void PolarTransform(Image<OutputStorageType>& gx,
80  Image<float>& magnitude,
81  Image<float>& phase);
82 
83  /** @brief if true, we use a filter of [1 -1] otherwise [1 0 -1]
84 
85  If true we get a better spatial resolution of gradients, however, the
86  result is shifted by 0.5;0.5 pixels. Take care of noise in your input data.
87  @author koeser
88  @date 03/2006 */
89  void UseDirectNeighbors(bool UseDirectNeighbors) {
90  if (UseDirectNeighbors != useDirectNeighbors_) {
91  useDirectNeighbors_ = UseDirectNeighbors;
92  InitKernel_();
93  }
94  }
95 
96  protected:
97 
98  /// set up pRadius and pAngle for polar coordinate transformation
99  void BuildPolarCoordinateMap_();
100 
101 
102  /// @brief sets the sobel kernel for the convolution object
103  void InitKernel_();
104 
105  /// computation object to execute the convolution
107 
108  /** @brief loop unrolled fast float version for [1 0 -1] */
109  int SimpleGreyValidFloat_(const Image<InputStorageType>& src,
112 
113  /** @brief loop unrolled fast int version [1 0 -1] */
114  int SimpleGreyValidInt_(const Image<InputStorageType>& src,
117 
118  /** @brief loop unrolled fast float version [1 -1]*/
119  int DirectNeighborsGreyValidFloat_(const Image<InputStorageType>& src,
122 
123  /** @brief loop unrolled fast int version [1 -1] */
124  int DirectNeighborsGreyValidInt_(const Image<InputStorageType>& src,
127 
128  virtual void GetBordersValid_(int &border_x, int &border_y) const;
129 
130  /// polar coordinate transformation for char values
131  float **pRadius_, **pAngle_;
132 
133  /// if true, we use a filter of [-1 1] otherwise [-1 0 1]
135 
136  }; // class
137 
138 } // namsepace
139 
140 #endif // __GradientSimple_hh__
void UseDirectNeighbors(bool UseDirectNeighbors)
if true, we use a filter of [1 -1] otherwise [1 0 -1]
float ** pRadius_
polar coordinate transformation for char values
generic convolution class.
Definition: Convolution.hh:66
base class for simple n-&gt;2n filter implementations
Definition: FilterNTo2N.hh:44
simple gradient calculation gx(x,y) = I(x+1,y) - I(x-1,y) gy(x,y) = I(x,y+1) - I(x,y-1)
Convolution< InputStorageType, OutputStorageType > _Conv
computation object to execute the convolution
bool useDirectNeighbors_
if true, we use a filter of [-1 1] otherwise [-1 0 1]
virtual FilterNTo2N< InputStorageType, OutputStorageType > * Clone() const