* scribo/primitive/extract/horizontal_separators.hh,
* scribo/primitive/extract/separators.hh,
* scribo/primitive/extract/vertical_separators.hh,
* scribo/primitive/remove/separators.hh: New.
---
scribo/ChangeLog | 9 ++
.../primitive/extract/horizontal_separators.hh | 69 ++++++++--------
.../extract/{lines_v_pattern.hh => separators.hh} | 78 ++++++++----------
.../primitive/extract/vertical_separators.hh | 69 ++++++++--------
.../lines_v_pattern.hh => remove/separators.hh} | 86 +++++++++----------
5 files changed, 155 insertions(+), 156 deletions(-)
copy milena/mln/world/inter_pixel/full2image.hh =>
scribo/primitive/extract/horizontal_separators.hh (53%)
copy scribo/primitive/extract/{lines_v_pattern.hh => separators.hh} (53%)
copy milena/mln/world/inter_pixel/full2image.hh =>
scribo/primitive/extract/vertical_separators.hh (53%)
copy scribo/primitive/{extract/lines_v_pattern.hh => remove/separators.hh} (50%)
diff --git a/scribo/ChangeLog b/scribo/ChangeLog
index b4d325e..4aa545d 100644
--- a/scribo/ChangeLog
+++ b/scribo/ChangeLog
@@ -1,5 +1,14 @@
2010-04-30 Guillaume Lazzara <z(a)lrde.epita.fr>
+ Add new routines to detect separators.
+
+ * scribo/primitive/extract/horizontal_separators.hh,
+ * scribo/primitive/extract/separators.hh,
+ * scribo/primitive/extract/vertical_separators.hh,
+ * scribo/primitive/remove/separators.hh: New.
+
+2010-04-30 Guillaume Lazzara <z(a)lrde.epita.fr>
+
Add A first draft of a README in Scribo.
* README: New.
diff --git a/milena/mln/world/inter_pixel/full2image.hh
b/scribo/primitive/extract/horizontal_separators.hh
similarity index 53%
copy from milena/mln/world/inter_pixel/full2image.hh
copy to scribo/primitive/extract/horizontal_separators.hh
index db3bcf3..9a6ea39 100644
--- a/milena/mln/world/inter_pixel/full2image.hh
+++ b/scribo/primitive/extract/horizontal_separators.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2010 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -23,37 +23,44 @@
// exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
-#ifndef MLN_WORLD_INTER_PIXEL_FULL2IMAGE_HH
-# define MLN_WORLD_INTER_PIXEL_FULL2IMAGE_HH
+#ifndef SCRIBO_PRIMITIVE_EXTRACT_VERTICAL_SEPARATORS_HH
+# define SCRIBO_PRIMITIVE_EXTRACT_VERTICAL_SEPARATORS_HH
/// \file
///
-/// Convert an inter-pixel image to a classical image.
+/// Extract vertical separators.
# include <mln/core/concept/image.hh>
-# include <mln/data/paste_without_localization.hh>
-# include <mln/geom/nsites.hh>
-# include <mln/world/inter_pixel/is_pixel.hh>
+# include <mln/arith/plus.hh>
+# include <scribo/primitive/extract/lines_v_pattern.hh>
-namespace mln
+
+namespace scribo
{
- namespace world
+ namespace primitive
{
- namespace inter_pixel
+ namespace extract
{
- /// Convert an inter-pixel image to a classical image.
- ///
- /// \param[in] input An inter-pixel image.
- ///
- /// \return A classical image without inter-pixel data.
- //
+ using namespace mln;
+
+ /// \brief Extract vertical separators.
+ /*!
+ *
+ * \param[in] input A binary image.
+ * \param[in] line_length The minimum line length.
+ *
+ * \return A binary image were separators are set to 'True'.
+ *
+ * \sa primitive::remove::separators
+ */
template <typename I>
mln_concrete(I)
- full2image(const Image<I>& input);
+ vertical_separators(const Image<I>& input, unsigned line_length);
+
# ifndef MLN_INCLUDE_ONLY
@@ -61,34 +68,28 @@ namespace mln
template <typename I>
mln_concrete(I)
- full2image(const Image<I>& input_)
+ vertical_separators(const Image<I>& input_, unsigned line_length)
{
- trace::entering("world::inter_pixel::full2image");
-
- mlc_is_a(mln_domain(I), Box)::check();
+ trace::entering("scribo::primitive::extract::vertical_separators");
const I& input = exact(input_);
+ mlc_is(mln_value(I), bool)::check();
mln_precondition(input.is_valid());
- mln_domain(I) b(input.domain().pmin() / 2,
- input.domain().pmax() / 2);
- mln_concrete(I) output(b);
- mln_assertion(geom::nsites(output) == geom::nsites(input | is_pixel()));
+ mln_concrete(I)
+ vlines = extract::lines_v_pattern(input, line_length, 3);
- data::paste_without_localization(input | is_pixel(), output);
-
- trace::exiting("world::inter_pixel::full2image");
- return output;
+ trace::exiting("scribo::primitive::extract::vertical_separators");
+ return vlines;
}
# endif // ! MLN_INCLUDE_ONLY
+ } // end of namespace scribo::primitive::extract
- } // end of namespace mln::world::inter_pixel
-
- } // end of namespace mln::world
+ } // end of namespace scribo::primitive
-} // end of namespace mln
+} // end of namespace scribo
-#endif // ! MLN_WORLD_INTER_PIXEL_FULL2IMAGE_HH
+#endif // ! SCRIBO_PRIMITIVE_EXTRACT_VERTICAL_SEPARATORS_HH
diff --git a/scribo/primitive/extract/lines_v_pattern.hh
b/scribo/primitive/extract/separators.hh
similarity index 53%
copy from scribo/primitive/extract/lines_v_pattern.hh
copy to scribo/primitive/extract/separators.hh
index ccd21c5..2ba22b4 100644
--- a/scribo/primitive/extract/lines_v_pattern.hh
+++ b/scribo/primitive/extract/separators.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2010 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -23,21 +23,19 @@
// exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
-#ifndef SCRIBO_PRIMITIVE_EXTRACT_LINES_V_PATTERN_HH
-# define SCRIBO_PRIMITIVE_EXTRACT_LINES_V_PATTERN_HH
+#ifndef SCRIBO_PRIMITIVE_EXTRACT_SEPARATORS_HH
+# define SCRIBO_PRIMITIVE_EXTRACT_SEPARATORS_HH
/// \file
///
-/// Extract vertical lines matching a specific pattern.
+/// Extract vertical and horizontal separators.
-#include <mln/core/concept/image.hh>
-#include <mln/core/alias/window2d.hh>
+# include <mln/core/concept/image.hh>
+# include <mln/arith/plus.hh>
-# include <mln/win/hline2d.hh>
+# include <scribo/primitive/extract/lines_h_pattern.hh>
+# include <scribo/primitive/extract/lines_v_pattern.hh>
-# include <mln/morpho/dilation.hh>
-
-# include <scribo/primitive/extract/lines_pattern.hh>
namespace scribo
{
@@ -50,17 +48,20 @@ namespace scribo
using namespace mln;
-
- /// Extract vertical lines matching a specific pattern.
- ///
- /// \param[in] input A binary image.
- /// \param[in] length The minimum line length.
- ///
- /// \result An image of vertical lines.
- //
+ /// \brief Extract vertical and horizontal separators.
+ /*!
+ *
+ * \param[in] input A binary image.
+ * \param[in] line_length The minimum line length.
+ *
+ * \return A binary image were separators are set to 'True'.
+ *
+ * \sa primitive::remove::separators
+ */
template <typename I>
mln_concrete(I)
- lines_v_pattern(const Image<I>& input, unsigned length, unsigned delta);
+ separators(const Image<I>& input, unsigned line_length);
+
# ifndef MLN_INCLUDE_ONLY
@@ -68,28 +69,21 @@ namespace scribo
template <typename I>
mln_concrete(I)
- lines_v_pattern(const Image<I>& input, unsigned length, unsigned delta)
+ separators(const Image<I>& input_, unsigned line_length)
{
- mln_precondition(length % 2 == 1);
-
-// bool win_def[1][7] = { { 1, 0, 0, 0, 0, 0, 1 } };
-
-// window2d win;
-// convert::from_to(win_def, win);
-
- // FIXME: not generic.
- window2d win;
- mln_deduce(I, site, dpsite)
- dp1(0, -delta),
- dp2(0, delta);
- win.insert(dp1);
- win.insert(dp2);
-
- //FIXME: Add reconstruction instead of this arbitrary dilation.
- win::vline2d vwin(length/2 + 2);
-// win::vline2d vwin(length);
- return morpho::dilation(lines_pattern(input, length, 0, win), vwin);
-// return lines_pattern(input, length, 0, win);
+ trace::entering("scribo::primitive::extract::separators");
+
+ const I& input = exact(input_);
+ mlc_is(mln_value(I), bool)::check();
+ mln_precondition(input.is_valid());
+
+ mln_concrete(I)
+ hlines = extract::lines_h_pattern(input, line_length, 3),
+ vlines = extract::lines_v_pattern(input, line_length, 3);
+ hlines += vlines;
+
+ trace::exiting("scribo::primitive::extract::separators");
+ return hlines;
}
@@ -101,6 +95,4 @@ namespace scribo
} // end of namespace scribo
-
-#endif // ! SCRIBO_PRIMITIVE_EXTRACT_LINES_V_PATTERN_HH
-
+#endif // ! SCRIBO_PRIMITIVE_EXTRACT_SEPARATORS_HH
diff --git a/milena/mln/world/inter_pixel/full2image.hh
b/scribo/primitive/extract/vertical_separators.hh
similarity index 53%
copy from milena/mln/world/inter_pixel/full2image.hh
copy to scribo/primitive/extract/vertical_separators.hh
index db3bcf3..9a6ea39 100644
--- a/milena/mln/world/inter_pixel/full2image.hh
+++ b/scribo/primitive/extract/vertical_separators.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2010 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -23,37 +23,44 @@
// exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
-#ifndef MLN_WORLD_INTER_PIXEL_FULL2IMAGE_HH
-# define MLN_WORLD_INTER_PIXEL_FULL2IMAGE_HH
+#ifndef SCRIBO_PRIMITIVE_EXTRACT_VERTICAL_SEPARATORS_HH
+# define SCRIBO_PRIMITIVE_EXTRACT_VERTICAL_SEPARATORS_HH
/// \file
///
-/// Convert an inter-pixel image to a classical image.
+/// Extract vertical separators.
# include <mln/core/concept/image.hh>
-# include <mln/data/paste_without_localization.hh>
-# include <mln/geom/nsites.hh>
-# include <mln/world/inter_pixel/is_pixel.hh>
+# include <mln/arith/plus.hh>
+# include <scribo/primitive/extract/lines_v_pattern.hh>
-namespace mln
+
+namespace scribo
{
- namespace world
+ namespace primitive
{
- namespace inter_pixel
+ namespace extract
{
- /// Convert an inter-pixel image to a classical image.
- ///
- /// \param[in] input An inter-pixel image.
- ///
- /// \return A classical image without inter-pixel data.
- //
+ using namespace mln;
+
+ /// \brief Extract vertical separators.
+ /*!
+ *
+ * \param[in] input A binary image.
+ * \param[in] line_length The minimum line length.
+ *
+ * \return A binary image were separators are set to 'True'.
+ *
+ * \sa primitive::remove::separators
+ */
template <typename I>
mln_concrete(I)
- full2image(const Image<I>& input);
+ vertical_separators(const Image<I>& input, unsigned line_length);
+
# ifndef MLN_INCLUDE_ONLY
@@ -61,34 +68,28 @@ namespace mln
template <typename I>
mln_concrete(I)
- full2image(const Image<I>& input_)
+ vertical_separators(const Image<I>& input_, unsigned line_length)
{
- trace::entering("world::inter_pixel::full2image");
-
- mlc_is_a(mln_domain(I), Box)::check();
+ trace::entering("scribo::primitive::extract::vertical_separators");
const I& input = exact(input_);
+ mlc_is(mln_value(I), bool)::check();
mln_precondition(input.is_valid());
- mln_domain(I) b(input.domain().pmin() / 2,
- input.domain().pmax() / 2);
- mln_concrete(I) output(b);
- mln_assertion(geom::nsites(output) == geom::nsites(input | is_pixel()));
+ mln_concrete(I)
+ vlines = extract::lines_v_pattern(input, line_length, 3);
- data::paste_without_localization(input | is_pixel(), output);
-
- trace::exiting("world::inter_pixel::full2image");
- return output;
+ trace::exiting("scribo::primitive::extract::vertical_separators");
+ return vlines;
}
# endif // ! MLN_INCLUDE_ONLY
+ } // end of namespace scribo::primitive::extract
- } // end of namespace mln::world::inter_pixel
-
- } // end of namespace mln::world
+ } // end of namespace scribo::primitive
-} // end of namespace mln
+} // end of namespace scribo
-#endif // ! MLN_WORLD_INTER_PIXEL_FULL2IMAGE_HH
+#endif // ! SCRIBO_PRIMITIVE_EXTRACT_VERTICAL_SEPARATORS_HH
diff --git a/scribo/primitive/extract/lines_v_pattern.hh
b/scribo/primitive/remove/separators.hh
similarity index 50%
copy from scribo/primitive/extract/lines_v_pattern.hh
copy to scribo/primitive/remove/separators.hh
index ccd21c5..9b45919 100644
--- a/scribo/primitive/extract/lines_v_pattern.hh
+++ b/scribo/primitive/remove/separators.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2010 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -23,21 +23,22 @@
// exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
-#ifndef SCRIBO_PRIMITIVE_EXTRACT_LINES_V_PATTERN_HH
-# define SCRIBO_PRIMITIVE_EXTRACT_LINES_V_PATTERN_HH
+#ifndef SCRIBO_PRIMITIVE_REMOVE_SEPARATORS_HH
+# define SCRIBO_PRIMITIVE_REMOVE_SEPARATORS_HH
/// \file
///
-/// Extract vertical lines matching a specific pattern.
+/// Remove separators in a binary image.
-#include <mln/core/concept/image.hh>
-#include <mln/core/alias/window2d.hh>
+# include <mln/core/concept/image.hh>
-# include <mln/win/hline2d.hh>
+# include <mln/core/routine/duplicate.hh>
-# include <mln/morpho/dilation.hh>
+# include <mln/core/image/dmorph/image_if.hh>
+# include <mln/pw/all.hh>
+
+# include <mln/data/fill.hh>
-# include <scribo/primitive/extract/lines_pattern.hh>
namespace scribo
{
@@ -45,22 +46,26 @@ namespace scribo
namespace primitive
{
- namespace extract
+ namespace remove
{
using namespace mln;
-
- /// Extract vertical lines matching a specific pattern.
- ///
- /// \param[in] input A binary image.
- /// \param[in] length The minimum line length.
- ///
- /// \result An image of vertical lines.
- //
+ /// \brief Remove separators in a binary image.
+ /*!
+ *
+ * \param[in] input A binary image. 'True' for objects, 'False'
+ * for the background.
+ * \param[in] separators A binary image of separators.
+ *
+ * \return \p input without separators.
+ *
+ * \sa primitive::extract::separators
+ */
template <typename I>
mln_concrete(I)
- lines_v_pattern(const Image<I>& input, unsigned length, unsigned delta);
+ separators(const Image<I>& input, const Image<I>& separators);
+
# ifndef MLN_INCLUDE_ONLY
@@ -68,39 +73,30 @@ namespace scribo
template <typename I>
mln_concrete(I)
- lines_v_pattern(const Image<I>& input, unsigned length, unsigned delta)
+ separators(const Image<I>& input_, const Image<I>&
separators_)
{
- mln_precondition(length % 2 == 1);
-
-// bool win_def[1][7] = { { 1, 0, 0, 0, 0, 0, 1 } };
-
-// window2d win;
-// convert::from_to(win_def, win);
-
- // FIXME: not generic.
- window2d win;
- mln_deduce(I, site, dpsite)
- dp1(0, -delta),
- dp2(0, delta);
- win.insert(dp1);
- win.insert(dp2);
-
- //FIXME: Add reconstruction instead of this arbitrary dilation.
- win::vline2d vwin(length/2 + 2);
-// win::vline2d vwin(length);
- return morpho::dilation(lines_pattern(input, length, 0, win), vwin);
-// return lines_pattern(input, length, 0, win);
- }
+ trace::entering("scribo::primitive::remove::separators");
+
+ const I& input = exact(input_);
+ const I& separators = exact(separators_);
+ mlc_is(mln_value(I), bool)::check();
+ mln_precondition(input.is_valid());
+ mln_precondition(separators.is_valid());
+ mln_concrete(I) output = duplicate(input);
+ data::fill((output | (pw::value(separators) == pw::cst(true))).rw(),
+ false);
+
+ trace::exiting("scribo::primitive::remove::separators");
+ return output;
+ }
# endif // ! MLN_INCLUDE_ONLY
- } // end of namespace scribo::primitive::extract
+ } // end of namespace scribo::primitive::remove
} // end of namespace scribo::primitive
} // end of namespace scribo
-
-#endif // ! SCRIBO_PRIMITIVE_EXTRACT_LINES_V_PATTERN_HH
-
+#endif // ! SCRIBO_PRIMITIVE_REMOVE_SEPARATORS_HH
--
1.5.6.5