Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
BlobDetectorDOM.hh
1 /*
2  * BlobDetectorDOM.hh
3  *
4  * Created on: Nov 10, 2009
5  * Author: jordt
6  */
7 
8 #ifndef BLOBDETECTORDOM_HH_
9 #define BLOBDETECTORDOM_HH_
10 
11 // includes
12 #include <bias_config.h>
13 //#include <vector>
14 #include <Base/Math/Vector2.hh>
15 #include <Base/Image/Image.hh>
16 #include <Base/Geometry/HomgPoint2D.hh>
17 #include "BlobDetectorBase.hh"
18 
19 namespace BIAS {
20 
21  /**
22  @class BlobDetectorDOM
23  Blob detector for 'Difference Of Means'-blobs (so this is not a binary blob detector). Blob
24  detection is done by distributing
25  starting points in the DOM-Space (3dimensional, image dimensions + scale). An element of the
26  DOM space is given by the difference between the mean value of a square area at a certain position +
27  size and the mean value of the surrounding square (double sized). Initial seeds in the DOM space
28  are used to converge to local minima => DOM blobs. This implementation uses sum-images (integral images)
29  to speed up the calculation.
30  @author jordt 11/2009
31 
32  */
33  template <class StorageType>
34  class BIASFeatureDetector_EXPORT BlobDetectorDOM :
35  public BlobDetectorBase<StorageType>
36  {
37  public:
38  /**
39  @brief standard constructor
40  */
42 
43  /**
44  @brief standard destructor
45  */
46  virtual ~BlobDetectorDOM();
47 
48  /**
49  @brief Detect and return blobs in an image
50  @param[in] image the image to detect blobs in
51  @param[out] vector to store the blobs in. If the vector is empty, seeds are generated
52  automatically according to the settings. If the vector allready contains blobs,
53  these blobs are optimized.
54  @return 0 on success, -1 on failure
55  */
56  int Detect(BIAS::Image<StorageType> &image, std::vector<BIAS::BIASBlob> &blobs);
57 
58 
59  /**
60  @brief draws the detected blobs in image
61  @param image image the blobs are drawn in here
62  @return 0 on success, -1 on failure
63  */
64  int DrawInImage(BIAS::Image<StorageType> &image, StorageType* color);
65 
66 
67  /**
68  @brief Set threshold for blob detection
69  @param threshold Difference threshold between background and blob content
70  */
71  void SetThreshold(float threshold);
72 
73 
74  /**
75  * Allow just a maximum number of DOM extrema in one cabin.
76  @brief Set the cabin-optimization parameters
77  @param cabinsPerAxis The number of cabins per axis, i.e. the square root of the overall number of cabins
78  @param maxPopulation the maximum number of DOM extrema in one cabin
79  */
80  void SetCabin(int cabinsPerAxis, int maxPopulation);
81 
82 
83  /**
84  @brief Set minimum size of blobs
85  @param minsize Minimum size in pixel
86  */
87  void SetMinSize(unsigned int minSize);
88 
89  /**
90  @brief Set maximum size of blobs
91  @param maxsize Maximum size in pixel
92  */
93  void SetMaxSize(unsigned int maxSize);
94 
95 
96  /** Returns the blobs generated by Detect() as HomgPoin2D vector and quality vector (Like feature points).
97  @brief Get blobs as HomgPoin2D vector
98  @param blobs Location vector, 3rd component is the size
99  @param qual_vec Quality vector, contains the actual difference of means
100  */
101  void GetBlobsAsHomgPoint2D(std::vector<HomgPoint2D> &blobs, std::vector<float> &qual_vec);
102 
103 
104  /** If the automatic seed generation is used (by passing an empty
105  * vector to the Detect() function), the seeds are generated by this parameters.
106  * @brief Set seed parameters for auto seed generation
107  * @param minSeedSize Size of the smallest blob seeds
108  * @param maxSeedSize Size of the largest blob seeds
109  * @param seedStepSize Step size to get from minSeedSize to maxSeedSize
110  */
111  void SetSeedGenerationParams(unsigned int minSeedSize,
112  unsigned int maxSeedSize,
113  unsigned int seedSizeStep);
114 
115  float GetAbsoluteDOM(int x, int y, int halfLevelSize);
116 
117  protected:
118 
119  void refineBlobPosAndSize(Image<StorageType> img);
120 
121  void GenerateAndOptimize(std::vector<HomgPoint2D> &pos_vec, std::vector<float> &qual_vec);
122  HomgPoint2D GetLocalMaximum(int x, int y, int halfLevelSize);
123 
124  float GetDOM(int x, int y, int halfLevelSize);
125 
127  unsigned int minBlobSize_;
128  unsigned int maxBlobSize_;
129  unsigned int minSeedSize_;
130  unsigned int maxSeedSize_;
131  unsigned int seedSizeStep_;
132  unsigned int numberOfBins_;
133  unsigned int maximumBinPopulation_;
134  unsigned int similarityThreshold_;
135  std::vector<HomgPoint2D> generatedBlobs_;
136  std::vector<float> blobQualityVec_;
137 
138 
139 
140  // Integral image routines:
141 
142  void CreateIntegralImage(Image<StorageType> &in);
143 
144  double EvalIntegralImage(int xA, int yA, int xB, int yB);
145 
146  double* intImg_;
147  unsigned int width_;
148  unsigned int height_;
149 
150 
151  }; // class BlobDetectorDOM
152 
153 } // namespace
154 
155 
156 #endif /* BLOBDETECTORDOM_HH_ */
unsigned int similarityThreshold_
class HomgPoint2D describes a point with 2 degrees of freedom in projective coordinates.
Definition: HomgPoint2D.hh:67
std::vector< HomgPoint2D > generatedBlobs_
purly virtual interface defining class for blob detectors
The image template class for specific storage types.
Definition: Image.hh:78
std::vector< float > blobQualityVec_
unsigned int maximumBinPopulation_
Blob detector for &#39;Difference Of Means&#39;-blobs (so this is not a binary blob detector).