Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
GradientSobel3x3.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 __GradientSobel3x3_hh__
27 #define __GradientSobel3x3_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 GradientSobel3x3
38  @ingroup g_filter
39  @brief gradient calculation with sobel 3 by 3 masks
40 
41  calculates the gradient using the sobel operators<br>
42  -1 0 1 -1 -2 -1
43  WE: -2 0 2 NS: 0 0 0
44  -1 0 1 1 2 1
45 
46  They can be separated into:
47 
48  WE: vh = (-1, 0, 1) and vv = (1, 2, 1)^T
49 
50  NS: vh = (1, 2, 1) and vv = (-1, 0, 1)^T
51 
52  @author woelk 09/2004 */
53  template <class InputStorageType, class OutputStorageType>
54  class BIASFilter_EXPORT GradientSobel3x3 : public FilterNTo2N<InputStorageType,
55  OutputStorageType>
56  {
57  public:
60  virtual ~GradientSobel3x3();
61 
62  /** returns a 2 channel image containing gx and gy
63  @author woelk 12/2004, untested */
64  virtual int Filter(const Image<InputStorageType>& src,
66 
67  virtual int Filter(const Image<InputStorageType>& src,
70 
71  virtual int Filter(const Image<InputStorageType>& src,
75 
78 
79  protected:
80  /// @brief sets the sobel kernel for the convolution object
81  void InitKernel_();
82 
83  /// computation object to execute the convolution
85 
86  /// uses CONV_FLOAT for calculation
87  int Sobel3x3GreyValidFloat_(const Image<InputStorageType>& src,
90 
91  /// uses CONV_INT for calculation
92  int Sobel3x3GreyValidInt_(const Image<InputStorageType>& src,
95 
96  /** Repeats the border pixel infinitly in direction perpendicular to
97  the border to achieve destination image ROIs of same size as
98  source image ROIs. Untested !!
99  @author woelk 07/2005 */
100  int Sobel3x3GreySameFloat_(const Image<InputStorageType>& src,
103 
104  CONV_FLOAT **_fwork, **_fwork2;
105  CONV_INT **_iwork, **_iwork2;
106 
109 
110  void _DeleteInternalMem();
111  /** deletes _work1 and _work2 and sets _InternalMemSize */
112  void _AllocInternalMem(const int width, const int height);
113 
114  virtual void GetBordersValid_(int &border_x, int &border_y) const;
115 
116  // shrinks the roi according to filter size
117  void ShrinkROI_(ROI *roi) const;
118 
119  }; // class
120 
121 } // namsepace
122 
123 #endif // __GradientSobel3x3_hh__
class for handling different region of interest (ROI) representations...
Definition: ROI.hh:118
generic convolution class.
Definition: Convolution.hh:66
Convolution< InputStorageType, OutputStorageType > _Conv
computation object to execute the convolution
base class for simple n-&gt;2n filter implementations
Definition: FilterNTo2N.hh:44
gradient calculation with sobel 3 by 3 masks
virtual FilterNTo2N< InputStorageType, OutputStorageType > * Clone() const