URL:
https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena/sandbox
ChangeLog:
2008-10-30 Matthieu Garrigues <garrigues(a)lrde.epita.fr>
Add is_curve_extremum to detect curve extrema.
* garrigues/ocr/simple_point.hh: (is_curve_extremum) Tell if a point
is a curve extremum.
---
simple_point.hh | 32 ++++++++++++++++++++++++--------
1 file changed, 24 insertions(+), 8 deletions(-)
Index: branches/cleanup-2008/milena/sandbox/garrigues/ocr/simple_point.hh
===================================================================
--- branches/cleanup-2008/milena/sandbox/garrigues/ocr/simple_point.hh (revision 2735)
+++ branches/cleanup-2008/milena/sandbox/garrigues/ocr/simple_point.hh (revision 2736)
@@ -30,7 +30,7 @@
/*! \file simple_point.hh
*
- * \brief simple_point tell if a point is simple or not (Cf
+ * \brief is_simple_point tell if a point is simple or not (Cf
* bertrand.07.chap).
*
*/
@@ -57,10 +57,12 @@
*
*/
- bool simple_point(const image2d<bool>& ima, const neighb2d& nbh, const
point2d& p);
+ bool is_simple_point(const image2d<bool>& ima, const neighb2d& nbh, const
point2d& p);
unsigned nb_connexity2d(const image2d<bool>& ima, const neighb2d& nbh,
const point2d& p);
+ bool is_curve_extremum(const image2d<bool>& ima, unsigned nbh, const
point2d& p);
+
# ifndef MLN_INCLUDE_ONLY
static const unsigned char nb_connexity_c8[256] =
@@ -129,15 +131,15 @@
return 0;
}
- unsigned nb_connexity2d(const image2d<bool>& ima, unsigned nbh, const
point2d& p, bool complemented)
+ unsigned nb_connexity2d(const image2d<bool>& ima, unsigned nbh, const
point2d& p, bool object)
{
unsigned res = 0;
- mln_fwd_niter_(neighb2d) n(c8() , p);
+ mln_bkd_niter_(neighb2d) n(c8() , p);
for_all(n)
{
res = (res << 1);
- if (ima(n) == complemented)
+ if (ima(n) == object)
res = res | 1;
}
@@ -150,12 +152,26 @@
}
}
- bool simple_point2d(const image2d<bool>& ima, unsigned nbh, const
point2d& p)
+ bool is_curve_extremum(const image2d<bool>& ima, unsigned nbh, const
point2d& p)
+ {
+ unsigned cpt = 0;
+ mln_bkd_niter_(neighb2d) n(c8() , p);
+
+ for_all(n)
+ {
+ if (ima(n) == true)
+ cpt++;
+ }
+
+ return cpt == 1;
+ }
+
+ bool is_simple_point2d(const image2d<bool>& ima, unsigned nbh, const
point2d& p)
{
mln_assertion(nbh == 4 || nbh == 8);
- return nb_connexity2d(ima, nbh, p, true) == 1 &&
- nb_connexity2d(ima, complement_neighb(nbh), p, false) == 1;
+ return (nb_connexity2d(ima, nbh, p, true) == 1) &&
+ (nb_connexity2d(ima, complement_neighb(nbh), p, false) == 1);
}
# endif // MLN_INCLUDE_ONLY