* mln/detection/corner/achard.hh: New.
* mln/detection/corner/achard_criterion.hh: New.
---
milena/ChangeLog | 7 ++
.../mln/detection/corner/{harris.hh => achard.hh} | 76 +++++---------------
.../{harris_criterion.hh => achard_criterion.hh} | 72 ++++++++++---------
3 files changed, 63 insertions(+), 92 deletions(-)
copy milena/mln/detection/corner/{harris.hh => achard.hh} (58%)
copy milena/mln/detection/corner/{harris_criterion.hh => achard_criterion.hh} (58%)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index b88c960..22afbd2 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,3 +1,10 @@
+2012-10-05 Jonathan Fabrizio <jonathan(a)lrde.epita.fr>
+
+ Add Achard corner detection.
+
+ * mln/detection/corner/achard.hh: New.
+ * mln/detection/corner/achard_criterion.hh: New.
+
2012-10-04 Jonathan Fabrizio <jonathan(a)lrde.epita.fr>
Add test for Harris corner detection.
diff --git a/milena/mln/detection/corner/harris.hh
b/milena/mln/detection/corner/achard.hh
similarity index 58%
copy from milena/mln/detection/corner/harris.hh
copy to milena/mln/detection/corner/achard.hh
index 0acce69..1197ae0 100644
--- a/milena/mln/detection/corner/harris.hh
+++ b/milena/mln/detection/corner/achard.hh
@@ -23,8 +23,8 @@
// exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
-#ifndef MLN_DETECTION_CORNER_HARRIS_HH
-# define MLN_DETECTION_CORNER_HARRIS_HH
+#ifndef MLN_DETECTION_CORNER_ACHARD_HH
+# define MLN_DETECTION_CORNER_ACHARD_HH
#include <mln/core/site_set/p_array.hh>
//#include <mln/win/rectangle2d.hh>
@@ -36,11 +36,11 @@
#include <mln/core/alias/w_window2d_int.hh>
//#include <mln/core/alias/window2d.hh>
-#include <mln/detection/corner/harris_criterion.hh>
+#include <mln/detection/corner/achard_criterion.hh>
/// \file
///
-/// \brief Implementation of Harris corner detection.
+/// \brief Implementation of Achard corner detection.
namespace mln
@@ -50,47 +50,16 @@ namespace mln
namespace corner
{
/**
- Computes Harris corner detection on \p in_image
+ Computes Achard corner detection on \p in_image
\param image_in_ The input image
- \param k the k parameter in Harris algorithm
- \param sigma the standard deviation of the gaussian used in
- Harris algorithm
\return The list of points detected as corner
\author J. Fabrizio
*/
template<typename I>
p_array<mln_site(I)>
- harris(const Image<I>& in_image_, float k, float sigma);
-
- /**
- Computes Harris corner detection on \p in_image with the
- standard deviation of the guassian sets to 0.34
-
- \param image_in_ The input image
- \param k the k parameter in Harris algorithm
- \return The list of points detected as corner
-
- \author J. Fabrizio
- */
- template<typename I>
- p_array<mln_site(I)>
- harris(const Image<I>& in_image_, float k);
-
- /**
- Computes Harris corner detection on \p in_image with the k
- parameter sets to 0.04 and the standard deviation of the
- guassian sets to 0.34.
-
- \param image_in_ The input image
- \return The list of points detected as corner
-
- \author J. Fabrizio
- */
- template<typename I>
- p_array<mln_site(I)>
- harris(const Image<I>& in_image_);
+ achard(const Image<I>& in_image_);
# ifndef MLN_INCLUDE_ONLY
@@ -101,16 +70,16 @@ namespace mln
/**
\iternal Computes local max to find corner in an image
- \param image_in_ The result of harris_criterion
+ \param image_in_ The result of achard_criterion
\return The list of local min
\author J. Fabrizio
*/
template<typename I>
p_array<mln_site(I)>
- harris_local_max(const Image<I>& in_image_)
+ achard_local_max(const Image<I>& in_image_)
{
- trace::exiting("detection::corner::harris_local_max");
+ trace::exiting("detection::corner::achard_local_max");
const I& in_image = exact(in_image_);
p_array<mln_site(I)> result;
mln_piter(I) p(in_image.domain());
@@ -129,7 +98,7 @@ namespace mln
result.append(p);
}
}
- trace::exiting("detection::corner::harris_local_max");
+ trace::exiting("detection::corner::achard_local_max");
return result;
}
@@ -137,24 +106,13 @@ namespace mln
template<typename I>
p_array<mln_site(I)>
- harris(const Image<I>& in_image_, float k, float sigma) {
- trace::entering("detection::corner::harris");
+ achard(const Image<I>& in_image_) {
+ trace::entering("detection::corner::achard");
mln_ch_convolve(I, w_window2d_int) criterion_image;
- criterion_image = harris_criterion(in_image_, k, sigma);
- trace::exiting("detection::corner::harris");
- return internal::harris_local_max(criterion_image);
- }
-
- template<typename I>
- p_array<mln_site(I)>
- harris(const Image<I>& in_image_, float k) {
- return harris(in_image_, k, 0.34);
- }
-
- template<typename I>
- p_array<mln_site(I)>
- harris(const Image<I>& in_image_) {
- return harris(in_image_, 0.04, 0.34);
+ criterion_image = achard_criterion(in_image_);
+ p_array<mln_site(I)> result = internal::achard_local_max(criterion_image);
+ trace::exiting("detection::corner::achard");
+ return result;
}
@@ -167,4 +125,4 @@ namespace mln
} // end of namespace mln
-#endif // ! MLN_DETECTION_CORNER_HARRIS_HH
+#endif // ! MLN_DETECTION_CORNER_ACHARD_HH
diff --git a/milena/mln/detection/corner/harris_criterion.hh
b/milena/mln/detection/corner/achard_criterion.hh
similarity index 58%
copy from milena/mln/detection/corner/harris_criterion.hh
copy to milena/mln/detection/corner/achard_criterion.hh
index 0b125c6..b7274a2 100644
--- a/milena/mln/detection/corner/harris_criterion.hh
+++ b/milena/mln/detection/corner/achard_criterion.hh
@@ -23,8 +23,8 @@
// exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
-#ifndef MLN_DETECTION_CORNER_HARRIS_CRITERION_HH
-# define MLN_DETECTION_CORNER_HARRIS_CRITERION_HH
+#ifndef MLN_DETECTION_CORNER_ACHARD_CRITERION_HH
+# define MLN_DETECTION_CORNER_ACHARD_CRITERION_HH
//#include <mln/io/essential.hh>
@@ -35,7 +35,7 @@
/// \file
///
-/// \brief Implementation of Harris corner detection.
+/// \brief Implementation of Achard, Bigorgne and Devars corner detection.
namespace mln
@@ -45,39 +45,28 @@ namespace mln
namespace corner
{
/**
- Computes Harris corner detection criterion on \p in_image.
+ Computes Achard, Bigorgne and Devars corner detection criterion on \p in_image.
\param image_in_ The input image.
- \param k The k parameter in harris algorithm (use 0.04 if you
- do not know what to do).
- \param sigma The standard deviation of the gaussian used harris algorithm.
- \return Harris criterion computed for evey pixel.
+ \return Achard criterion computed for evey pixel.
\author J. Fabrizio
*/
template<typename I>
mln_ch_convolve(I, w_window2d_int)
- harris_criterion(const Image<I>& in_image_, float k, float sigma);
+ achard_criterion(const Image<I>& in_image_);
# ifndef MLN_INCLUDE_ONLY
-
template<typename I>
mln_ch_convolve(I, w_window2d_int)
- harris_criterion(const Image<I>& in_image_, float k, float sigma)
+ achard_criterion(const Image<I>& in_image_)
{
- trace::entering("detection::corner::haris_criterion");
+ trace::entering("detection::corner::achard_criterion");
const I& in_image = exact(in_image_);
- p_array<mln_site(I)> result;
typedef mln_ch_convolve(I, w_window2d_int) O;
- O dx_image;
- O dy_image;
- O dxx_image;
- O dxy_image;
- O dyy_image;
- O harris_criterion(in_image.domain());
typedef dpoint2d D;
w_window2d_int dx_grad;
@@ -89,27 +78,44 @@ namespace mln
.insert(-1, D(-1, 0))
.insert(+1, D(+1, 0));
- dx_image=linear::convolve(in_image, dx_grad);
- dy_image=linear::convolve(in_image, dy_grad);
+ O dx_image=linear::convolve(in_image, dx_grad);
+ O dy_image=linear::convolve(in_image, dy_grad);
+
+ w_window2d_int mask_M;
+ mask_M
+ .insert(+1, D( 0, -1))
+ .insert(+1, D( 0, +1))
+ .insert(+1, D(+1, -1))
+ .insert(+1, D(+1, +1))
+ .insert(+1, D(-1, -1))
+ .insert(+1, D(-1, +1))
+ .insert(+1, D(-1, 0))
+ .insert(+1, D(+1, 0));
+
+ O dxxj_image=linear::convolve(dx_image*dx_image, mask_M);
+ O dyyj_image=linear::convolve(dy_image*dy_image, mask_M);
+ O dxyj_image=linear::convolve(dx_image*dy_image, mask_M);
- dxx_image=linear::gaussian(dx_image*dx_image, sigma);
- dxy_image=linear::gaussian(dx_image*dy_image, sigma);
- dyy_image=linear::gaussian(dy_image*dy_image, sigma);
+ O achard_criterion(in_image.domain());
typedef mln_value(O) V;
mln_piter(I) p(in_image.domain());
for_all(p) {
- V a = dxx_image(p);
- V b = dyy_image(p);
- V c = dxy_image(p);
- harris_criterion(p)=(a*b-c*c)-k*(a+b)*(a+b);
+ V ix = dx_image(p);
+ V iy = dy_image(p);
+ V ixxj = dxxj_image(p);
+ V iyyj = dyyj_image(p);
+ V ixyj = dxyj_image(p);
+ V grad_magnitude = ix*ix+iy*iy;
+ achard_criterion(p)=ix*ix*iyyj+iy*iy*ixxj-2*ix*iy*ixyj;
+ if (grad_magnitude>1) achard_criterion(p)/=grad_magnitude;
}
- // I output = data::stretch(mln_value(I)(), harris_criterion);
- // io::pgm::save(output, "harris-criterion-result.pgm");
+ // I output = data::stretch(mln_value(I)(), achard_criterion);
+ // io::pgm::save(output, "achard-criterion-result.pgm");
- trace::exiting("detection::corner::harris_criterion");
- return harris_criterion;
+ trace::exiting("detection::corner::achard_criterion");
+ return achard_criterion;
}
# endif // ! MLN_INCLUDE_ONLY
@@ -120,4 +126,4 @@ namespace mln
} // end of namespace mln
-#endif // ! MLN_DETECTION_CORNER_HARRIS_CRITERION_HH
+#endif // ! MLN_DETECTION_CORNER_ACHARD_CRITERION_HH
--
1.7.2.5