Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
TestBlobDetectDOM.cpp
1 /**
2  @file TestBlobDetectDOM
3  @brief Test the difference of means blob detector
4  @ingroup g_tests
5  @author jordt
6  @date 11/2010
7 */
8 
9 #include <FeatureDetector/BlobDetectorDOM.hh>
10 #include <Base/ImageUtils/ImageDraw.hh>
11 
12 using namespace BIAS;
13 using namespace std;
14 
15 
16 /// Paint Circles and detect them
17 int main(int argc, char* argv[]){
18 
19  // Generate a checkerboard image
20  Image<float> testImg;
21  testImg.Init(1024,768,3);
22  testImg.Clear();
23  float white[] = {255.0,255.0,255.0};
24  for (int xpos = 100; xpos < 1000; xpos+= 200)
25  for (int ypos = 100; ypos < 700; ypos+= 200)
26  ImageDraw<float>::RectangleCornersFill(testImg,xpos-15,ypos-15,xpos+15,ypos+15,white);
27 
28  // Detect blobs
29  vector<HomgPoint2D> blobs;
30  vector<float> qualvec;
32  bdd.SetThreshold(50.0);
33  bdd.SetCabin(4,2);
34  vector<BIASBlob> b;
35  bdd.Detect(testImg,b);
36  bdd.GetBlobsAsHomgPoint2D(blobs,qualvec);
37 
38  // Check if result is correct
39  for (int xpos = 100; xpos < 1000; xpos+= 200)
40  for (int ypos = 100; ypos < 700; ypos+= 200){
41  bool foundBlob = false;
42  for (int i = 0; i < (int)blobs.size(); i++)
43  if (fabs(blobs[i][0] - (double)xpos) < 1.0 && fabs(blobs[i][1] - (double)ypos) < 1.0)
44  foundBlob = true;
45  if (foundBlob == false) return 1;
46  }
47  return 0;
48 
49 }
void GetBlobsAsHomgPoint2D(std::vector< HomgPoint2D > &blobs, std::vector< float > &qual_vec)
Returns the blobs generated by Detect() as HomgPoin2D vector and quality vector (Like feature points)...
void SetThreshold(float threshold)
Set threshold for blob detection.
void Clear(const StorageType value=0)
sets all pixels to zero/value
Definition: Image.hh:289
void SetCabin(int cabinsPerAxis, int maxPopulation)
Allow just a maximum number of DOM extrema in one cabin.
void Init(unsigned int Width, unsigned int Height, unsigned int channels=1, enum EStorageType storageType=ST_unsignedchar, const bool interleaved=true)
calls Init from ImageBase storageType is ignored, just dummy argument
Definition: Image.cpp:421
int Detect(BIAS::Image< StorageType > &image, std::vector< BIAS::BIASBlob > &blobs)
Detect and return blobs in an image.
Blob detector for &#39;Difference Of Means&#39;-blobs (so this is not a binary blob detector).
drawing simple entities into the image like rectangles or lines As all functions are static they have...
Definition: ImageDraw.hh:72