* scribo/core/component_info.hh,
* scribo/core/component_set.hh,
* scribo/core/document.hh,
* scribo/core/tag/component.hh,
* scribo/primitive/extract/components.hh,
* scribo/primitive/identify.hh: Explicitly set component type to
Separator when extracting separator components.
---
scribo/ChangeLog | 12 ++++++
scribo/scribo/core/component_info.hh | 8 ++-
scribo/scribo/core/component_set.hh | 50 ++++++++++++++++---------
scribo/scribo/core/document.hh | 6 ++-
scribo/scribo/core/tag/component.hh | 20 ++++++---
scribo/scribo/primitive/extract/components.hh | 18 ++++++---
scribo/scribo/primitive/identify.hh | 2 +-
7 files changed, 79 insertions(+), 37 deletions(-)
diff --git a/scribo/ChangeLog b/scribo/ChangeLog
index 3d23191..63e3fee 100644
--- a/scribo/ChangeLog
+++ b/scribo/ChangeLog
@@ -1,3 +1,15 @@
+2011-03-01 Guillaume Lazzara <z(a)lrde.epita.fr>
+
+ Set component type during component extraction.
+
+ * scribo/core/component_info.hh,
+ * scribo/core/component_set.hh,
+ * scribo/core/document.hh,
+ * scribo/core/tag/component.hh,
+ * scribo/primitive/extract/components.hh,
+ * scribo/primitive/identify.hh: Explicitly set component type to
+ Separator when extracting separator components.
+
2011-02-17 Guillaume Lazzara <z(a)lrde.epita.fr>
Add new tools in Scribo.
diff --git a/scribo/scribo/core/component_info.hh b/scribo/scribo/core/component_info.hh
index 1b03318..6fc73f8 100644
--- a/scribo/scribo/core/component_info.hh
+++ b/scribo/scribo/core/component_info.hh
@@ -53,7 +53,8 @@ namespace scribo
component_info(const component_id_t& id,
const mln::box2d& bbox,
const mln::point2d& mass_center,
- unsigned card);
+ unsigned card,
+ component::Type type = component::Undefined);
component_id_t id() const;
const mln::box2d& bbox() const;
@@ -101,9 +102,10 @@ namespace scribo
component_info::component_info(const component_id_t& id,
const mln::box2d& bbox,
const mln::point2d& mass_center,
- unsigned card)
+ unsigned card,
+ component::Type type)
: id_(id), bbox_(bbox), mass_center_(mass_center), card_(card),
- tag_(component::None), type_(component::Undefined)
+ tag_(component::None), type_(type)
{
}
diff --git a/scribo/scribo/core/component_set.hh b/scribo/scribo/core/component_set.hh
index 7ddcf16..442e8d6 100644
--- a/scribo/scribo/core/component_set.hh
+++ b/scribo/scribo/core/component_set.hh
@@ -86,16 +86,20 @@ namespace scribo
component_set_data();
component_set_data(const L& ima, const mln_value(L)& ncomps);
component_set_data(const L& ima, const mln_value(L)& ncomps,
- const mln::util::array<pair_accu_t>& attribs);
+ const mln::util::array<pair_accu_t>& attribs,
+ component::Type type = component::Undefined);
component_set_data(const L& ima, const mln_value(L)& ncomps,
- const mln::util::array<pair_data_t>& attribs);
+ const mln::util::array<pair_data_t>& attribs,
+ component::Type type = component::Undefined);
component_set_data(const L& ima, const mln_value(L)& ncomps,
const mln::util::array<scribo::component_info>& infos);
- void fill_infos(const mln::util::array<pair_accu_t>& attribs);
+ void fill_infos(const mln::util::array<pair_accu_t>& attribs,
+ component::Type type = component::Undefined);
- void fill_infos(const mln::util::array<pair_data_t>& attribs);
+ void fill_infos(const mln::util::array<pair_data_t>& attribs,
+ component::Type type = component::Undefined);
// Useful while constructing incrementaly (XML loading).
void soft_init(const mln_value(L) ncomps);
@@ -141,10 +145,12 @@ namespace scribo
/// Constructor from an image \p ima, the number of labels \p ncomps and
/// attributes values (bounding box and mass center).
component_set(const L& ima, const mln_value(L)& ncomps,
- const mln::util::array<pair_accu_t>& attribs);
+ const mln::util::array<pair_accu_t>& attribs,
+ component::Type type = component::Undefined);
component_set(const L& ima, const mln_value(L)& ncomps,
- const mln::util::array<pair_data_t>& attribs);
+ const mln::util::array<pair_data_t>& attribs,
+ component::Type type = component::Undefined);
/// @}
/// Return the component count.
@@ -284,26 +290,28 @@ namespace scribo
inline
component_set_data<L>::component_set_data(const L& ima,
const mln_value(L)& ncomps,
- const mln::util::array<pair_accu_t>& attribs)
+ const mln::util::array<pair_accu_t>& attribs,
+ component::Type type)
: ima_(ima), ncomps_(ncomps)
{
initialize(separators_, ima); // FIXME: do we really want that?
mln::data::fill(separators_, false);
- fill_infos(attribs);
+ fill_infos(attribs, type);
}
template <typename L>
inline
component_set_data<L>::component_set_data(const L& ima,
const mln_value(L)& ncomps,
- const mln::util::array<pair_data_t>& attribs)
+ const mln::util::array<pair_data_t>& attribs,
+ component::Type type)
: ima_(ima), ncomps_(ncomps)
{
initialize(separators_, ima); // FIXME: do we really want that?
mln::data::fill(separators_, false);
- fill_infos(attribs);
+ fill_infos(attribs, type);
}
template <typename L>
@@ -321,7 +329,8 @@ namespace scribo
template <typename L>
inline
void
- component_set_data<L>::fill_infos(const
mln::util::array<pair_accu_t>& attribs)
+ component_set_data<L>::fill_infos(const
mln::util::array<pair_accu_t>& attribs,
+ component::Type type)
{
typedef mln_site(L) P;
@@ -331,7 +340,8 @@ namespace scribo
for_all_comp_data(i, attribs)
{
component_info info(i, attribs[i].first(),
- attribs[i].second(), attribs[i].second_accu().nsites());
+ attribs[i].second(), attribs[i].second_accu().nsites(),
+ type);
infos_.append(info);
}
}
@@ -339,7 +349,8 @@ namespace scribo
template <typename L>
inline
void
- component_set_data<L>::fill_infos(const
mln::util::array<pair_data_t>& attribs)
+ component_set_data<L>::fill_infos(const
mln::util::array<pair_data_t>& attribs,
+ component::Type type)
{
typedef mln_site(L) P;
@@ -349,7 +360,8 @@ namespace scribo
for_all_comp_data(i, attribs)
{
component_info info(i, attribs[i].first,
- attribs[i].second.first, attribs[i].second.second);
+ attribs[i].second.first, attribs[i].second.second,
+ type);
infos_.append(info);
}
}
@@ -397,9 +409,10 @@ namespace scribo
template <typename L>
inline
component_set<L>::component_set(const L& ima, const mln_value(L)&
ncomps,
- const mln::util::array<pair_accu_t>& attribs)
+ const mln::util::array<pair_accu_t>& attribs,
+ component::Type type)
{
- data_ = new internal::component_set_data<L>(ima, ncomps, attribs);
+ data_ = new internal::component_set_data<L>(ima, ncomps, attribs, type);
}
@@ -407,9 +420,10 @@ namespace scribo
inline
component_set<L>::component_set(const L& ima, const mln_value(L)&
ncomps,
- const mln::util::array<pair_data_t>& attribs)
+ const mln::util::array<pair_data_t>& attribs,
+ component::Type type)
{
- data_ = new internal::component_set_data<L>(ima, ncomps, attribs);
+ data_ = new internal::component_set_data<L>(ima, ncomps, attribs, type);
}
diff --git a/scribo/scribo/core/document.hh b/scribo/scribo/core/document.hh
index e5ac825..ef0869e 100644
--- a/scribo/scribo/core/document.hh
+++ b/scribo/scribo/core/document.hh
@@ -297,7 +297,8 @@ namespace scribo
mln_value(L) ncomps;
whitespace_seps_comps_ = primitive::extract::components(whitespace_seps,
- mln::c8(), ncomps);
+ mln::c8(), ncomps,
+ component::WhitespaceSeparator);
}
@@ -333,7 +334,8 @@ namespace scribo
mln_value(L) ncomps;
line_seps_comps_ = primitive::extract::components(line_seps,
- mln::c8(), ncomps);
+ mln::c8(), ncomps,
+ component::LineSeparator);
}
diff --git a/scribo/scribo/core/tag/component.hh b/scribo/scribo/core/tag/component.hh
index 10b86a6..7cd2ede 100644
--- a/scribo/scribo/core/tag/component.hh
+++ b/scribo/scribo/core/tag/component.hh
@@ -1,5 +1,5 @@
-// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory
-// (LRDE)
+// Copyright (C) 2009, 2010, 2011 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -55,7 +55,8 @@ namespace scribo
{
Undefined = 0,
Character,
- Separator,
+ LineSeparator,
+ WhitespaceSeparator,
Noise,
Punctuation,
Image
@@ -116,8 +117,11 @@ namespace scribo
case Character:
str = "Character";
break;
- case Separator:
- str = "Separator";
+ case LineSeparator:
+ str = "LineSeparator";
+ break;
+ case WhitespaceSeparator:
+ str = "WhitespaceSeparator";
break;
case Noise:
str = "Noise";
@@ -139,8 +143,10 @@ namespace scribo
{
if (str == "Character")
return Character;
- else if (str == "Separator")
- return Separator;
+ else if (str == "LineSeparator")
+ return LineSeparator;
+ else if (str == "WhitespaceSeparator")
+ return WhitespaceSeparator;
else if (str == "Noise")
return Noise;
else if (str == "Punctuation")
diff --git a/scribo/scribo/primitive/extract/components.hh
b/scribo/scribo/primitive/extract/components.hh
index 4994d4b..849dd7b 100644
--- a/scribo/scribo/primitive/extract/components.hh
+++ b/scribo/scribo/primitive/extract/components.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009, 2011 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of Olena.
//
@@ -68,6 +69,7 @@ namespace scribo
/// and background to 'false'.
/// \param[in] nbh A neighborhood to be used for labeling.
/// \param[in,out] ncomponents Will store the numbers of components found.
+ /// \param[in] type The default component type set to components.
///
/// \return An image of labeled components.
//
@@ -75,7 +77,8 @@ namespace scribo
inline
component_set<mln_ch_value(I,V)>
components(const Image<I>& input,
- const Neighborhood<N>& nbh, V& ncomponents);
+ const Neighborhood<N>& nbh, V& ncomponents,
+ component::Type type = component::Undefined);
# ifndef MLN_INCLUDE_ONLY
@@ -88,7 +91,8 @@ namespace scribo
inline
void
components_tests(const Image<I>& input,
- const Neighborhood<N>& nbh, V& ncomponents)
+ const Neighborhood<N>& nbh, V& ncomponents,
+ component::Type type)
{
mlc_equal(mln_value(I),bool)::check();
// mlc_is_a(V, mln::value::Symbolic)::check();
@@ -97,6 +101,7 @@ namespace scribo
(void) input;
(void) nbh;
(void) ncomponents;
+ (void) type;
}
@@ -107,11 +112,12 @@ namespace scribo
inline
component_set<mln_ch_value(I,V)>
components(const Image<I>& input,
- const Neighborhood<N>& nbh, V& ncomponents)
+ const Neighborhood<N>& nbh, V& ncomponents,
+ component::Type type = component::Undefined)
{
trace::entering("scribo::components");
- internal::components_tests(input, nbh, ncomponents);
+ internal::components_tests(input, nbh, ncomponents, type);
typedef mln_ch_value(I,V) L;
typedef mln::accu::shape::bbox<mln_site(L)> bbox_accu_t;
@@ -129,7 +135,7 @@ namespace scribo
pair_accu_t());
component_set<L>
- output(results.first(), ncomponents, results.second().second());
+ output(results.first(), ncomponents, results.second().second(), type);
trace::exiting("scribo::components");
return output;
diff --git a/scribo/scribo/primitive/identify.hh b/scribo/scribo/primitive/identify.hh
index 81a7d16..1bed712 100644
--- a/scribo/scribo/primitive/identify.hh
+++ b/scribo/scribo/primitive/identify.hh
@@ -61,7 +61,7 @@ namespace scribo
std::swap(min, max);
if (max/min > 10)
- output(c).update_type(component::Separator);
+ output(c).update_type(component::LineSeparator);
}
mln::trace::exiting("scribo::primitive::identify");
--
1.5.6.5