KJB
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
blob_spot_detector.h
Go to the documentation of this file.
1 
7 /*
8  * $Id: blob_spot_detector.h 17797 2014-10-21 04:41:57Z predoehl $
9  */
10 
11 #ifndef BLOB_SPOT_DETECTOR_H_INCLUDED
12 #define BLOB_SPOT_DETECTOR_H_INCLUDED
13 
14 #include <m_cpp/m_matrix.h>
15 #include <m_cpp/m_vector.h>
16 #include <i_cpp/i_image.h>
17 #include <vector>
18 
19 namespace kjb
20 {
21 
36 {
37 public:
38  typedef std::vector<Vector> Centroid_set;
39  typedef std::vector<std::pair<int, int> > Pair_vector;
40 
41 private:
42  Matrix m_background, m_thresholds;
43  int m_min_brightness, m_min_size, m_max_size;
44  double m_similarity;
45  mutable Centroid_set spot_centroids;
46  mutable std::vector<Pair_vector> spot_coordinates;
47 
48  void swap(Spot_detector& sd)
49  {
50  using std::swap;
51 
52  m_background.swap(sd.m_background);
53  m_thresholds.swap(sd.m_thresholds);
54  swap(m_min_brightness, sd.m_min_brightness);
55  swap(m_min_size, sd.m_min_size);
56  swap(m_max_size, sd.m_max_size);
57  swap(m_similarity, sd.m_similarity);
58  spot_centroids.swap(sd.spot_centroids);
59  spot_coordinates.swap(sd.spot_coordinates);
60  }
61 
62 public:
94  (
95  const Matrix& background,
96  const Matrix& thresholds,
97  int min_brightness,
98  int min_size,
99  int max_size,
100  double similarity
101  ) :
102  m_background(background),
103  m_thresholds(thresholds),
104  m_min_brightness(min_brightness),
105  m_min_size(min_size),
106  m_max_size(max_size),
107  m_similarity(similarity)
108  {}
109 
129  (
130  int num_rows,
131  int num_cols,
132  double background,
133  double threshold,
134  int min_brightness,
135  int min_size,
136  int max_size,
137  double similarity
138  )
139  {
140  Spot_detector sd(
141  Matrix(num_rows, num_cols, background),
142  Matrix(num_rows, num_cols, threshold),
143  min_brightness,
144  min_size,
145  max_size,
146  similarity
147  );
148  swap(sd);
149  }
150 
158  const Centroid_set& operator()(const Image&) const;
159 
166  const std::vector<Pair_vector>& get_spot_coordinates() const
167  {
168  return spot_coordinates;
169  }
170 
178  {
179  return spot_centroids;
180  }
181 };
182 
183 } //namespace kjb
184 
185 #endif /* BLOB_SPOT_DETECTOR_H_INCLUDED */
186 
Definition for the Matrix class, a thin wrapper on the KJB Matrix struct and its related functionalit...
const std::vector< Pair_vector > & get_spot_coordinates() const
Retrieves the spots computed in the last call to operator().
Definition: blob_spot_detector.h:166
const Centroid_set & get_spot_centroids() const
Retrieves the spot centroids computed in last operator() call.
Definition: blob_spot_detector.h:177
A spot detector functor, comparable to a blob detector.
Definition: blob_spot_detector.h:35
void swap(kjb::Gsl_Multimin_fdf &m1, kjb::Gsl_Multimin_fdf &m2)
Swap two wrapped multimin objects.
Definition: gsl_multimin.h:693
const Centroid_set & operator()(const Image &) const
Applies this spot detector to the given image.
Definition: blob_spot_detector.cpp:40
Spot_detector(const Matrix &background, const Matrix &thresholds, int min_brightness, int min_size, int max_size, double similarity)
Construct a spot detector with the given parameters.
Definition: blob_spot_detector.h:94
std::vector< std::pair< int, int > > Pair_vector
Definition: blob_spot_detector.h:39
This class implements matrices, in the linear-algebra sense, with real-valued elements.
Definition: m_matrix.h:94
Code for a wrapper class around the C struct KJB_Image.
Wrapped version of the C struct KJB_image.
Definition: i_image.h:76
void swap(Matrix &other)
Swap the representations of two matrices.
Definition: m_matrix.h:532
Definition for the Vector class, a thin wrapper on the KJB Vector struct and its related functionalit...
std::vector< Vector > Centroid_set
Definition: blob_spot_detector.h:38