Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
ConstantRegionDetector.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 #ifndef __ConstantRegionDetector_hh__
26 #define __ConstantRegionDetector_hh__
27 
28 #include <Base/Image/Image.hh>
29 #include <Base/Geometry/HomgPoint2D.hh>
30 
31 namespace BIAS {
32 
33 /**
34  @class ColFeat
35  @brief internal class for feature (with color) passing only
36  @author koeser 09/2004
37  */
38 template<class StorageType>
39  class BIASFeatureDetector_EXPORT ColFeat {
40  public:
41  int x, y;
42  double val;
44 
45  bool operator<(const ColFeat<StorageType>& r) const
46  { return val>r.val; }
47 
49  { x=f.x; y=f.y; val=f.val; col = f.col; return *this; }
50 
51 // std::ostream& operator<<(std::ostream & os, const ColFeat<StorageType>& f)
52 // { os << "("<<f.x<<", "<<f.y<<") = "<<f.val << " color: " << f.col; return os; }
53 
54  }; // end of class Feat
55 
56 
57 
58 
59 /**
60  @class ConstantRegionDetector
61  @brief detects regions with close to zero gradients in images, works on color images only
62  @author sedlazeck 12/2008
63  */
64 
65 template<class StorageType, class CalculationType>
66 class BIASFeatureDetector_EXPORT ConstantRegionDetector : public Debug {
67 
68 public:
70  virtual ~ConstantRegionDetector();
71 
72  void SetThreshold(CalculationType threshold){
73  threshold_ = threshold;
74  };
75  CalculationType GetThreshold(){
76  return threshold_;
77  };
78 
79  void SetHalfWinSize(int halfWinSize){
80  halfWinSize_ = halfWinSize;
81  };
83  return halfWinSize_;
84  };
85 
87  maskImg_ = maskImg;
88  };
89 
90  void SetMinDistance(int minDistance){
91  minDistance_ = minDistance;
92  };
93 
94  /**
95  * restrict maximum number of features -1 is default and all features are returned.
96  */
97  void SetMaxNumFeatures(int maxNumFeatures){
98  maxNumFeatures_ = maxNumFeatures;
99  };
100 
102  return maxNumFeatures_;
103  };
104 
105  /** @brief Detects constant regions in image src
106 
107  Constant regions around pixels in images are detected by a histogram-based method, that is applied to windows around
108  the pixel in question. The differences in color are compared.
109  threshold is the allowed average deviation from the color of the middle pixel.
110  halfWinSize the size of the window used for detection.
111  if useMedian is set to true, the input image will be filtered by a median filter first.
112  The result is written into a vector with homogenuous 2D points and a segmentation image.
113  @author sedlazeck 01/2009
114  @todo optimize for ROI usage */
115  virtual int Detect(Image<StorageType>& src,
116  std::vector<HomgPoint2D>& points2d, std::vector<Vector3<
117  StorageType> >& colors, bool useMedian = false);
118 
119 
120 protected:
121  CalculationType threshold_;
123  std::vector<ColFeat<StorageType> > featureList_;
124  /// restrict maximum number of features -1 is default and all features are returned.
126  /// required min distance between two constance regions
128 
129  /// mask image usefull for water regions in images which usually have very constant regions compared to the rest of the image (set to one if water/ to to be used)
131 
132 }; // class
133 
134 } // namespace
135 
136 
137 #endif // __ConstantRegionDetector_hh__
int minDistance_
required min distance between two constance regions
void SetMaskImage(BIAS::Image< unsigned char > &maskImg)
BIAS::Image< unsigned char > maskImg_
mask image usefull for water regions in images which usually have very constant regions compared to t...
void SetThreshold(CalculationType threshold)
void SetMinDistance(int minDistance)
void SetMaxNumFeatures(int maxNumFeatures)
restrict maximum number of features -1 is default and all features are returned.
int maxNumFeatures_
restrict maximum number of features -1 is default and all features are returned.
void SetHalfWinSize(int halfWinSize)
detects regions with close to zero gradients in images, works on color images only ...
internal class for feature (with color) passing only
ColFeat< StorageType > & operator=(const ColFeat< StorageType > &f)
BIAS::Vector3< StorageType > col
std::vector< ColFeat< StorageType > > featureList_