Olena-patches
Threads by month
- ----- 2025 -----
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
May 2009
- 11 participants
- 312 discussions
* doc/tutorial/tutorial.tex: fix compilation.
* mln/core/internal/neighb_niter_impl.hh: fix ambiguities and add more
doc.
* mln/fun/v2v/rgb_to_hsl.hh: remove duplicate declarations.
* mln/literal/one.hh,
* mln/literal/zero.hh: add 'const' qualification to conversion
operator.
* mln/make/edge_image.hh: update prototype.
* mln/make/rag_and_labeled_wsl.hh: remove useless local variable.
* mln/pw/internal/image_base.hh: add missing include.
* mln/util/vertex.hh: add missing include and forward declaration.
* tests/util/set.cc: update header.
---
milena/ChangeLog | 25 +++++++++++
milena/doc/tutorial/tutorial.tex | 25 +++++++----
milena/mln/core/internal/neighb_niter_impl.hh | 56 ++++++++++++++++++++++---
milena/mln/fun/v2v/rgb_to_hsl.hh | 56 -------------------------
milena/mln/literal/one.hh | 14 +++---
milena/mln/literal/zero.hh | 6 +-
milena/mln/make/edge_image.hh | 9 ++--
milena/mln/make/rag_and_labeled_wsl.hh | 2 -
milena/mln/pw/internal/image_base.hh | 1 +
milena/mln/util/vertex.hh | 2 +
milena/tests/util/set.cc | 1 +
11 files changed, 108 insertions(+), 89 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index a5e7011..d68a7e9 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,3 +1,28 @@
+2009-05-06 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
+
+ Small fixes.
+
+ * doc/tutorial/tutorial.tex: fix compilation.
+
+ * mln/core/internal/neighb_niter_impl.hh: fix ambiguities and add more
+ doc.
+
+ * mln/fun/v2v/rgb_to_hsl.hh: remove duplicate declarations.
+
+ * mln/literal/one.hh,
+ * mln/literal/zero.hh: add 'const' qualification to conversion
+ operator.
+
+ * mln/make/edge_image.hh: update prototype.
+
+ * mln/make/rag_and_labeled_wsl.hh: remove useless local variable.
+
+ * mln/pw/internal/image_base.hh: add missing include.
+
+ * mln/util/vertex.hh: add missing include and forward declaration.
+
+ * tests/util/set.cc: update header.
+
2009-05-06 Frederic Bour <bour(a)lrde.epita.fr>
Correct typo errors, rename storage_ to state, update thrubin morpher.
diff --git a/milena/doc/tutorial/tutorial.tex b/milena/doc/tutorial/tutorial.tex
index b07b170..509a002 100644
--- a/milena/doc/tutorial/tutorial.tex
+++ b/milena/doc/tutorial/tutorial.tex
@@ -1118,7 +1118,7 @@ A list of available site sets is available in section \ref{siteset}.
%--------------------------
-\doxysubsection{Creating a site set}
+\doxysubsection{tuto4createsiteset}{Creating a site set}
In this section, we will detail how to create common site sets.
@@ -1126,7 +1126,7 @@ This is actually simple.
%--------------------------
-\doxysubsection{Getting access to sites}
+\doxysubsection{tuto4accesstosites}{Getting access to sites}
@@ -1137,15 +1137,15 @@ In milena, an image is seen as a composition of both a site set and a function
mapping a site to a value.
%--------------------------
-\doxysubsection{Creating an image}
+\doxysubsection{tuto4createimate}{Creating an image}
In this section, we will detail how to create common images.
%--------------------------
-\doxysubsection{Reading an image from a file}
+\doxysubsection{tuto4readimage}{Reading an image from a file}
%--------------------------
-\doxysubsection{Accessing data}
+\doxysubsection{tuto4accessdata}{Accessing data}
@@ -1224,7 +1224,8 @@ Finally, you may want to save the image. Since we use bool as image value, the
PBM format is the best choice. Therefore, we use io::pbm::save.
\doxycode[4]{tuto2_first_image}
-The output image looks like the following:
+The output image looks like the following: \\
+
\doxyfigure{tuto2_first_image}{3cm}
In this first step we used a boolean image. Many other value types are available
@@ -1262,25 +1263,29 @@ Updating a site value is also possible using \code{operator()} or the
\doxycode[3]{tuto3_rw_image}
\doxycode[4]{tuto3_rw_image}
-The corresponding image:
+The corresponding image: \\
+
\doxyfigure[1]{tuto3_rw_image}{3cm}
An image can also be initialized/modified thanks to another image.
Let's load a new image.
\doxycode[5]{tuto3_rw_image}
-\var{lena} looks like:
+\var{lena} looks like: \\
+
\doxyimg{small-enlarged}{3cm}
If we want to initialize \var{ima} with \var{lena}, we can use \code{data::fill}:
\doxycode[6]{tuto3_rw_image}
-Output:
+Output: \\
+
\doxyfigure[2]{tuto3_rw_image}{3cm}
Note that to fill an image with some data, the image domain \must be smaller
or equal to the data.
Likewise, it is possible to paste data from an image to another:
\doxycode[7]{tuto3_rw_image}
-Output:
+Output: \\
+
\doxyfigure[3]{tuto3_rw_image}{3cm}
More details can be found in sections \doxyref{imaaccessmodval}, \doxyref{fillop} and \doxyref{pasteop} in
diff --git a/milena/mln/core/internal/neighb_niter_impl.hh b/milena/mln/core/internal/neighb_niter_impl.hh
index a21f690..060f574 100644
--- a/milena/mln/core/internal/neighb_niter_impl.hh
+++ b/milena/mln/core/internal/neighb_niter_impl.hh
@@ -44,6 +44,11 @@ namespace mln
template <typename G, typename F> class graph_elt_window;
template <typename G, typename F, typename I> class graph_elt_window_if;
template <typename G, typename F> class line_graph_elt_window;
+ namespace util
+ {
+ template <typename G> class vertex;
+ template <typename G> class edge;
+ }
namespace internal
@@ -56,11 +61,54 @@ namespace mln
};
+ /// Add more implementation for neighborhoods made from
+ /// graph_window_base windows.
+ ///
+ /// FIXME: we need to redeclare the graph element interface.
+ /// Here, a neighb niter iterator encapsulates a window qiter iterator.
+ /// A window qiter iterator is a Proxy on a site P and can convert towards
+ /// a graph element through its member element().
+ ///
+ /// The window qiter iterator cannot have an automatic conversion towards
+ /// a graph element since there would be an ambiguity between this
+ /// conversion and the conversion to a psite P, if P is also a graph
+ /// element.
+ template <typename P, typename E>
+ struct neighb_niter_impl_graph_window
+ {
+ unsigned id() const
+ {
+ return internal::force_exact<E>(*this).compute_p_().id();
+ }
+
+ };
+
+ /// In this case, The site P is a util::vertex which means this iterator
+ /// can automatically converts towards this type.
+ /// There would be an ambiguity between util::vertex members and the one
+ /// declared in neighb_niter_impl_graph_window<P,E> if this
+ /// specialization did not exist.
+ template <typename G, typename E>
+ struct neighb_niter_impl_graph_window< util::vertex<G>, E >
+ {
+ };
+
+ /// In this case, The site P is a util::vertex which means this iterator
+ /// can automatically converts towards this type.
+ /// There would be an ambiguity between util::edge members and the one
+ /// declared in neighb_niter_impl_graph_window<P,E> if this
+ /// specialization did not exist.
+ template <typename G, typename E>
+ struct neighb_niter_impl_graph_window< util::edge<G>, E >
+ {
+ };
+
/// Add more implementation for neighborhoods made from
/// graph_window_base windows.
template <typename P, typename T, typename E>
- struct neighb_niter_impl<graph_window_base<P,T>, E>
+ struct neighb_niter_impl< graph_window_base<P, T>, E >
+ : neighb_niter_impl_graph_window<P,E>
{
typedef typename T::target S;
@@ -69,14 +117,10 @@ namespace mln
return internal::force_exact<E>(*this).compute_p_().element();
}
- unsigned id() const
- {
- return internal::force_exact<E>(*this).compute_p_().id();
- }
-
};
+
/// Add more implementation for neighborhoods made from a
/// graph_window_piter.
template <typename G, typename S, typename E>
diff --git a/milena/mln/fun/v2v/rgb_to_hsl.hh b/milena/mln/fun/v2v/rgb_to_hsl.hh
index a27e80c..7645750 100644
--- a/milena/mln/fun/v2v/rgb_to_hsl.hh
+++ b/milena/mln/fun/v2v/rgb_to_hsl.hh
@@ -69,31 +69,11 @@ namespace mln
extern f_rgb_to_hsl_f_t f_rgb_to_hsl_f;
- template <typename T_rgb>
- struct f_hsl_to_rgb_ : public Function_v2v< f_hsl_to_rgb_<T_rgb> >
- {
- typedef T_rgb result;
-
- template <typename T_hsl>
- T_rgb operator()(const T_hsl& hsl) const;
-
- };
-
- typedef f_hsl_to_rgb_< value::rgb<8> > f_hsl_to_rgb_3x8_t;
- typedef f_hsl_to_rgb_< value::rgb<16> > f_hsl_to_rgb_3x16_t;
-
- extern f_hsl_to_rgb_3x8_t f_hsl_to_rgb_3x8;
- extern f_hsl_to_rgb_3x16_t f_hsl_to_rgb_3x16;
-
-
# ifndef MLN_INCLUDE_ONLY
/// Global variables.
/// \{
f_rgb_to_hsl_f_t f_rgb_to_hsl_f;
-
- f_hsl_to_rgb_3x8_t f_hsl_to_rgb_3x8;
- f_hsl_to_rgb_3x16_t f_hsl_to_rgb_3x16;
/// \}
@@ -144,42 +124,6 @@ namespace mln
}
- template <typename T_rgb>
- template <typename T_hsl>
- inline
- T_rgb
- f_hsl_to_rgb_<T_rgb>::operator()(const T_hsl& hsl) const
- {
- typedef typename T_rgb::red_t red_t;
- typedef typename T_rgb::green_t green_t;
- typedef typename T_rgb::blue_t blue_t;
-
- static math::round<red_t> to_r;
- static math::round<green_t> to_g;
- static math::round<blue_t> to_b;
-
- static const float
- sqrt3_3 = std::sqrt(3) / 3,
- inv_sqrt6 = 1 / std::sqrt(6),
- inv_sqrt2 = 1 / std::sqrt(2);
-
- float
- h = hsl.hue() / 180.0 * 3.1415,
- alpha = hsl.sat() * std::cos(h),
- beta = hsl.sat() * std::sin(h);
-
-
- red_t r = to_r(sqrt3_3 * hsl.lum() + 2 * inv_sqrt6 * beta);
- green_t g =
- to_g(sqrt3_3 * hsl.lum() + inv_sqrt2 * alpha - inv_sqrt6 * beta);
- blue_t b =
- to_b(sqrt3_3 * hsl.lum() - inv_sqrt2 * alpha - inv_sqrt6 * beta);
-
- T_rgb rgb(r, g, b);
-
- return rgb;
- }
-
# endif // !MLN_INCLUDE_ONLY
} // end of namespace fun::v2v
diff --git a/milena/mln/literal/one.hh b/milena/mln/literal/one.hh
index 8176ce2..68fde6d 100644
--- a/milena/mln/literal/one.hh
+++ b/milena/mln/literal/one.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2009 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -28,10 +29,9 @@
#ifndef MLN_LITERAL_ONE_HH
# define MLN_LITERAL_ONE_HH
-/*! \file mln/literal/one.hh
- *
- * \brief Definition of the literal of mln::one.
- */
+/// \file mln/literal/one.hh
+///
+/// Definition of the literal of mln::one.
# include <mln/core/concept/literal.hh>
# include <mln/metal/converts_to.hh>
@@ -49,7 +49,7 @@ namespace mln
// FIXME: Cf. comments in literal/zero.hh.
template <typename T>
- operator T () const;
+ operator const T () const;
};
@@ -61,7 +61,7 @@ namespace mln
template <typename T>
inline
- one_t::operator T () const
+ one_t::operator const T () const
{
mlc_converts_to(int, T)::check();
return 1;
diff --git a/milena/mln/literal/zero.hh b/milena/mln/literal/zero.hh
index b6b4e48..62acfbf 100644
--- a/milena/mln/literal/zero.hh
+++ b/milena/mln/literal/zero.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory
// (LRDE)
//
// This file is part of the Olena Library. This library is free
@@ -51,7 +51,7 @@ namespace mln
// FIXME: (for the record) Add "friend class Literal<zero_t>;" and a protected ctor.
template <typename T>
- operator T () const;
+ operator const T () const;
};
/// Literal zero.
@@ -61,7 +61,7 @@ namespace mln
template <typename T>
inline
- zero_t::operator T () const
+ zero_t::operator const T () const
{
mlc_converts_to(int, T)::check();
return 0;
diff --git a/milena/mln/make/edge_image.hh b/milena/mln/make/edge_image.hh
index d4510c1..bd03162 100644
--- a/milena/mln/make/edge_image.hh
+++ b/milena/mln/make/edge_image.hh
@@ -94,16 +94,15 @@ namespace mln
/// Construct an edge image.
///
/// \param[in] v_ima_ A vertex image.
- /// \param[in] pe A p_edges mapping graph element to themselves.
/// \param[in] fv A function mapping two vertex ids to a value.
/// The result is associated to the corresponding edge.
///
- /// \return an edge image.
+ /// \return an edge image without localization information mapped to
+ /// graph elements.
//
template <typename P, typename V, typename G, typename FV>
mln::edge_image<void,mln_result(FV),G>
edge_image(const vertex_image<P,V,G>& v_ima_,
- const p_edges<G,util::internal::id2element<G,util::edge<G> > > pe,
const Function_vv2v<FV>& fv_);
@@ -174,7 +173,6 @@ namespace mln
template <typename P, typename V, typename G, typename FV>
mln::edge_image<void,mln_result(FV),G>
edge_image(const vertex_image<P,V,G>& v_ima_,
- const p_edges<G,util::internal::id2element<G,util::edge<G> > > pe,
const Function_vv2v<FV>& fv_)
{
trace::entering("make::edge_image");
@@ -183,12 +181,13 @@ namespace mln
const vertex_image<P,V,G>& v_ima = exact(v_ima_);
mln_precondition(v_ima.is_valid());
+ p_edges<G> pe(v_ima.graph());
typedef mln::edge_image<void,mln_result(FV),G> edge_ima_t;
edge_ima_t ima_e(pe);
mln_piter(edge_ima_t) e(ima_e.domain());
for_all(e)
- ima_e(e) = fv(e.element().v1(), e.element().v2());
+ ima_e(e) = fv(v_ima(e.element().v1()), v_ima(e.element().v2()));
trace::exiting("make::edge_image");
return ima_e;
diff --git a/milena/mln/make/rag_and_labeled_wsl.hh b/milena/mln/make/rag_and_labeled_wsl.hh
index 774c78a..60f2824 100644
--- a/milena/mln/make/rag_and_labeled_wsl.hh
+++ b/milena/mln/make/rag_and_labeled_wsl.hh
@@ -140,8 +140,6 @@ namespace mln
const N& nbh = exact(nbh_);
typedef mln_value(I) L;
- mln::image2d<bool> adj(mln::box2d(nbasins.next(), nbasins.next()));
- data::fill(adj, false);
extension::adjust_fill(wshd, nbh, 0u);
mln_concrete(I) output(wshd.domain());
diff --git a/milena/mln/pw/internal/image_base.hh b/milena/mln/pw/internal/image_base.hh
index b6571b9..d1dd608 100644
--- a/milena/mln/pw/internal/image_base.hh
+++ b/milena/mln/pw/internal/image_base.hh
@@ -33,6 +33,7 @@
/// Definition of the common base class for all point-wise images.
# include <mln/core/internal/image_primary.hh>
+# include <mln/core/routine/init.hh>
# include <mln/metal/unqualif.hh>
# include <mln/metal/not_equal.hh>
# include <mln/value/set.hh>
diff --git a/milena/mln/util/vertex.hh b/milena/mln/util/vertex.hh
index 0cde7a1..4f0c5ad 100644
--- a/milena/mln/util/vertex.hh
+++ b/milena/mln/util/vertex.hh
@@ -35,6 +35,7 @@
# include <mln/core/concept/proxy.hh>
# include <mln/core/concept/site.hh>
# include <mln/util/graph_ids.hh>
+# include <mln/util/edge.hh>
/// \file mln/util/vertex.hh
///
@@ -47,6 +48,7 @@ namespace mln
// Forward declaration.
namespace util { template<typename G> class vertex; }
+ namespace util { template<typename G> class edge; }
/// Vertex category flag type.
template <typename E>
diff --git a/milena/tests/util/set.cc b/milena/tests/util/set.cc
index f97449f..988a397 100644
--- a/milena/tests/util/set.cc
+++ b/milena/tests/util/set.cc
@@ -1,4 +1,5 @@
// Copyright (C) 2008, 2009 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
--
1.5.6.5
1
0
milena r3761: Correct typo errors, rename storage_ to state, update thrubin morpher
by Frederic Bour 06 May '09
by Frederic Bour 06 May '09
06 May '09
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2009-05-06 Frederic Bour <bour(a)lrde.epita.fr>
Correct typo errors, rename storage_ to state, update thrubin morpher.
* mln/core/concept/meta_function.hh: Add mln_fun_withbin for binary
metafunction.
* mln/core/image/thrubin_morpher.hh: Correct implementation of
thrubin_morpher.hh.
* mln/core/image/thru_morpher.hh: Typos correction.
* mln/fun/binary.hh,
* mln/fun/binary_param.hh: Renamed storage_get to state.
* mln/fun/math/inf.hh,
* mln/fun/math/sup.hh: Correct bug when working on two different
types.
* mln/fun/spe/binary.hh,
* mln/fun/spe/unary.hh,
* mln/fun/unary.hh,
* mln/fun/unary_param.hh: Renamed storage_get to state.
* mln/trait/next/solve_proxy.hh: Added one inclusion to prevent
errors.
* sandbox/fred/tests/thru.cc: Added test for thrubin.
---
mln/core/concept/meta_function.hh | 9 -
mln/core/image/thru_morpher.hh | 21 ++-
mln/core/image/thrubin_morpher.hh | 206 ++++++++++++++++----------------------
mln/fun/binary.hh | 14 +-
mln/fun/binary_param.hh | 2
mln/fun/math/inf.hh | 10 -
mln/fun/math/sup.hh | 8 -
mln/fun/spe/binary.hh | 16 ++
mln/fun/spe/unary.hh | 18 ++-
mln/fun/unary.hh | 18 +--
mln/fun/unary_param.hh | 4
mln/trait/next/solve_proxy.hh | 2
sandbox/fred/tests/thru.cc | 12 +-
13 files changed, 178 insertions(+), 162 deletions(-)
Index: trunk/milena/mln/trait/next/solve_proxy.hh
===================================================================
--- trunk/milena/mln/trait/next/solve_proxy.hh (revision 3760)
+++ trunk/milena/mln/trait/next/solve_proxy.hh (revision 3761)
@@ -37,6 +37,8 @@
# include <mln/core/concept/proxy.hh>
# include <mln/core/concept/proxy.hxx>
+# include <mln/trait/next/solve.hh>
+
namespace mln
{
Index: trunk/milena/mln/core/image/thru_morpher.hh
===================================================================
--- trunk/milena/mln/core/image/thru_morpher.hh (revision 3760)
+++ trunk/milena/mln/core/image/thru_morpher.hh (revision 3761)
@@ -123,12 +123,14 @@
typedef mln_psite(I) psite;
/// Value associated type.
- typedef typename F::result value;
+ typedef mln_result(F) value;
/// Return type of read-only access.
- typedef typename F::result rvalue;
+ typedef value rvalue;
+ typedef value lvalue; // Workaround for write operator()
rvalue operator()(const mln_psite(I)& p) const;
+ rvalue operator()(const mln_psite(I)& p);
};
@@ -221,7 +223,7 @@
thru_image<I, F>::thru_image(I& ima)
{
mln_precondition(ima.is_valid());
- init_(ima, mln_value(I)());
+ init_(ima, F());
}
template <typename I, typename F>
@@ -256,6 +258,15 @@
template <typename I, typename F>
inline
+ typename thru_image_read<I, F>::rvalue
+ thru_image_read<I, F>::operator()(const mln_psite(I)& p)
+ {
+ mln_precondition(this->is_valid());
+ return this->data_->f_(this->data_->ima_(p));
+ }
+
+ template <typename I, typename F>
+ inline
typename thru_image_write<I, F>::lvalue
thru_image_write<I, F>::operator()(const mln_psite(I)& p)
{
@@ -287,7 +298,7 @@
thru(const mln::Meta_Function<M>& f, Image<I>& ima)
{
typedef mln_fun_with(M, mln_value(I)) F;
- thru_image<I, F> tmp(exact(ima), F());
+ thru_image<I, F> tmp(exact(ima), F(exact(f).state()));
return tmp;
}
@@ -297,7 +308,7 @@
thru(const mln::Meta_Function<M>& f, const Image<I>& ima)
{
typedef mln_fun_with(M, mln_value(I)) F;
- thru_image<const I, F> tmp(exact(ima), F());
+ thru_image<const I, F> tmp(exact(ima), F(exact(f).state()));
return tmp;
}
Index: trunk/milena/mln/core/image/thrubin_morpher.hh
===================================================================
--- trunk/milena/mln/core/image/thrubin_morpher.hh (revision 3760)
+++ trunk/milena/mln/core/image/thrubin_morpher.hh (revision 3761)
@@ -43,7 +43,7 @@
{
// Forward declaration.
- template <typename I, typename F> struct thrubin_image;
+ template <typename I1, typename I2, typename F> struct thrubin_image;
namespace internal
{
@@ -53,7 +53,7 @@
{
data(I1& ima1, I2& ima2, const F& f);
- I1 ima1_;
+ I1 ima_;
I2 ima2_;
F f_;
};
@@ -65,94 +65,68 @@
{
template <typename I1, typename I2, typename F>
- struct image_< thrubin_image<I1, I2, F> > : image_< typename mln::internal::thrubin_find_impl<I1, , F>::ret > // Same as I except...
+ struct image_< thrubin_image<I1, I2, F> > : image_< I1 > // Same as I except...
{
// ...these changes.
typedef trait::image::category::value_morpher category;
- typedef mln_internal_trait_image_speed_from(I) speed; // Un-fastest.
+ typedef mln_internal_trait_image_speed_from(I1) speed; // Un-fastest.
typedef trait::image::value_access::computed value_access;
typedef trait::image::vw_io::read vw_io;
};
} // end of namespace mln::trait
-
-
- // FIXME: Doc!
-
- namespace internal
- {
-
- template <typename I, typename F>
- class thrubin_image_read : public internal::image_value_morpher< I, typename F::result, thrubin_image<I,F> >
+ /// \brief Morphes values from two images through a binary function.
+ ///
+ /// \ingroup modimagevaluemorpher
+ template <typename I1, typename I2, typename F>
+ class thrubin_image : public internal::image_value_morpher< I1, typename F::result, thrubin_image<I1,I2,F> >
{
public:
+ thrubin_image();
+ thrubin_image(I1& ima1, I2& ima2);
+ thrubin_image(I1& ima1, I2& ima2, const F& f);
+
/// Skeleton.
- typedef thrubin_image<tag::image_<I>, F> skeleton;
+ typedef thrubin_image<tag::image_<I1>, tag::image_<I2>, F> skeleton;
/// Point_Site associated type.
- typedef mln_psite(I) psite;
+ typedef mln_psite(I1) psite;
/// Value associated type.
- typedef typename F::result value;
+ typedef mln_result(F) value;
/// Return type of read-only access.
- typedef typename F::result rvalue;
-
- rvalue operator()(const mln_psite(I)& p) const;
-
- };
-
- // Inheritance from read ?!
- template <typename I, typename F>
- class thrubin_image_write : public thrubin_image_read<I,F>
- {
- public:
-
- /// Type returned by the read-write pixel value operator.
-// typedef typename F::template lresult<typename F::argument>::ret lvalue;
- typedef typename F::lresult lvalue;
-
- using thrubin_image_read<I,F>::operator();
- lvalue operator()(const mln_psite(I)& p);
-
- };
- }
-
- /// \brief Morphes values from two images through a binary function.
- ///
- /// \ingroup modimagevaluemorpher
- template <typename I, typename F>
- class thrubin_image : public internal::thrubin_find_impl<I, F>::ret
- {
- public:
+ typedef value rvalue;
+ typedef value lvalue; // Workaround for write operator()
- thrubin_image();
- thrubin_image(I& ima);
- thrubin_image(I& ima, const F& f);
+ rvalue operator()(const mln_psite(I1)& p) const;
+ rvalue operator()(const mln_psite(I1)& p);
- void init_(I& ima, const F& f);
+ void init_(I1& ima1, I2& ima2, const F& f);
/// Const promotion via conversion.
- operator thrubin_image<const I, F>() const;
+ operator thrubin_image<const I1, const I2, F>() const;
};
- template <typename I, typename F>
- thrubin_image<I, F> thrubin(const mln::Function<F>& f,
- Image<I>& ima);
-
- template <typename I, typename F>
- const thrubin_image<const I, F> thrubin(const mln::Function<F>& f,
- const Image<I>& ima);
-
- template <typename I, typename M>
- thrubin_image<I, mln_fun_with(M, mln_value(I))>
- thrubin(const mln::Meta_Function<M>& f, Image<I>& ima);
-
- template <typename I, typename M>
- const thrubin_image<const I, mln_fun_with(M, mln_value(I))>
- thrubin(const mln::Meta_Function<M>& f, const Image<I>& ima);
+ template <typename I1, typename I2, typename F>
+ thrubin_image<I1, I2, F>
+ thru(const mln::Function<F>& f,
+ Image<I1>& ima1, Image<I2>& ima2);
+
+ template <typename I1, typename I2, typename F>
+ const thrubin_image<const I1, const I2, F>
+ thru(const mln::Function<F>& f,
+ const Image<I1>& ima1, const Image<I2>& ima2);
+
+ template <typename I1, typename I2, typename M>
+ thrubin_image<I1, I2, mln_fun_withbin(M, mln_value(I1), mln_value(I2))>
+ thru(const mln::Meta_Function<M>& f, Image<I1>& ima1, Image<I1>& ima2);
+
+ template <typename I1, typename I2, typename M>
+ const thrubin_image<const I1, const I2, mln_fun_withbin(M, mln_value(I1), mln_value(I2))>
+ thru(const mln::Meta_Function<M>& f, const Image<I1>& ima1, const Image<I2>& ima2);
# ifndef MLN_INCLUDE_ONLY
@@ -161,10 +135,10 @@
namespace internal
{
- template <typename I, typename F>
+ template <typename I1, typename I2, typename F>
inline
- data< thrubin_image<I, F> >::data(I& ima, const F& f)
- : ima_(ima),
+ data< thrubin_image<I1, I2, F> >::data(I1& ima1, I2& ima2, const F& f)
+ : ima_(ima1), ima2_(ima2),
f_(f)
{
}
@@ -173,102 +147,102 @@
// thrubin_image<I>
- template <typename I, typename F>
+ template <typename I1, typename I2, typename F>
inline
- thrubin_image<I, F>::thrubin_image()
+ thrubin_image<I1, I2, F>::thrubin_image()
{
}
- template <typename I, typename F>
+ template <typename I1, typename I2, typename F>
inline
- thrubin_image<I, F>::thrubin_image(I& ima, const F& f)
+ thrubin_image<I1, I2, F>::thrubin_image(I1& ima1, I2& ima2, const F& f)
{
- mln_precondition(ima.is_valid());
- init_(ima, f);
+ mln_precondition(ima1.is_valid());
+ mln_precondition(ima2.is_valid());
+ init_(ima1, ima2, f);
}
- template <typename I, typename F>
+ template <typename I1, typename I2, typename F>
inline
- thrubin_image<I, F>::thrubin_image(I& ima)
+ thrubin_image<I1, I2, F>::thrubin_image(I1& ima1, I2& ima2)
{
- mln_precondition(ima.is_valid());
- init_(ima, mln_value(I)());
+ mln_precondition(ima1.is_valid());
+ mln_precondition(ima2.is_valid());
+ init_(ima1, ima2, F());
}
- template <typename I, typename F>
+ template <typename I1, typename I2, typename F>
inline
void
- thrubin_image<I, F>::init_(I& ima, const F& f)
+ thrubin_image<I1, I2, F>::init_(I1& ima1, I2& ima2, const F& f)
{
mln_precondition(! this->is_valid());
- mln_precondition(ima.is_valid());
- this->data_ = new internal::data< thrubin_image<I, F> >(ima, f);
+ mln_precondition(ima1.is_valid());
+ mln_precondition(ima2.is_valid());
+ this->data_ = new internal::data< thrubin_image<I1, I2, F> >(ima1, ima2, f);
}
- template <typename I, typename F>
+ template <typename I1, typename I2, typename F>
inline
- thrubin_image<I, F>::operator thrubin_image<const I, F>() const
+ thrubin_image<I1, I2, F>::operator thrubin_image<const I1, const I2, F>() const
{
- thrubin_image<const I, F> tmp(this->data_->ima_, this->data_->f_);
+ thrubin_image<const I1, const I2, F> tmp(this->data_->ima_, this->data_->ima2_, this->data_->f_);
return tmp;
}
- namespace internal
- {
-
- template <typename I, typename F>
+ template <typename I1, typename I2, typename F>
inline
- typename thrubin_image_read<I, F>::rvalue
- thrubin_image_read<I, F>::operator()(const mln_psite(I)& p) const
+ typename thrubin_image<I1, I2, F>::rvalue
+ thrubin_image<I1, I2, F>::operator()(const mln_psite(I1)& p) const
{
mln_precondition(this->is_valid());
- return this->data_->f_(this->data_->ima_(p));
+ return this->data_->f_(this->data_->ima_(p), this->data_->ima2_(p));
}
- template <typename I, typename F>
+ template <typename I1, typename I2, typename F>
inline
- typename thrubin_image_write<I, F>::lvalue
- thrubin_image_write<I, F>::operator()(const mln_psite(I)& p)
+ typename thrubin_image<I1, I2, F>::rvalue
+ thrubin_image<I1, I2, F>::operator()(const mln_psite(I1)& p)
{
mln_precondition(this->is_valid());
- return this->data_->f_(this->data_->ima_(p));
- }
-
+ return this->data_->f_(this->data_->ima_(p), this->data_->ima2_(p));
}
// thrubin
- template <typename I, typename F>
- thrubin_image<I, F> thrubin(const mln::Function<F>& f,
- Image<I>& ima)
+ template <typename I1, typename I2, typename F>
+ thrubin_image<I1, I2, F>
+ thru(const mln::Function<F>& f,
+ Image<I1>& ima1, Image<I2>& ima2)
{
- thrubin_image<I, F> tmp(exact(ima), exact(f));
+ thrubin_image<I1, I2, F> tmp(exact(ima1), exact(ima2), exact(f).state());
return tmp;
}
- template <typename I, typename F>
- thrubin_image<const I, F> thrubin(const mln::Function<F>& f,
- const Image<I>& ima)
+ template <typename I1, typename I2, typename F>
+ const thrubin_image<const I1, const I2, F>
+ thru(const mln::Function<F>& f,
+ const Image<I1>& ima1, const Image<I2>& ima2)
{
- thrubin_image<const I, F> tmp(exact(ima), exact(f));
+ thrubin_image<const I1, const I2, F> tmp(exact(ima1), exact(ima2), exact(f).state());
return tmp;
}
- template <typename I, typename M>
- thrubin_image<I, mln_fun_with(M, mln_value(I))>
- thrubin(const mln::Meta_Function<M>& f, Image<I>& ima)
+ template <typename I1, typename I2, typename M>
+ thrubin_image<I1, I2, mln_fun_withbin(M, mln_value(I1), mln_value(I2))>
+ thru(const mln::Meta_Function<M>& f, Image<I1>& ima1, Image<I2>& ima2)
{
- typedef mln_fun_with(M, mln_value(I)) F;
- thrubin_image<I, F> tmp(exact(ima), F());
+ typedef mln_fun_withbin(M, mln_value(I1), mln_value(I2)) F;
+ thrubin_image<I1, I2, F> tmp(exact(ima1), exact(ima2), F(exact(f).state()));
return tmp;
}
- template <typename I, typename M>
- thrubin_image<const I, mln_fun_with(M, mln_value(I))>
- thrubin(const mln::Meta_Function<M>& f, const Image<I>& ima)
+ template <typename I1, typename I2, typename M>
+ const thrubin_image<const I1, const I2, mln_fun_withbin(M, mln_value(I1), mln_value(I2))>
+ thru(const mln::Meta_Function<M>& f, const Image<I1>& ima1, const Image<I2>& ima2)
{
- typedef mln_fun_with(M, mln_value(I)) F;
- thrubin_image<const I, F> tmp(exact(ima), F());
+ typedef mln_fun_withbin(M, mln_value(I1), mln_value(I2)) F;
+ thrubin_image<const I1, const I2, F> tmp(exact(ima1), exact(ima2), F(exact(f).state()));
return tmp;
}
Index: trunk/milena/mln/core/concept/meta_function.hh
===================================================================
--- trunk/milena/mln/core/concept/meta_function.hh (revision 3760)
+++ trunk/milena/mln/core/concept/meta_function.hh (revision 3761)
@@ -35,23 +35,24 @@
# include <mln/core/concept/object.hh>
# include <mln/core/concept/function.hh>
-
# define mln_fun_with(F, T) \
typename F::template with< T >::ret
# define mln_fun_with_(F, T) \
F::with< T >::ret
+# define mln_fun_withbin(F, T1, T2) \
+typename F::template with< T1, T2 >::ret
+
+# define mln_fun_withbin_(F, T1, T2) \
+F::with< T1, T2 >::ret
# define mln_fun_result(F, T) \
typename F::template with< T >::ret::result
-
# define mln_fun_result_(F, T) \
F::with< T >::ret::result
-
-
namespace mln
{
Index: trunk/milena/mln/fun/spe/binary.hh
===================================================================
--- trunk/milena/mln/fun/spe/binary.hh (revision 3760)
+++ trunk/milena/mln/fun/spe/binary.hh (revision 3761)
@@ -93,17 +93,27 @@
result operator () (const argument1& a, const argument2& b) const
{
- return def::read(storage_, a, b);
+ return def::read(state_, a, b);
}
template <typename U>
void init(const U& value)
{
- storage_ = mln::trait::function::internal::introspect::has_storage_t<def, void>::compute(value);
+ state_ = mln::trait::function::internal::introspect::has_storage_t<def, void>::compute(value);
+ }
+
+ stored<storage>& state()
+ {
+ return state_;
+ }
+
+ const stored<storage>& state() const
+ {
+ return state_;
}
protected:
- mln::fun::stored<storage> storage_;
+ mln::fun::stored<storage> state_;
};
} // end of namespace mln::fun::spe::impl
Index: trunk/milena/mln/fun/spe/unary.hh
===================================================================
--- trunk/milena/mln/fun/spe/unary.hh (revision 3760)
+++ trunk/milena/mln/fun/spe/unary.hh (revision 3761)
@@ -233,17 +233,27 @@
result operator () (const argument& value) const
{
- return def::read(this->storage_, value);
+ return def::read(this->state_, value);
}
template <typename U>
void init(const U& value)
{
- storage_ = mln::trait::function::internal::introspect::has_storage_t<def, void>::compute(value);
+ state_ = mln::trait::function::internal::introspect::has_storage_t<def, void>::compute(value);
};
+ stored<storage>& state()
+ {
+ return state_;
+ }
+
+ const stored<storage>& state() const
+ {
+ return state_;
+ }
+
protected:
- storage storage_;
+ stored<storage> state_;
};
template <typename Fun, typename T>
@@ -262,7 +272,7 @@
void set(lvalue l, const typename super::result& r) const
{
- super::def::write(this->storage_, l, r);
+ super::def::write(this->state(), l, r);
}
using super::operator ();
Index: trunk/milena/mln/fun/math/sup.hh
===================================================================
--- trunk/milena/mln/fun/math/sup.hh (revision 3760)
+++ trunk/milena/mln/fun/math/sup.hh (revision 3761)
@@ -47,12 +47,12 @@
{
template <typename T>
- struct set_binary_<mln::fun::sup, mln::Object, T, mln::Object, T>
+ struct set_binary_<mln::fun::sup, mln::Object, T1, mln::Object, T2>
{
typedef set_binary_ ret;
- typedef T result;
- typedef T argument1;
- typedef T argument2;
+ typedef mln_trait_promote(T1, T2) result;
+ typedef T1 argument1;
+ typedef T2 argument2;
static result read(const argument1& a, const argument1& b)
{
Index: trunk/milena/mln/fun/math/inf.hh
===================================================================
--- trunk/milena/mln/fun/math/inf.hh (revision 3760)
+++ trunk/milena/mln/fun/math/inf.hh (revision 3761)
@@ -46,13 +46,13 @@
namespace next
{
- template <typename T>
- struct set_binary_<mln::fun::inf, mln::Object, T, mln::Object, T>
+ template <typename T1, typename T2>
+ struct set_binary_<mln::fun::inf, mln::Object, T1, mln::Object, T2>
{
typedef set_binary_ ret;
- typedef T result;
- typedef T argument1;
- typedef T argument2;
+ typedef mln_trait_promote(T1, T2) result;
+ typedef T1 argument1;
+ typedef T2 argument2;
static result read(const argument1& a, const argument1& b)
{
Index: trunk/milena/mln/fun/unary.hh
===================================================================
--- trunk/milena/mln/fun/unary.hh (revision 3760)
+++ trunk/milena/mln/fun/unary.hh (revision 3761)
@@ -71,19 +71,19 @@
template <typename T>
typename with<T>::ret::template lresult_with<T>::ret operator()(T& v) const
{
- return typename with<T>::ret(storage_get()).apply_rw(v);
+ return typename with<T>::ret(state()).apply_rw(v);
}
template <typename T, typename R>
void set(T& v, const R& r) const
{
- typename with<T>::ret(storage_).set(v, r);
+ typename with<T>::ret(state()).set(v, r);
}
template <typename U>
void init(const U& value)
{
- storage_ = mln::trait::function::internal::introspect::has_storage_t<flag, void>::compute(value);
+ state_ = mln::trait::function::internal::introspect::has_storage_t<flag, void>::compute(value);
};
unary()
@@ -96,18 +96,18 @@
this->init(param);
}
- stored<storage>& storage_get()
+ stored<storage>& state()
{
- return storage_;
+ return state_;
}
- const stored<storage>& storage_get() const
+ const stored<storage>& state() const
{
- return storage_;
+ return state_;
}
protected:
- stored<storage> storage_;
+ stored<storage> state_;
};
} // end of namespace mln::fun
@@ -128,7 +128,7 @@
static typename ret::result call(const F& f, const T& v)
{
- return ret(f.storage_get())(v);
+ return ret(f.state())(v);
}
};
Index: trunk/milena/mln/fun/unary_param.hh
===================================================================
--- trunk/milena/mln/fun/unary_param.hh (revision 3760)
+++ trunk/milena/mln/fun/unary_param.hh (revision 3761)
@@ -41,6 +41,10 @@
template <typename F, typename Param, typename Storage = void, typename E = F>
struct unary_param: unary< unary_param<F,Param,Storage,E>, E>
{
+ typedef F flag;
+ typedef Param param;
+ typedef Storage storage;
+
unary_param()
{
}
Index: trunk/milena/mln/fun/binary.hh
===================================================================
--- trunk/milena/mln/fun/binary.hh (revision 3760)
+++ trunk/milena/mln/fun/binary.hh (revision 3761)
@@ -54,13 +54,13 @@
template <typename T1, typename T2>
typename with<T1, T2>::ret::result operator()(const T1& a, const T2& b) const
{
- return typename with<T1, T2>::ret(storage_)(a, b);
+ return typename with<T1, T2>::ret(state())(a, b);
}
template <typename U>
void init(const U& value)
{
- storage_ = mln::trait::function::internal::introspect::has_storage_t<flag, void>::compute(value);
+ state_ = mln::trait::function::internal::introspect::has_storage_t<flag, void>::compute(value);
};
binary()
@@ -73,18 +73,18 @@
this->init(param);
}
- stored<storage>& storage_get()
+ stored<storage>& state()
{
- return storage_;
+ return state_;
}
- const stored<storage>& storage_get() const
+ const stored<storage>& state() const
{
- return storage_;
+ return state_;
}
protected:
- stored<storage> storage_;
+ stored<storage> state_;
};
} // end of namespace mln::fun
Index: trunk/milena/mln/fun/binary_param.hh
===================================================================
--- trunk/milena/mln/fun/binary_param.hh (revision 3760)
+++ trunk/milena/mln/fun/binary_param.hh (revision 3761)
@@ -42,6 +42,8 @@
struct binary_param: binary<binary_param<F,Param,Storage>, E>
{
typedef F flag;
+ typedef Param param;
+ typedef Storage storage;
binary_param()
{
Index: trunk/milena/sandbox/fred/tests/thru.cc
===================================================================
--- trunk/milena/sandbox/fred/tests/thru.cc (revision 3760)
+++ trunk/milena/sandbox/fred/tests/thru.cc (revision 3761)
@@ -2,12 +2,14 @@
#include <mln/fun/v2v/convert.hh>
#include <mln/fun/math/cos.hh>
#include <mln/core/image/thru_morpher.hh>
+#include <mln/core/image/thrubin_morpher.hh>
#include <mln/fun/compose.hh>
#include <mln/core/var.hh>
#include <mln/core/image/image2d.hh>
#include <mln/fun/point/row.hh>
+#include <mln/fun/math/inf.hh>
#include <mln/value/int_u8.hh>
#include <mln/debug/all.hh>
@@ -23,24 +25,24 @@
using namespace mln;
fun::cos cos;
+ fun::inf inf;
+
typedef image2d<float> I;
I ima(5, 5);
-
image2d<value::int_u8> tmp(5, 5);
+
+
debug::iota(tmp);
data::fill_with_image(ima, tmp);
debug::println(ima);
debug::println(thru(cos, ima));
+ debug::println(thru(inf, ima, tmp));
mln_VAR(ima2, thru(cos(cos), ima));
- data::fill_with_image(ima2, tmp);
-
mln::fun::row row;
-
mln_piter_(I) p(ima.domain());
-
for_all(p)
std::cout << row(p);
1
0
https://svn.lrde.epita.fr/svn/oln/trunk/milena/sandbox
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Add a file to test exprs like ''pw::value(ima) < 3''.
* theo/experimental/op_pw_value_pw_cst.cc: New.
op_pw_value_pw_cst.cc | 91 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 91 insertions(+)
Index: theo/experimental/op_pw_value_pw_cst.cc
--- theo/experimental/op_pw_value_pw_cst.cc (revision 0)
+++ theo/experimental/op_pw_value_pw_cst.cc (revision 0)
@@ -0,0 +1,91 @@
+#include <mln/core/image/image2d.hh>
+#include <mln/value/int_u8.hh>
+#include <mln/pw/value.hh>
+#include <mln/pw/cst.hh>
+#include <mln/fun/ops.hh>
+#include <mln/value/scalar.hh>
+
+
+namespace mln
+{
+
+
+ namespace trait
+ {
+
+// template <typename L, typename R>
+// struct set_binary_< op::less,
+// mln::Function_p2v, L,
+// mln::value::Scalar, R >
+// {
+// typedef fun::less_p2b_expr_< L, pw::cst_<mln_result(L)> > ret;
+// };
+
+
+ template <typename L, typename R>
+ struct set_binary_< op::less,
+ mln::Function_p2v, L,
+ mln::Object, R >
+ {
+ typedef fun::less_p2b_expr_< L, pw::cst_<mln_result(L)> > ret;
+ };
+
+ }
+
+
+// template <typename L, typename R>
+// fun::less_p2b_expr_< L, pw::cst_<mln_result(L)> >
+// operator < (const Function_p2v<L>& lhs, const value::Scalar<R>& rhs)
+// {
+// mlc_converts_to(mln_equiv(R), mln_result(L))::check();
+// mln_equiv(R) rhs_ = exact(rhs).to_equiv();
+// typedef pw::cst_<mln_result(L)> C;
+// fun::less_p2b_expr_<L, C> tmp(exact(lhs), C(rhs_));
+// return tmp;
+// }
+
+
+ template <typename L, typename R>
+ fun::less_p2b_expr_< L, pw::cst_<mln_result(L)> >
+ operator < (const Function_p2v<L>& lhs, const Object<R>& rhs)
+ {
+ // mln_trait_op_less(L, mln_result(L)) b = lhs;
+
+ typedef pw::cst_<mln_result(L)> C;
+ fun::less_p2b_expr_<L, C> tmp(exact(lhs), C(exact(rhs)));
+ return tmp;
+ }
+
+
+// template <typename L>
+// fun::less_p2b_expr_< L, pw::cst_<mln_result(L)> >
+// operator < (const Function_p2v<L>& lhs, const mln_result(L)& rhs)
+// {
+// mln_trait_op_less(L, mln_result(L)) b = lhs;
+
+// typedef pw::cst_<mln_result(L)> C;
+// fun::less_p2b_expr_<L, C> tmp(exact(lhs), C(rhs));
+// return tmp;
+// }
+
+
+}
+
+
+
+
+int main()
+{
+ using namespace mln;
+
+ image2d<value::int_u8> ima(1,1);
+ point2d p(0,0);
+ ima(p) = 2;
+
+// void* v =
+ (pw::value(ima) < 3);
+
+// std::cout << (pw::value(ima) < 3u)(p) << std::endl;
+
+ // pw::value(ima) < 3;
+}
1
0
---
ChangeLog | 4 ++++
configure.ac | 3 +++
2 files changed, 7 insertions(+), 0 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 836f6fe..d32d1c1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
2009-05-05 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
+ * configure.ac: Configure tests/world/*
+
+2009-05-05 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
+
* configure.ac: Configure tests/linera/gaussian.
2009-04-30 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
diff --git a/configure.ac b/configure.ac
index 7cdcdbb..ada07fa 100644
--- a/configure.ac
+++ b/configure.ac
@@ -275,6 +275,9 @@ AC_CONFIG_FILES([
milena/tests/value/builtin/Makefile
milena/tests/value/concept/Makefile
milena/tests/win/Makefile
+ milena/tests/world/Makefile
+ milena/tests/world/inter_pixel/Makefile
+ milena/tests/world/inter_pixel/dim2/Makefile
])
--
1.5.6.5
1
0
3758: Add make_edge_image in world::inter_pixel and few missing tests.
by Guillaume Lazzara 05 May '09
by Guillaume Lazzara 05 May '09
05 May '09
* mln/world/inter_pixel/dim2/make_edge_image.hh: new routine.
* mln/world/inter_pixel/full2image.hh,
* mln/world/inter_pixel/image2full.hh,
* mln/world/inter_pixel/neighb2d.hh: update doc.
* tests/Makefile.am,
* tests/world/Makefile.am,
* tests/world/inter_pixel/Makefile.am,
* tests/world/inter_pixel/dim2/Makefile.am,
* tests/world/inter_pixel/dim2/make_edge_image.cc,
* tests/world/inter_pixel/image2full.cc: new tests.
---
milena/ChangeLog | 17 +++
.../mln/world/inter_pixel/dim2/make_edge_image.hh | 104 ++++++++++++++++++++
milena/mln/world/inter_pixel/full2image.hh | 30 +++++-
milena/mln/world/inter_pixel/image2full.hh | 29 +++++-
milena/mln/world/inter_pixel/neighb2d.hh | 37 +++++---
milena/tests/Makefile.am | 3 +-
milena/tests/world/Makefile.am | 2 +
milena/tests/world/inter_pixel/Makefile.am | 13 +++
milena/tests/world/inter_pixel/dim2/Makefile.am | 10 ++
.../world/inter_pixel/dim2/make_edge_image.cc} | 66 +++++++------
.../world/inter_pixel/image2full.cc} | 60 +++++-------
11 files changed, 280 insertions(+), 91 deletions(-)
create mode 100644 milena/mln/world/inter_pixel/dim2/make_edge_image.hh
create mode 100644 milena/tests/world/Makefile.am
create mode 100644 milena/tests/world/inter_pixel/Makefile.am
create mode 100644 milena/tests/world/inter_pixel/dim2/Makefile.am
copy milena/{mln/world/inter_pixel/full2image.hh => tests/world/inter_pixel/dim2/make_edge_image.cc} (55%)
copy milena/{mln/world/inter_pixel/image2full.hh => tests/world/inter_pixel/image2full.cc} (60%)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 9851a79..b4bb872 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,3 +1,20 @@
+2009-05-05 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
+
+ Add make_edge_image in world::inter_pixel and few missing tests.
+
+ * mln/world/inter_pixel/dim2/make_edge_image.hh: new routine.
+
+ * mln/world/inter_pixel/full2image.hh,
+ * mln/world/inter_pixel/image2full.hh,
+ * mln/world/inter_pixel/neighb2d.hh: update doc.
+
+ * tests/Makefile.am,
+ * tests/world/Makefile.am,
+ * tests/world/inter_pixel/Makefile.am,
+ * tests/world/inter_pixel/dim2/Makefile.am,
+ * tests/world/inter_pixel/dim2/make_edge_image.cc,
+ * tests/world/inter_pixel/image2full.cc: new tests.
+
2009-05-05 Fabien Freling <fabien.freling(a)lrde.epita.fr>
Update inter_pixel files to match coding style.
diff --git a/milena/mln/world/inter_pixel/dim2/make_edge_image.hh b/milena/mln/world/inter_pixel/dim2/make_edge_image.hh
new file mode 100644
index 0000000..0624067
--- /dev/null
+++ b/milena/mln/world/inter_pixel/dim2/make_edge_image.hh
@@ -0,0 +1,104 @@
+// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This 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_DIM2_MAKE_EDGE_IMAGE_HH
+# define MLN_WORLD_INTER_PIXEL_DIM2_MAKE_EDGE_IMAGE_HH
+
+/// \file mln/world/inter_pixel/dim2/make_edge_image.hh
+///
+/// Construct a valued image of edges.
+
+# include <mln/core/image/extension_ima.hh>
+# include <mln/core/image/image_if.hh>
+
+# include <mln/core/routine/extend.hh>
+
+# include <mln/world/inter_pixel/neighb2d.hh>
+# include <mln/world/inter_pixel/dim2/is_edge.hh>
+# include <mln/data/fill.hh>
+
+namespace mln
+{
+
+ namespace world
+ {
+
+ namespace inter_pixel
+ {
+
+ namespace dim2
+ {
+
+ template <typename I, typename F>
+ mln_concrete(I)
+ make_edge_image(const Image<I>& input_, const Function_vv2v<F>& f_)
+ {
+ trace::entering("world::inter_pixel::dim2::make_edge_image");
+
+ const I& input = exact(input_);
+ const F& f = exact(f_);
+ mln_precondition(input.is_valid());
+
+ typedef image_if<const image2d<value::int_u<8u> >,
+ world::inter_pixel::dim2::is_edge> edges_t;
+ edges_t edges = input | is_edge();
+ typedef extension_ima<const edges_t,const I> edges_ext_t;
+ edges_ext_t edges_ext = extend(edges, input);
+
+ mln_piter(edges_ext_t) p(edges_ext.domain());
+ dbl_neighb2d nbh = e2c();
+ mln_niter(dbl_neighb2d) n(nbh, p);
+ mln_value(I) vs[2];
+
+ mln_concrete(I) output;
+ initialize(output, input);
+ data::fill(output, literal::zero);
+
+ for_all(p)
+ {
+ unsigned i = 0;
+ for_all(n)
+ {
+ mln_assertion(i < 2);
+ vs[i++] = input(n);
+ }
+ output(p) = f(vs[0], vs[1]);
+ }
+
+ trace::exiting("world::inter_pixel::dim2::make_edge_image");
+ return output;
+ }
+
+ } // end of namespace mln::world::inter_pixel::dim2
+
+ } // end of namespace mln::world::inter_pixel
+
+ } // end of namespace mln::world
+
+} // end of namespace mln
+
+#endif // ! MLN_WORLD_INTER_PIXEL_DIM2_MAKE_EDGE_IMAGE_HH
diff --git a/milena/mln/world/inter_pixel/full2image.hh b/milena/mln/world/inter_pixel/full2image.hh
index d08ada2..c116964 100644
--- a/milena/mln/world/inter_pixel/full2image.hh
+++ b/milena/mln/world/inter_pixel/full2image.hh
@@ -30,9 +30,16 @@
/// \file mln/world/inter_pixel/full.hh
///
-/// FIXME: insert comment.
+/// Convert an inter-pixel image to a classical image.
+///
+/// FIXME: will NOT work if the image has an origin different from (0,0).
# include <mln/core/image/image2d.hh>
+# include <mln/geom/max_col.hh>
+# include <mln/geom/max_row.hh>
+# include <mln/geom/min_col.hh>
+# include <mln/geom/min_row.hh>
+
namespace mln
{
@@ -43,6 +50,12 @@ namespace mln
namespace inter_pixel
{
+ /// Convert an inter-pixel image to a classical image.
+ ///
+ /// \param[in] input An inter-pixel image.
+ ///
+ /// \return A classical image without inter-pixel data.
+ //
template <typename T>
image2d<T>
full2image(const image2d<T>& input);
@@ -50,19 +63,26 @@ namespace mln
# ifndef MLN_INCLUDE_ONLY
+
template <typename T>
image2d<T>
full2image(const image2d<T>& input)
{
- image2d<T> output((input.nrows() + 1) / 2,
- (input.ncols() + 1) / 2);
- for (int row = 0; row < input.nrows(); row += 2)
- for (int col = 0; col < input.ncols(); col += 2)
+ trace::entering("world::inter_pixel::full2image");
+ mln_precondition(input.is_valid());
+
+ image2d<T> output((input.nrows() + 1) / 2, (input.ncols() + 1) / 2);
+
+ for (int row = geom::min_row(input); row <= geom::max_row(input); row += 2)
+ for (int col = geom::min_col(input); col <= geom::max_col(input); col += 2)
opt::at(output, row / 2, col / 2) =
opt::at(input, row, col);
+
+ trace::exiting("world::inter_pixel::full2image");
return output;
}
+
# endif // ! MLN_INCLUDE_ONLY
diff --git a/milena/mln/world/inter_pixel/image2full.hh b/milena/mln/world/inter_pixel/image2full.hh
index 0c32ad1..03102f7 100644
--- a/milena/mln/world/inter_pixel/image2full.hh
+++ b/milena/mln/world/inter_pixel/image2full.hh
@@ -30,9 +30,16 @@
/// \file mln/world/inter_pixel/full.hh
///
-/// FIXME: insert comment.
+/// Convert a classical 2D image to an inter-pixel image.
+///
+/// FIXME: will NOT work if the image has an origin different from (0,0).
# include <mln/core/image/image2d.hh>
+# include <mln/geom/max_col.hh>
+# include <mln/geom/max_row.hh>
+# include <mln/geom/min_col.hh>
+# include <mln/geom/min_row.hh>
+
namespace mln
{
@@ -43,6 +50,12 @@ namespace mln
namespace inter_pixel
{
+ /// Convert a classical 2D image to an inter-pixel image.
+ ///
+ /// \param[in] input A 2d image.
+ ///
+ /// \return An inter-pixel image.
+ //
template <typename T>
image2d<T>
image2full(const image2d<T>& input);
@@ -50,18 +63,24 @@ namespace mln
# ifndef MLN_INCLUDE_ONLY
+
template <typename T>
image2d<T>
image2full(const image2d<T>& input)
{
- image2d<T> output(2 * input.nrows() - 1,
- 2 * input.ncols() - 1);
- for (int row = 0; row < input.nrows(); ++row)
- for (int col = 0; col < input.ncols(); ++col)
+ trace::entering("world::inter_pixel::image2full");
+ mln_precondition(input.is_valid());
+
+ image2d<T> output(2 * input.nrows() - 1, 2 * input.ncols() - 1);
+ for (int row = geom::min_row(input); row <= geom::max_row(input); ++row)
+ for (int col = geom::min_col(input); col <= geom::max_col(input); ++col)
opt::at(output, 2 * row, 2 * col) = opt::at(input, row, col);
+
+ trace::exiting("world::inter_pixel::image2full");
return output;
}
+
# endif // ! MLN_INCLUDE_ONLY
diff --git a/milena/mln/world/inter_pixel/neighb2d.hh b/milena/mln/world/inter_pixel/neighb2d.hh
index 6ad7101..a61edeb 100644
--- a/milena/mln/world/inter_pixel/neighb2d.hh
+++ b/milena/mln/world/inter_pixel/neighb2d.hh
@@ -30,7 +30,8 @@
/// \file mln/world/inter_pixel/neighb2d.hh
///
-/// FIXME: insert comment.
+/// Common neighborhood on inter-pixel images.
+
# include <mln/core/alias/neighb2d.hh>
# include <mln/make/double_neighb2d.hh>
@@ -45,9 +46,13 @@ namespace mln
namespace inter_pixel
{
+ /// Double neighborhood used for inter-pixel images.
typedef neighb< win::multiple<window2d, dim2::is_row_odd> > dbl_neighb2d;
+ /// C4 neighborhood on pixels centered on an edge.
const dbl_neighb2d& e2c();
+
+ /// C8 neighborhood on edges centered on an edge.
const dbl_neighb2d& e2e();
@@ -56,27 +61,33 @@ namespace mln
const dbl_neighb2d& e2c()
{
static bool e2c_h[] = { 0, 1, 0,
- 0, 0, 0,
- 0, 1, 0 };
+ 0, 0, 0,
+ 0, 1, 0 };
+
static bool e2c_v[] = { 0, 0, 0,
- 1, 0, 1,
- 0, 0, 0 };
+ 1, 0, 1,
+ 0, 0, 0 };
+
static dbl_neighb2d nbh = make::double_neighb2d(dim2::is_row_odd(), e2c_h, e2c_v);
return nbh;
}
+
+
const dbl_neighb2d& e2e()
{
static bool e2e_h[] = { 0, 0, 1, 0, 0,
- 0, 1, 0, 1, 0,
- 0, 0, 0, 0, 0,
- 0, 1, 0, 1, 0,
- 0, 0, 1, 0, 0 };
+ 0, 1, 0, 1, 0,
+ 0, 0, 0, 0, 0,
+ 0, 1, 0, 1, 0,
+ 0, 0, 1, 0, 0 };
+
static bool e2e_v[] = { 0, 0, 0, 0, 0,
- 0, 1, 0, 1, 0,
- 1, 0, 0, 0, 1,
- 0, 1, 0, 1, 0,
- 0, 0, 0, 0, 0 };
+ 0, 1, 0, 1, 0,
+ 1, 0, 0, 0, 1,
+ 0, 1, 0, 1, 0,
+ 0, 0, 0, 0, 0 };
+
static dbl_neighb2d nbh = make::double_neighb2d(dim2::is_row_odd(), e2e_h, e2e_v);
return nbh;
}
diff --git a/milena/tests/Makefile.am b/milena/tests/Makefile.am
index 9945b19..23cb39e 100644
--- a/milena/tests/Makefile.am
+++ b/milena/tests/Makefile.am
@@ -46,7 +46,8 @@ SUBDIRS = \
unit_test \
util \
value \
- win
+ win \
+ world
check_PROGRAMS = \
diff --git a/milena/tests/world/Makefile.am b/milena/tests/world/Makefile.am
new file mode 100644
index 0000000..7a41ecd
--- /dev/null
+++ b/milena/tests/world/Makefile.am
@@ -0,0 +1,2 @@
+SUBDIRS = \
+ inter_pixel
diff --git a/milena/tests/world/inter_pixel/Makefile.am b/milena/tests/world/inter_pixel/Makefile.am
new file mode 100644
index 0000000..cffbcdd
--- /dev/null
+++ b/milena/tests/world/inter_pixel/Makefile.am
@@ -0,0 +1,13 @@
+## Process this file through Automake to create Makefile.in -*- Makefile -*-
+
+include $(top_srcdir)/milena/tests/tests.mk
+
+SUBDIRS = \
+ dim2
+
+check_PROGRAMS = \
+ image2full
+
+image2full_SOURCES = image2full.cc
+
+TESTS = $(check_PROGRAMS)
diff --git a/milena/tests/world/inter_pixel/dim2/Makefile.am b/milena/tests/world/inter_pixel/dim2/Makefile.am
new file mode 100644
index 0000000..51fef42
--- /dev/null
+++ b/milena/tests/world/inter_pixel/dim2/Makefile.am
@@ -0,0 +1,10 @@
+## Process this file through Automake to create Makefile.in -*- Makefile -*-
+
+include $(top_srcdir)/milena/tests/tests.mk
+
+check_PROGRAMS = \
+ make_edge_image
+
+make_edge_image_SOURCES = make_edge_image.cc
+
+TESTS = $(check_PROGRAMS)
diff --git a/milena/mln/world/inter_pixel/full2image.hh b/milena/tests/world/inter_pixel/dim2/make_edge_image.cc
similarity index 55%
copy from milena/mln/world/inter_pixel/full2image.hh
copy to milena/tests/world/inter_pixel/dim2/make_edge_image.cc
index d08ada2..34f16cc 100644
--- a/milena/mln/world/inter_pixel/full2image.hh
+++ b/milena/tests/world/inter_pixel/dim2/make_edge_image.cc
@@ -25,51 +25,57 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_WORLD_INTER_PIXEL_FULL_HH
-# define MLN_WORLD_INTER_PIXEL_FULL_HH
-
-/// \file mln/world/inter_pixel/full.hh
+/// \file tests/world/inter_pixel/dim2/make_edge_image.cc
///
-/// FIXME: insert comment.
+/// Tests on mln::world::inter_pixel::dim2::make_edge_image
+
+
+#include <mln/core/image/image2d.hh>
+#include <mln/world/inter_pixel/dim2/make_edge_image.hh>
+#include <mln/value/int_u8.hh>
+#include <mln/make/image.hh>
+#include <mln/math/abs.hh>
+#include <mln/level/compare.hh>
-# include <mln/core/image/image2d.hh>
namespace mln
{
- namespace world
+ struct myfun : Function_vv2v<myfun>
{
+ typedef mln::value::int_u8 result;
- namespace inter_pixel
+ result operator()(const value::int_u8& v1, const value::int_u8& v2) const
{
+ return math::abs(v1-v2);
+ }
+ };
- template <typename T>
- image2d<T>
- full2image(const image2d<T>& input);
+}
-# ifndef MLN_INCLUDE_ONLY
- template <typename T>
- image2d<T>
- full2image(const image2d<T>& input)
- {
- image2d<T> output((input.nrows() + 1) / 2,
- (input.ncols() + 1) / 2);
- for (int row = 0; row < input.nrows(); row += 2)
- for (int col = 0; col < input.ncols(); col += 2)
- opt::at(output, row / 2, col / 2) =
- opt::at(input, row, col);
- return output;
- }
-
-# endif // ! MLN_INCLUDE_ONLY
+int main()
+{
+ using namespace mln;
+ value::int_u8 vals[][5] = { { 3, 0, 4, 0, 5 },
+ { 0, 0, 0, 0, 0 },
+ { 1, 0, 3, 0, 6 },
+ { 0, 0, 0, 0, 0 },
+ { 8, 0, 7, 0, 3 } };
- } // end of namespace mln::world::inter_pixel
+ value::int_u8 refs[][5] = { { 0, 1, 0, 1, 0 },
+ { 2, 0, 1, 0, 1 },
+ { 0, 2, 0, 3, 0 },
+ { 7, 0, 4, 0, 3 },
+ { 0, 1, 0, 4, 0 } };
- } // end of namespace mln::world
+ typedef image2d<value::int_u8> ima_t;
+ ima_t ima = make::image(vals);
+ ima_t ref = make::image(refs);
-} // end of namespace mln
+ ima_t res = world::inter_pixel::dim2::make_edge_image(ima, myfun());
-#endif // ! MLN_WORLD_INTER_PIXEL_FULL
+ mln_assertion(res == ref);
+}
diff --git a/milena/mln/world/inter_pixel/image2full.hh b/milena/tests/world/inter_pixel/image2full.cc
similarity index 60%
copy from milena/mln/world/inter_pixel/image2full.hh
copy to milena/tests/world/inter_pixel/image2full.cc
index 0c32ad1..06398a1 100644
--- a/milena/mln/world/inter_pixel/image2full.hh
+++ b/milena/tests/world/inter_pixel/image2full.cc
@@ -25,50 +25,36 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_WORLD_INTER_PIXEL_FULL_HH
-# define MLN_WORLD_INTER_PIXEL_FULL_HH
-
-/// \file mln/world/inter_pixel/full.hh
+/// \file tests/world/inter_pixel/image2full.cc
///
-/// FIXME: insert comment.
+/// Tests on mln::world::inter_pixel::image2full
-# include <mln/core/image/image2d.hh>
+#include <mln/core/image/image2d.hh>
+#include <mln/make/image.hh>
+#include <mln/value/int_u8.hh>
+#include <mln/level/compare.hh>
+#include <mln/world/inter_pixel/image2full.hh>
-namespace mln
+int main()
{
+ using namespace mln;
- namespace world
- {
-
- namespace inter_pixel
- {
-
- template <typename T>
- image2d<T>
- image2full(const image2d<T>& input);
-
-
-# ifndef MLN_INCLUDE_ONLY
-
- template <typename T>
- image2d<T>
- image2full(const image2d<T>& input)
- {
- image2d<T> output(2 * input.nrows() - 1,
- 2 * input.ncols() - 1);
- for (int row = 0; row < input.nrows(); ++row)
- for (int col = 0; col < input.ncols(); ++col)
- opt::at(output, 2 * row, 2 * col) = opt::at(input, row, col);
- return output;
- }
-
-# endif // ! MLN_INCLUDE_ONLY
+ value::int_u8 vals[][3] = { { 3, 4, 5 },
+ { 1, 3, 6 },
+ { 8, 7, 3 } } ;
+ value::int_u8 refs[][5] = { { 3, 0, 4, 0, 5 },
+ { 0, 0, 0, 0, 0 },
+ { 1, 0, 3, 0, 6 },
+ { 0, 0, 0, 0, 0 },
+ { 8, 0, 7, 0, 3 } };
- } // end of namespace mln::world::inter_pixel
+ typedef image2d<value::int_u8> ima_t;
+ ima_t ima = make::image(vals);
+ ima_t ref = make::image(refs);
- } // end of namespace mln::world
+ ima_t ima_l = world::inter_pixel::image2full(ima);
-} // end of namespace mln
+ mln_assertion(ima_l == ref);
-#endif // ! MLN_WORLD_INTER_PIXEL_FULL
+}
--
1.5.6.5
1
0
https://svn.lrde.epita.fr/svn/oln/trunk/milena/sandbox
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Make room for INIM 2011 and store 2009 stuff.
* inim/2011: New directory.
* inim/2009: New directory.
* inim/ocr,
* inim/classif,
* inim/binarization,
* inim/color,
* inim/nature:
Move to...
* inim/2009/ocr,
* inim/2009/classif,
* inim/2009/binarization,
* inim/2009/color,
* inim/2009/nature: ...these new directories.
* inim/ocr/resize.hh,
* inim/ocr/ocr_without_preprocess.cc,
* inim/ocr/skeleton.old.hh,
* inim/ocr/simple_point.hh,
* inim/ocr/skeleton.hh,
* inim/ocr/check_simple_point.cc,
* inim/ocr/compute_local_configurations.cc,
* inim/ocr/tesseract_wrap.hh,
* inim/ocr/skeleton.old.cc,
* inim/ocr/check.sh,
* inim/ocr/simple_point.cc,
* inim/ocr/ocr_with_preprocess.cc,
* inim/ocr/enlarge.hh,
* inim/ocr/Makefile,
* inim/classif/plotscript,
* inim/classif/src,
* inim/classif/src/max_tree.hh,
* inim/classif/src/display.hh,
* inim/classif/src/iccvg04.cc,
* inim/classif/src/proj.hh,
* inim/classif/src/v2.cc,
* inim/classif/Makefile,
* inim/binarization/proof-of-concept,
* inim/binarization/proof-of-concept/build,
* inim/binarization/proof-of-concept/build/configure.in,
* inim/binarization/proof-of-concept/build/Makefile,
* inim/binarization/proof-of-concept/configure,
* inim/binarization/proof-of-concept/configure.in,
* inim/binarization/proof-of-concept/scripts,
* inim/binarization/proof-of-concept/scripts/init_tar.sh,
* inim/binarization/proof-of-concept/scripts/flower,
* inim/binarization/proof-of-concept/scripts/todo.sh,
* inim/binarization/proof-of-concept/src,
* inim/binarization/proof-of-concept/src/gradient.cc,
* inim/binarization/proof-of-concept/src/util.hxx,
* inim/binarization/proof-of-concept/src/basic.cc,
* inim/binarization/proof-of-concept/src/snake2d.hh,
* inim/binarization/proof-of-concept/ChangeLog,
* inim/binarization/proof-of-concept/check,
* inim/binarization/proof-of-concept/check/graph.sh,
* inim/binarization/proof-of-concept/check/histo.gp,
* inim/binarization/proof-of-concept/check/Makefile,
* inim/binarization/proof-of-concept/Makefile,
* inim/binarization/snake2d.hh,
* inim/binarization/binarization.hh,
* inim/binarization/snake2d.cc,
* inim/binarization/binarization.cc,
* inim/color/min_tree_volume_filter.cc,
* inim/color/reference.cc,
* inim/color/min_tree_area_filter.cc,
* inim/color/min_tree_height_filter.cc,
* inim/color/min_tree_color.cc,
* inim/color/reference2.cc,
* inim/color/src,
* inim/color/src/graph.hh,
* inim/color/src/io.hh,
* inim/color/src/distance.hh,
* inim/color/src/convert.hh,
* inim/color/min_tree_color_v2.cc,
* inim/color/laplacien.cc,
* inim/color/README,
* inim/nature/gradient.cc,
* inim/nature/erosion.cc,
* inim/nature/mco.cc,
* inim/nature/closing.cc,
* inim/nature/nature.cc,
* inim/nature/opening.cc,
* inim/nature/fft.cc,
* inim/nature/co_occurence.hh,
* inim/nature/hom.cc,
* inim/nature/proj.hh,
* inim/nature/test.sh,
* inim/nature/Makefile,
* inim/nature/histo_hsi.cc,
* inim/nature/proj.cc: Respectively move...
* inim/2009/ocr,
* inim/2009/classif,
* inim/2009/binarization,
* inim/2009/color,
* inim/2009/nature: ...here.
binarization/binarization.cc | 36 -
binarization/binarization.hh | 78 --
binarization/proof-of-concept/ChangeLog | 69 --
binarization/proof-of-concept/Makefile | 87 ---
binarization/proof-of-concept/build/Makefile | 79 --
binarization/proof-of-concept/build/configure.in | 5
binarization/proof-of-concept/check/Makefile | 71 --
binarization/proof-of-concept/check/graph.sh | 27
binarization/proof-of-concept/check/histo.gp | 19
binarization/proof-of-concept/configure | 264 ---------
binarization/proof-of-concept/configure.in | 26
binarization/proof-of-concept/scripts/flower | 33 -
binarization/proof-of-concept/scripts/init_tar.sh | 14
binarization/proof-of-concept/scripts/todo.sh | 26
binarization/proof-of-concept/src/basic.cc | 75 --
binarization/proof-of-concept/src/gradient.cc | 109 ---
binarization/proof-of-concept/src/snake2d.hh | 190 ------
binarization/proof-of-concept/src/util.hxx | 97 ---
binarization/snake2d.cc | 39 -
binarization/snake2d.hh | 190 ------
classif/Makefile | 87 ---
classif/plotscript | 4
classif/src/display.hh | 80 --
classif/src/iccvg04.cc | 171 ------
classif/src/max_tree.hh | 312 -----------
classif/src/proj.hh | 139 ----
classif/src/v2.cc | 178 ------
color/README | 83 --
color/laplacien.cc | 130 ----
color/min_tree_area_filter.cc | 515 ------------------
color/min_tree_color.cc | 536 -------------------
color/min_tree_color_v2.cc | 533 -------------------
color/min_tree_height_filter.cc | 553 -------------------
color/min_tree_volume_filter.cc | 551 -------------------
color/reference.cc | 557 --------------------
color/reference2.cc | 408 --------------
color/src/convert.hh | 37 -
color/src/distance.hh | 52 -
color/src/graph.hh | 62 --
color/src/io.hh | 57 --
nature/Makefile | 24
nature/closing.cc | 61 --
nature/co_occurence.hh | 77 --
nature/erosion.cc | 60 --
nature/fft.cc | 61 --
nature/gradient.cc | 60 --
nature/histo_hsi.cc | 181 ------
nature/hom.cc | 316 -----------
nature/mco.cc | 48 -
nature/nature.cc | 499 -----------------
nature/opening.cc | 61 --
nature/proj.cc | 68 --
nature/proj.hh | 64 --
nature/test.sh | 11
ocr/Makefile | 26
ocr/check.sh | 31 -
ocr/check_simple_point.cc | 61 --
ocr/compute_local_configurations.cc | 74 --
ocr/enlarge.hh | 202 -------
ocr/ocr_with_preprocess.cc | 170 ------
ocr/ocr_without_preprocess.cc | 90 ---
ocr/resize.hh | 96 ---
ocr/simple_point.cc | 39 -
ocr/simple_point.hh | 206 -------
ocr/skeleton.hh | 200 -------
ocr/skeleton.old.cc | 30 -
ocr/skeleton.old.hh | 612 ----------------------
ocr/tesseract_wrap.hh | 91 ---
68 files changed, 10098 deletions(-)
Index: inim/ocr/resize.hh
--- inim/ocr/resize.hh (revision 3756)
+++ inim/ocr/resize.hh (working copy)
@@ -1,96 +0,0 @@
-// Copyright (C) 2008 EPITA Research and Development Laboratory
-//
-// This file is part of the Olena Library. This library is free
-// software; you can redistribute it and/or modify it under the terms
-// of the GNU General Public License version 2 as published by the
-// Free Software Foundation.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this library; see the file COPYING. If not, write to
-// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
-// Boston, MA 02111-1307, USA.
-//
-// As a special exception, you may use this file as part of a free
-// software library without restriction. Specifically, if other files
-// instantiate templates or use macros or inline functions from this
-// file, or you compile this file and link it with other files to
-// produce an executable, this file does not by itself cause the
-// resulting executable to be covered by the GNU General Public
-// License. This exception does not however invalidate any other
-// reasons why the executable file might be covered by the GNU General
-// Public License.
-
-#ifndef MLN_GEOM_RESIZE_HH
-# define MLN_GEOM_RESIZE_HH
-
-# include <mln/win/rectangle2d.hh>
-
-namespace mln
-{
-
- namespace geom
- {
-
-
- /*!
- * \brief Resize an image \p input_ with \p ratio.
- *
- * \param[in] input_ The image to resize.
- * \param[in] ratio The ratio of the resize image.
- *
- * \pre \p input_ has to be initialized.
- * \pre \p ratio >= 1.
- *
- * \return The resized image.
- */
- template <typename I>
- mln_concrete(I)
- resize(const Image<I>& input_, const unsigned ratio);
-
-# ifndef MLN_INCLUDE_ONLY
-
-
- template <typename I>
- mln_concrete(I)
- resize(const Image<I>& input_, const unsigned ratio)
- {
- trace::entering("mln::geom::resize");
-
- typedef mln_concrete(I) O;
-
- const I input = exact (input_);
-
- std::size_t rows = input.domain().len(0);
- std::size_t cols = input.domain().len(1);
- std::size_t new_rows = ratio * rows;
- std::size_t new_cols = ratio * cols;
-
- O output(new_rows, new_cols);
-
- mln_piter(O) p(output.domain());
-
- for_all(p)
- {
- output(p) = input(point2d(p[0] / ratio, p[1] / ratio)) ? 255 : 0;
- }
-
- trace::exiting("mln::geom::resize");
- return output;
-
- }
-
-# endif // ! MLN_INCLUDE_ONLY
-
-
- } // end of namespace mln::geom
-
-} // end of namespace mln
-
-
-
-#endif // ! MLN_GEOM_RESIZE_HH
Index: inim/ocr/ocr_without_preprocess.cc
--- inim/ocr/ocr_without_preprocess.cc (revision 3756)
+++ inim/ocr/ocr_without_preprocess.cc (working copy)
@@ -1,90 +0,0 @@
-// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
-//
-// This file is part of the Olena Library. This library is free
-// software; you can redistribute it and/or modify it under the terms
-// of the GNU General Public License version 2 as published by the
-// Free Software Foundation.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this library; see the file COPYING. If not, write to
-// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
-// Boston, MA 02111-1307, USA.
-//
-// As a special exception, you may use this file as part of a free
-// software library without restriction. Specifically, if other files
-// instantiate templates or use macros or inline functions from this
-// file, or you compile this file and link it with other files to
-// produce an executable, this file does not by itself cause the
-// resulting executable to be covered by the GNU General Public
-// License. This exception does not however invalidate any other
-// reasons why the executable file might be covered by the GNU General
-// Public License.
-
-#include <iostream>
-
-#include <mln/core/image/image2d.hh>
-#include <mln/core/alias/window2d.hh>
-#include <mln/core/alias/neighb2d.hh>
-
-#include <mln/core/image/cast_image.hh>
-
-#include <mln/value/int_u8.hh>
-
-#include "resize.hh"
-#include "enlarge.hh"
-//#include "skeleton.hh"
-#include <mln/linear/gaussian.hh>
-
-#include <mln/trace/all.hh>
-#include <mln/io/pgm/load.hh>
-#include <mln/io/pgm/save.hh>
-#include <mln/io/pbm/load.hh>
-#include <mln/io/pbm/save.hh>
-#include <mln/core/alias/w_window2d_float.hh>
-
-#include <mln/debug/println.hh>
-#include <mln/geom/chamfer.hh>
-#include <mln/make/win_chamfer.hh>
-#include <mln/labeling/regional_maxima.hh>
-#include <mln/morpho/dilation.hh>
-
-#include "tesseract_wrap.hh"
-
-// _COMPILATION_
-// g++ -DNDEBUG -O3 -I../../.. ocr.cc -L/usr/lib -ltesseract_full -lpthread
-
-
-// Call tesseract
-// lang: expected language
-
-int main(int argc, char** argv)
-{
- using namespace mln;
- using value::int_u8;
-
- image2d<bool> input;
-
- if (argc < 2)
- {
- std::cerr << "Usage: " << argv[0] << " in.pbm" << std::endl;
- return 1;
- }
-
- mln::border::thickness = 0;
-
- io::pbm::load(input, argv[1]);
-
- {
- image2d<int_u8> tmp = duplicate(cast_image<int_u8>(input));
- float score = 0;
- char* s = tesseract("fra", tmp, &score);
- std::cerr << "Tesseract result: (score " << score << ")" << std::endl;
- std::cout << s;
- delete[] s;
- }
-}
Index: inim/ocr/skeleton.old.hh
--- inim/ocr/skeleton.old.hh (revision 3756)
+++ inim/ocr/skeleton.old.hh (working copy)
@@ -1,612 +0,0 @@
-// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
-//
-// This file is part of the Olena Library. This library is free
-// software; you can redistribute it and/or modify it under the terms
-// of the GNU General Public License version 2 as published by the
-// Free Software Foundation.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this library; see the file COPYING. If not, write to
-// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
-// Boston, MA 02111-1307, USA.
-//
-// As a special exception, you may use this file as part of a free
-// software library without restriction. Specifically, if other files
-// instantiate templates or use macros or inline functions from this
-// file, or you compile this file and link it with other files to
-// produce an executable, this file does not by itself cause the
-// resulting executable to be covered by the GNU General Public
-// License. This exception does not however invalidate any other
-// reasons why the executable file might be covered by the GNU General
-// Public License.
-#ifndef SKELETON_HH
-# define SKELETON_HH
-
-#include <mln/core/image/image2d.hh>
-#include <mln/core/alias/neighb2d.hh>
-#include <sandbox/aroumougame/skeleton/sedt.hh>
-
-#include <mln/core/site_set/p_set.hh>
-#include <mln/math/sqrt.hh>
-#include <mln/opt/at.hh>
-
-namespace mln
-{
-
-
-template <typename P>
- std::vector< std::pair< double, P > > remove(std::vector< std::pair< double, P > > Q, P p)
-{
- typename std::vector<std::pair< double, P > >::iterator it;
-
- for(it = Q.begin(); it!=Q.end(); it++)
- {
- if((*it).second==p)
- {
- it = Q.erase(it);
- break;
- }
- }
- return Q;
-}
-template <typename N>
- double distance(N a, N b, N c, N d)
-{
- double dist = sqrt((a-c)*(a-c)+(b-d)*(b-d));
- return dist;
-}
-template <typename P>
- std::vector< std::pair< double, P > > insertDicho(std::vector< std::pair< double, P > > Q, std::pair< double, P> p)
-{
- int indMin, indMax, indMid;
-
- indMin = 0;
- indMax = Q.size();
-
- if(indMax==0 || Q[indMax-1].first <= p.first)
- Q.push_back(p);
- else
- {
- while(indMax > indMin)
- {
- indMid = int(indMin + (indMax-indMin)/2);
- if(Q[indMid].first < p.first)
- {
- indMin = indMid+1;
- if(Q[indMin].first > p.first)
- {
- indMax = indMid;
- }
- }
- else
- {
- indMax = indMid-1;
- if(Q[indMax].first < p.first)
- {
- indMin = indMid;
- }
- }
- }
-
- typename std::vector< std::pair< double, P > >::iterator it=Q.begin();
- it = Q.insert ( it+indMin, p);
- }
-
- return Q;
-}
-
-
-const neighb2d& complement_neighborhood(const Neighborhood<neighb2d>& nbh)
-{
- if(&nbh == &c4())
- return c8();
- return c4();
-}
-
-template <typename N>
- int nb_composant_connexe(p_set< mln_psite(N) > X_full,const Neighborhood<N>& nbh_,const mln_psite(N)& p_ref, bool local)
-{
- N nbh = exact(nbh_);
- p_set< mln_psite(N) > X;
- if(local)
- {
- mln_niter(N) n(max_neighborhood(nbh), p_ref);
-
- for_all(n)
- {
- if (X_full.has(n))
- X.insert(n);
- }
- }
- else
- {
- X = X_full;
- }
-
- int T;
- p_set< mln_psite(N) > done;
- p_set< mln_psite(N) > neighbors;
- p_set< mln_psite(N) > composant;
-
- done.insert(p_ref);
- mln_niter(N) q(nbh, p_ref);
- for_all(q)
- {
- if (X.has(q)&&!done.has(q))
- {
- neighbors.insert(q);
- }
- }
-// std::cout << "nb_composant_connexe: neighbors " << neighbors.nsites() <<std::endl;
- if(neighbors.nsites()<=1)
- {
- return neighbors.nsites();
- }
- else
- T=0;
-
- while(neighbors.nsites()!=0)
- {
- T++;
- done.insert(neighbors[0]);
- mln_niter(N) t(nbh, neighbors[0]);
- neighbors.remove(neighbors[0]);
- for_all(t)
- {
- if (X.has(t)&&!done.has(t))
- {
- composant.insert(t);
- }
- }
-
- while(composant.nsites()!=0)
- {
- done.insert(composant[0]);
- if(neighbors.has(composant[0]))
- {
- neighbors.remove(composant[0]);
- if(neighbors.nsites()==0)
- return T;
- }
-
- mln_niter(N) r(nbh, composant[0]);
- composant.remove(composant[0]);
- for_all(r)
- {
- if (X.has(r) && !done.has(r))
- {
- composant.insert(r);
- }
- }
- }
- }
- return T;
-}
-
-template <typename N>
- bool simple_point(p_set< mln_psite(N) > X,const Neighborhood<N>& nbh, p_set< mln_psite(N) > X_complement, const mln_psite(N)& p_ref, bool local)
-{
- int nX = nb_composant_connexe(X,exact(nbh),p_ref,local);
- int nX_complement = nb_composant_connexe(X_complement,complement_neighborhood(exact(nbh)),p_ref,local);
-
- if((nX_complement == 1)&&(nX == 1))
- return true;
- return false;
-}
-
-
- template <typename N>
- p_set<mln_psite(N)> euclideanSkeleton(p_set<mln_psite(N)> X, p_set<mln_psite(N)> X_complement, image2d<value::int_u8> dt, p_set<mln_psite(N)>& Y, const Neighborhood<N>& nbh_, bool local)
- {
- std::vector< std::pair< double, mln::point2d> > Q;
- std::vector< std::pair< double, mln::point2d> > R;
- N nbh = exact(nbh_);
-
- // fill Q
- for (uint i = 0; i < X.nsites(); i++)
- {
- if (!Y.has(X[i]))
- {
- std::pair<double, mln_psite(N)> p(math::sqrt(double(dt(X[i]))),X[i]);
- Q = insertDicho(Q,p);
- }
- }
-
- // fill R
- for (uint i = 0; i < X.nsites(); i++)
- {
- if (!Y.has(X[i]))
- {
- double min = 1023.99;
- mln_niter(N) r(nbh, X[i]);
- for_all(r)
- {
- if (Y.has(r))
- {
- double tmp = distance(r[0], r[1], X[i][0], X[i][1]);
- double d = math::sqrt(double(dt(r)))+(math::sqrt(double(dt(X[i])))-math::sqrt(double(dt(r))))/tmp;
- min = math::min(min,d);
- }
- }
- if (min!=1023.99)
- {
- std::pair<double, mln_psite(N)> p(min,X[i]);
- R = insertDicho(R, p);
- }
- }
- }
-
- while (!Q.empty() || !R.empty())
- {
- mln_psite(N) tmp;
- if (Q[0].first < R[0].first)
- {
- tmp = Q[0].second;
- }
- else
- {
- tmp = R[0].second;
- }
-
- Q = remove(Q, tmp);
- R = remove(R, tmp);
-
- if (!Y.has(tmp) && X.has(tmp))
- {
- if (simple_point(X, nbh, X_complement, tmp, local))
- {
- X.remove(tmp);
- X_complement.insert(tmp);
- }
- else
- {
- Y.insert(tmp);
- mln_niter(N) r(nbh, tmp);
- for_all(r)
- {
- if (!Y.has(r) && X.has(r))
- {
- double dist = distance(r[0], r[1], tmp[0], tmp[1]);
- double d = math::sqrt(double(dt(tmp)))+(math::sqrt(double(dt(r)))-math::sqrt(double(dt(tmp))))/dist;
- std::pair<double, mln_psite(N)> p(d,r);
- R = insertDicho(R, p);
- }
- }
-
- }
- }
-
- }
- return X;
- }
-
-
- p_set<point2d> EP(image2d<value::int_u8> dt, point2d x, std::vector< std::vector<std::pair< int, int> > > lut, const neighb2d& nbh)
- {
- p_set<point2d> EP;
- p_set<point2d> tmp;
- int w = geom::ncols(dt);
- int h = geom::nrows(dt);
-
-
- mln_niter_(neighb2d) r(nbh, x);
- for_all(r)
- {
- if (dt(r) <= dt(x))
- {
- for (uint i=0; i<lut[dt(r)].size(); i++)
- {
- if ((r[0]+lut[dt(r)][i].first < h) && (r[1]+lut[dt(r)][i].second < w))
- {
- if (!dt(r+dpoint2d(lut[dt(r)][i].first, lut[dt(r)][i].second)))
- EP.insert(r+dpoint2d(lut[dt(r)][i].first, lut[dt(r)][i].second));
- }
- if ((r[0]-lut[dt(r)][i].first >= 0) && (r[1]-lut[dt(r)][i].second >= 0))
- {
- if (!dt(r+dpoint2d(-lut[dt(r)][i].first, -lut[dt(r)][i].second)))
- EP.insert(r+dpoint2d(-lut[dt(r)][i].first, -lut[dt(r)][i].second));
- }
- if ((r[0]+lut[dt(r)][i].first < h) && (r[1]-lut[dt(r)][i].second >= 0))
- {
- if (!dt(r+dpoint2d(lut[dt(r)][i].first, -lut[dt(r)][i].second)))
- EP.insert(r+dpoint2d(lut[dt(r)][i].first, -lut[dt(r)][i].second));
- }
- if ((r[0]-lut[dt(r)][i].first >= 0) && (r[1]+lut[dt(r)][i].second < w))
- {
- if (!dt(r+dpoint2d(-lut[dt(r)][i].first, lut[dt(r)][i].second)))
- EP.insert(r+dpoint2d(-lut[dt(r)][i].first, lut[dt(r)][i].second));
- }
- if ((r[0]+lut[dt(r)][i].second < h) && (r[1]+lut[dt(r)][i].first < w))
- {
- if (!dt(r+dpoint2d(lut[dt(r)][i].second, lut[dt(r)][i].first)))
- EP.insert(r+dpoint2d(lut[dt(r)][i].second, lut[dt(r)][i].first));
- }
- if ((r[0]-lut[dt(r)][i].second >= 0) && (r[1]-lut[dt(r)][i].first >= 0))
- {
- if (!dt(r+dpoint2d(-lut[dt(r)][i].second, -lut[dt(r)][i].first)))
- EP.insert(r+dpoint2d(-lut[dt(r)][i].second, -lut[dt(r)][i].first));
- }
- if ((r[0]+lut[dt(r)][i].second < h) && (r[1]-lut[dt(r)][i].first >= 0))
- {
- if (!dt(r+dpoint2d(lut[dt(r)][i].second, -lut[dt(r)][i].first)))
- EP.insert(r+dpoint2d(lut[dt(r)][i].second, -lut[dt(r)][i].first));
- }
- if ((r[0]-lut[dt(r)][i].second >= 0) && (r[1]+lut[dt(r)][i].first < w))
- {
- if (!dt(r+dpoint2d(-lut[dt(r)][i].second, lut[dt(r)][i].first)))
- EP.insert(r+dpoint2d(-lut[dt(r)][i].second, lut[dt(r)][i].first));
- }
- }
- }
- }
-
- return EP;
- }
-
- std::vector< std::vector<std::pair< int, int> > > Lut2d(int N)
- {
- int n = int(sqrt(N))+1;
- int i=0;
- std::vector< std::vector<std::pair< int, int> > > lut;
-
- for(i = 0; i <= N; i++)
- {
- std::vector<std::pair< int, int> > vect;
- lut.push_back(vect);
- }
-
- for(int x = 0; x <= n; x++)
- {
- for(int y = 0; y <= x; y++)
- {
- i=x*x+y*y;
- if(i<=N)
- {
- std::pair<int,int> p(x,y);
- lut[i].push_back(p);
- }
- }
- }
-
- return lut;
-}
-
- image2d<value::int_u8> DiscreteBisector(image2d<value::int_u8> dt, p_set<point2d> Y, const neighb2d& nbh, int N)
- {
- int w = geom::ncols(dt);
- int h = geom::nrows(dt);
-
- int ux,uy,vx,vy, produit, angle, max;
- double cos, normu, normv;
-
- std::vector< std::vector<std::pair< int, int> > > lut;
- lut = Lut2d(N);
-
- p_set<point2d> proj;
-
- image2d<value::int_u8> bisector(h, w);
- data::fill(bisector, 0);
-
- for (uint i=0; i<Y.nsites(); i++)
- {
- proj = EP(dt, Y[i], lut, nbh);
-
- int n=proj.nsites();
-
- if (n>1)
- {
- max = 0;
- for (int y=0; y<n; y++)
- {
- for (int z=0; z<y; z++)
- {
- ux = proj[y][0]-Y[i][0];
- uy = proj[y][1]-Y[i][1];
- vx = proj[z][0]-Y[i][0];
- vy = proj[z][1]-Y[i][1];
-
- produit = ux * vx + uy * vy;
-
- normu = sqrt(ux*ux + uy*uy);
- normv = sqrt(vx*vx + vy*vy);
-
- cos = produit/(normu*normv);
- angle = int(acos(cos)*180.0/3.1415);
-
- max = math::max(max, angle);
- }
- }
- bisector(Y[i]) = max;
- }
-
- }
-
- return bisector;
-
- }
-
-
-
-const neighb2d& max_neighborhood(const Neighborhood<neighb2d>& nbh)
-{
- return c8();
-}
-template <typename N>
- p_set<mln_psite(N)> ultimateSkeleton(p_set<mln_psite(N)> X, p_set<mln_psite(N)> X_complement, image2d<value::int_u8> dt, p_set<mln_psite(N)> Y, const Neighborhood<N>& nbh_, bool local)
-{
- std::vector< std::pair< double, mln::point2d> > Q;
-
- N nbh = exact(nbh_);
- // fill Q
- for(uint i = 0; i < X.nsites(); i++)
- {
- if (!Y.has(X[i]))
- {
- std::pair<double, mln_psite(N)> p(dt(X[i]),X[i]);
- Q = insertDicho(Q,p);
- }
- }
-
-
- while(!Q.empty())
- {
- mln_psite(N) tmp = Q[0].second;
-
- Q = remove(Q, tmp);
-
- if(simple_point(X, nbh, X_complement, tmp, local))
- {
- X.remove(tmp);
- X_complement.insert(tmp);
- mln_niter(N) r(nbh, tmp);
- for_all(r)
- {
- if(!Y.has(r) && X.has(r))
- {
- std::pair<double, mln_psite(N)> p(dt(r),r);
- Q = insertDicho(Q, p);
- }
- }
- }
-
- }
- return X;
-}
-
- image2d<value::int_u8> intImage(image2d<bool> pic)
-{
- int w = geom::ncols(pic);
- int h = geom::nrows(pic);
-
- image2d<value::int_u8> out(h,w);
- for(int i=0; i<w; i++)
- for(int j=0; j<h; j++)
- {
- if(opt::at(pic, j,i))
- opt::at(out, j,i) = 1;
- else
- opt::at(out, j,i) = 0;
- }
- return out;
-}
- image2d<bool> filteredSkeleton(image2d<bool> pic, const neighb2d& nbh, uint r, uint alpha, bool local)
- {
- using value::int_u8;
-
- typedef image2d<bool> I;
- typedef p_set<point2d> S;
-
- image2d<value::int_u8> pic1 = intImage(pic);
- image2d<value::int_u8> dt = sedt(pic1);
-
- mln::io::pgm::save(dt, "dt.pgm");
-
- int w = geom::ncols(pic);
- int h = geom::nrows(pic);
- int l= math::min(w, h);
- uint rmax = getRMax(dt);
- uint rknown = 0;
- p_set<point2d> X,Y,Z;
- p_set<point2d> X_complement, Z_complement;
-
- image2d<value::int_u8> DTg(l,l,0);
- std::vector< std::vector<int> > Mgl;
- std::vector< std::vector<int> > Lut;
-
- Mgl = CompLutMask (DTg,Mgl,Lut,l,0,rmax);
-
- rknown =rmax;
-
- mln_fwd_piter_(image2d<bool>) p(pic.domain());
-
- for_all(p)
- {
- if (pic(p)==1)
- {
- X.insert(p);
- }
- else
- {
- X_complement.insert(p);
- }
- }
- std::cout << " medial axis " << std::endl;
- pic = MA(pic, Mgl, dt, Lut);
-
- mln::io::pbm::save(pic, "ma.pbm");
-
- for_all(p)
- {
- if (pic(p)==1)
- {
- Y.insert(p);
- }
- }
-
- std::cout << " euclidean skeleton " << std::endl;
- Z = euclideanSkeleton(X, X_complement, dt, Y, nbh, local);
-
- sub_image<I, S> es = pic | Z;
- I es1(pic.domain());
- data::fill(es1, false);
-
- data::paste(es, es1);
-
- mln::io::pbm::save(es1, "euclidean.pbm");
-
- for_all(p)
- {
- if (!Z.has(p))
- {
- Z_complement.insert(p);
- }
- }
- std::cout << " discrete bisector " << std::endl;
- pic1 = DiscreteBisector(dt, Y, nbh, rmax);
-
-
- mln::io::pgm::save(pic1, "bisector.pgm");
-
- uint cpt=0;
- while (cpt!=Y.nsites())
- {
- if (dt(Y[cpt])>=r && pic1(Y[cpt])>=alpha)
- {
- cpt++;
- }
- else
- {
- Y.remove(Y[cpt]);
- }
- }
-
-
- sub_image<I, S> skel = pic | Y;
- I test(pic.domain());
- data::fill(test, false);
-
- data::paste(skel, test);
-
- mln::io::pbm::save(test, "Y.pbm");
-
- std::cout << " ultimate skeleton " << std::endl;
- Z = ultimateSkeleton(Z, Z_complement, dt, Y, nbh, local);
-
-
-
- sub_image<I, S> skeleton = pic | Z;
- I output(pic.domain());
- data::fill(output, false);
-
- data::paste(skeleton, output);
-
- return output;
- }
-
-} // End of namespace mln
-#endif // ! SKELETON_HH
Index: inim/ocr/simple_point.hh
--- inim/ocr/simple_point.hh (revision 3756)
+++ inim/ocr/simple_point.hh (working copy)
@@ -1,206 +0,0 @@
-// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
-//
-// This file is part of the Olena Library. This library is free
-// software; you can redistribute it and/or modify it under the terms
-// of the GNU General Public License version 2 as published by the
-// Free Software Foundation.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this library; see the file COPYING. If not, write to
-// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
-// Boston, MA 02111-1307, USA.
-//
-// As a special exception, you may use this file as part of a free
-// software library without restriction. Specifically, if other files
-// instantiate templates or use macros or inline functions from this
-// file, or you compile this file and link it with other files to
-// produce an executable, this file does not by itself cause the
-// resulting executable to be covered by the GNU General Public
-// License. This exception does not however invalidate any other
-// reasons why the executable file might be covered by the GNU General
-// Public License.
-
-#ifndef MLN_SIMPLE_POINT_HH
-# define MLN_SIMPLE_POINT_HH
-
-/*! \file simple_point.hh
- *
- * \brief is_simple_point tell if a point is simple or not (Cf
- * bertrand.07.chap).
- *
- */
-
-#include <mln/core/alias/point2d.hh>
-#include <mln/core/image/image2d.hh>
-#include <mln/core/alias/neighb2d.hh>
-
-namespace mln
-{
-
-/*! Tell if a point is simple or not. A point of an object is simple
- * if in its c8 neiborhood, there is exactly one connected component of the
- * object, and only one connected component of the background
- * Examples : ( | == object, - = background)
- *
- * - - |
- * | P | Here p is simple in the c4 and c8 case.
- * | | |
- *
- * - | -
- * | P | Here p is never simple.
- * | | |
- *
- */
-
- 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] =
- {
- 0, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 2, 2, 1, 1,
- 1, 2, 1, 1, 1, 2, 1, 1, 2, 2, 1, 1, 2, 2, 1, 1,
- 1, 2, 2, 2, 2, 3, 2, 2, 1, 1, 1, 1, 2, 2, 1, 1,
- 2, 3, 2, 2, 2, 3, 2, 2, 2, 2, 1, 1, 2, 2, 1, 1,
-
- 1, 2, 2, 2, 2, 3, 2, 2, 1, 1, 1, 1, 2, 2, 1, 1,
- 1, 2, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 2, 2, 2, 2, 3, 2, 2, 1, 1, 1, 1, 2, 2, 1, 1,
- 1, 2, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
-
- 1, 2, 2, 2, 2, 3, 2, 2, 2, 2, 2, 2, 3, 3, 2, 2,
- 1, 2, 1, 1, 1, 2, 1, 1, 2, 2, 1, 1, 2, 2, 1, 1,
- 2, 3, 3, 3, 3, 4, 3, 3, 2, 2, 2, 2, 3, 3, 2, 2,
- 2, 3, 2, 2, 2, 3, 2, 2, 2, 2, 1, 1, 2, 2, 1, 1,
-
- 1, 2, 2, 2, 2, 3, 2, 2, 1, 1, 1, 1, 2, 2, 1, 1,
- 1, 2, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 2, 2, 2, 2, 3, 2, 2, 1, 1, 1, 1, 2, 2, 1, 1,
- 1, 2, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
- };
-
- static const unsigned char nb_connexity_c4[256] =
- {
- 0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 2, 1, 1, 1, 2, 1,
- 1, 1, 2, 2, 1, 1, 1, 1, 2, 2, 3, 2, 2, 2, 2, 1,
- 0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 2, 1, 1, 1, 2, 1,
- 1, 1, 2, 2, 1, 1, 1, 1, 2, 2, 3, 2, 2, 2, 2, 1,
-
- 1, 1, 2, 2, 1, 1, 2, 2, 2, 2, 3, 2, 2, 2, 3, 2,
- 2, 2, 3, 3, 2, 2, 2, 2, 3, 3, 4, 3, 3, 3, 3, 2,
- 1, 1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 1, 1, 1, 2, 1,
- 2, 2, 3, 3, 2, 2, 2, 2, 2, 2, 3, 2, 2, 2, 2, 1,
-
- 0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 2, 1, 1, 1, 2, 1,
- 1, 1, 2, 2, 1, 1, 1, 1, 2, 2, 3, 2, 2, 2, 2, 1,
- 0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 2, 1, 1, 1, 2, 1,
- 1, 1, 2, 2, 1, 1, 1, 1, 2, 2, 3, 2, 2, 2, 2, 1,
-
- 1, 1, 2, 2, 1, 1, 2, 2, 2, 2, 3, 2, 2, 2, 3, 2,
- 1, 1, 2, 2, 1, 1, 1, 1, 2, 2, 3, 2, 2, 2, 2, 1,
- 1, 1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 1, 1, 1, 2, 1,
- 1, 1, 2, 2, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1
- };
-
- neighb2d int_to_neighb(unsigned i)
- {
- if (i == 8)
- return c8();
- if (i == 4)
- return c4();
- mln_assertion(0);
- return c4();
- }
-
- unsigned complement_neighb(unsigned i)
- {
- if (i == 8)
- return 4;
- if (i == 4)
- return 8;
- mln_assertion(0);
- return 0;
- }
-
- unsigned nb_connexity2d(const image2d<bool>& ima, unsigned nbh, const point2d& p, bool object)
- {
- unsigned res = 0;
-
- mln_bkd_niter_(neighb2d) n(c8() , p);
- for_all(n)
- {
- res = (res << 1);
- if (ima.domain().has(n) && ima(n) == object)
- res = res | 1;
- }
-
- if (nbh == 8)
- return nb_connexity_c8[res];
- else
- {
- mln_assertion(nbh == 4);
- return nb_connexity_c4[res];
- }
- }
-
- bool is_curve_extremum(const image2d<bool>& ima, unsigned nbh_i, const point2d& p_, unsigned deep)
- {
-// return false;
- unsigned cpt = 0;
- mln_site_(image2d<bool>) next = p_;
- mln_site_(image2d<bool>) p = next;
- mln_niter_(neighb2d) n(int_to_neighb(nbh_i) , p);
-
- p = next;
- for_all(n)
- {
- if (ima.domain().has(n) && ima(n) == true)
- {
- next = n;
- cpt++;
- }
- }
- if (cpt != 1)
- return false;
-
- for (unsigned i = 0; i < deep - 1; i++)
- {
- cpt = 0;
- p = next;
- for_all(n)
- {
- if (ima.domain().has(n) && ima(n) == true)
- {
- next = n;
- cpt++;
- }
- }
- if (cpt != 2)
- return false;
- }
-
- return true;
- }
-
- 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);
- }
-
-# endif // MLN_INCLUDE_ONLY
-
-} // end of namespace mln
-
-#endif // ! MLN_SIMPLE_POINT_HH
Index: inim/ocr/skeleton.hh
--- inim/ocr/skeleton.hh (revision 3756)
+++ inim/ocr/skeleton.hh (working copy)
@@ -1,200 +0,0 @@
-// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
-//
-// This file is part of the Olena Library. This library is free
-// software; you can redistribute it and/or modify it under the terms
-// of the GNU General Public License version 2 as published by the
-// Free Software Foundation.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this library; see the file COPYING. If not, write to
-// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
-// Boston, MA 02111-1307, USA.
-//
-// As a special exception, you may use this file as part of a free
-// software library without restriction. Specifically, if other files
-// instantiate templates or use macros or inline functions from this
-// file, or you compile this file and link it with other files to
-// produce an executable, this file does not by itself cause the
-// resulting executable to be covered by the GNU General Public
-// License. This exception does not however invalidate any other
-// reasons why the executable file might be covered by the GNU General
-// Public License.
-
-#ifndef MLN_SKELETON_HH
-# define MLN_SKELETON_HH
-
-# include <iomanip>
-# include <iostream>
-# include <sstream>
-
-# include <mln/core/var.hh>
-
-# include <mln/core/image/image2d.hh>
-# include <mln/core/image/cast_image.hh>
-# include <mln/core/alias/neighb2d.hh>
-# include <mln/core/site_set/p_queue_fast.hh>
-# include <mln/core/site_set/p_priority.hh>
-
-# include <mln/value/int_u8.hh>
-# include <mln/arith/revert.hh>
-# include <mln/transform/distance.hh>
-
-# include <mln/make/w_window2d_int.hh>
-
-# include <mln/data/fill.hh>
-
-# include <mln/debug/println.hh>
-
-# include <mln/logical/not.hh>
-
-# include "simple_point.hh"
-
-#include <mln/make/w_window2d_int.hh>
-
-# include <mln/io/pgm/save.hh>
-# include <mln/io/pbm/save.hh>
-
-namespace mln
-{
-
- template <typename V>
- void save_state(const image2d<V>& ima)
- {
- static int id = 0;
- std::stringstream filename;
-
- std::cout << id << std::endl;
- filename << "skel_trace_" << std::setw(5) << std::setfill('0')
- << std::right << id++ << ".ppm";
-
- io::pbm::save(ima, filename.str());
- }
-
- image2d<bool> crest(const image2d<bool>& input,
- const image2d<value::int_u8>& dist_map,
- const neighb2d& nbh)
- {
- image2d<bool> is_crest;
- initialize(is_crest, input);
- data::fill(is_crest, false);
-
- mln_piter_(image2d<bool>) p(input.domain());
- mln_niter_(neighb2d) n(nbh, p);
- for_all(p)
- {
- if (!input(p) || dist_map(p) < 0)
- continue;
-
- unsigned nb_eq = 0;
- unsigned nb_gt = 0;
- unsigned nb_lt = 0;
- for_all(n)
- if (input.domain().has(n))
- {
- if (dist_map(n) == dist_map(p))
- nb_eq++;
- else if (dist_map(n) > dist_map(p))
- nb_gt++;
- else
- nb_lt++;
- }
-
-
-// if ((nb_gt == 1 && nb_eq == 0) ||
-// (nb_gt == 0))
-
- if ((nb_lt + nb_eq) > 5) // Pixel Superiority index
- is_crest(p) = true;
- }
- return is_crest;
- }
-
-
- image2d<bool>
- skeleton_with_constraint(const image2d<bool>& input,
- unsigned nbh_i,
- const image2d<bool>& K,
- const image2d<value::int_u8>& priority)
- {
- mln_assertion(nbh_i == 4 || nbh_i == 8);
-
- neighb2d nbh = int_to_neighb(nbh_i);
- image2d<bool> output;
- initialize(output, input);
-
- typedef mln_site_(image2d<bool>) P;
- p_priority<value::int_u8, p_queue_fast<P> > q;
-
- // Initialization.
- {
- p_priority<value::int_u8, p_queue_fast<P> > q_tmp;
-
- data::fill(output, input);
- mln_piter_(image2d<bool>) p(input.domain());
- for_all(p)
- if (!input(p) &&
- is_simple_point2d(input, nbh_i, p)) // p is a simple point of background
- q.push(priority(p), p);
- }
-
- // Propagation.
- {
- P p;
- mln_niter_(neighb2d) n(nbh, p);
- while (! q.is_empty())
- {
- p = q.pop_front();
-
- for_all(n)
- if (output.domain().has(n) &&
- output(n) &&
- K(n) == false &&
- is_simple_point2d(output, nbh_i, n)
- // && // n is simple
- // !is_curve_extremum(output, nbh_i, n, 1)
- )
- {
- output(n) = false; // Remove n from object
- // save_state(output);
- q.push(priority(n), n);
- }
- }
- }
-
- return output;
- }
-
-
- image2d<bool>
- skeleton(const image2d<bool>& input, unsigned nbh_i)
- {
- mln_assertion(nbh_i == 4 || nbh_i == 8);
- neighb2d nbh = int_to_neighb(nbh_i);
-
- int vals[] = { 0, 9, 0, 9, 0,
- 9, 6, 4, 6, 9,
- 0, 4, 0, 4, 0, // Values of distances.
- 9, 6, 4, 6, 9,
- 0, 9, 0, 9, 0 };
-
- image2d<value::int_u8> dist_map_n = transform::distance(value::int_u8(), logical::not_(input), nbh, make::w_window2d_int(vals));
- image2d<value::int_u8> dist_map = arith::revert(dist_map_n);
-
- io::pgm::save(dist_map, "distance.pgm");
- io::pgm::save(dist_map_n, "distance_n.pgm");
-
- // Make K
- image2d<bool> K = crest(input, dist_map_n, nbh);
- io::pbm::save(K, "K.pbm");
-
- return skeleton_with_constraint(input, nbh_i, K, dist_map);
- }
-
-} // end of namespace mln
-
-#endif
Index: inim/ocr/check_simple_point.cc
--- inim/ocr/check_simple_point.cc (revision 3756)
+++ inim/ocr/check_simple_point.cc (working copy)
@@ -1,61 +0,0 @@
-#include <mln/core/image/image2d.hh>
-#include <mln/core/alias/neighb2d.hh>
-
-#include <mln/labeling/blobs.hh>
-#include <mln/data/fill.hh>
-#include <mln/debug/println.hh>
-#include "simple_point.hh"
-
-
-int main()
-{
- using namespace mln;
- using namespace mln::value;
-
- typedef image2d<bool> I;
- image2d<bool> ima(3,3);
- point2d p(1,1);
-
- std::cout << "----- Object in C8 ------" << std::endl;
-
- for (unsigned i = 0; i < 256; i++)
- {
- data::fill(ima, false);
- int_u8 tmp = i;
-
- mln_niter_(neighb2d) n(c8() , p);
- for_all(n)
- {
- if (tmp % 2)
- ima(n) = true;
- tmp = tmp >> 1;
- }
-
- unsigned x;
- labeling::blobs(ima, c8(), x);
-
- mln_assertion(nb_connexity2d(ima, 8, p, true) == x);
- }
-
- std::cout << "----- Object in C4 ------" << std::endl;
-
- for (unsigned i = 0; i < 256; i++)
- {
- data::fill(ima, false);
- int_u8 tmp = i;
-
- mln_niter_(neighb2d) n(c8() , p);
- for_all(n)
- {
- if (tmp % 2)
- ima(n) = true;
- tmp = tmp >> 1;
- }
-
-
- unsigned x;
- labeling::blobs(ima, c4(), x);
-
- mln_assertion(nb_connexity2d(ima, 4, p, true) == x);
- }
-}
Index: inim/ocr/compute_local_configurations.cc
--- inim/ocr/compute_local_configurations.cc (revision 3756)
+++ inim/ocr/compute_local_configurations.cc (working copy)
@@ -1,74 +0,0 @@
-#include <mln/core/image/image2d.hh>
-#include <mln/core/alias/neighb2d.hh>
-
-#include <mln/labeling/blobs.hh>
-#include <mln/data/fill.hh>
-#include <mln/debug/println.hh>
-#include <iomanip>
-
-
-int main()
-{
- using namespace mln;
- using value::int_u8;
-
- typedef image2d<bool> I;
-
- box2d b = make::box2d(-1,-1, 1,1);
- image2d<bool> ima(b, 0);
- point2d p(0, 0);
-
- std::vector<int_u8> x8(256), x4(256);
-
-
- for (unsigned i = 0; i < 256; i++)
- {
- data::fill(ima, false);
-
- int_u8 tmp = i;
- mln_fwd_niter_(neighb2d) n(c8(), p);
- for_all(n)
- {
- if (tmp % 2)
- ima(n) = true;
- tmp = tmp >> 1;
- }
-
- labeling::blobs(ima, c8(), x8[i]);
-
- {
- int_u8 nl;
- image2d<int_u8> lab = labeling::blobs(ima, c4(), nl);
- std::set<int_u8> s;
- mln_fwd_niter_(neighb2d) n(c4(), p);
- for_all(n)
- if (lab(n) != 0)
- s.insert(lab(n));
- x4[i] = s.size();
- }
- }
-
-
- // Now printing!
-
- std::cout << "----- Object in C8 ------" << std::endl;
-
- for (unsigned i = 0; i < 256; i++)
- {
- std::cout << std::setw(2) << x8[i] << ", ";
- if (! ((i + 1) % 4)) std::cout << " ";
- if (! ((i + 1) % 16)) std::cout << std::endl;
- if (! ((i + 1) % 64)) std::cout << std::endl;
- }
-
- std::cout << "----- Object in C4 ------" << std::endl;
-
- for (unsigned i = 0; i < 256; i++)
- {
- std::cout << std::setw(2) << x4[i] << ", ";
- if (! ((i + 1) % 4)) std::cout << " ";
- if (! ((i + 1) % 16)) std::cout << std::endl;
- if (! ((i + 1) % 64)) std::cout << std::endl;
- }
-
-}
Index: inim/ocr/tesseract_wrap.hh
--- inim/ocr/tesseract_wrap.hh (revision 3756)
+++ inim/ocr/tesseract_wrap.hh (working copy)
@@ -1,91 +0,0 @@
-#ifndef TESSERACT_WRAP_HH
-# define TESSERACT_WRAP_HH
-
-# include <cassert>
-
-# include <mln/core/image/image2d.hh>
-
-# include <tesseract/baseapi.h>
-
-struct TessWrap : public TessBaseAPI
-{
- static int InitWithLanguage(const char* datapath, const char* outputbase,
- const char* language, const char* configfile,
- bool numeric_mode, int argc, char* argv[])
- {
- return TessBaseAPI::InitWithLanguage(datapath, outputbase,
- language, configfile,
- numeric_mode, argc, argv);
- }
-
- static char* TesseractRect(const unsigned char* imagedata,
- int bytes_per_pixel,
- int bytes_per_line,
- int left, int top, int width, int height,
- float* score)
- {
- int kMinRectSize = 10; // Quick and dirty... (value imported from tesseract src)
- if (width < kMinRectSize || height < kMinRectSize)
- return NULL; // Nothing worth doing.
-
- // Copy/Threshold the image to the tesseract global page_image.
- CopyImageToTesseract(imagedata, bytes_per_pixel, bytes_per_line,
- left, top, width, height);
-
- { // RecognizeToString
- BLOCK_LIST* block_list = FindLinesCreateBlockList();
- PAGE_RES* page_res = Recognize(block_list, NULL);
-
- char* string;
- int* lengths;
- float* costs;
- int* x0;
- int* y0;
- int* x1;
- int* y1;
- // Retrieve Tesseract internal data to compute the quality score.
- int n = TessBaseAPI::TesseractExtractResult(&string, &lengths, &costs, &x0, &y0, &x1, &y1, page_res);
-
- float average_uncertainty = 0.f;
- for (int i = 0; i < n; ++i)
- average_uncertainty += costs[i];
-
- if (n)
- *score = average_uncertainty / n;
- else
- *score = -1;
-
- // Some memory cleanup
- delete[] string;
- delete[] lengths;
- delete[] costs;
- delete[] x0;
- delete[] y0;
- delete[] x1;
- delete[] y1;
-
- return TesseractToText(page_res);
- }
- }
-};
-
-// Call tesseract
-// lang: expected language
-template <typename T>
-char* tesseract(const char* lang, const mln::image2d<T>& input, float* score)
-{
- assert(score);
- TessWrap::InitWithLanguage(NULL, NULL, lang, NULL, false, 0, NULL);
- char* s = TessWrap::TesseractRect(
- (unsigned char*) input.buffer(),
- sizeof (T),
- input.ncols() * sizeof (T),
- 0, 0,
- input.ncols(),
- input.nrows(),
- score);
- return s;
-}
-
-
-#endif // ! TESSERACT_WRAP_HH
Index: inim/ocr/skeleton.old.cc
--- inim/ocr/skeleton.old.cc (revision 3756)
+++ inim/ocr/skeleton.old.cc (working copy)
@@ -1,30 +0,0 @@
-
-#include <mln/core/alias/point2d.hh>
-#include "skeleton.hh"
-#include <mln/data/paste.hh>
-#include <mln/data/fill.hh>
-#include <mln/core/image/sub_image.hh>
-#include <mln/io/pgm/save.hh>
-#include <mln/io/pbm/save.hh>
-#include <mln/io/pbm/load.hh>
-
-
-int main(int argc, char* argv[])
-{
- if(argc!=5)
- {
- std::cout << "arguments: filename voisinage R alpha" << std::endl;
- exit(1);
- }
- image2d<bool> output;
- std::string filename = argv[1];
- int r = atoi(argv[3]);
- int alpha = atoi(argv[4]);
-
- image2d<bool> pic = io::pbm::load(filename);
- if(atoi(argv[2])==4)
- output = filteredSkeleton( pic, c4(), r, alpha, true);
- else
- output = filteredSkeleton( pic, c8(), r, alpha, true);
- mln::io::pbm::save(output, "FS-"+std::string(argv[2])+"_"+std::string(argv[3])+"_"+std::string(argv[4])+"_"+filename);
-}
Index: inim/ocr/check.sh
--- inim/ocr/check.sh (revision 3756)
+++ inim/ocr/check.sh (working copy)
@@ -1,31 +0,0 @@
-output_dir=tmp/`date '+%y_%m_%d__%H_%M_%S'`
-mkdir $output_dir
-for i in input/*.pbm ; do
- echo "==========================================="
- echo "--------- $i"
- echo "==========================================="
-
- ref="$i.txt"
- echo "______________________________Reference"
- cat $ref
- sed -e 's/\(.\)/\1\n/g' $ref > tmp/ref
- total=`cat tmp/ref | wc -l `
-
- echo "______________________________without preprocessing"
- ./ocr_without_preprocess $i > tmp/without
- cat tmp/without
- cat tmp/without | sed -e 's/\(.\)/\1\n/g' > tmp/without
-
- echo "______________________________with preprocessing"
- ./ocr_with_preprocess $i $output_dir/`basename $i` > tmp/with
- cat tmp/with
- cat tmp/with | sed -e 's/\(.\)/\1\n/g' > tmp/with
-
-
- d_without=`diff ./tmp/without tmp/ref | diffstat | grep insert | sed -r 's/.*, ([0-9]+) insertion.*/\1/g'`
- echo "$(($d_without * 100 / $total))% missmatch without preprocessing"
-
- d_with=`diff ./tmp/with tmp/ref | diffstat | grep insert | sed -r 's/.*, ([0-9]+) insertion.*/\1/g'`
- echo "$(($d_with * 100 / $total))% missmatch with preprocessing"
- echo ""
-done
Index: inim/ocr/simple_point.cc
--- inim/ocr/simple_point.cc (revision 3756)
+++ inim/ocr/simple_point.cc (working copy)
@@ -1,39 +0,0 @@
-# include <mln/core/image/image2d.hh>
-# include <mln/io/pbm/load.hh>
-# include <mln/io/pbm/save.hh>
-# include <mln/data/fill.hh>
-
-# include "simple_point.hh"
-
-
-void usage(char* argv[])
-{
- std::cerr << "usage: " << argv[0] << " input.pbm output.pbm" << std::endl;
- abort();
-}
-
-
-
-int main(int argc, char* argv[])
-{
- using namespace mln;
- using value::int_u8;
-
- if (argc != 3)
- usage(argv);
-
- typedef image2d<bool> I;
- I input;
- io::pbm::load(input, argv[1]);
-
- I output;
- initialize(output, input);
- data::fill(output, false);
-
- mln_piter_(I) p(input.domain());
- for_all(p)
- if (input(p) && simple_point2d(input, 4, p))
- output(p) = true;
-
- io::pbm::save(output, argv[2]);
-}
Index: inim/ocr/ocr_with_preprocess.cc
--- inim/ocr/ocr_with_preprocess.cc (revision 3756)
+++ inim/ocr/ocr_with_preprocess.cc (working copy)
@@ -1,170 +0,0 @@
-// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
-//
-// This file is part of the Olena Library. This library is free
-// software; you can redistribute it and/or modify it under the terms
-// of the GNU General Public License version 2 as published by the
-// Free Software Foundation.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this library; see the file COPYING. If not, write to
-// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
-// Boston, MA 02111-1307, USA.
-//
-// As a special exception, you may use this file as part of a free
-// software library without restriction. Specifically, if other files
-// instantiate templates or use macros or inline functions from this
-// file, or you compile this file and link it with other files to
-// produce an executable, this file does not by itself cause the
-// resulting executable to be covered by the GNU General Public
-// License. This exception does not however invalidate any other
-// reasons why the executable file might be covered by the GNU General
-// Public License.
-
-#include <iostream>
-
-#include <mln/core/image/image2d.hh>
-#include <mln/core/alias/window2d.hh>
-#include <mln/core/alias/neighb2d.hh>
-
-#include <mln/core/image/cast_image.hh>
-
-#include <mln/value/int_u8.hh>
-
-#include "resize.hh"
-#include "enlarge.hh"
-#include "skeleton.hh"
-
-#include <mln/linear/gaussian.hh>
-
-#include <mln/trace/all.hh>
-
-#include <mln/fun/p2v/ternary.hh>
-#include <mln/pw/image.hh>
-
-#include <mln/debug/println.hh>
-#include <mln/labeling/regional_maxima.hh>
-#include <mln/morpho/dilation.hh>
-#include <mln/win/octagon2d.hh>
-#include <mln/border/resize.hh>
-
-#include <mln/io/pgm/load.hh>
-#include <mln/io/pgm/save.hh>
-#include <mln/io/pbm/load.hh>
-#include <mln/io/pbm/save.hh>
-#include <mln/logical/not.hh>
-
-#include "tesseract_wrap.hh"
-#include <mln/subsampling/subsampling.hh>
-
-// _COMPILATION_
-// g++ -DNDEBUG -O3 -I../../.. ocr.cc -L/usr/lib -ltesseract_full -lpthread
-
-// image2d<int_u8> tmp = duplicate(cast_image<int_u8>(Var)); \
-
-#if 1
-# define OCR_TEST(Var) \
- { \
- float score = 0.f; \
- char* s = tesseract("fra", Var, &score); \
- std::cerr << #Var << ": " << score << std::endl << s; \
- delete[] s; \
- }
-#else
-# define OCR_TEST(Var)
-#endif
-
-
-int main(int argc, char** argv)
-{
- using namespace mln;
- using value::int_u8;
-
- image2d<bool> input;
-
- if (argc < 2)
- {
- std::cerr << "Usage: " << argv[0] << " in.pbm out.pbm" << std::endl;
- return 1;
- }
-
- mln::border::thickness = 0;
-
- io::pbm::load(input, argv[1]);
-
- // Resize
- image2d<int_u8> enlarged = enlarge(logical::not_(input), 2);
- image2d<bool> big = geom::resize(logical::not_(input), 4);
- io::pgm::save(enlarged, std::string(argv[2]) + "_1_enlarge.pgm");
- OCR_TEST(enlarged);
-
- // Blur.
- image2d<int_u8> blur = linear::gaussian(enlarged, 2);
- io::pgm::save(blur, std::string(argv[2]) + "_2_gaussian.pgm");
- OCR_TEST(blur);
-
-// // Threshold
-// image2d<bool> binary;
-// {
-// initialize(binary, blur);
-// mln_piter_(image2d<int_u8>) p(blur.domain());
-// for_all(p)
-// binary(p) = blur(p) > 100;
-
-// io::pbm::save(binary, std::string(argv[2]) + "_3_threshold.pbm");
-// OCR_TEST(binary);
-// }
-
-// // Skeleton
-// image2d<bool> skel = skeleton(binary, 4);
-// io::pbm::save(skel, std::string(argv[2]) + "_4_skeleton.pbm");
-// OCR_TEST(skel);
-
-// // Dilation
-// win::octagon2d oct(5);
-// image2d<bool> dilate = morpho::dilation(skel, oct);
-// border::resize(dilate, 0);
-// io::pbm::save(dilate, std::string(argv[2]) + "_5_dilation.pbm");
-// OCR_TEST(dilate);
-
-// // Subsampling
-// image2d<bool> subsampled = subsampling::subsampling(dilate, dpoint2d(1,1), 2);
-// io::pbm::save(subsampled, std::string(argv[2]) + "_6_subsampling.pbm");
-// OCR_TEST(subsampled);
-
-// io::pbm::save(subsampled, argv[2]);
-
-
- image2d<bool> K = crest(big, blur, c8());
- OCR_TEST(K);
- io::pbm::save(K, std::string(argv[2]) + "_6_K.pbm");
-
- image2d<bool> skel_on_gaussian = skeleton_with_constraint(big, 8, K, arith::revert(blur));
- OCR_TEST(skel_on_gaussian);
- io::pbm::save(skel_on_gaussian, std::string(argv[2]) + "_7_skeleton_on_gaussian.pbm");
-
- // Dilation
- win::octagon2d oct(5);
- image2d<bool> dilate_on_gaussian = morpho::dilation(skel_on_gaussian, oct);
- border::resize(dilate_on_gaussian, 0);
- io::pbm::save(dilate_on_gaussian, std::string(argv[2]) + "_8_dilation_on_gaussian.pbm");
- OCR_TEST(dilate_on_gaussian);
-
- // Subsampling
- image2d<bool> subsampled_on_gaussian = subsampling::subsampling(dilate_on_gaussian, dpoint2d(1,1), 2);
- io::pbm::save(subsampled_on_gaussian, std::string(argv[2]) + "_9_subsampling_on_gaussian.pbm");
- OCR_TEST(subsampled_on_gaussian);
-
- {
- float score = 0;
- char* s = tesseract("fra", subsampled_on_gaussian, &score);
- std::cerr << "Tesseract result: (score " << score << ")" << std::endl;
- std::cout << s;
- delete[] s;
- }
-
-}
Index: inim/ocr/enlarge.hh
--- inim/ocr/enlarge.hh (revision 3756)
+++ inim/ocr/enlarge.hh (working copy)
@@ -1,202 +0,0 @@
-# include <iostream>
-
-# include <mln/core/image/image2d.hh>
-# include <mln/core/routine/initialize.hh>
-
-# include <mln/value/int_u8.hh>
-# include <mln/fun/p2v/ternary.hh>
-
-# include <mln/pw/image.hh>
-# include <mln/pw/cst.hh>
-# include <mln/pw/value.hh>
-# include <mln/opt/at.hh>
-
-# include <mln/core/routine/duplicate.hh>
-
-
-float val(bool b) { return b ? 1 : 0; }
-
-int do_threshold(float value)
-{
- return 255.f * value;
-}
-
-namespace mln
-{
-
- image2d<value::int_u8>
- enlargex2(const image2d<bool>& input)
- {
- using value::int_u8;
-
- unsigned nrows, ncols;
-
- nrows = input.nrows();
- ncols = input.ncols();
-
- image2d<int_u8> output(2 * nrows, 2 * ncols);
- float value;
-
- // row 0
-
- opt::at(output, 0, 0) = do_threshold(opt::at(input, 0, 0));
-
- for (int col = 2; col < output.ncols(); col += 2)
- {
- value = val(opt::at(input, 0, col / 2));
- value += val(opt::at(input, 0, col / 2 - 1));
- opt::at(output, 0, col) = do_threshold(value / 2);
- }
-
- for (int col = 1; col < output.ncols(); col += 2)
- opt::at(output, 0, col) = do_threshold(opt::at(input, 0, col / 2));
-
- // col 0
-
- for (int row = 2; row < output.nrows(); row += 2)
- {
- value = val(opt::at(input, row / 2, 0));
- value += val(opt::at(input, row / 2 - 1, 0));
- opt::at(output, row, 0) = do_threshold(value / 2);
- }
-
- for (int row = 1; row < output.nrows(); row += 2)
- opt::at(output, row, 0) = do_threshold(opt::at(input, row / 2, 0));
-
- // others
-
- for (int row = 2; row < output.nrows(); row += 2)
- {
- for (int col = 2; col < output.ncols(); col += 2)
- {
- value = val(opt::at(input, row / 2, col / 2));
- value += val(opt::at(input, row / 2 - 1, col / 2));
- value += val(opt::at(input, row / 2, col / 2 - 1));
- value += val(opt::at(input, row / 2 - 1, col / 2 - 1));
- opt::at(output, row, col) = do_threshold(value / 4);
- }
- for (int col = 1; col < output.ncols(); col += 2)
- {
- value = val(opt::at(input, row / 2, col / 2));
- value += val(opt::at(input, row / 2 - 1, col / 2));
- opt::at(output, row, col) = do_threshold(value / 2);
- }
- }
-
- for (int row = 1; row < output.nrows(); row += 2)
- {
- for (int col = 2; col < output.ncols(); col += 2)
- {
- value = val(opt::at(input, row / 2, col / 2));
- value += val(opt::at(input, row / 2, col / 2 - 1));
- opt::at(output, row, col) = do_threshold(value / 2);
- }
- for (int col = 1; col < output.ncols(); col += 2)
- opt::at(output, row, col) = do_threshold(opt::at(input, row / 2, col / 2));
- }
-
- return output;
- }
-
-
-
- image2d<value::int_u8>
- enlargex2(const image2d<value::int_u8>& input)
- {
- using value::int_u8;
-
- unsigned nrows, ncols;
-
- nrows = input.nrows();
- ncols = input.ncols();
-
- image2d<int_u8> output(2 * nrows, 2 * ncols);
- unsigned value;
-
- // row 0
-
- opt::at(output, 0, 0) = (opt::at(input, 0, 0));
-
- for (int col = 2; col < output.ncols(); col += 2)
- {
- value = (opt::at(input, 0, col / 2));
- value += (opt::at(input, 0, col / 2 - 1));
- opt::at(output, 0, col) = (value / 2);
- }
-
- for (int col = 1; col < output.ncols(); col += 2)
- opt::at(output, 0, col) = (opt::at(input, 0, col / 2));
-
- // col 0
-
- for (int row = 2; row < output.nrows(); row += 2)
- {
- value = (opt::at(input, row / 2, 0));
- value += (opt::at(input, row / 2 - 1, 0));
- opt::at(output, row, 0) = (value / 2);
- }
-
- for (int row = 1; row < output.nrows(); row += 2)
- opt::at(output, row, 0) = (opt::at(input, row / 2, 0));
-
- // others
-
- for (int row = 2; row < output.nrows(); row += 2)
- {
- for (int col = 2; col < output.ncols(); col += 2)
- {
- value = (opt::at(input, row / 2, col / 2));
- value += (opt::at(input, row / 2 - 1, col / 2));
- value += (opt::at(input, row / 2, col / 2 - 1));
- value += (opt::at(input, row / 2 - 1, col / 2 - 1));
- opt::at(output, row, col) = ((unsigned(value)+2) / 4);
- }
- for (int col = 1; col < output.ncols(); col += 2)
- {
- value = (opt::at(input, row / 2, col / 2));
- value += (opt::at(input, row / 2 - 1, col / 2));
- opt::at(output, row, col) = (value / 2);
- }
- }
-
- for (int row = 1; row < output.nrows(); row += 2)
- {
- for (int col = 2; col < output.ncols(); col += 2)
- {
- value = (opt::at(input, row / 2, col / 2));
- value += (opt::at(input, row / 2, col / 2 - 1));
- opt::at(output, row, col) = (value / 2);
- }
- for (int col = 1; col < output.ncols(); col += 2)
- opt::at(output, row, col) = (opt::at(input, row / 2, col / 2));
- }
-
- return output;
- }
-
-
-
-
-
-
- // enlarge 2^n times
- image2d<value::int_u8>
- enlarge(const image2d<bool>& input, unsigned int n)
- {
- using value::int_u8;
-
- if (n == 0)
- return duplicate(fun::p2v::ternary(pw::value(input),
- pw::cst(int_u8(255)),
- pw::cst(int_u8(0)))
- | input.domain());
-
- image2d<int_u8> output = enlargex2(input);
-
- while (--n)
- output = enlargex2(output);
-
- return output;
- }
-
-} // mln
Index: inim/ocr/Makefile
--- inim/ocr/Makefile (revision 3756)
+++ inim/ocr/Makefile (working copy)
@@ -1,26 +0,0 @@
-CXXFLAGS=-I../../.. -I${HOME}/local/include
-LFLAGS=-L${HOME}/local/lib -ltesseract_full -lpthread
-
-all: ocr_without_preprocess ocr_with_preprocess
-
-ocr_without_preprocess: ocr_without_preprocess.cc
- g++ -DNDEBUG -O3 ${CXXFLAGS} $< ${LFLAGS} -o $@
-
-ocr_with_preprocess: ocr_with_preprocess.cc
- g++ -DNDEBUG -O3 ${CXXFLAGS} $< ${LFLAGS} -o $@
-clean:
- rm -f *.o ocr_without_preprocess ocr_with_preprocess
-
-logs:
- mkdir logs
-
-tmp:
- mkdir tmp
-
-check: logs tmp ocr_without_preprocess ocr_with_preprocess
- ./check.sh
-
-skeleton: skeleton.cc
- g++ -DNDEBUG -W -Wall -Wextra ${CXXFLAGS} $< -o $@
-
-.PHONY: skeleton
Index: inim/classif/plotscript
--- inim/classif/plotscript (revision 3756)
+++ inim/classif/plotscript (working copy)
@@ -1,4 +0,0 @@
-set xlabel "red"
-set ylabel "green"
-set zlabel "blue"
-splot "plot"
Index: inim/classif/src/max_tree.hh
--- inim/classif/src/max_tree.hh (revision 3756)
+++ inim/classif/src/max_tree.hh (working copy)
@@ -1,312 +0,0 @@
-#ifndef MAX_TREE_HH_
-# define MAX_TREE_HH_
-
-# include <mln/core/concept/image.hh>
-# include <mln/core/concept/neighborhood.hh>
-# include <mln/data/fill.hh>
-# include <mln/util/pix.hh>
-# include <mln/morpho/includes.hh>
-# include <mln/level/sort_psites.hh>
-
-# include <mln/core/image/image2d.hh>
-# include <mln/core/image/image3d.hh>
-# include <mln/core/alias/neighb2d.hh>
-# include <mln/value/int_u8.hh>
-# include <mln/value/rgb8.hh>
-# include <mln/io/pgm/load.hh>
-# include <mln/core/site_set/p_array.hh>
-# include <mln/debug/println.hh>
-# include <mln/io/ppm/save.hh>
-
-using namespace mln;
-
-template <typename I, typename N>
-struct max_tree_
-{
- typedef mln_site(I) point;
- typedef p_array<point> S;
-
- // in:
- const I& f;
- const N& nbh;
-
- // aux:
- S s;
- mln_ch_value(I, bool) deja_vu;
- mln_ch_value(I, point) parent;
- mln_ch_value(I, point) new_parent;
- mln_ch_value(I, point) zpar;
-
- //tags
- image3d<bool> is_active;
-
- max_tree_(const I& f, const N& nbh)
- : f(f), nbh(nbh), is_active(f.domain()), new_parent(f.domain())
- {
- run();
- data::fill(is_active, true);
-
- new_parent = parent;
- }
-
- void run()
- {
- // init
- {
- initialize(deja_vu, f);
- mln::data::fill(deja_vu, false);
- initialize(parent, f);
- initialize(zpar, f);
- s = level::sort_psites_decreasing(f);
- }
-
- // first pass
- {
- mln_fwd_piter(S) p(s);
- mln_niter(N) n(nbh, p);
- for_all(p)
- {
- make_set(p);
- for_all(n)
- if (f.has(n) && deja_vu(n))
- do_union(n, p);
- deja_vu(p) = true;
- }
- }
-
- // second pass: canonization
- {
- mln_bkd_piter(S) p(s);
- for_all(p)
- {
- point q = parent(p);
- if (f(parent(q)) == f(q))
- parent(p) = parent(q);
- }
- }
-
- } // end of run()
-
- point active_parent(const point& p)
- {
- point node = new_parent(p);
-
- while (not is_active(node) && not is_root(node))
- node = new_parent(node);
-
- return node;
- }
-
- void make_set(const point& p)
- {
- parent(p) = p;
- zpar(p) = p;
- }
-
- image3d<unsigned> compute_nb_represent()
- {
- image3d<unsigned> nb_represent(f.domain());
-
- data::fill(nb_represent, 0);
- mln_fwd_piter(S) p(s);
-
- for_all(p)
- {
- nb_represent(p) += f(p);
- if (not is_root(p))
- nb_represent(parent(p)) += nb_represent(p);
- }
-
- return nb_represent;
- }
-
- image3d<unsigned> compute_volume()
- {
- image3d<unsigned> volume(f.domain());
-
- data::fill(volume, 0);
- mln_fwd_piter(S) p(s);
-
- for_all(p)
- {
- volume(p) += 1;
- if (not is_root(p))
- volume(parent(p)) += volume(p);
- }
-
- return volume;
- }
-
- image3d< algebra::vec<3, double> > compute_mean_color()
- {
- image3d< algebra::vec<3, double> > mean_color(f.domain());
-
- update_parents();
-
- mln_fwd_piter(S) p(s);
- for_all(p)
- mean_color(p) = make::vec(p[0], p[1], p[2]);
-
- for_all(p)
- mean_color(new_parent(p)) = (mean_color(new_parent(p)) + mean_color(p)) / 2.;
-
- return mean_color;
- }
-
- // Filter method
- template<typename X>
- void lumberjack(const X& ima, const mln_value(X)& lambda)
- {
- unsigned progress = 0;
- unsigned step = s.nsites() / 100;
-
- mln_fwd_piter(S) p(s);
-
- for_all(p)
- {
- if (ima(p) < lambda)
- is_active(p) = false;
-
- ++progress;
- if (progress % step == 0)
- {
- std::cout << "." << std::flush;
- progress = 0;
- }
- }
-
- std::cout << std::endl;
- }
-
- // Fusion method
- template<typename X>
- void nuclear_fusion(const X& ima, double lambda)
- {
- unsigned progress = 0;
- unsigned step = s.nsites() / 100;
-
- update_parents();
-
- mln_fwd_piter(S) p(s);
- for_all(p)
- {
- if (ima(p) != 0)
- if (fabs(1. - ima(new_parent(p)) / (double) ima(p)) < lambda)
- is_active(p) = false;
-
- ++progress;
- if (progress % step == 0)
- {
- std::cout << "." << std::flush;
- progress = 0;
- }
- }
-
- std::cout << std::endl;
- }
-
- void color_fusion(int lambda)
- {
- unsigned progress = 0;
- unsigned step = s.nsites() / 100;
-
- update_parents();
-
- mln_fwd_piter(S) p(s);
- for_all(p)
- {
- if (new_parent(p)[0] - p[0] < lambda &&
- new_parent(p)[1] - p[1] < lambda &&
- new_parent(p)[2] - p[2] < lambda)
- is_active(p) = false;
-
- ++progress;
- if (progress % step == 0)
- {
- std::cout << "." << std::flush;
- progress = 0;
- }
- }
- std::cout << std::endl;
- }
-
- void update_parents()
- {
- unsigned progress = 0;
- unsigned step = s.nsites() / 100;
-
- std::cout << "Update parents";
-
- mln_fwd_piter(S) p(s);
- for_all(p)
- {
- new_parent(p) = active_parent(p);
-
- ++progress;
- if (progress % step == 0)
- {
- std::cout << "." << std::flush;
- progress = 0;
- }
- }
- std::cout << std::endl;
- }
-
- template < typename J >
- void to_ppm(const J& ima, const std::string& file, unsigned f,
- const image3d< algebra::vec<3, double> >& mean_color)
- {
- update_parents();
-
- J out(ima.domain());
- data::fill(out, value::rgb8(0, 0, 0));
-
- mln_piter(J) p(ima.domain());
- for_all(p)
- {
- point3d node = new_parent(point3d(ima(p).red() / f, ima(p).green() / f, ima(p).blue() / f));
-
- out(p) = value::rgb8(static_cast<unsigned char>(mean_color(node)[0] * f),
- static_cast<unsigned char>(mean_color(node)[1] * f),
- static_cast<unsigned char>(mean_color(node)[2] * f));
- }
-
- io::ppm::save(out, file);
- }
-
- unsigned number_of_nodes()
- {
- return s.nsites();
- }
-
- bool is_root(const point& p) const
- {
- return parent(p) == p;
- }
-
- bool is_node(const point& p) const
- {
- return is_root(p) || f(parent(p)) != f(p);
- }
-
- point find_root(const point& x)
- {
- if (zpar(x) == x)
- return x;
- else
- return zpar(x) = find_root(zpar(x));
- }
-
- void do_union(const point& n, const point& p)
- {
- point r = find_root(n);
- if (r != p)
- {
- parent(r) = p;
- zpar(r) = p;
- }
- }
-};
-
-
-#endif /* !MAX_TREE_HH_ */
Index: inim/classif/src/display.hh
--- inim/classif/src/display.hh (revision 3756)
+++ inim/classif/src/display.hh (working copy)
@@ -1,80 +0,0 @@
-// Copyright (C) 2008 EPITA Research and Development Laboratory
-//
-// This file is part of the Olena Library. This library is free
-// software; you can redistribute it and/or modify it under the terms
-// of the GNU General Public License version 2 as published by the
-// Free Software Foundation.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this library; see the file COPYING. If not, write to
-// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
-// Boston, MA 02111-1307, USA.
-//
-// As a special exception, you may use this file as part of a free
-// software library without restriction. Specifically, if other files
-// instantiate templates or use macros or inline functions from this
-// file, or you compile this file and link it with other files to
-// produce an executable, this file does not by itself cause the
-// resulting executable to be covered by the GNU General Public
-// License. This exception does not however invalidate any other
-// reasons why the executable file might be covered by the GNU General
-// Public License.
-
-#ifndef MLN__DISPLAY_HH
-# define MLN__DISPLAY_HH
-
-#include <mln/io/ppm/save.hh>
-#include <mln/geom/nrows.hh>
-#include <mln/geom/ncols.hh>
-#include <mln/geom/nslis.hh>
-#include <mln/value/all.hh>
-#include <mln/core/image/image3d.hh>
-#include <mln/literal/colors.hh>
-
-#include <sys/stat.h>
-#include <sstream>
-#include <string.h>
-#include <stdlib.h>
-
-
-namespace mln
-{
-
- template <typename I, typename J, typename K>
- void display(const I& histo, const J& ws, K mean, const char * dir)
- {
- mkdir(dir, 0777);
- chdir(dir);
-
- image2d< value::rgb8 > out(geom::nrows(histo), geom::ncols(histo));
- data::fill(out, literal::white);
-
- for (int s = 0; s < geom::nslis(histo); ++s)
- {
- for (int r = 0; r < geom::nrows(histo); ++r)
- for (int c = 0; c < geom::ncols(histo); ++c)
- if (histo(point3d(s,r,c)) > 0)
- {
- if (ws(point3d(s,r,c)) > 0)
- out(point2d(r, c)) = convert::to<value::rgb8>(mean[ws(point3d(s,r,c))]);
- else
- out(point2d(r, c)) = literal::red;
- }
-
- std::ostringstream is;
- is << "out_00" << s << ".ppm";
- io::ppm::save(out, is.str());
- }
-
- chdir("..");
- }
-
-} // end of namespace mln
-
-#endif /* MLN__DISPLAY_HH */
-
Index: inim/classif/src/iccvg04.cc
--- inim/classif/src/iccvg04.cc (revision 3756)
+++ inim/classif/src/iccvg04.cc (working copy)
@@ -1,171 +0,0 @@
-#include <iostream>
-
-#include <mln/core/image/image2d.hh>
-#include <mln/core/image/image3d.hh>
-#include <mln/value/all.hh>
-
-#include <mln/data/fill.hh>
-
-#include <mln/morpho/closing_volume.hh>
-#include <mln/morpho/closing_area.hh>
-#include <mln/morpho/opening_volume.hh>
-#include <mln/morpho/opening_area.hh>
-
-#include <mln/arith/revert.hh>
-#include <mln/morpho/meyer_wst.hh>
-#include <mln/core/alias/neighb3d.hh>
-#include <mln/util/array.hh>
-#include <mln/labeling/compute.hh>
-
-#include <mln/geom/nrows.hh>
-#include <mln/geom/ncols.hh>
-#include <mln/geom/nslis.hh>
-
-#include <mln/io/ppm/load.hh>
-#include <mln/io/pgm/save.hh>
-#include <mln/io/ppm/save.hh>
-
-#include <mln/estim/min_max.hh>
-#include <mln/algebra/vec.hh>
-#include <mln/algebra/vec.hh>
-
-#include <mln/literal/all.hh>
-
-#include <mln/level/stretch.hh>
-
-#include <sys/stat.h>
-#include <sstream>
-#include <string.h>
-#include <stdlib.h>
-
-#include "proj.hh"
-#include "display.hh"
-
-using namespace mln;
-
-unsigned max = 0;
-
-template <typename I>
-mln::image3d<unsigned>
-fill_histo(const I& ima, int f)
-{
- const value::int_u8 v = 255 / f; // FIXME
- image3d<unsigned> histo(v,v,v);
- data::fill(histo, 0);
-
- mln_piter(I) p(ima.domain());
- for_all(p)
- {
- point3d p3(ima(p).red() / f, ima(p).green() / f, ima(p).blue() / f);
- histo(p3)++;
- }
- return histo;
-}
-
-template <typename I>
-void gplot(const I& ima)
-{
- mln_piter(I) p(ima.domain());
- for_all(p)
- {
- if (ima(p) != 0)
- std::cout << p[0] << ' ' << p[1] << ' ' << p[2] << std::endl;
- }
-}
-
-template <typename I, typename J, typename K>
-void
-classify_image(const I& ima, const J& histo, const K& ws, int nbasins, int f)
-{
- unsigned border = 0;
- unsigned count[nbasins + 1];
- memset(count, 0, (nbasins + 1) * sizeof (unsigned));
-
- algebra::vec<3, double> sum[nbasins + 1];
- for (int i = 0; i < nbasins + 1; ++i)
- sum[i] = literal::zero;
-
- // Compute representatives of every class
- mln_piter(I) p(ima.domain());
- for_all(p)
- {
- point3d p3(ima(p).red() / f, ima(p).green() / f, ima(p).blue() / f);
- int w = ws(p3);
-
- //Even if we are not on a border of the WS
- count[w] += histo(p3);
- sum[w] += histo(p3) * convert::to< algebra::vec<3, value::int_u8> >(p3);
-
- std::cerr << "p3 : " << p3 << " == " <<
- convert::to<algebra::vec<3, value::int_u8> >(p3) << std::endl;
- }
-
- std::cout << "dyke point : " << count[0] << std::endl;
- for (int i = 0; i < nbasins + 1; ++i)
- {
- std::cout << "sum[" << i << "] = " << sum[i] * f << " / " << count[i] << " == ";
- sum[i] = (sum[i] * f) / count[i];
- std::cout << sum[i] << std::endl;
- }
-
- // Make an output image where colors are replaced by their representatives.
- mln_piter(I) pi(ima.domain());
- I out(ima.domain());
- for_all(pi)
- {
- //retrieve color class
- value::rgb8 coul = ima(pi);
- int w = ws(point3d(coul.red() / f, coul.green() / f, coul.blue() / f));
-
- //if w == 0, out(pi) = 0 ie is part of a border of the watershed
- if (w == 0)
- out(pi) = literal::red;
- else
- out(pi) = convert::to<value::rgb8>(sum[w]);
-
- std::cerr << "out(" << pi << ") = sum[" << w << "]; //"
- << sum[w] << " : rgb8(" << sum[w] << ")" << std::endl;
- }
-
- io::ppm::save(out, "out.ppm");
- save_class(histo, ws, sum, "palette.ppm");
- display(histo, ws, sum, "histo");
-}
-
-bool usage(int argc, char ** argv)
-{
- if (argc != 4)
- {
- std::cout << "usage: " << argv[0] << " image div_factor lambda" << std::endl;
- return false;
- }
- return true;
-}
-
-
-int main(int argc, char **argv)
-{
- if (not usage(argc, argv))
- return 1;
- const int div_factor = atoi(argv[2]);
- const int lambda = atoi(argv[3]);
-
- image2d<value::rgb8> ima;
- ima = io::ppm::load<value::rgb8>(argv[1]);
-
- //make histo
- image3d<unsigned> histo = fill_histo(ima,div_factor);
-
- //compute opening_volume of histo
- image3d<unsigned> histo_filtered;
- histo_filtered = morpho::opening_volume(histo, c6(), lambda);
-
- //watershed over histo_closure
- unsigned nbasins = 0;
- image3d<unsigned> ws = morpho::meyer_wst(arith::revert(histo_filtered),
- c6(), nbasins);
- std::cout << "nbassins : " << nbasins << std::endl;
-
- //classify image
- classify_image(ima, histo, ws, nbasins, div_factor);
-}
Index: inim/classif/src/proj.hh
--- inim/classif/src/proj.hh (revision 3756)
+++ inim/classif/src/proj.hh (working copy)
@@ -1,139 +0,0 @@
-// Copyright (C) 2008 EPITA Research and Development Laboratory
-//
-// This file is part of the Olena Library. This library is free
-// software; you can redistribute it and/or modify it under the terms
-// of the GNU General Public License version 2 as published by the
-// Free Software Foundation.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this library; see the file COPYING. If not, write to
-// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
-// Boston, MA 02111-1307, USA.
-//
-// As a special exception, you may use this file as part of a free
-// software library without restriction. Specifically, if other files
-// instantiate templates or use macros or inline functions from this
-// file, or you compile this file and link it with other files to
-// produce an executable, this file does not by itself cause the
-// resulting executable to be covered by the GNU General Public
-// License. This exception does not however invalidate any other
-// reasons why the executable file might be covered by the GNU General
-// Public License.
-
-#ifndef MLN_PROJ_HH
-# define MLN_PROJ_HH
-
-#include <mln/io/ppm/save.hh>
-#include <mln/io/pgm/save.hh>
-#include <mln/data/paste.hh>
-#include <mln/accu/mean.hh>
-#include <mln/accu/maj_h.hh>
-#include <mln/literal/white.hh>
-#include <mln/literal/colors.hh>
-#include <mln/make/vec.hh>
-#include <mln/opt/at.hh>
-
-namespace mln
-{
-
- template <typename T, typename A>
- image2d<mln_result(A)>
- proj(const image3d<T>& input, A)
- {
- image2d<A> acc(geom::nslis(input), geom::nrows(input));
- mln_piter(image3d<T>) p(input.domain());
- for_all(p) // 3d
- if (input(p) != literal::zero)
- opt::at(acc, p.sli(), p.row()).take(input(p));
-
- image2d<mln_result(A)> output(acc.domain());
- data::paste(acc, output);
- return output;
- }
-
- template <typename T, typename U, typename K>
- void
- save_class(const image3d<T>& histo, const image3d<U>& ws,
- K mean, const char * fn)
- {
- accu::maj_h<value::int_u8> maj_1;
- image2d<value::int_u8> hproj = proj(histo, maj_1);
-
- accu::maj_h<value::int_u8> maj_2;
- image2d<value::int_u8> proj_class = proj(ws, maj_2);
-
- //std::cout << histo;
-
- image2d<value::rgb8> out(proj_class.domain());
- data::fill(out, literal::white);
-
- mln_piter(image2d<value::int_u8>) p(proj_class.domain());
- for_all(p)
- if (hproj(p) > 0)
- {
- if (proj_class(p) > 0)
- out(p) = convert::to<value::rgb8>(mean[proj_class(p)]);
- else
- out(p) = literal::red;
- }
- io::ppm::save(out, fn);
- }
-
- template <typename T, typename I, typename A>
- image2d<mln_result(A)>
- proj_vec(const image3d<T>& input, const I& histo, A)
- {
- image2d<A> acc(geom::nslis(input), geom::nrows(input));
- mln_piter(image3d<T>) p(input.domain());
- for_all(p) // 3d
- if (histo(p) != literal::zero)
- opt::at(acc, p.sli(), p.row()).take(input(p));
-
- image2d<mln_result(A)> output(acc.domain());
- data::paste(acc, output);
- return output;
- }
-
- template <typename I, typename T, typename U, typename V>
- void
- save_class_v2(const I& ima, const T& histo, image3d<U>& mean,
- const image3d<V>& parent, unsigned f,
- const char * fn)
- {
- image3d<value::rgb8> out3d(histo.domain());
-
- mln_piter(I) p(ima.domain());
- for_all(p)
- {
- point3d p3 = point3d(ima(p).red() / f,
- ima(p).green() / f,
- ima(p).blue() / f);
- out3d(p3) = convert::to<value::rgb8>(mean(parent(p3)));
- }
-
- //FIXME: maj_h implies set is finite, mx set is ordered
- accu::mean<mln::algebra::vec<3u, float> > maj_2;
- image2d<mln::algebra::vec<3u, float> > mproj =
- proj_vec(out3d, histo, maj_2);
-
- image2d<value::rgb8> out(geom::nslis(histo), geom::nrows(histo));
- data::fill(out, literal::white);
-
- mln_piter(image2d<value::int_u8>) p1(out.domain());
- for_all(p1)
- {
- out(p1) = convert::to<value::rgb8>(mproj(p1));
- }
-
- io::ppm::save(out, fn);
- }
-
-} // end of namespace mln
-
-#endif /* MLN_PROJ_HH */
-
Index: inim/classif/src/v2.cc
--- inim/classif/src/v2.cc (revision 3756)
+++ inim/classif/src/v2.cc (working copy)
@@ -1,178 +0,0 @@
-#include <mln/core/image/image2d.hh>
-#include <mln/core/image/image3d.hh>
-
-#include <mln/value/all.hh>
-
-#include <mln/data/fill.hh>
-#include <mln/geom/nrows.hh>
-#include <mln/geom/ncols.hh>
-#include <mln/geom/nslis.hh>
-
-
-#include <mln/io/ppm/load.hh>
-#include <mln/io/pgm/save.hh>
-#include <mln/io/ppm/save.hh>
-
-#include <mln/arith/revert.hh>
-#include <mln/core/alias/neighb3d.hh>
-
-#include "max_tree.hh"
-#include "proj.hh"
-#include "display.hh"
-
-using namespace mln;
-
-template <typename I>
-mln::image3d<unsigned>
-fill_histo(const I& ima, int f)
-{
- const value::int_u8 v = 256 / f; // FIXME
- image3d<unsigned> histo(v,v,v);
- data::fill(histo, 0);
-
- mln_piter(I) p(ima.domain());
- for_all(p)
- {
- point3d p3(ima(p).red() / f, ima(p).green() / f, ima(p).blue() / f);
- histo(p3)++;
- }
- return histo;
-}
-
-template <typename I>
-image3d< double >
-compute_density(const I& weight, const I& volume)
-{
- image3d< double > density(volume.domain());
-
- mln_piter(I) p(volume.domain());
- for_all(p)
- density(p) = weight(p) / volume(p);
-
- return density;
-}
-
-template <typename I, typename J, typename N>
-void
-process_max_tree(const I& ima, const J& histo, const N& nbh,
- double density_lambda, double value_lambda,
- unsigned volume_lambda, unsigned nb_represent_lambda,
- unsigned color_lambda, unsigned div_factor)
-{
- max_tree_<J,N> run(histo, nbh);
-
-
- // FIXME: write a compute() method with functor argument
- image3d<unsigned> nb_represent = run.compute_nb_represent();
- image3d<unsigned> volume = run.compute_volume(); // surface (area)
- image3d< algebra::vec<3, double> > mean_color = run.compute_mean_color();
- image3d<double> density = compute_density(nb_represent, volume);
-
- // Density fusion
- if (density_lambda > 0.00001)
- {
- std::cout << "Density fusion" << std::endl;
- run.nuclear_fusion(density, density_lambda);
- }
-
- // value fusion
- if (value_lambda > 0.00001)
- {
- std::cout << "Value fusion" << std::endl;
- run.nuclear_fusion(histo, value_lambda);
- }
-
- // Volume cutting
- if (volume_lambda != 0)
- {
- std::cout << "Volume cutting" << std::endl;
- run.lumberjack(volume, volume_lambda);
- }
-
- // Represent cutting
- if (nb_represent_lambda != 0)
- {
- std::cout << "nb_represent cutting" << std::endl;
- run.lumberjack(nb_represent, nb_represent_lambda);
- }
-
- // Color fusion
- if (color_lambda != 0)
- {
- std::cout << "Color fusion" << std::endl;
- run.color_fusion(color_lambda); // FIXME: factorize the code with a functor
- }
-
- // Compute mean color of active nodes
- std::cout << "Compute mean color" << std::endl;
- run.compute_mean_color();
-
- // Print informations on the filtered max tree
- {
- int nb_class = 0;
-
- mln_piter(image3d<unsigned>) p(nb_represent.domain());
-
- std::cerr.precision(2);
-
- std::cerr << "Color\t\tId\t\tdensity\t\tvolume\t\tnb_represent" << std::endl;
-
- for_all(p)
- if (run.is_active(p))
- {
- std::cerr << mean_color(p) << "\t\t" << nb_class
- << "\t\t" << density(p) << "\t\t" << volume(p)
- << "\t\t" << nb_represent(p) << std::endl;
- ++nb_class;
- }
-
- std::cout << "Number of classes : " << nb_class << std::endl;
- }
-
-
- // Write the image w.r.t. the max tree
- run.to_ppm(ima, "out.ppm", div_factor, mean_color);
-
- //proj
- save_class_v2(ima, histo, mean_color, run.new_parent,
- div_factor, "histo.ppm");
-}
-
-bool usage(int argc, char ** argv)
-{
- if (argc != 8)
- {
- std::cout << "usage: " << argv[0] << " image div_factor "
- << "density_lambda value_lambda volume_lambda "
- << "nb_represent_lambda color_lambda" << std::endl;
- std::cout << "Help: A value of 0 for any lambda means "
- << "the related action won't be performed" << std::endl;
- return false;
- }
-
- return true;
-}
-
-int main(int argc, char* argv[])
-{
- if (not usage(argc, argv))
- return 1;
-
- image2d<value::rgb8> ima;
-
- ima = io::ppm::load<value::rgb8>(argv[1]);
-
- int div_factor = atoi(argv[2]);
- float density_lambda = atof(argv[3]);
- float value_lambda = atof(argv[4]);
- unsigned volume_lambda = atoi(argv[5]);
- unsigned nb_represent_lambda = atoi(argv[6]);
- unsigned color_lambda = atoi(argv[7]);
-
- //make histo
- image3d<unsigned> histo = fill_histo(ima, div_factor);
-
- // Process max_tree
- process_max_tree(ima, histo, c6(), density_lambda, value_lambda,
- volume_lambda, nb_represent_lambda, color_lambda, div_factor);
-}
Index: inim/classif/Makefile
--- inim/classif/Makefile (revision 3756)
+++ inim/classif/Makefile (working copy)
@@ -1,87 +0,0 @@
-DISP=xv
-
-# ICCVG
-ICCVG_INCLUDES=-I../../..
-ICCVG_SRC=src/iccvg04.cc
-ICCVG=iccvg
-ICCVG_DBG=iccvg_dbg
-
-IMG?=../../img/lena.ppm
-DIV?=4
-LAMBDA?=10
-
-# V2
-V2_INCLUDES=-I../../..
-V2_SRC=src/v2.cc src/max_tree.hh
-V2=v2
-V2_DBG=v2_dbg
-
-
-LOG=> stdout.log 2> stderr.log
-
-all: $(ICCVG) $(V2)
-
-$(ICCVG): $(ICCVG_SRC)
- g++ $(ICCVG_INCLUDES) -O1 -DNDEBUG $(ICCVG_SRC) -o $(ICCVG)
-
-
-$(ICCVG_DBG): $(ICCVG_SRC)
- g++ $(ICCVG_INCLUDES) -Wall -W -O0 -g3 -ggdb3 $(ICCVG_SRC) -o $(ICCVG_DBG)
-
-$(V2): $(V2_SRC)
- g++ $(V2_INCLUDES) -O1 -DNDEBUG $(V2_SRC) -o $(V2)
-
-
-$(V2_DBG): $(V2_SRC) .dep_v2
- g++ $(V2_INCLUDES) -Wall -W -O0 -g3 -ggdb3 $(V2_SRC) -o $(V2_DBG)
-
-
-.PHONY:clean check check-debug valgrind .dep_iccvg .dep_v2
-
-clean:
- rm -f $(ICCVG)
- rm -f $(ICCVG_DBG)
- rm -f $(V2)
- rm -f $(V2_DBG)
- rm -f *.log
- rm -f .dep_iccvg .dep_v2 .dep_iccvgr .dep_v2r
-
-check-debug: $(ICCVG_DBG)
- ./iccvg_dbg $(IMG) $(DIV) $(LAMBDA) $(LOG)
- cat stdout.log
- $(DISP) out.ppm &
-
-check: $(ICCVG)
- ./iccvg $(IMG) $(DIV) $(LAMBDA) $(LOG)
- cat stdout.log
- $(DISP) out.ppm &
-
-v2-check: $(V2)
- ./v2 $(IMG) $(DIV) $(LAMBDA) $(LOG)
- cat stdout.log
- $(DISP) out.ppm &
-
-valgrind: $(ICCVG_DBG)
- valgrind --log-file=valgrind.log ./iccvg_dbg ../../img/lena.ppm $(DIV) $(LAMBDA) $(LOG)
-
-gdb: $(ICCVG_DBG)
- echo "run ../../img/lena.ppm $(DIV) $(LAMBDA)" > gdb.cmd
- gdb $(ICCVG_DBG) -x gdb.cmd
-
-v2-gdb: $(V2_DBG)
- echo "run ../../img/lena.ppm $(DIV) $(LAMBDA) $(LOG)" > gdb.cmd
- gdb $(V2_DBG) -x gdb.cmd
-
-
-.dep_iccvg:
- g++ $(ICCVG_INCLUDES) -MM src/iccvg04.cc > $@
- @sed -ir s/iccvg04.cc// .dep_iccvg
- @sed -ir s/iccvg04.o/iccvg/ .dep_iccvg
-
-.dep_v2:
- g++ $(V2_INCLUDES) -MM src/v2.cc > $@
- @sed -ir s/v2.cc// .dep_v2
- @sed -ir s/v2.o/v2/ .dep_v2
-
--include .dep_iccvg
--include .dep_v2
Index: inim/binarization/proof-of-concept/build/configure.in
--- inim/binarization/proof-of-concept/build/configure.in (revision 3756)
+++ inim/binarization/proof-of-concept/build/configure.in (working copy)
@@ -1,5 +0,0 @@
-## configure.in
-## Made by nicuveo for owl
-
-CFIL1 = ../src/basic.cc
-CFIL2 = ../src/gradient.cc
Index: inim/binarization/proof-of-concept/build/Makefile
--- inim/binarization/proof-of-concept/build/Makefile (revision 3756)
+++ inim/binarization/proof-of-concept/build/Makefile (working copy)
@@ -1,79 +0,0 @@
-##
-## Makefile for owl
-## Made by nicuveo <nicuveo(a)lrde.epita.fr>
-##
-
-include Makefile.rules
-
-
-
-# VARIABLES
-
-EXE1 = ../bin/basic
-EXE2 = ../bin/gradient
-
-OBJS1 = $(notdir $(CFIL1:.cc=.o))
-OBJS2 = $(notdir $(CFIL2:.cc=.o))
-
-CFIL = $(sort $(CFIL1) $(CFIL2))
-OBJS = $(sort $(OBJS1) $(OBJS2))
-DEPS = $(notdir $(CFIL:.cc=.d))
-
-
-
-# MAIN
-
-all: $(EXE1) $(EXE2)
-
-basic: $(EXE1)
-
-gradient : $(EXE2)
-
-clean: do_clean
-
-distclean: do_distclean
-
-
-
-# CLEAN
-
-do_clean:
- rm -f $(OBJS)
-
-do_distclean: do_clean
- rm -f $(EXE1) $(EXE2) $(DEPS)
- rm -f Makefile.rules Makefile.deps tmp
-
-
-
-# COMPIL
-
-$(EXE1): $(OBJS1)
- $(CC) $(OBJS1) $(LDFLAGS) -o $(EXE1)
-
-$(EXE2): $(OBJS2)
- $(CC) $(OBJS2) $(LDFLAGS) -o $(EXE2)
-
-$(OBJS):
- $(CC) $(CFLAGS) -c $< -o $@
-
-
-
-# DEPS
-
-Makefile.deps:
- rm -f $@
- @echo "-- Regenerating basic dependencies"
- @for f in $(CFIL) ; do \
- echo "`basename $$f`: \\" | sed 's/\(.*\)\.cc/\1.d/' >> $@; \
- echo "$$f" >> $@ ; done
- @echo "-include $(DEPS)" >> Makefile.deps
-
-$(DEPS):
- @echo "$(CC) $(DEPFLAGS) $< > $@"
- @$(CC) $(DEPFLAGS) $< -MT "$(@:.d=.o) $@" > tmp
- @mv tmp $@
-
-
-
-include Makefile.deps
Index: inim/binarization/proof-of-concept/configure
--- inim/binarization/proof-of-concept/configure (revision 3756)
+++ inim/binarization/proof-of-concept/configure (working copy)
@@ -1,264 +0,0 @@
-#!/bin/sh
-## configure for inim
-## Made by nicuveo <nicuveo(a)lrde.epita.fr>
-##
-
-
-
-######################################################################
-## Vars
-
-base=""
-block=""
-nonbl=""
-verbose="true"
-profile=""
-options=""
-folders=""
-os=`uname -s`
-cc="cc"
-
-
-
-######################################################################
-## Extraction functions
-
-# Prepare file
-getfile()
-{
- expand "$1" | sed ':a
-/\\$/N
-s/ *\\\n */ /
-ta
-s/#.*$//
-s/^ *//
-/^$/d'
-}
-
-# Get 'system' value
-getsysvalue()
-{
- getfile "$1" | sed -n "s/^$2: *//p" | tail -n 1
-}
-
-getvalue()
-{
- gdef=`echo "$block" | sed -n "s/^$1 *= *//p" | tail -n 1`
- gspe=`echo "$block" | sed -n "s/^$os@$1 *= *//p" | tail -n 1`
- ndef=`echo "$nonbl" | sed -n "s/^$1 *= *//p" | tail -n 1`
- nspe=`echo "$nonbl" | sed -n "s/^$os@$1 *= *//p" | tail -n 1`
-
- if [ -n "$gspe" ] ; then
- echo "$gspe"
- else
- if [ -n "$gdef" ] ; then
- echo "$gdef"
- else
- if [ -n "$nspe" ] ; then
- echo "$nspe"
- else
- echo "$ndef"
- fi
- fi
- fi
-}
-
-# Get block
-getblock()
-{
- getfile "$1" | sed -n "/\[$2\]/,/\[.*\]/P"
-}
-
-# Get non-block
-getnonblock()
-{
- getfile "$1" | sed -n '1,/\[.*\]/p'
-}
-
-
-
-######################################################################
-## Init functions
-
-# Print usage
-usage()
-{
- echo "usage: configure [options] [profile name]"
- echo "options:"
- echo " -h : print this help"
- echo " -q : disable verbose mode"
- echo " -o arg: compilation options string"
-}
-
-# getoptions
-getoptions()
-{
- while [ $# -ne 0 ] ; do
- if [ -z "`echo "$1" | sed -n '/^-/P'`" ] ; then
- if [ "$current" = "" ] ; then
- profile="$1"
- else
- usage
- echo "!!! you can provide only one profile name"
- exit 1
- fi
- else
- case "$1" in
- "-h")
- usage
- exit 0;;
- "-q")
- verbose="";;
- "-o")
- if [ $# -eq 1 ] ; then
- usage
- echo "!!! -o option takes a argument"
- exit 3
- fi
- shift
- cfil="$1";;
- *)
- usage
- echo "!!! $1 is not a valid option"
- exit 2;;
- esac
- fi
- shift
- done
-}
-
-# profile selection and test
-getprofile()
-{
- if [ -z "$profile" ] ; then
- profile=`getsysvalue configure.in profile`
- if [ -n "$verbose" ] ; then
- echo "--- using default profile '$profile'"
- fi
- else
- if [ -n "$verbose" ] ; then
- echo "--- using profile '$profile'"
- fi
- fi
-
- if [ -z "`getblock configure.in "$profile"`" ] ; then
- echo "!!! unknown profile '$profile'"
- exit 4
- fi
-}
-
-# init script
-init()
-{
- getoptions "$@"
- getprofile
- folders=`find ./*/ -name "configure.in" | sed 's/configure.in//'`
- block=`getblock configure.in "$profile"`
- nonbl=`getnonblock configure.in`
- base="$PWD"
-}
-
-
-
-######################################################################
-## Specific tasks
-
-# File header
-print_header()
-{
- echo "##"
- echo "## $1"
- echo "## generated with configure script"
- echo "##"
-}
-
-print_os ()
-{
- echo ""
- echo ""
- echo "## OS"
- echo "OS = $os"
-}
-
-print_rule()
-{
- echo ""
- echo ""
- echo "## $1"
- echo "$nonbl" | sed -n "s/^\($os@\)\{0,1\}$1 *\([:+]\{0,1\}=\) */$1 \2 /p"
- echo "$block" | sed -n "s/^\($os@\)\{0,1\}$1 *\([:+]\{0,1\}=\) */$1 \2 /p"
-}
-
-# Get compiler
-checkcc()
-{
- cc=`getvalue "CC"`
- if [ -z "$cc" ] ; then
- echo "!!! No compiler specified"
- exit 5
- fi
- if [ ! -x "`which "$cc" 2> /dev/null`" ] ; then
- echo "!!! $cc is not a valid executable file"
- exit 6
- fi
- if [ -n "$verbose" ] ; then
- echo "--- using '`which "$cc" 2> /dev/null`' as compiler"
- fi
-}
-
-# Extract all rules from file
-createrules()
-{
- for rule in `echo "$block
-$nonbl" | sed -n 's/^ *\([^ ]\{1,\}\@\)\{0,1\}\([^ ]\{1,\}\) *[:+]\{0,1\}=.*$/\2/p'\
- | sort | uniq` ; do
- print_rule "$rule" >> Makefile.rules
- done
-}
-
-# Copy Makefile
-copymakefile()
-{
- if [ -n "$verbose" ] ; then
- echo ">>> $1/Makefile.rules" | tr -s '/'
- fi
-
- block=`getblock configure.in "$profile"`
- nonbl=`getnonblock configure.in`
- createrules
-
- if [ -n "$verbose" ] ; then
- echo ">>> Creating dependencies"
- fi
- rm -f Makefile.deps *.d > /dev/null 2>&1
- make -k Makefile.deps > /dev/null 2>&1
-}
-
-
-
-######################################################################
-## Code
-
-# Main function
-main()
-{
- checkcc
- print_header "Makefile.rules" > Makefile.rules
- print_os >> Makefile.rules
- createrules ./
-
- for folder in $folders ; do
- cp Makefile.rules "$folder" 2> /dev/null
- cd "$folder"
- copymakefile "$folder"
- cd "$base"
- done
-
- if [ -n "$options" ] ; then
- echo "CFLAGS += $options" >> Makefile.rules
- fi
-}
-
-# Calls
-init "$@"
-main
Index: inim/binarization/proof-of-concept/configure.in
--- inim/binarization/proof-of-concept/configure.in (revision 3756)
+++ inim/binarization/proof-of-concept/configure.in (working copy)
@@ -1,26 +0,0 @@
-## configure.in
-## Made by nicuveo for inim
-
-
-
-## Configuration
-profile: release
-
-
-## Defaults
-CC = g++
-CFLAGS = -W -Wall -Werror -ansi -I ../../../../..
-LDFLAGS =
-DEPFLAGS = -I ../../../../.. -MM
-
-#Darwin@LDFLAGS :=
-
-
-## Debug
-[debug]
- CFLAGS += -Wextra -g -pg
- LDFLAGS += -pg
-
-## Release
-[release]
- CFLAGS += -DNDEBUG -O1
Index: inim/binarization/proof-of-concept/scripts/init_tar.sh
--- inim/binarization/proof-of-concept/scripts/init_tar.sh (revision 3756)
+++ inim/binarization/proof-of-concept/scripts/init_tar.sh (working copy)
@@ -1,14 +0,0 @@
-#! /bin/sh
-
-if [ $# -ne 1 ] ; then
- echo "usage : init_tar.sh \"tarball_root_dir\""
- return 1
-fi
-echo "rm -Rf $1"
-rm -Rf "$1"
-echo "mkdir $1 2> /dev/null"
-mkdir "$1" 2> /dev/null
-for file in `ls | grep -v $1` ; do
- echo "ln -fs ../$file $1/$file"
- ln -fs "../$file" "$1/$file"
-done
Index: inim/binarization/proof-of-concept/scripts/flower
--- inim/binarization/proof-of-concept/scripts/flower (revision 3756)
+++ inim/binarization/proof-of-concept/scripts/flower (working copy)
@@ -1,33 +0,0 @@
- ....
- ,;;'''';;, ,;;;;,
- , ;;' `;;, .,;;;' ;
- ,;;; ;; `;;,';;;,. ,%;;' '
- ,;;,;; ;; ,;`;;;, `;::. %%;'
- ;;;,;;; `' ,;;; ;;,;;, `::,%%;'
- ;;;,;;;, .,%%%%%'% ;;;;,;; %;;;
- ,%,. `;;;,;;;, .,%%%%%%%%%'%; ;;;;;,;; %;;;
- ;,`%%%%%%%%%%`;;,;;'%%%%%%%%%%%%%'%%' `;;;;;,;, %;;;
- ;;;,`%%%%%%%%%%%,; ..`%%%%%%%%;'%%%' `;;;;,;; %%;;
- `;;;;;,`%%%%%,;;/, .. `"""'',%%%%% `;;;;;; %%;;,
- `;;;;;;;,;;/////,. ,;%%%%%%% `;;;;,`%%;;
- ;;;/%%%%,%///;;;';%%%%%%, `;;;%%;;,
- ;;;/%%%,%%%%%/;;;';;'%%%%%, `%%;;
- .;;/%%,%%%%%//;;' ;;;'%%%%%, %%;;,
- ;;//%,%%%%//;;;' `;;;;'%%%% `%;;;
- ;;//%,%//;;;;' `;;;;'%%% %;;;,
- `;;//,/;;;' `;;;'%%' `%;;;
- `;;;;' `;'%' `;;;;
- ' .,,,. `;;;;
- ,;;;;;;;;;;, `;;;;
- ;;;' ;;;,;;, `;;;;
- ;;; ;;;;,;;. `;;;;
- `;; ;;;;;,;; ;;;;
- `' `;;;;,;; ;;;;
- `;;,;, ;;;;
- ;;, ;;;;
- ';;;;;
- ;;;;;
- .;;;;'
- .;;;;'
- ;;;;;'
- ,;;;;'
Index: inim/binarization/proof-of-concept/scripts/todo.sh
--- inim/binarization/proof-of-concept/scripts/todo.sh (revision 3756)
+++ inim/binarization/proof-of-concept/scripts/todo.sh (working copy)
@@ -1,26 +0,0 @@
-#! /bin/sh
-
-IFS="
-"
-KEYWORD="TODO
-FIXME"
-
-print ()
-{
- for k in $KEYWORD ; do
- for line in `find src -type f | fgrep -v ".svn" | xargs fgrep -nH $k` ; do
- info=`echo $line | sed 's/\([^:]*\):\([^:]*\):[ ]*\(.*\)/in \1 at line \2:/'`
- text=`echo $line | sed 's/\([^:]*\):\([^:]*\):[ ]*\(.*\)/\3/'`
- size=`echo $info | wc -c`
-
- void=""
- for i in `seq $size 80` ; do
- void="$void "
- done
-
- echo "$info$void$text"
- done
- done
-}
-
-print | sort
Index: inim/binarization/proof-of-concept/src/gradient.cc
--- inim/binarization/proof-of-concept/src/gradient.cc (revision 3756)
+++ inim/binarization/proof-of-concept/src/gradient.cc (working copy)
@@ -1,109 +0,0 @@
-//
-// main.cc for INIM
-// Made by nicuveo <crucuny(a)gmail.com>
-//
-
-
-
-//HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH
-// Includes
-
-#include <cassert>
-#include <string>
-#include <vector>
-
-#include <mln/core/image/image2d.hh>
-#include <mln/histo/all.hh>
-#include <mln/io/pgm/all.hh>
-#include <mln/accu/histo.hh>
-#include <mln/arith/revert.hh>
-#include <mln/convert/to_image.hh>
-#include <mln/morpho/meyer_wst.hh>
-#include <mln/core/alias/neighb1d.hh>
-#include <mln/core/alias/window2d.hh>
-#include <mln/geom/all.hh>
-#include <mln/morpho/closing_area.hh>
-#include <mln/morpho/gradient.hh>
-#include <mln/data/fill.hh>
-#include <mln/opt/at.hh>
-
-// DEBUG
-#include <mln/debug/all.hh>
-
-#include <cmath>
-
-#include "util.hxx"
-
-
-
-//HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH
-// Implementation
-
-template <int P, int Q>
-double
-strength_of (mln::value::int_u8 x)
-{
- double xprime = 1 - pow (x / 255., P);
-
- return 255 * log10 (1 + 9 * xprime);
-}
-
-template <int P>
-double
-strength_of (mln::value::int_u8 x)
-{
- return strength_of<P, 1> (x);
-}
-
-int
-main (int argc, char** argv)
-{
- using namespace mln;
-
- if (argc != 5)
- return 1;
- std::string file_in = argv[1];
- std::string file_out = argv[2];
- std::string file_hist = argv[3];
- std::istringstream is(argv[4]);
- int strength;
- is >> strength;
-
- image2d<value::int_u8> in;
- image2d<value::int_u8> grad;
- image1d<unsigned long> hist(256);
- image1d<unsigned long> hist_close(256);
-
- io::pgm::load (in, file_in);
-
- initialize(grad, in);
- grad = morpho::gradient(in, win_c4p());
-
- data::fill(hist, 0);
- image2d<value::int_u8>::fwd_piter p (in.domain ());
- for_all (p)
- opt::at(hist, in(p)) += (unsigned) strength_of<2> (grad (p));
-
- // Histo
- print_histo (hist, file_hist + "_1.histo");
-
- hist = arith::revert(hist);
- morpho::closing_area(hist, c2(), strength, hist_close);
-
- // Closed reverted histo
- print_histo (arith::revert(hist_close), file_hist + "_2.histo");
-
- image1d<size_t> wst = morpho::meyer_wst<size_t, image1d<unsigned long>, neighb1d> (hist_close, c2());
- std::vector<value::int_u8> colors = colors_init (wst);
-
- image2d<value::int_u8> cla;
- initialize(cla, in);
-
- image2d<value::int_u8>::fwd_piter q (in.domain ());
- for_all (q)
- cla (q) = colors_match (colors, in (q));
-
- image2d<value::int_u8> out = binarization(cla, 20);
-
- mln::io::pgm::save (out, file_out);
-}
Index: inim/binarization/proof-of-concept/src/util.hxx
--- inim/binarization/proof-of-concept/src/util.hxx (revision 3756)
+++ inim/binarization/proof-of-concept/src/util.hxx (working copy)
@@ -1,97 +0,0 @@
-//
-// util.hxx for inim
-// Made by nicuveo <crucuny(a)gmail.com>
-//
-
-#ifndef UTIL_HXX_
-# define UTIL_HXX_
-
-
-
-//HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH
-// Includes
-
-# include <cassert>
-# include <string>
-# include <vector>
-
-# include <mln/core/image/image2d.hh>
-# include <mln/core/image/image1d.hh>
-# include <mln/value/all.hh>
-# include <mln/accu/maj_h.hh>
-# include <mln/border/resize.hh>
-# include <mln/win/rectangle2d.hh>
-# include "snake2d.hh"
-
-
-
-//HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH
-// Declarations
-
-std::vector<mln::value::int_u8>
-colors_init (const mln::image1d<size_t>& wst)
-{
- std::vector<mln::value::int_u8> res;
- mln::image1d<size_t>::fwd_piter p (wst.domain ());
-
- for_all (p)
- {
- if (wst (p) != 0)
- continue;
-
- if (p[0] != 0)
- {
- res.push_back (p[0]);
- }
- }
-
- if (res.empty() || res.back () != 255u)
- res.push_back (255u);
-
- return res;
-}
-
-mln::value::int_u8
-colors_match (const std::vector<mln::value::int_u8>& vec, mln::value::int_u8 x)
-{
- unsigned i;
-
- for (i = 0; i < vec.size (); ++i)
- if (x <= vec[i])
- break;
-
- if (vec.size() == 1)
- return (127);
- return (i * 255) / (vec.size () - 1);
-}
-
-template <typename T>
-void
-print_histo (const mln::image1d<T>& hist, const std::string& f)
-{
- std::ofstream fo;
- typename mln::image1d<T>::fwd_piter p (hist.domain ());
-
- fo.open (f.c_str ());
-
- for_all (p)
- fo << p[0] << "\t" << hist (p) << std::endl;
-
- fo.close ();
-}
-
-mln::image2d<mln::value::int_u8>
-binarization(mln::image2d<mln::value::int_u8>& input, int size)
-{
- mln::image2d<mln::value::int_u8> output;
- initialize(output, input);
-
- mln::border::resize(input, 0);
- mln::image2d<mln::value::int_u8> maj = snake2d(mln::accu::maj_h<mln::value::int_u8>(), input, mln::win::rectangle2d(size,size));
- mln::image2d<mln::value::int_u8>::fwd_piter p (input.domain());
- for_all (p)
- output(p) = (input(p) != maj(p)) * 255;
- return output;
-}
-
-#endif /* !UTIL_HH_ */
Index: inim/binarization/proof-of-concept/src/basic.cc
--- inim/binarization/proof-of-concept/src/basic.cc (revision 3756)
+++ inim/binarization/proof-of-concept/src/basic.cc (working copy)
@@ -1,75 +0,0 @@
-//
-// main.cc for INIM
-// Made by nicuveo <crucuny(a)gmail.com>
-//
-
-
-
-//HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH
-// Includes
-
-#include <mln/core/image/image2d.hh>
-#include <mln/core/image/image1d.hh>
-#include <mln/histo/all.hh>
-#include <mln/io/pgm/all.hh>
-#include <mln/value/all.hh>
-#include <mln/accu/histo.hh>
-#include <mln/arith/revert.hh>
-#include <mln/convert/to_image.hh>
-#include <mln/morpho/meyer_wst.hh>
-#include <mln/core/alias/neighb1d.hh>
-#include <mln/geom/all.hh>
-#include <mln/morpho/closing_area.hh>
-
-#include "util.hxx"
-
-
-
-//HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH
-// Implementation
-
-int
-main (int argc, char** argv)
-{
- using namespace mln;
-
- if (argc != 5)
- return 1;
- std::string file_in = argv[1];
- std::string file_out = argv[2];
- std::string file_hist = argv[3];
- std::istringstream is(argv[4]);
- int strength;
- is >> strength;
-
- image2d<value::int_u8> in;
-
- io::pgm::load (in, file_in);
- histo::data<value::int_u8> histo = histo::compute (in);
-
- image1d<size_t> hist = convert::to_image (histo);
-
- // Histo
- print_histo (hist, file_hist + "_1.histo");
-
- image1d<size_t> hist_close;
- initialize(hist_close, hist);
- morpho::closing_area(arith::revert(hist), c2(), strength, hist_close);
-
- // Closed reverted histo
- print_histo (arith::revert(hist_close), file_hist + "_2.histo");
-
- image1d<size_t> wst = morpho::meyer_wst<size_t, image1d<size_t>, neighb1d> (hist_close, c2());
- std::vector<value::int_u8> colors = colors_init (wst);
-
- image2d<value::int_u8> cla;
- initialize(cla, in);
-
- image2d<value::int_u8>::fwd_piter p (in.domain ());
- for_all (p)
- cla (p) = colors_match (colors, in (p));
-
- image2d<value::int_u8> out = binarization(cla, 20);
-
- mln::io::pgm::save (out, file_out);
-}
Index: inim/binarization/proof-of-concept/src/snake2d.hh
--- inim/binarization/proof-of-concept/src/snake2d.hh (revision 3756)
+++ inim/binarization/proof-of-concept/src/snake2d.hh (working copy)
@@ -1,190 +0,0 @@
-#include <mln/core/alias/neighb2d.hh>
-#include <mln/win/diff.hh>
-#include <mln/win/shift.hh>
-#include <mln/extension/adjust_fill.hh>
-#include <mln/canvas/browsing/snake_generic.hh>
-
-namespace mln
-{
-
- template <typename I, typename W, typename A>
- struct snake2d_functor
- {
- typedef snake2d_functor<I,W, A> self;
- typedef void (self::*move_fun)();
- typedef mln_deduce(I, psite, delta) dpsite;
-
- const I& input;
- const W& win;
- mln_ch_value(I, mln_result(A)) output;
- A accu;
-
- mln_psite(I) p;
-
- window2d
- win_left_fwd,
- win_right_fwd,
- win_left_bkd,
- win_right_bkd,
- win_bot_up,
- win_top_up,
- win_bot_down,
- win_top_down;
-
- mln_qiter(window2d)
- q_l_fwd,
- q_r_fwd,
- q_l_bkd,
- q_r_bkd,
- q_top_up,
- q_bot_up,
- q_top_down,
- q_bot_down;
-
- std::vector<move_fun> moves;
- std::vector<dpsite> dps;
-
- snake2d_functor(const I& input, const W& win)
- : input(input),
- win(win),
- accu(),
-
- win_left_fwd(win::shift(win, mln::left) - win),
- win_right_fwd(win - win::shift(win, mln::left)),
- win_left_bkd(win::shift(win_left_fwd, mln::right)),
- win_right_bkd(win::shift(win_right_fwd, mln::right)),
-
- win_bot_up(win::shift(win, mln::down) - win),
- win_top_up(win - win::shift(win, mln::down)),
- win_bot_down(win::shift(win_bot_up, mln::up)),
- win_top_down(win::shift(win_top_up, mln::up)),
-
- q_l_fwd(win_left_fwd, p),
- q_r_fwd(win_right_fwd, p),
- q_l_bkd(win_left_bkd, p),
- q_r_bkd(win_right_bkd, p),
-
- q_top_up(win_top_up, p),
- q_bot_up(win_bot_up, p),
- q_top_down(win_top_down, p),
- q_bot_down(win_bot_down, p),
-
- moves(3),
- dps(3)
- {
- if (win_bot_up.size() + win_top_up.size() +
- win_bot_down.size() + win_top_down.size() <
- win_left_fwd.size() + win_right_fwd.size() +
- win_left_bkd.size() + win_right_bkd.size())
- {
- // Vertical snake
- dps[0] = mln::right;
- dps[1] = mln::down;
- dps[2] = mln::up;
- moves[0] = &self::right;
- moves[1] = &self::down;
- moves[2] = &self::up;
- }
- else
- {
- // Horizontal snake
- dps[0] = mln::down;
- dps[1] = mln::right;
- dps[2] = mln::left;
- moves[0] = &self::down;
- moves[1] = &self::right;
- moves[2] = &self::left;
- }
- }
-
- void init()
- {
- initialize(output, input);
- accu.init();
- p = input.domain().pmin() - dps[0];
- mln_qiter(W) q(win, p);
- for_all(q)
- if (input.has(q))
- accu.take(input(q));
- p = input.domain().pmin();
- }
-
- void right()
- {
- for_all(q_l_fwd)
- if (input.has(q_l_fwd))
- accu.untake(input(q_l_fwd));
- for_all(q_r_fwd)
- if (input.has(q_r_fwd))
- accu.take(input(q_r_fwd));
- output(p) = accu;
- }
-
- void left()
- {
- for_all(q_r_bkd)
- if (input.has(q_r_bkd))
- accu.untake(input(q_r_bkd));
- for_all(q_l_bkd)
- if (input.has(q_l_bkd))
- accu.take(input(q_l_bkd));
- output(p) = accu;
- }
-
- void down()
- {
- for_all(q_top_down)
- if (input.has(q_top_down))
- accu.untake(input(q_top_down));
- for_all(q_bot_down)
- if (input.has(q_bot_down))
- accu.take(input(q_bot_down));
- output(p) = accu;
- }
-
- void up()
- {
- for_all(q_bot_up)
- if (input.has(q_bot_up))
- accu.untake(input(q_bot_up));
- for_all(q_top_up)
- if (input.has(q_top_up))
- accu.take(input(q_top_up));
- output(p) = accu;
- }
-
- };
-
- template <typename A, typename I, typename W>
- inline
- mln_ch_value(I, mln_result(A))
- snake2d(const Accumulator<A>&, const Image<I>& input, const Window<W>& win)
- {
- trace::entering("accu::snake2d");
-
- typedef snake2d_functor<I, W, A> F;
- F f(exact(input), exact(win));
- canvas::browsing::snake_generic(f);
-
- trace::exiting("accu::snake2d");
-
- return f.output;
- }
-
- template <typename A, typename I, typename W>
- inline
- mln_ch_value(I, mln_accu_with(A, mln_value(I))::result)
- snake2d(const Meta_Accumulator<A>&, const Image<I>& input, const Window<W>& win)
- {
- trace::entering("accu::snake2d");
-
- typedef mln_accu_with(A, mln_value(I)) A_;
- typedef snake2d_functor<I, W, A_> F;
- F f(exact(input), exact(win));
- canvas::browsing::snake_generic(f);
-
- trace::exiting("accu::snake2d");
- return f.output;
- }
-
-} // mln
Index: inim/binarization/proof-of-concept/ChangeLog
--- inim/binarization/proof-of-concept/ChangeLog (revision 3756)
+++ inim/binarization/proof-of-concept/ChangeLog (working copy)
@@ -1,69 +0,0 @@
-2008-11-01 Vivien Delmon <vivien.delmon(a)lrde.epita.fr>
-
- Add snake2d and apply it on the classified image.
- * src/basic.cc: .
- * src/gradient.cc: .
- * src/snake2d.hh: New.
- * src/util.hxx: .
-
-2008-10-31 Vivien Delmon <vivien.delmon(a)lrde.epita.fr>
-
- Fix bugs and improve histogram io.
- * build/configure.in: .
- * configure.in: .
- * src/basic.cc: .
- * src/gradient.cc: .
- * src/util.cc: Remove.
- * src/util.hh: Remove.
- * src/util.hxx: New.
-
-2008-10-27 Vivien Delmon <vivien.delmon(a)lrde.epita.fr>
-
- Remove debug.
- * src/gradient/gradient.cc: remove std::cout.
-
-2008-10-27 Vivien Delmon <vivien.delmon(a)lrde.epita.fr>
-
- Add gradient implementation.
- * Makefile,
- * configure,
- * src/gradient/gradient.cc: do it.
-
-2008-10-27 Vivien Delmon <vivien.delmon(a)lrde.epita.fr>
-
- Update svn:ignore.
-
-2008-10-27 Vivien Delmon <vivien.delmon(a)lrde.epita.fr>
-
- Add kind of a real Makefile.
- * Makefile: TC-11 Makefile.
- * configure: New.
- * main.cc: Remove.
- * src/basic/basic.cc: New.
- * src/basic: New.
- * src/gradient/gradient.cc: New.
- * src/gradient: New.
- * src: New.
-
-2008-10-27 Vivien Delmon <vivien.delmon(a)lrde.epita.fr>
-
- Remove debug and make some cosmetic rewriting.
- * main.cc: .
-
-2008-10-17 Vivien Delmon <vivien.delmon(a)lrde.epita.fr>
-
- Add - 1.
- * main.cc: Fix - 1.
-
-2008-10-15 Vivien Delmon <vivien.delmon(a)lrde.epita.fr>
-
- Add closing area.
- * main.cc: add closing area on the reverted histo and correct the
- neighborhood usage.
-
-2008-10-15 Vivien Delmon <vivien.delmon(a)lrde.epita.fr>
-
- Make main.cc compatible with cleanup branch of milena.
- * ChangeLog: New.
- * main.cc: Fix include paths.
-
Index: inim/binarization/proof-of-concept/check/graph.sh
--- inim/binarization/proof-of-concept/check/graph.sh (revision 3756)
+++ inim/binarization/proof-of-concept/check/graph.sh (working copy)
@@ -1,27 +0,0 @@
-#! /bin/sh
-## graph.sh for memory
-## Made by leblanc <nicuveo(a)lrde.epita.fr>
-##
-
-
-## Vars
-
-in=$1
-out=$2
-w=$3
-h=$4
-if [ -z "$w" ] ; then
- w=800
-fi
-if [ -z "$h" ] ; then
- h=600
-fi
-
-## Code
-
-export w
-export h
-export in
-export out
-
-gnuplot histo.gp
Index: inim/binarization/proof-of-concept/check/histo.gp
--- inim/binarization/proof-of-concept/check/histo.gp (revision 3756)
+++ inim/binarization/proof-of-concept/check/histo.gp (working copy)
@@ -1,19 +0,0 @@
-# group.gp
-# print epsilon evolution for a game at a fixed complexity
-
-
-set term png enhanced size `echo "$w,$h"`
-
-set style data boxes
-
-set xlabel "color"
-
-set xrange [0:255]
-set yrange [0:*]
-
-set xtics border nomirror
-set ytics border nomirror
-
-set output "`echo "$out"`"
-
-plot "`echo "$in"`" using 1:2 notitle
Index: inim/binarization/proof-of-concept/check/Makefile
--- inim/binarization/proof-of-concept/check/Makefile (revision 3756)
+++ inim/binarization/proof-of-concept/check/Makefile (working copy)
@@ -1,71 +0,0 @@
-# Vars
-
-PROGS := $(notdir $(wildcard ../bin/*))
-IMG := $(wildcard *.pgm)
-HISTS := $(shell seq 2)
-PARAM := 5 10 20 40
-
-all: check
-
-
-
-# Histo rule generation
-
-define HISTO_RULE
-$1-$2/$4.png: $1-$2/$4.histo histo.gp graph.sh
- ./graph.sh $$< $$@ "$(W)" "$(H)"
-$1-$2/$4.histo: $3 ../bin/$1
- ../bin/$1 $3 $1-$2/$3 $1-$2/$(3:.pgm=) $2
-
-TODO += $1-$2/$4.png
-endef
-
-
-
-# Images rule generation
-
-define IMG_RULE
-$1-$2/$3: $3 ../bin/$1
- ../bin/$1 $$< $$@ $$(@:.pgm=) $2
-TODO += $1-$2/$3
-$(foreach num,$(HISTS),$(eval $(call HISTO_RULE,$1,$2,$3,$(3:.pgm=_$(strip $(num))))))
-endef
-
-
-
-# Folder rule generation
-
-define PROG_RULE
-FOLDS += $1-$2
-$1-$2: ../bin/$1
-$(foreach img,$(IMG),$(eval $(call IMG_RULE,$1,$2,$(strip $(img)))))
-endef
-
-
-
-# Param rule generation
-
-define PARAM_RULE
-$(foreach param,$(PARAM),$(eval $(call PROG_RULE,$1,$(strip $(param)))))
-endef
-
-
-
-# Main
-
-$(foreach prog,$(PROGS),$(eval $(call PARAM_RULE,$(strip $(prog)))))
-
-
-
-# Main
-
-check: $(FOLDS) $(TODO)
-
-$(FOLDS):
- mkdir -p $@
-
-clean:
- find . -name "*.histo" -delete
-
-distclean: clean
- find * -type d \! -path '*svn*' | xargs rm -Rf
Index: inim/binarization/proof-of-concept/Makefile
--- inim/binarization/proof-of-concept/Makefile (revision 3756)
+++ inim/binarization/proof-of-concept/Makefile (working copy)
@@ -1,87 +0,0 @@
-##
-## Makefile for inim
-## Made by nicuveo <nicuveo(a)lrde.epita.fr>
-##
-
-include Makefile.rules
-
-
-
-# VARS
-
-PROJ = binarisation
-
-TB = $(PROJ)
-TB_TGZ = $(TB).tgz
-TB_BZ2 = $(TB).bz2
-TB_TAR.GZ = $(TB).tar.gz
-TB_TAR.BZ2 = $(TB).tar.bz2
-
-CLEAN = '*~' '\#*' '.\#*' '.DS_Store' '.gdb_history' '*.stackdump'\
-'.gdb_history' 'gmon.out'
-
-
-
-# MAIN
-
-all:
- cd ./build/ && make all
-
-basic:
- cd ./build/ && make basic
-
-gradient:
- cd ./build/ && make gradient
-
-clean: do_clean
- cd ./build/ && make -k clean
- cd ./check/ && make -k clean
-
-distclean: do_distclean
- cd ./build/ && make -k distclean
- cd ./check/ && make -k distclean
-
-check: all
- cd ./check/ && make check
-
-recheck: all
- cd ./check/ && make clean check
-
-flower:
- cat ./scripts/flower
-
-todo:
- ./scripts/todo.sh
-
-dist tar tarball: $(TB_TAR.BZ2)
-
-
-
-# CLEAN
-
-do_clean:
- for f in ${CLEAN} ; do find . -name "$$f" | xargs rm -f ; done
-
-do_distclean: do_clean
- rm -f $(TB_TGZ) $(TB_BZ2) $(TB_TAR.GZ) $(TB_TAR.BZ2)
- rm -f Makefile.rules
-
-
-
-# TARBALLS
-
-$(TB_TAR.GZ) $(TB_TGZ) : distclean
- ./scripts/init_tar.sh "$(TB)"
- tar -hcvzf $@ --exclude=".svn" "$(TB)"
- rm -Rf "$(TB)"
-
-$(TB_TAR.BZ2) $(TB_BZ2) : distclean
- ./scripts/init_tar.sh "$(TB)"
- tar -hcvjf $@ --exclude=".svn" "$(TB)"
- rm -Rf "$(TB)"
-
-
-
-# SPECIALS
-
-.PHONY: todo
Index: inim/binarization/snake2d.hh
--- inim/binarization/snake2d.hh (revision 3756)
+++ inim/binarization/snake2d.hh (working copy)
@@ -1,190 +0,0 @@
-#include <mln/core/alias/neighb2d.hh>
-#include <mln/win/diff.hh>
-#include <mln/win/shift.hh>
-#include <mln/extension/adjust_fill.hh>
-#include <mln/canvas/browsing/snake_generic.hh>
-
-namespace mln
-{
-
- template <typename I, typename W, typename A>
- struct snake2d_functor
- {
- typedef snake2d_functor<I,W, A> self;
- typedef void (self::*move_fun)();
- typedef mln_deduce(I, psite, delta) dpsite;
-
- const I& input;
- const W& win;
- mln_ch_value(I, mln_result(A)) output;
- A accu;
-
- mln_psite(I) p;
-
- window2d
- win_left_fwd,
- win_right_fwd,
- win_left_bkd,
- win_right_bkd,
- win_bot_up,
- win_top_up,
- win_bot_down,
- win_top_down;
-
- mln_qiter(window2d)
- q_l_fwd,
- q_r_fwd,
- q_l_bkd,
- q_r_bkd,
- q_top_up,
- q_bot_up,
- q_top_down,
- q_bot_down;
-
- std::vector<move_fun> moves;
- std::vector<dpsite> dps;
-
- snake2d_functor(const I& input, const W& win)
- : input(input),
- win(win),
- accu(),
-
- win_left_fwd(win::shift(win, mln::left) - win),
- win_right_fwd(win - win::shift(win, mln::left)),
- win_left_bkd(win::shift(win_left_fwd, mln::right)),
- win_right_bkd(win::shift(win_right_fwd, mln::right)),
-
- win_bot_up(win::shift(win, mln::down) - win),
- win_top_up(win - win::shift(win, mln::down)),
- win_bot_down(win::shift(win_bot_up, mln::up)),
- win_top_down(win::shift(win_top_up, mln::up)),
-
- q_l_fwd(win_left_fwd, p),
- q_r_fwd(win_right_fwd, p),
- q_l_bkd(win_left_bkd, p),
- q_r_bkd(win_right_bkd, p),
-
- q_top_up(win_top_up, p),
- q_bot_up(win_bot_up, p),
- q_top_down(win_top_down, p),
- q_bot_down(win_bot_down, p),
-
- moves(3),
- dps(3)
- {
- if (win_bot_up.size() + win_top_up.size() +
- win_bot_down.size() + win_top_down.size() <
- win_left_fwd.size() + win_right_fwd.size() +
- win_left_bkd.size() + win_right_bkd.size())
- {
- // Vertical snake
- dps[0] = mln::right;
- dps[1] = mln::down;
- dps[2] = mln::up;
- moves[0] = &self::right;
- moves[1] = &self::down;
- moves[2] = &self::up;
- }
- else
- {
- // Horizontal snake
- dps[0] = mln::down;
- dps[1] = mln::right;
- dps[2] = mln::left;
- moves[0] = &self::down;
- moves[1] = &self::right;
- moves[2] = &self::left;
- }
- }
-
- void init()
- {
- initialize(output, input);
- accu.init();
- p = input.domain().pmin() - dps[0];
- mln_qiter(W) q(win, p);
- for_all(q)
- if (input.has(q))
- accu.take(input(q));
- p = input.domain().pmin();
- }
-
- void right()
- {
- for_all(q_l_fwd)
- if (input.has(q_l_fwd))
- accu.untake(input(q_l_fwd));
- for_all(q_r_fwd)
- if (input.has(q_r_fwd))
- accu.take(input(q_r_fwd));
- output(p) = accu;
- }
-
- void left()
- {
- for_all(q_r_bkd)
- if (input.has(q_r_bkd))
- accu.untake(input(q_r_bkd));
- for_all(q_l_bkd)
- if (input.has(q_l_bkd))
- accu.take(input(q_l_bkd));
- output(p) = accu;
- }
-
- void down()
- {
- for_all(q_top_down)
- if (input.has(q_top_down))
- accu.untake(input(q_top_down));
- for_all(q_bot_down)
- if (input.has(q_bot_down))
- accu.take(input(q_bot_down));
- output(p) = accu;
- }
-
- void up()
- {
- for_all(q_bot_up)
- if (input.has(q_bot_up))
- accu.untake(input(q_bot_up));
- for_all(q_top_up)
- if (input.has(q_top_up))
- accu.take(input(q_top_up));
- output(p) = accu;
- }
-
- };
-
- template <typename A, typename I, typename W>
- inline
- mln_ch_value(I, mln_result(A))
- snake2d(const Accumulator<A>&, const Image<I>& input, const Window<W>& win)
- {
- trace::entering("accu::snake2d");
-
- typedef snake2d_functor<I, W, A> F;
- F f(exact(input), exact(win));
- canvas::browsing::snake_generic(f);
-
- trace::exiting("accu::snake2d");
-
- return f.output;
- }
-
- template <typename A, typename I, typename W>
- inline
- mln_ch_value(I, mln_accu_with(A, mln_value(I))::result)
- snake2d(const Meta_Accumulator<A>&, const Image<I>& input, const Window<W>& win)
- {
- trace::entering("accu::snake2d");
-
- typedef mln_accu_with(A, mln_value(I)) A_;
- typedef snake2d_functor<I, W, A_> F;
- F f(exact(input), exact(win));
- canvas::browsing::snake_generic(f);
-
- trace::exiting("accu::snake2d");
- return f.output;
- }
-
-} // mln
Index: inim/binarization/binarization.hh
--- inim/binarization/binarization.hh (revision 3756)
+++ inim/binarization/binarization.hh (working copy)
@@ -1,78 +0,0 @@
-#include <mln/histo/all.hh>
-#include <mln/convert/to_image.hh>
-#include <mln/core/image/image1d.hh>
-#include <mln/core/alias/neighb1d.hh>
-#include <mln/arith/revert.hh>
-#include <mln/morpho/closing_area.hh>
-#include <mln/morpho/meyer_wst.hh>
-#include <mln/border/resize.hh>
-#include <mln/accu/maj_h.hh>
-#include <mln/opt/at.hh>
-#include "snake2d.hh"
-
-namespace mln
-{
-
- namespace binarization
- {
- template<typename I, typename W>
- mln_concrete_ch_value(I, bool)
- binarization(const Image<I>& input, const Window<W>& win, int strength);
-
-# ifndef MLN_INCLUDE_ONLY
- namespace impl
- {
- template<typename I, typename W>
- mln_concrete_ch_value(I, bool)
- binarization_(const I& input, const W& win, int strength)
- {
- trace::entering("binarisation_");
- mln_concrete_ch_value(I, bool) output(input.domain());
-
- histo::data<mln_value(I)> hist = histo::compute (input);
- image1d<std::size_t> hist_img = convert::to_image(hist);
- image1d<std::size_t> hist_revert_closed;
- initialize(hist_revert_closed, hist_img);
- morpho::closing_area(arith::revert(hist_img), c2(), strength, hist_revert_closed);
- int nbasins;
- image1d<int> wst = morpho::meyer_wst(hist_revert_closed, c2(), nbasins);
-// if (wst(wst.nelements() - 1) == 0)
-// wst(p) = wst(p++);
- I cla;
- initialize(cla, input);
- typename I::fwd_piter q (input.domain());
- for_all (q)
- if (opt::at(wst, input(q)) == 0)
- cla(q) = opt::at(wst, input(q) + 1);
- else
- cla(q) = opt::at(wst, input(q));
- border::resize(cla, 0);
- I maj = snake2d(accu::meta::maj_h(), cla, win);
- typename I::fwd_piter r (cla.domain());
- for_all (r)
- output(r) = (cla(r) != maj(r));
-
- trace::exiting("binarisation_");
- return output;
- }
- }
-
- template<typename I, typename W>
- mln_concrete_ch_value(I, bool)
- binarization(const Image<I>& input, const Window<W>& win, int strength)
- {
- trace::entering("binarisation");
- mln_precondition(exact(input).is_valid());
-
- mln_concrete_ch_value(I, bool) output(exact(input).domain());
- output = impl::binarization_(exact(input), exact(win), strength);
-
- trace::exiting("binarisation");
- return output;
- }
-
-# endif // ! MLN_INCLUDE_ONLY
-
- } // end of namespace mln::binarization
-
-} // end of namespace mln
Index: inim/binarization/snake2d.cc
--- inim/binarization/snake2d.cc (revision 3756)
+++ inim/binarization/snake2d.cc (working copy)
@@ -1,39 +0,0 @@
-#include <mln/win/rectangle2d.hh>
-#include <mln/accu/maj_h.hh>
-#include <mln/value/int_u8.hh>
-#include <mln/level/compare.hh>
-#include <mln/make/image2d.hh>
-#include <mln/border/thickness.hh>
-#include "snake2d.hh"
-
-#include <mln/debug/all.hh>
-
-int main()
-{
- using namespace mln;
- using value::int_u8;
-
- int_u8 vals [5][5] = {
- {0, 0, 0, 1, 1},
- {0, 0, 0, 1, 1},
- {0, 0, 1, 1, 1},
- {2, 3, 3, 3, 3},
- {5, 4, 4, 5, 5}
- };
-
- int_u8 valres [5][5] = {
- {0, 0, 0, 1, 1},
- {0, 0, 0, 1, 1},
- {0, 0, 0, 1, 1},
- {0, 0, 1, 1, 1},
- {0, 3, 3, 3, 3}
- };
-
- border::thickness = 0;
- image2d<int_u8> ima = make::image2d(vals);
- image2d<int_u8> res = snake2d(accu::maj_h<int_u8>(), ima, win::rectangle2d(5,5));
- mln_assertion (res == make::image2d(valres));
- image2d<int_u8> res2 = snake2d(accu::maj_h<int_u8>(), ima, win::rectangle2d(5,5));
- mln_assertion (res2 == make::image2d(valres));
- return 0;
-}
Index: inim/binarization/binarization.cc
--- inim/binarization/binarization.cc (revision 3756)
+++ inim/binarization/binarization.cc (working copy)
@@ -1,36 +0,0 @@
-#include <iostream>
-#include <string>
-#include <mln/io/pgm/all.hh>
-#include <mln/win/rectangle2d.hh>
-#include <mln/value/all.hh>
-#include <mln/core/image/image2d.hh>
-#include "binarization.hh"
-
-
-int main(int argc, char** argv)
-{
- if (argc != 5)
- {
- std::cerr << argv[0] << " in out strength size" << std::endl;
- return 42;
- }
- std::string in(argv[1]);
- std::string out(argv[2]);
- std::istringstream is(argv[3]);
- int strength;
- is >> strength;
- std::istringstream iss(argv[4]);
- int size;
- iss >> size;
-
- mln::image2d<mln::value::int_u8> input;
- mln::image2d<mln::value::int_u8> to_print;
- mln::io::pgm::load(input, in);
- mln::image2d<bool> output = mln::binarization::binarization(input, mln::win::rectangle2d(size,size), strength);
- initialize(to_print, output);
- mln::image2d<mln::value::int_u8>::fwd_piter p(input.domain());
- for_all (p)
- to_print(p) = output(p) * 255;
- mln::io::pgm::save(to_print, out);
- return 0;
-}
Property changes on: inim/2009/classif
___________________________________________________________________
Added: svn:mergeinfo
Property changes on: inim/2009/binarization
___________________________________________________________________
Added: svn:mergeinfo
Index: inim/color/min_tree_volume_filter.cc
--- inim/color/min_tree_volume_filter.cc (revision 3756)
+++ inim/color/min_tree_volume_filter.cc (working copy)
@@ -1,551 +0,0 @@
-# include <mln/core/var.hh>
-
-# include <mln/core/image/image2d.hh>
-# include <mln/core/image/image_if.hh>
-# include <mln/core/image/extended.hh>
-# include <mln/core/routine/extend.hh>
-
-# include <mln/core/alias/window2d.hh>
-# include <mln/core/alias/neighb2d.hh>
-# include <mln/make/double_neighb2d.hh>
-# include <mln/core/site_set/p_centered.hh>
-
-
-# include <mln/literal/black.hh>
-
-# include <mln/value/int_u8.hh>
-# include <mln/value/int_u16.hh>
-# include <mln/io/pgm/load.hh>
-# include <mln/io/pgm/save.hh>
-
-# include <mln/value/rgb8.hh>
-# include <mln/io/ppm/load.hh>
-# include <mln/io/ppm/save.hh>
-
-# include <mln/accu/min_max.hh>
-
-# include <mln/fun/i2v/array.hh>
-# include <mln/fun/p2v/iota.hh>
-
-# include <mln/data/paste.hh>
-# include <mln/data/fill.hh>
-# include <mln/level/transform.hh>
-# include <mln/extension/fill.hh>
-
-# include <mln/morpho/closing_area.hh>
-# include <mln/opt/at.hh>
-
-
-# include <mln/debug/println.hh>
-
-# include "src/distance.hh"
-
-
-namespace mln
-{
- template <typename I, typename N, typename Ic, typename Nc>
- struct min_tree_
- {
- typedef mln_site(I) point;
- typedef p_array<point> S;
-
- // in:
- const I& f;
- const N& nbh;
- const Ic& ref;
- const Nc& nbhc;
-
- // aux:
- S s;
- mln_ch_value(I, bool) deja_vu;
- mln_ch_value(I, point) parent;
- mln_ch_value(I, bool) resp;
- mln_ch_value(I, point) zpar;
-
- // attached data:
- int lambda;
- mln_ch_value(I, int) volume;
- mln_ch_value(Ic, value::rgb8) color;
-
-
- min_tree_(const I& f, const N& nbh, const Ic& ref, const Nc& nbhc,
- int lambda)
- : f(f),
- nbh(nbh),
- ref(ref),
- nbhc(nbhc),
- lambda(lambda)
- {
- run();
- }
-
- void run()
- {
- // init
- {
- initialize(deja_vu, f);
- initialize(parent, f);
- initialize(resp, f);
- initialize(zpar, f);
- initialize(volume, f);
- initialize(color, f);
-
- mln::data::fill(deja_vu, false);
- mln::data::fill(color, value::rgb8(255, 255, 255));
- mln::data::fill(volume, 0);
-
- s = level::sort_psites_increasing(f);
- }
-
- // first pass
- {
- mln_fwd_piter(S) p(s);
- mln_niter(N) n(nbh, p);
- for_all(p)
- {
- make_set(p);
- for_all(n)
- if (f.has(n) && deja_vu(n))
- do_union(n, p);
- deja_vu(p) = true;
- }
- }
-
- // second pass: canonization
- {
- mln_bkd_piter(S) p(s);
- for_all(p)
- {
- point q = parent(p);
- if (f(parent(q)) == f(q))
- {
- parent(p) = parent(q);
- resp(q) = false;
- }
- }
- }
-
- // third pass: Merging region with volume < lambda
- {
- mln_fwd_piter(S) p(s);
- for_all(p)
- {
- if (resp(p) && (volume(p) < lambda))
- {
- resp(p) = false;
- update_data(parent(p), volume(p), color(p));
- }
- }
- }
-
- } // end of run()
-
- void make_set(const point& p)
- {
- parent(p) = p;
- zpar(p) = p;
- init_data(p);
- }
-
- void set_parent(const point& r, const point& p)
- {
- parent(r) = p;
- merge_data(r, p);
- }
-
- bool is_root(const point& p) const
- {
- return parent(p) == p;
- }
-
- bool is_node(const point& p) const
- {
- //return is_root(p) || f(parent(p)) != f(p);
- return (is_root(p) || resp(p));
- }
-
- point find_root(const point& x)
- {
- if (zpar(x) == x)
- return x;
- else
- return zpar(x) = find_root(zpar(x));
- }
-
- point find_representative(const point& x)
- {
- if (parent(x) == x || resp(x))
- return x;
- else
- return find_representative(parent(x));
- }
-
- void do_union(const point& n, const point& p)
- {
- point r = find_root(n);
- if (r != p)
- {
- set_parent(r, p);
- zpar(r) = p;
- }
- }
-
- void init_data(const point& p)
- {
- // init volume
- volume(p) = f(p);
-
-
- // init color
- int red =0, green = 0, blue = 0;
-
- mln_niter(Nc) n(nbhc, p);
- for_all(n)
- {
- red += ref(n).red();
- green += ref(n).green();
- blue += ref(n).blue();
- }
-
- red /= 2;
- green /= 2;
- blue /= 2;
-
- color(p).red() = red;
- color(p).green() = green;
- color(p).blue() = blue;
-
-
- resp(p) = true;
- }
-
- void merge_data(const point& r, const point& p)
- {
- if (f(p) == f(r))
- {
- resp(p) = false;
-
- // merge volume
- volume(r) += volume(p);
-
- // merge color
- color(r) = (color(r) + color(p)) / 2;
- }
- }
-
- void update_data(const point& p, int val, value::rgb8 c)
- {
- // update volume
- volume(p) += val;
- // update color
- color(p) = (color(p) + c) / 2;
-
- if (parent(p) != p && !resp(p))
- update_data(parent(p), val, color(p));
- }
-
- };
-}
-
-namespace mln
-{
- image2d<value::int_u16> convert_to_grey(const image2d<value::rgb8>& data)
- {
- image2d<value::int_u16> output(data.domain());
- mln_piter_(image2d<value::int_u16>) p(output.domain());
- for_all(p)
- output(p) = (int) (data(p).red() * 0.3 + data(p).green() * 0.58 + data(p).blue()) * 0.12;
- return output;
- }
-} // end of mln
-
-namespace mln
-{
-
- struct colorize : Function_v2v< colorize >
- {
- typedef value::rgb8 result;
- colorize(unsigned max)
- : lut(max + 1)
- {
- lut[0] = literal::black;
- for (unsigned i = 1; i <= max; ++i)
- lut[i] = result(100 + std::rand() % 150,
- 100 + std::rand() % 150,
- 100 + std::rand() % 150);
- }
- result operator()(unsigned i) const
- {
- return lut[i];
- }
- std::vector<result> lut;
- };
-
- template <typename I>
- I display_edge(const I& ima, mln_value(I) bg, unsigned zoom)
- {
- unsigned nrows = ima.nrows() / 2 + 1;
- unsigned ncols = ima.ncols() / 2 + 1;
- I output(nrows * (zoom + 1) - 1,
- ncols * (zoom + 1) - 1);
- data::fill(output, bg);
-
- mln_VAR(edge, ima | is_edge);
- mln_piter(edge_t) p(edge.domain());
- for_all(p)
- if (p.row() % 2) // horizontal edge
- {
- unsigned row = (p.row() / 2 + 1) * (zoom + 1) - 1;
- unsigned col = (p.col() / 2) * (zoom + 1);
- for (unsigned i = 0; i < zoom; ++i)
- opt::at(output, row, col + i) = ima(p);
- }
- else // vertical edge
- {
- unsigned row = (p.row() / 2) * (zoom + 1);
- unsigned col = (p.col() / 2 + 1) * (zoom + 1) - 1;
- for (unsigned i = 0; i < zoom; ++i)
- opt::at(output, row + i, col) = ima(p);
- }
- return output;
- }
-
-
- template <typename I>
- I display_edge(const I& ima, unsigned zoom)
- {
- unsigned nrows = ima.nrows() / 2 + 1;
- unsigned ncols = ima.ncols() / 2 + 1;
- I output(nrows * (zoom + 1) - 1,
- ncols * (zoom + 1) - 1);
-
- mln_VAR( cell, ima | is_cell );
- mln_piter(cell_t) q(cell.domain());
- for_all(q)
- {
- unsigned row = (q.row() / 2) * (zoom + 1);
- unsigned col = (q.col() / 2) * (zoom + 1);
- for (unsigned i = 0; i < zoom; ++i)
- for (unsigned j = 0; j < zoom; ++j)
- opt::at(output, row + i, col + j) = ima(q);
- }
-
- mln_VAR( edge, ima | is_edge );
- mln_piter(edge_t) p(edge.domain());
- for_all(p)
- if (p.row() % 2) // horizontal edge
- {
- unsigned row = (p.row() / 2 + 1) * (zoom + 1) - 1;
- unsigned col = (p.col() / 2) * (zoom + 1);
- for (unsigned i = 0; i < zoom; ++i)
- opt::at(output, row, col + i) = ima(p);
- }
- else // vertical edge
- {
- unsigned row = (p.row() / 2) * (zoom + 1);
- unsigned col = (p.col() / 2 + 1) * (zoom + 1) - 1;
- for (unsigned i = 0; i < zoom; ++i)
- opt::at(output, row + i, col) = ima(p);
- }
- return output;
- }
-
-
- namespace morpho
- {
-
- template <typename I, typename N>
- mln_concrete(I)
- dilation(const I& input, const N& nbh)
- {
- typedef mln_value(I) V;
-
- mln_concrete(I) output;
- initialize(output, input);
-
- mln_piter(I) p(input.domain());
- mln_niter(N) n(nbh, p);
- for_all(p)
- {
- for_all(n)
- if (input.has(n) && input(n) != value::rgb8(0,0,0))
- output(p) = input(n);
- }
- return output;
- }
- } // mln::morpho
-
-} // mln
-
-
-
-template <typename T>
-mln::image2d<T>
-image2cells(const mln::image2d<T>& input)
-{
- mln::image2d<T> output(2 * input.nrows() - 1,
- 2 * input.ncols() - 1);
- for (unsigned row = 0; row < input.nrows(); ++row)
- for (unsigned col = 0; col < input.ncols(); ++col)
- mln::opt::at(output, 2 * row, 2 * col) = mln::opt::at(input, row, col);
- return output;
-}
-
-
-template <typename T>
-mln::image2d<T>
-cells2image(const mln::image2d<T>& input)
-{
- mln::image2d<T> output((input.nrows() + 1) / 2,
- (input.ncols() + 1) / 2);
- for (unsigned row = 0; row < input.nrows(); row += 2)
- for (unsigned col = 0; col < input.ncols(); col += 2)
- mln::opt::at(output, row / 2, col / 2) = mln::opt::at(input, row, col);
- return output;
-}
-
-
-
-
-template <typename I, typename N, typename Ic, typename Nc>
-unsigned min_tree(const I& f, const N& nbh, const Ic& ref, const Nc& nbhc,
- int lambda)
-{
- using namespace mln;
-
- min_tree_<I,N,Ic,Nc> run(f, nbh, ref, nbhc, lambda);
-
-
- mln_piter(I) p(f.domain());
- unsigned nnodes = 0;
- for_all(p)
- {
- if (run.is_node(p))
- ++nnodes;
- }
-
- colorize colors(nnodes);
- image2d<value::rgb8> tmp(ref.domain());
- data::fill(tmp, literal::black);
- image2d<value::rgb8> tmp2(ref.domain());
- data::fill(tmp, ref);
-
- mln_piter(I) q(f.domain());
- unsigned int i = 0;
- for_all(q)
- {
- if (run.is_node(q))
- {
- tmp(q) = run.color(q);
- tmp2(q) = colors(i);
- i++;
- }
- }
-
- mln_piter(I) r(f.domain());
- for_all(r)
- {
- if (!run.is_node(r))
- {
- tmp(r) = tmp(run.find_representative(r));
- tmp2(r) = tmp2(run.find_representative(r));
- }
- }
-
- image2d<value::rgb8> to_display(tmp.domain());
- image2d<value::rgb8> to_display2(tmp2.domain());
-
- data::fill(to_display, literal::black);
- data::paste((tmp | is_edge), to_display);
- data::paste(morpho::dilation(to_display, c4()), to_display);
-
- data::fill(to_display2, literal::black);
- data::paste((tmp2 | is_edge), to_display2);
- data::paste(morpho::dilation(to_display2, c4()), to_display2);
-
-
- io::ppm::save(display_edge(tmp, literal::black, 3), "edge.ppm");
- io::ppm::save(tmp, "full.ppm");
- io::ppm::save(cells2image(to_display), "colorize.ppm");
-
- io::ppm::save(display_edge(tmp2, literal::black, 3), "edge2.ppm");
- io::ppm::save(cells2image(to_display2), "colorize2.ppm");
-
- return nnodes;
-}
-
-
-
-template <typename I>
-I
-do_it(I& input, int lambda, unsigned& nbasins)
-{
- using namespace mln;
-
- /// Graph creation
- I graph;
- create_graph(input, graph, value::rgb8(0, 0, 0));
-
- // Initialization
- image2d<value::int_u16> ima = convert_to_grey(graph);
-
- // Neigbhorhood
- // e2c
- bool e2c_h[] = { 0, 1, 0,
- 0, 0, 0,
- 0, 1, 0 };
- bool e2c_v[] = { 0, 0, 0,
- 1, 0, 1,
- 0, 0, 0 };
-
- mln_VAR(e2c, make::double_neighb2d(is_row_odd, e2c_h, e2c_v));
-
- bool e2e_h[] = { 0, 0, 1, 0, 0,
- 0, 1, 0, 1, 0,
- 0, 0, 0, 0, 0,
- 0, 1, 0, 1, 0,
- 0, 0, 1, 0, 0 };
-
- bool e2e_v[] = { 0, 0, 0, 0, 0,
- 0, 1, 0, 1, 0,
- 1, 0, 0, 0, 1,
- 0, 1, 0, 1, 0,
- 0, 0, 0, 0, 0 };
- mln_VAR(e2e, make::double_neighb2d(is_row_odd, e2e_h, e2e_v));
-
- // Algorithm
- distance(extend((graph | is_edge).rw(), pw::value(graph)), e2c, ima);
-
- io::pgm::save(ima, "edge.pgm");
-
- nbasins = min_tree((ima | is_edge), e2e, graph, e2c, lambda);
-
- return graph;
-}
-
-void usage(char* argv[])
-{
- std::cerr << "usage: " << argv[0] << " input.pgm lambda" << std::endl;
- std::cerr << " lambda >= 0" << std::endl;
- abort();
-}
-
-int main(int argc, char* argv[])
-{
- using namespace mln;
-
- if (argc != 3)
- usage(argv);
-
- int lambda = atoi(argv[2]);
- if (lambda < 0)
- usage(argv);
-
- image2d<value::rgb8> ima;
- io::ppm::load(ima, argv[1]);
-
- unsigned nbasins;
- image2d<value::rgb8> output = do_it(ima, lambda, nbasins);
-
- //io::ppm::save(output, argv[3]);
-}
Index: inim/color/reference.cc
--- inim/color/reference.cc (revision 3756)
+++ inim/color/reference.cc (working copy)
@@ -1,557 +0,0 @@
-# include <mln/core/var.hh>
-
-# include <mln/core/image/image2d.hh>
-# include <mln/core/image/image_if.hh>
-# include <mln/core/image/extended.hh>
-# include <mln/core/routine/extend.hh>
-
-# include <mln/core/alias/window2d.hh>
-# include <mln/core/alias/neighb2d.hh>
-# include <mln/make/double_neighb2d.hh>
-# include <mln/core/site_set/p_centered.hh>
-
-# include <mln/literal/origin.hh>
-# include <mln/literal/black.hh>
-# include <mln/literal/white.hh>
-
-# include <mln/value/int_u8.hh>
-# include <mln/io/pgm/load.hh>
-# include <mln/io/pgm/save.hh>
-
-# include <mln/value/rgb8.hh>
-# include <mln/io/ppm/load.hh>
-# include <mln/io/ppm/save.hh>
-
-# include <mln/accu/min_max.hh>
-# include <mln/accu/mean.hh>
-
-# include <mln/fun/i2v/array.hh>
-# include <mln/fun/p2v/iota.hh>
-
-# include <mln/data/paste.hh>
-# include <mln/data/fill.hh>
-# include <mln/level/transform.hh>
-# include <mln/extension/fill.hh>
-# include <mln/convert/to.hh>
-
-# include <mln/linear/gaussian.hh>
-
-# include <mln/morpho/meyer_wst.hh>
-# include <mln/morpho/closing_volume.hh>
-
-# include <mln/make/w_window2d.hh>
-# include <mln/opt/at.hh>
-
-# include <mln/debug/println.hh>
-
-// Laplacian method
-namespace mln
-{
- namespace linear
- {
- // required to deal with a input image that differ from the output since I
- //don't succeed in using a float image in entry.
- template <class I, class O>
- inline
- void
- gaussian_2nd_derivative(const Image<I>& input, float sigma, Image<O>& output)
- {
- mln_precondition(exact(input).is_valid());
-
- impl::recursivefilter_coef_
- coef(-1.331f, 3.661f,
- 1.24f, 1.314f,
- 0.3225f, -1.738f,
- 0.748f, 2.166f,
- sigma, impl::gaussian_2nd_deriv_coef_norm_);
- impl::generic_filter_common_(mln_trait_value_nature(mln_value(I))(),
- input, coef, sigma, output);
- }
-
- template <class I, class O>
- inline
- void
- gaussian_1st_derivative(const Image<I>& input, float sigma, Image<O>& output)
- {
- mln_precondition(exact(input).is_valid());
-
- impl::recursivefilter_coef_
- coef(-0.6472f, -4.531f,
- 1.527f, 1.516f,
- 0.6494f, 0.9557f,
- 0.6719f, 2.072f,
- sigma, impl::gaussian_1st_deriv_coef_norm_);
- impl::generic_filter_common_(mln_trait_value_nature(mln_value(I))(),
- input, coef, sigma, output);
- }
- }
-}
-
-// Gradient + watershed method
-namespace mln
-{
- namespace morpho
- {
- template <typename I, typename N>
- mln_concrete(I)
- closing_volume(const I& input, const Neighborhood<N>& nbh, std::size_t lambda)
- {
- mln_concrete(I) output;
- initialize(output, input);
- closing_volume(input, nbh, lambda, output);
- return output;
- }
- }
-} // !mln
-
-namespace mln
-{
- image2d<value::int_u8> convert_to_grey(const image2d<value::rgb8>& data)
- {
- image2d<value::int_u8> output(data.domain());
- mln_piter_(image2d<value::int_u8>) p(output.domain());
- for_all(p)
- output(p) = (int) (data(p).red() * 0.3 + data(p).green() * 0.58 + data(p).blue()) * 0.12;
- return output;
- }
-} // !mln
-
-// Functions
-
-inline
-bool is_row_odd(const mln::point2d& p)
-{
- return p.row() % 2;
-}
-
-inline
-bool is_cell(const mln::point2d& p)
-{
- return p.row() % 2 == 0 && p.col() % 2 == 0;
-}
-
-inline
-bool is_edge(const mln::point2d& p)
-{
- return p.row() % 2 + p.col() % 2 == 1;
-}
-
-inline
-bool is_point(const mln::point2d& p)
-{
- return p.row() % 2 && p.col() % 2;
-}
-
-inline
-bool is_not_edge(const mln::point2d& p)
-{
- return ! is_edge(p);
-}
-
-
-
-namespace mln
-{
-
- namespace border
- {
-
- template <typename I>
- void
- fill(I& ima, const mln_value(I)& v)
- {
- const int nrows = ima.nrows();
- const int ncols = ima.ncols();
- for (int r = -1; r <= nrows; ++r)
- {
- opt::at(ima, r, -1) = v;
- opt::at(ima, r, ncols) = v;
- }
- for (int c = -1; c <= ncols; ++c)
- {
- opt::at(ima, -1, c) = v;
- opt::at(ima, nrows, c) = v;
- }
- }
-
- } // mln::border
-
- namespace accu
- {
-
- template <typename I, typename L, typename A, typename V>
- inline
- void
- compute(const Image<I>& input_,
- const Image<L>& label_,
- const Accumulator<A>&,
- V& v)
- {
- trace::entering("accu::compute");
-
- const I& input = exact(input_);
- const L& label = exact(label_);
-
- const unsigned n = v.size();
- std::vector<A> a(n);
-
- mln_piter(I) p(input.domain());
- for_all(p)
- a[label(p)].take(input(p));
-
- for (unsigned l = 1; l < n; ++l)
- v(l) = a[l].to_result();
-
- trace::exiting("accu::compute");
- }
-
- } // mln::accu
-
- namespace morpho
- {
-
- template <typename I, typename N>
- mln_concrete(I)
- gradient(const I& input, const N& nbh)
- {
- mln_concrete(I) output;
- initialize(output, input);
- accu::min_max<mln_value(I)> mm;
-
- mln_piter(I) p(input.domain());
- mln_niter(N) n(nbh, p);
- for_all(p)
- {
- mm.init();
- for_all(n) if (input.has(n))
- mm.take(input(n));
- output(p) = mm.second() - mm.first();
- }
- return output;
- }
-
- template <typename I, typename N>
- mln_concrete(I)
- dilation(const I& input, const N& nbh)
- {
- typedef mln_value(I) V;
-
- mln_concrete(I) output;
- initialize(output, input);
-
- mln_piter(I) p(input.domain());
- mln_niter(N) n(nbh, p);
- for_all(p)
- {
- for_all(n)
- if (input.has(n) && input(n) != value::rgb8(0,0,0))
- output(p) = input(n);
- }
- return output;
- }
- } // mln::morpho
-
-
- struct colorize : Function_v2v< colorize >
- {
- typedef value::rgb8 result;
- colorize(unsigned max)
- : lut(max + 1)
- {
- lut[0] = literal::black;
- for (unsigned i = 1; i <= max; ++i)
- lut[i] = result(100 + std::rand() % 150,
- 100 + std::rand() % 150,
- 100 + std::rand() % 150);
- }
- result operator()(unsigned i) const
- {
- return lut[i];
- }
- std::vector<result> lut;
- };
-
-
- template <typename I>
- I display_edge_with_bg(const I& ima, unsigned zoom, mln_value(I) bg)
- {
- unsigned nrows = ima.nrows() / 2 + 1;
- unsigned ncols = ima.ncols() / 2 + 1;
- I output(nrows * (zoom + 1) - 1,
- ncols * (zoom + 1) - 1);
- data::fill(output, bg);
- mln_VAR( edge, ima | is_edge );
- mln_piter(edge_t) p(edge.domain());
- for_all(p)
- if (p.row() % 2) // horizontal edge
- {
- unsigned row = (p.row() / 2 + 1) * (zoom + 1) - 1;
- unsigned col = (p.col() / 2) * (zoom + 1);
- for (unsigned i = 0; i < zoom; ++i)
- opt::at(output, row, col + i) = ima(p);
- }
- else // vertical edge
- {
- unsigned row = (p.row() / 2) * (zoom + 1);
- unsigned col = (p.col() / 2 + 1) * (zoom + 1) - 1;
- for (unsigned i = 0; i < zoom; ++i)
- opt::at(output, row + i, col) = ima(p);
- }
- return output;
- }
-
- template <typename I>
- I display_edge(const I& ima, unsigned zoom)
- {
- unsigned nrows = ima.nrows() / 2 + 1;
- unsigned ncols = ima.ncols() / 2 + 1;
- I output(nrows * (zoom + 1) - 1,
- ncols * (zoom + 1) - 1);
-
- mln_VAR( cell, ima | is_cell );
- mln_piter(cell_t) q(cell.domain());
- for_all(q)
- {
- unsigned row = (q.row() / 2) * (zoom + 1);
- unsigned col = (q.col() / 2) * (zoom + 1);
- for (unsigned i = 0; i < zoom; ++i)
- for (unsigned j = 0; j < zoom; ++j)
- opt::at(output, row + i, col + j) = ima(q);
- }
-
- mln_VAR( edge, ima | is_edge );
- mln_piter(edge_t) p(edge.domain());
- for_all(p)
- if (p.row() % 2) // horizontal edge
- {
- unsigned row = (p.row() / 2 + 1) * (zoom + 1) - 1;
- unsigned col = (p.col() / 2) * (zoom + 1);
- for (unsigned i = 0; i < zoom; ++i)
- opt::at(output, row, col + i) = ima(p);
- }
- else // vertical edge
- {
- unsigned row = (p.row() / 2) * (zoom + 1);
- unsigned col = (p.col() / 2 + 1) * (zoom + 1) - 1;
- for (unsigned i = 0; i < zoom; ++i)
- opt::at(output, row + i, col) = ima(p);
- }
- return output;
- }
-
-} // mln
-
-
-
-template <typename T>
-mln::image2d<T>
-image2cells(const mln::image2d<T>& input)
-{
- mln::image2d<T> output(2 * input.nrows() - 1,
- 2 * input.ncols() - 1);
- for (int row = 0; row < input.nrows(); ++row)
- for (int col = 0; col < input.ncols(); ++col)
- mln::opt::at(output, 2 * row, 2 * col) = mln::opt::at(input, row, col);
- return output;
-}
-
-namespace mln {
-
- template <typename I, typename N, typename M>
- mln_concrete(I)
- mean(const I& input, const N& nbh, const M& nbh2)
- {
- mln_concrete(I) output;
- initialize(output, input);
-
- mln_piter(I) p(input.domain());
- mln_niter(N) n(nbh, p);
- mln_niter(M) m(nbh2, p);
- for_all(p)
- {
- if (is_edge(p))
- {
- int nb = 0;
- int r = 0, g = 0, b = 0;
- for_all(n)
- {
- if (input.has(n))
- {
- r += input(n).red();
- g += input(n).green();
- b += input(n).blue();
- ++nb;
- }
- }
- output(p) = value::rgb8(r / nb, g / nb, b / nb);
- }
- if (is_point(p))
- {
- int nb = 0;
- int r = 0, g = 0, b = 0;
- for_all(m)
- {
- if (input.has(m))
- {
- r += input(m).red();
- g += input(m).green();
- b += input(m).blue();
- ++nb;
- }
- }
- output(p) = value::rgb8(r / nb, g / nb, b / nb);
- }
- if (is_cell(p))
- output(p) = input(p);
- }
- return output;
- }
-
-}
-
-template <typename T>
-mln::image2d<T>
-cells2image(const mln::image2d<T>& input)
-{
- mln::image2d<T> output((input.nrows() + 1) / 2,
- (input.ncols() + 1) / 2);
- for (int row = 0; row < input.nrows(); row += 2)
- for (int col = 0; col < input.ncols(); col += 2)
- mln::opt::at(output, row / 2, col / 2) = mln::opt::at(input, row, col);
- return output;
-}
-
-
-
-
-template <typename I>
-mln_concrete(I)
-do_it(I& input, float lambda, unsigned& nbasins)
-{
- using namespace mln;
-
- /**************************/
- /* Neighborhood defintion */
- /**************************/
-
- // e2c
- bool e2c_h[] = { 0, 1, 0,
- 0, 0, 0,
- 0, 1, 0 };
- bool e2c_v[] = { 0, 0, 0,
- 1, 0, 1,
- 0, 0, 0 };
- mln_VAR( e2c, make::double_neighb2d(is_row_odd, e2c_h, e2c_v) );
-
- // e2e
- bool e2e_h[] = { 0, 0, 1, 0, 0,
- 0, 1, 0, 1, 0,
- 0, 0, 0, 0, 0,
- 0, 1, 0, 1, 0,
- 0, 0, 1, 0, 0 };
- bool e2e_v[] = { 0, 0, 0, 0, 0,
- 0, 1, 0, 1, 0,
- 1, 0, 0, 0, 1,
- 0, 1, 0, 1, 0,
- 0, 0, 0, 0, 0 };
- mln_VAR( e2e, make::double_neighb2d(is_row_odd, e2e_h, e2e_v) );
-
- // e2p
- bool e2p_h[] = { 1, 0, 1,
- 0, 0, 0,
- 1, 0, 1 };
- bool e2p_v[] = { 1, 0, 1,
- 0, 0, 0,
- 1, 0, 1 };
- mln_VAR( e2p, make::double_neighb2d(is_row_odd, e2p_h, e2p_v) );
-
- /******************/
- /* Initialisation */
- /******************/
-
- I output = mean(image2cells(input), e2c, e2p);
- io::ppm::save(output, "tmp_input.ppm");
- //image2d<value::int_u8> ima = convert_to_grey(output);
- image2d<value::int_u8> imau = convert_to_grey(output);
- io::pgm::save(imau, "tmp_grey_input.pgm");
-
- image2d<float> ima(exact(imau).domain());
-
- // cell
- mln_VAR(cell, imau | is_cell);
-
- // edge
- mln_VAR(edge, extend((imau | is_edge).rw(), pw::value(imau)));
-
- // FIXME until laplacian is working use gradient / closing_area / wst
-
- linear::gaussian_2nd_derivative(imau, lambda, ima);
-
- mln_piter(edge_t) p(edge.domain());
- for_all(p)
- {
- if (is_row_odd(p))
- {
- mln_value(image2d<float>) t = opt::at(ima, p.row() - 1, p.col());
- mln_value(image2d<float>) b = opt::at(ima, p.row() + 1, p.col());
- if ((t > 0 && b < 0) || (t < 0 && b > 0))
- output(p) = value::rgb8(255,0,0);
- }
- else
- {
- mln_value(image2d<float>) r = opt::at(ima, p.row(), p.col() - 1);
- mln_value(image2d<float>) d = opt::at(ima, p.row(), p.col() + 1);
- if ((r > 0 && d < 0) || (r < 0 && d > 0))
- output(p) = value::rgb8(255,0,0);
- }
- }
-
-#if 0
- data::paste(morpho::gradient(edge, e2c), edge);
- data::paste(morpho::closing_volume(edge, e2e, lambda), edge);
- data::fill(edge, morpho::meyer_wst(edge, e2e, nbasins));
-
- // Fill regions (with colorize) (won't work with laplacian...)
-
- colorize colors(nbasins);
-
- image2d<value::rgb8> cells(ima.domain());
- data::fill(cells, literal::white);
- data::paste(level::transform(edge, colors), cells);
- io::ppm::save(display_edge_with_bg(cells, 3, literal::white), "tmp_edge.ppm");
-
- // Move the color of an edge which is non black in the cell
- data::paste(morpho::dilation(cells, c4()), cells);
-#endif
-
- //cells = convert_to_rgb8(ima);
-
- return output;
-}
-
-void usage(char* argv[])
-{
- std::cerr << "usage: " << argv[0] << " input.pgm lambda output.ppm" << std::endl;
- std::cerr << " lambda >= 0" << std::endl;
- abort();
-}
-
-int main(int argc, char* argv[])
-{
- using namespace mln;
-
- if (argc != 4)
- usage(argv);
-
- float lambda = atof(argv[2]);
- if (lambda < 0)
- usage(argv);
-
- image2d<value::rgb8> ima;
- io::ppm::load(ima, argv[1]);
-
- unsigned nbasins;
- image2d<value::rgb8> output = do_it(ima, lambda, nbasins);
-
- io::ppm::save(display_edge(output, 3), argv[3]);
-}
Index: inim/color/min_tree_area_filter.cc
--- inim/color/min_tree_area_filter.cc (revision 3756)
+++ inim/color/min_tree_area_filter.cc (working copy)
@@ -1,515 +0,0 @@
-# include <mln/core/var.hh>
-
-# include <mln/core/image/image2d.hh>
-# include <mln/core/image/image_if.hh>
-# include <mln/core/image/extended.hh>
-# include <mln/core/routine/extend.hh>
-
-# include <mln/core/alias/window2d.hh>
-# include <mln/core/alias/neighb2d.hh>
-# include <mln/make/double_neighb2d.hh>
-# include <mln/core/site_set/p_centered.hh>
-
-# include <mln/literal/origin.hh>
-# include <mln/literal/black.hh>
-# include <mln/literal/white.hh>
-
-# include <mln/value/int_u8.hh>
-# include <mln/value/int_u16.hh>
-# include <mln/io/pgm/load.hh>
-# include <mln/io/pgm/save.hh>
-
-# include <mln/value/rgb8.hh>
-# include <mln/io/ppm/load.hh>
-# include <mln/io/ppm/save.hh>
-
-# include <mln/accu/min_max.hh>
-
-# include <mln/fun/i2v/array.hh>
-# include <mln/fun/p2v/iota.hh>
-
-# include <mln/data/paste.hh>
-# include <mln/data/fill.hh>
-# include <mln/level/transform.hh>
-# include <mln/extension/fill.hh>
-
-# include <mln/morpho/meyer_wst.hh>
-# include <mln/morpho/closing_area.hh>
-
-# include <mln/opt/at.hh>
-
-# include <mln/debug/println.hh>
-
-# if 0
-# include <mln/core/concept/image.hh>
-# include <mln/core/concept/neighborhood.hh>
-# include <mln/util/pix.hh>
-# include <mln/morpho/includes.hh>
-# include <mln/level/sort_psites.hh>
-#endif
-
-# include "src/distance.hh"
-
-namespace mln
-{
- template <typename I, typename N, typename Ic, typename Nc>
- struct min_tree_
- {
- typedef mln_site(I) point;
- typedef p_array<point> S;
-
- // in:
- const I& f;
- const N& nbh;
- const Ic& ref;
- const Nc& nbhc;
-
- // aux:
- S s;
- mln_ch_value(I, bool) deja_vu;
- mln_ch_value(I, point) parent;
- mln_ch_value(I, bool) resp;
- mln_ch_value(I, point) zpar;
-
- // attached data:
- int lambda;
- mln_ch_value(I, int) area;
- //mln_ch_value(Ic, value::rgb8) values;
- //initialize(values, ref);
- //mln_ch_value(I, int) comp;
-
- min_tree_(const I& f, const N& nbh, const Ic& ref, const Nc& nbhc,
- int lambda)
- : f(f),
- nbh(nbh),
- ref(ref),
- nbhc(nbhc),
- lambda(lambda)
- {
- run();
- }
-
- void run()
- {
- // init
- {
- initialize(deja_vu, f);
- initialize(parent, f);
- initialize(resp, f);
- initialize(zpar, f);
- initialize(area, f);
- //initialize(comp, f);
-
- mln::data::fill(deja_vu, false);
- //mln::data::fill(resp, false);
- mln::data::fill(area, 0);
-
- s = level::sort_psites_increasing(f);
- }
-
- // first pass
- {
- mln_fwd_piter(S) p(s);
- mln_niter(N) n(nbh, p);
- for_all(p)
- {
- make_set(p);
- for_all(n)
- if (f.has(n) && deja_vu(n))
- do_union(n, p);
- deja_vu(p) = true;
- }
- }
-
- // second pass: canonization
- {
- mln_bkd_piter(S) p(s);
- for_all(p)
- {
- point q = parent(p);
- if (f(parent(q)) == f(q))
- {
- parent(p) = parent(q);
- resp(q) = false;
- }
- }
- }
-
- // third pass: Merging region with area < lambda
- {
- mln_fwd_piter(S) p(s);
- for_all(p)
- {
- if (resp(p) && area(p) < lambda)
- {
- resp(p) = false;
- update_data(parent(p), area(p));
- }
- }
- }
- } // end of run()
-
- void make_set(const point& p)
- {
- parent(p) = p;
- zpar(p) = p;
- init_data(p);
- }
-
- void set_parent(const point& r, const point& p)
- {
- parent(r) = p;
- merge_data(r, p);
- }
-
- bool is_root(const point& p) const
- {
- return parent(p) == p;
- }
-
- bool is_node(const point& p) const
- {
- //return is_root(p) || f(parent(p)) != f(p);
- return (is_root(p) || resp(p));
- }
-
- point find_root(const point& x)
- {
- if (zpar(x) == x)
- return x;
- else
- return zpar(x) = find_root(zpar(x));
- }
-
- point find_representative(const point& x)
- {
- if (parent(x) == x || resp(x))
- return x;
- else
- return find_representative(parent(x));
- }
-
- void do_union(const point& n, const point& p)
- {
- point r = find_root(n);
- if (r != p)
- {
- set_parent(r, p);
- zpar(r) = p;
- }
- }
-
- void init_data(const point& p)
- {
- area(p) = 1;
- resp(p) = true;
- }
-
- void merge_data(const point& r, const point& p)
- {
- if (f(p) == f(r))
- {
- resp(p) = false;
- area(p) += area(r);
- }
- }
-
- void update_data(const point& p, int val)
- {
- area(p) += val;
- if (parent(p) != p && !resp(p))
- update_data(parent(p), val);
- }
-
- };
-}
-
-namespace mln
-{
- image2d<value::int_u16> convert_to_grey(const image2d<value::rgb8>& data)
- {
- image2d<value::int_u16> output(data.domain());
- mln_piter_(image2d<value::int_u16>) p(output.domain());
- for_all(p)
- output(p) = (int) (data(p).red() * 0.3 + data(p).green() * 0.58 + data(p).blue()) * 0.12;
- return output;
- }
-} // end of mln
-
-namespace mln
-{
-
- struct colorize : Function_v2v< colorize >
- {
- typedef value::rgb8 result;
- colorize(unsigned max)
- : lut(max + 1)
- {
- lut[0] = literal::black;
- for (unsigned i = 1; i <= max; ++i)
- lut[i] = result(100 + std::rand() % 150,
- 100 + std::rand() % 150,
- 100 + std::rand() % 150);
- }
- result operator()(unsigned i) const
- {
- return lut[i];
- }
- std::vector<result> lut;
- };
-
- template <typename I>
- I display_edge(const I& ima, mln_value(I) bg, unsigned zoom)
- {
- unsigned nrows = ima.nrows() / 2 + 1;
- unsigned ncols = ima.ncols() / 2 + 1;
- I output(nrows * (zoom + 1) - 1,
- ncols * (zoom + 1) - 1);
- data::fill(output, bg);
-
- mln_VAR(edge, ima | is_edge);
- mln_piter(edge_t) p(edge.domain());
- for_all(p)
- if (p.row() % 2) // horizontal edge
- {
- unsigned row = (p.row() / 2 + 1) * (zoom + 1) - 1;
- unsigned col = (p.col() / 2) * (zoom + 1);
- for (unsigned i = 0; i < zoom; ++i)
- opt::at(output, row, col + i) = ima(p);
- }
- else // vertical edge
- {
- unsigned row = (p.row() / 2) * (zoom + 1);
- unsigned col = (p.col() / 2 + 1) * (zoom + 1) - 1;
- for (unsigned i = 0; i < zoom; ++i)
- opt::at(output, row + i, col) = ima(p);
- }
- return output;
- }
-
- template <typename I>
- I display_edge(const I& ima, unsigned zoom)
- {
- unsigned nrows = ima.nrows() / 2 + 1;
- unsigned ncols = ima.ncols() / 2 + 1;
- I output(nrows * (zoom + 1) - 1,
- ncols * (zoom + 1) - 1);
-
- mln_VAR( cell, ima | is_cell );
- mln_piter(cell_t) q(cell.domain());
- for_all(q)
- {
- unsigned row = (q.row() / 2) * (zoom + 1);
- unsigned col = (q.col() / 2) * (zoom + 1);
- for (unsigned i = 0; i < zoom; ++i)
- for (unsigned j = 0; j < zoom; ++j)
- opt::at(output, row + i, col + j) = ima(q);
- }
-
- mln_VAR( edge, ima | is_edge );
- mln_piter(edge_t) p(edge.domain());
- for_all(p)
- if (p.row() % 2) // horizontal edge
- {
- unsigned row = (p.row() / 2 + 1) * (zoom + 1) - 1;
- unsigned col = (p.col() / 2) * (zoom + 1);
- for (unsigned i = 0; i < zoom; ++i)
- opt::at(output, row, col + i) = ima(p);
- }
- else // vertical edge
- {
- unsigned row = (p.row() / 2) * (zoom + 1);
- unsigned col = (p.col() / 2 + 1) * (zoom + 1) - 1;
- for (unsigned i = 0; i < zoom; ++i)
- opt::at(output, row + i, col) = ima(p);
- }
- return output;
- }
-
-
- namespace morpho
- {
-
- template <typename I, typename N>
- mln_concrete(I)
- dilation(const I& input, const N& nbh)
- {
- typedef mln_value(I) V;
-
- mln_concrete(I) output;
- initialize(output, input);
-
- mln_piter(I) p(input.domain());
- mln_niter(N) n(nbh, p);
- for_all(p)
- {
- for_all(n)
- if (input.has(n) && input(n) != value::rgb8(0,0,0))
- output(p) = input(n);
- }
- return output;
- }
- } // mln::morpho
-
-
-} // mln
-
-
-
-template <typename T>
-mln::image2d<T>
-image2cells(const mln::image2d<T>& input)
-{
- mln::image2d<T> output(2 * input.nrows() - 1,
- 2 * input.ncols() - 1);
- for (unsigned row = 0; row < input.nrows(); ++row)
- for (unsigned col = 0; col < input.ncols(); ++col)
- mln::opt::at(output, 2 * row, 2 * col) = mln::opt::at(input, row, col);
- return output;
-}
-
-
-template <typename T>
-mln::image2d<T>
-cells2image(const mln::image2d<T>& input)
-{
- mln::image2d<T> output((input.nrows() + 1) / 2,
- (input.ncols() + 1) / 2);
- for (unsigned row = 0; row < input.nrows(); row += 2)
- for (unsigned col = 0; col < input.ncols(); col += 2)
- mln::opt::at(output, row / 2, col / 2) = mln::opt::at(input, row, col);
- return output;
-}
-
-
-template <typename I, typename N, typename Ic, typename Nc>
-unsigned min_tree(const I& f, const N& nbh, const Ic& ref, const Nc& nbhc,
- int lambda)
-{
- using namespace mln;
-
- min_tree_<I,N,Ic,Nc> run(f, nbh, ref, nbhc, lambda);
-
-
- mln_piter(I) p(f.domain());
- unsigned nnodes = 0;
- for_all(p)
- {
- if (run.is_node(p))
- {
- std::cout << "nodes: " << p << std::endl;
- ++nnodes;
- }
- }
-
- colorize colors(nnodes);
- image2d<value::rgb8> tmp(ref.domain());
- data::fill(tmp, ref);
-
- mln_piter(I) q(f.domain());
- unsigned int i = 0;
- for_all(q)
- {
- if (run.is_node(q))
- {
- tmp(q) = colors(i);
- i++;
- }
- }
- mln_piter(I) r(f.domain());
- for_all(r)
- {
- if (!run.is_node(r))
- {
- tmp(r) = tmp(run.find_representative(r));
- }
- }
-
-
- image2d<value::rgb8> to_display(tmp.domain());
-
- data::fill(to_display, value::rgb8(255, 255, 255));
- data::paste((tmp | is_edge), to_display);
- data::paste(morpho::dilation(to_display, c4()), to_display);
-
- io::ppm::save(display_edge(tmp, literal::white, 3),
- "edge.ppm");
- io::ppm::save(tmp, "full.ppm");
- io::ppm::save(cells2image(to_display), "colorize.ppm");
-
- return nnodes;
-}
-
-
-template <typename I>
-I
-do_it(I& input, int lambda, unsigned& nbasins)
-{
- using namespace mln;
-
- /// Graph creation
- I graph;
- create_graph(input, graph, value::rgb8(0, 0, 0));
-
- // Initialization
- image2d<value::int_u16> ima = convert_to_grey(graph);
-
- // Neigbhorhood
- // e2c
- bool e2c_h[] = { 0, 1, 0,
- 0, 0, 0,
- 0, 1, 0 };
- bool e2c_v[] = { 0, 0, 0,
- 1, 0, 1,
- 0, 0, 0 };
-
- mln_VAR(e2c, make::double_neighb2d(is_row_odd, e2c_h, e2c_v));
-
- bool e2e_h[] = { 0, 0, 1, 0, 0,
- 0, 1, 0, 1, 0,
- 0, 0, 0, 0, 0,
- 0, 1, 0, 1, 0,
- 0, 0, 1, 0, 0 };
-
- bool e2e_v[] = { 0, 0, 0, 0, 0,
- 0, 1, 0, 1, 0,
- 1, 0, 0, 0, 1,
- 0, 1, 0, 1, 0,
- 0, 0, 0, 0, 0 };
- mln_VAR(e2e, make::double_neighb2d(is_row_odd, e2e_h, e2e_v));
-
- // Algorithm
- distance(extend((graph | is_edge).rw(), pw::value(graph)), e2c, ima);
- io::pgm::save(ima, "edge.pgm");
-
- nbasins = min_tree((ima | is_edge), e2e, graph, e2c, lambda);
-
- return graph;
-}
-
-void usage(char* argv[])
-{
- std::cerr << "usage: " << argv[0] << " input.pgm lambda" << std::endl;
- std::cerr << " lambda >= 0" << std::endl;
- abort();
-}
-
-int main(int argc, char* argv[])
-{
- using namespace mln;
-
- if (argc != 3)
- usage(argv);
-
- int lambda = atoi(argv[2]);
- if (lambda < 0)
- usage(argv);
-
- image2d<value::rgb8> ima;
- io::ppm::load(ima, argv[1]);
-
- unsigned nbasins;
- image2d<value::rgb8> output = do_it(ima, lambda, nbasins);
-
- //io::ppm::save(output, argv[3]);
-}
Index: inim/color/min_tree_height_filter.cc
--- inim/color/min_tree_height_filter.cc (revision 3756)
+++ inim/color/min_tree_height_filter.cc (working copy)
@@ -1,553 +0,0 @@
-# include <mln/core/var.hh>
-
-# include <mln/core/image/image2d.hh>
-# include <mln/core/image/image_if.hh>
-# include <mln/core/image/extended.hh>
-# include <mln/core/routine/extend.hh>
-
-# include <mln/core/alias/window2d.hh>
-# include <mln/core/alias/neighb2d.hh>
-# include <mln/make/double_neighb2d.hh>
-# include <mln/core/site_set/p_centered.hh>
-
-
-# include <mln/literal/black.hh>
-
-# include <mln/value/int_u8.hh>
-# include <mln/value/int_u16.hh>
-# include <mln/io/pgm/load.hh>
-# include <mln/io/pgm/save.hh>
-
-# include <mln/value/rgb8.hh>
-# include <mln/io/ppm/load.hh>
-# include <mln/io/ppm/save.hh>
-
-# include <mln/accu/min_max.hh>
-
-# include <mln/fun/i2v/array.hh>
-# include <mln/fun/p2v/iota.hh>
-
-# include <mln/data/paste.hh>
-# include <mln/data/fill.hh>
-# include <mln/level/transform.hh>
-# include <mln/extension/fill.hh>
-# include <mln/opt/at.hh>
-
-# include <mln/morpho/closing_area.hh>
-
-
-# include <mln/debug/println.hh>
-
-# include "src/distance.hh"
-
-
-namespace mln
-{
- template <typename I, typename N, typename Ic, typename Nc>
- struct min_tree_
- {
- typedef mln_site(I) point;
- typedef p_array<point> S;
-
- // in:
- const I& f;
- const N& nbh;
- const Ic& ref;
- const Nc& nbhc;
-
- // aux:
- S s;
- mln_ch_value(I, bool) deja_vu;
- mln_ch_value(I, point) parent;
- mln_ch_value(I, bool) resp;
- mln_ch_value(I, point) zpar;
-
- // attached data:
- int lambda;
- mln_ch_value(I, int) height;
- mln_ch_value(Ic, value::rgb8) color;
-
-
- min_tree_(const I& f, const N& nbh, const Ic& ref, const Nc& nbhc,
- int lambda)
- : f(f),
- nbh(nbh),
- ref(ref),
- nbhc(nbhc),
- lambda(lambda)
- {
- run();
- }
-
- void run()
- {
- // init
- {
- initialize(deja_vu, f);
- initialize(parent, f);
- initialize(resp, f);
- initialize(zpar, f);
- initialize(height, f);
- initialize(color, f);
-
- mln::data::fill(deja_vu, false);
- mln::data::fill(color, value::rgb8(255, 255, 255));
- mln::data::fill(height, 0);
-
- s = level::sort_psites_increasing(f);
- }
-
- // first pass
- {
- mln_fwd_piter(S) p(s);
- mln_niter(N) n(nbh, p);
- for_all(p)
- {
- make_set(p);
- for_all(n)
- if (f.has(n) && deja_vu(n))
- do_union(n, p);
- deja_vu(p) = true;
- }
- }
-
- // second pass: canonization
- {
- mln_bkd_piter(S) p(s);
- for_all(p)
- {
- point q = parent(p);
- if (f(parent(q)) == f(q))
- {
- parent(p) = parent(q);
- resp(q) = false;
- }
- }
- }
-
- // third pass: Merging region with height < lambda
- {
- mln_fwd_piter(S) p(s);
- for_all(p)
- {
- if (resp(p) && (height(p) < lambda))
- {
- resp(p) = false;
- update_data(parent(p), height(p), color(p));
- }
- }
- }
-
- } // end of run()
-
- void make_set(const point& p)
- {
- parent(p) = p;
- zpar(p) = p;
- init_data(p);
- }
-
- void set_parent(const point& r, const point& p)
- {
- parent(r) = p;
- merge_data(r, p);
- }
-
- bool is_root(const point& p) const
- {
- return parent(p) == p;
- }
-
- bool is_node(const point& p) const
- {
- //return is_root(p) || f(parent(p)) != f(p);
- return (is_root(p) || resp(p));
- }
-
- point find_root(const point& x)
- {
- if (zpar(x) == x)
- return x;
- else
- return zpar(x) = find_root(zpar(x));
- }
-
- point find_representative(const point& x)
- {
- if (parent(x) == x || resp(x))
- return x;
- else
- return find_representative(parent(x));
- }
-
- void do_union(const point& n, const point& p)
- {
- point r = find_root(n);
- if (r != p)
- {
- set_parent(r, p);
- zpar(r) = p;
- }
- }
-
- void init_data(const point& p)
- {
- // init height
- height(p) = f(p);
-
-
- // init color
- int red =0, green = 0, blue = 0;
-
- mln_niter(Nc) n(nbhc, p);
- for_all(n)
- {
- red += ref(n).red();
- green += ref(n).green();
- blue += ref(n).blue();
- }
-
- red /= 2;
- green /= 2;
- blue /= 2;
-
- color(p).red() = red;
- color(p).green() = green;
- color(p).blue() = blue;
-
-
- resp(p) = true;
- }
-
- void merge_data(const point& r, const point& p)
- {
- if (f(p) == f(r))
- {
- resp(p) = false;
-
- // merge height
- height(r) += height(r) > height(p) ? height(r) : height(p);
-
- // merge color
- color(r) = (color(r) + color(p)) / 2;
- }
- }
-
- void update_data(const point& p, int val, value::rgb8 c)
- {
- // update height
- height(p) = height(p) > val ? height(p) : val;
- // update color
- color(p) = (color(p) + c) / 2;
-
- if (parent(p) != p && !resp(p))
- update_data(parent(p), val, color(p));
- }
-
- };
-}
-
-namespace mln
-{
- image2d<value::int_u16> convert_to_grey(const image2d<value::rgb8>& data)
- {
- image2d<value::int_u16> output(data.domain());
- mln_piter_(image2d<value::int_u16>) p(output.domain());
- for_all(p)
- output(p) = (int) (data(p).red() * 0.3 + data(p).green() * 0.58 + data(p).blue()) * 0.12;
- return output;
- }
-} // end of mln
-
-namespace mln
-{
-
- struct colorize : Function_v2v< colorize >
- {
- typedef value::rgb8 result;
- colorize(unsigned max)
- : lut(max + 1)
- {
- lut[0] = literal::black;
- for (unsigned i = 1; i <= max; ++i)
- lut[i] = result(100 + std::rand() % 150,
- 100 + std::rand() % 150,
- 100 + std::rand() % 150);
- }
- result operator()(unsigned i) const
- {
- return lut[i];
- }
- std::vector<result> lut;
- };
-
- template <typename I>
- I display_edge(const I& ima, mln_value(I) bg, unsigned zoom)
- {
- unsigned nrows = ima.nrows() / 2 + 1;
- unsigned ncols = ima.ncols() / 2 + 1;
- I output(nrows * (zoom + 1) - 1,
- ncols * (zoom + 1) - 1);
- data::fill(output, bg);
-
- mln_VAR(edge, ima | is_edge);
- mln_piter(edge_t) p(edge.domain());
- for_all(p)
- if (p.row() % 2) // horizontal edge
- {
- unsigned row = (p.row() / 2 + 1) * (zoom + 1) - 1;
- unsigned col = (p.col() / 2) * (zoom + 1);
- for (unsigned i = 0; i < zoom; ++i)
- opt::at(output, row, col + i) = ima(p);
- }
- else // vertical edge
- {
- unsigned row = (p.row() / 2) * (zoom + 1);
- unsigned col = (p.col() / 2 + 1) * (zoom + 1) - 1;
- for (unsigned i = 0; i < zoom; ++i)
- opt::at(output, row + i, col) = ima(p);
- }
- return output;
- }
-
-
- template <typename I>
- I display_edge(const I& ima, unsigned zoom)
- {
- unsigned nrows = ima.nrows() / 2 + 1;
- unsigned ncols = ima.ncols() / 2 + 1;
- I output(nrows * (zoom + 1) - 1,
- ncols * (zoom + 1) - 1);
-
- mln_VAR( cell, ima | is_cell );
- mln_piter(cell_t) q(cell.domain());
- for_all(q)
- {
- unsigned row = (q.row() / 2) * (zoom + 1);
- unsigned col = (q.col() / 2) * (zoom + 1);
- for (unsigned i = 0; i < zoom; ++i)
- for (unsigned j = 0; j < zoom; ++j)
- opt::at(output, row + i, col + j) = ima(q);
- }
-
- mln_VAR( edge, ima | is_edge );
- mln_piter(edge_t) p(edge.domain());
- for_all(p)
- if (p.row() % 2) // horizontal edge
- {
- unsigned row = (p.row() / 2 + 1) * (zoom + 1) - 1;
- unsigned col = (p.col() / 2) * (zoom + 1);
- for (unsigned i = 0; i < zoom; ++i)
- opt::at(output, row, col + i) = ima(p);
- }
- else // vertical edge
- {
- unsigned row = (p.row() / 2) * (zoom + 1);
- unsigned col = (p.col() / 2 + 1) * (zoom + 1) - 1;
- for (unsigned i = 0; i < zoom; ++i)
- opt::at(output, row + i, col) = ima(p);
- }
- return output;
- }
-
-
- namespace morpho
- {
-
- template <typename I, typename N>
- mln_concrete(I)
- dilation(const I& input, const N& nbh)
- {
- typedef mln_value(I) V;
-
- mln_concrete(I) output;
- initialize(output, input);
-
- mln_piter(I) p(input.domain());
- mln_niter(N) n(nbh, p);
- for_all(p)
- {
- for_all(n)
- if (input.has(n) && input(n) != value::rgb8(0,0,0))
- output(p) = input(n);
- }
- return output;
- }
- } // mln::morpho
-
-} // mln
-
-
-
-template <typename T>
-mln::image2d<T>
-image2cells(const mln::image2d<T>& input)
-{
- mln::image2d<T> output(2 * input.nrows() - 1,
- 2 * input.ncols() - 1);
- for (unsigned row = 0; row < input.nrows(); ++row)
- for (unsigned col = 0; col < input.ncols(); ++col)
- mln::opt::at(output, 2 * row, 2 * col) =
- mln::opt::at(input, row, col);
- return output;
-}
-
-
-template <typename T>
-mln::image2d<T>
-cells2image(const mln::image2d<T>& input)
-{
- mln::image2d<T> output((input.nrows() + 1) / 2,
- (input.ncols() + 1) / 2);
- for (unsigned row = 0; row < input.nrows(); row += 2)
- for (unsigned col = 0; col < input.ncols(); col += 2)
- mln::opt::at(output, row / 2, col / 2) =
- mln::opt::at(input, row, col);
- return output;
-}
-
-
-
-
-template <typename I, typename N, typename Ic, typename Nc>
-unsigned min_tree(const I& f, const N& nbh, const Ic& ref, const Nc& nbhc,
- int lambda)
-{
- using namespace mln;
-
- min_tree_<I,N,Ic,Nc> run(f, nbh, ref, nbhc, lambda);
-
-
- mln_piter(I) p(f.domain());
- unsigned nnodes = 0;
- for_all(p)
- {
- if (run.is_node(p))
- ++nnodes;
- }
-
- colorize colors(nnodes);
- image2d<value::rgb8> tmp(ref.domain());
- data::fill(tmp, literal::black);
- image2d<value::rgb8> tmp2(ref.domain());
- data::fill(tmp, ref);
-
- mln_piter(I) q(f.domain());
- unsigned int i = 0;
- for_all(q)
- {
- if (run.is_node(q))
- {
- tmp(q) = run.color(q);
- tmp2(q) = colors(i);
- i++;
- }
- }
-
- mln_piter(I) r(f.domain());
- for_all(r)
- {
- if (!run.is_node(r))
- {
- tmp(r) = tmp(run.find_representative(r));
- tmp2(r) = tmp2(run.find_representative(r));
- }
- }
-
- image2d<value::rgb8> to_display(tmp.domain());
- image2d<value::rgb8> to_display2(tmp2.domain());
-
- data::fill(to_display, literal::black);
- data::paste((tmp | is_edge), to_display);
- data::paste(morpho::dilation(to_display, c4()), to_display);
-
- data::fill(to_display2, literal::black);
- data::paste((tmp2 | is_edge), to_display2);
- data::paste(morpho::dilation(to_display2, c4()), to_display2);
-
-
- io::ppm::save(display_edge(tmp, literal::black, 3), "edge.ppm");
- io::ppm::save(tmp, "full.ppm");
- io::ppm::save(cells2image(to_display), "colorize.ppm");
-
- io::ppm::save(display_edge(tmp2, literal::black, 3), "edge2.ppm");
- io::ppm::save(cells2image(to_display2), "colorize2.ppm");
-
- return nnodes;
-}
-
-
-
-template <typename I>
-I
-do_it(I& input, int lambda, unsigned& nbasins)
-{
- using namespace mln;
-
- /// Graph creation
- I graph;
- create_graph(input, graph, value::rgb8(0, 0, 0));
-
- // Initialization
- image2d<value::int_u16> ima = convert_to_grey(graph);
-
- // Neigbhorhood
- // e2c
- bool e2c_h[] = { 0, 1, 0,
- 0, 0, 0,
- 0, 1, 0 };
- bool e2c_v[] = { 0, 0, 0,
- 1, 0, 1,
- 0, 0, 0 };
-
- mln_VAR(e2c, make::double_neighb2d(is_row_odd, e2c_h, e2c_v));
-
- bool e2e_h[] = { 0, 0, 1, 0, 0,
- 0, 1, 0, 1, 0,
- 0, 0, 0, 0, 0,
- 0, 1, 0, 1, 0,
- 0, 0, 1, 0, 0 };
-
- bool e2e_v[] = { 0, 0, 0, 0, 0,
- 0, 1, 0, 1, 0,
- 1, 0, 0, 0, 1,
- 0, 1, 0, 1, 0,
- 0, 0, 0, 0, 0 };
- mln_VAR(e2e, make::double_neighb2d(is_row_odd, e2e_h, e2e_v));
-
- // Algorithm
- distance(extend((graph | is_edge).rw(), pw::value(graph)), e2c, ima);
-
- io::pgm::save(ima, "edge.pgm");
-
- nbasins = min_tree((ima | is_edge), e2e, graph, e2c, lambda);
-
- return graph;
-}
-
-void usage(char* argv[])
-{
- std::cerr << "usage: " << argv[0] << " input.pgm lambda" << std::endl;
- std::cerr << " lambda >= 0" << std::endl;
- abort();
-}
-
-int main(int argc, char* argv[])
-{
- using namespace mln;
-
- if (argc != 3)
- usage(argv);
-
- int lambda = atoi(argv[2]);
- if (lambda < 0)
- usage(argv);
-
- image2d<value::rgb8> ima;
- io::ppm::load(ima, argv[1]);
-
- unsigned nbasins;
- image2d<value::rgb8> output = do_it(ima, lambda, nbasins);
-
- //io::ppm::save(output, argv[3]);
-}
Index: inim/color/min_tree_color.cc
--- inim/color/min_tree_color.cc (revision 3756)
+++ inim/color/min_tree_color.cc (working copy)
@@ -1,536 +0,0 @@
-# include <mln/core/var.hh>
-
-# include <mln/core/image/image2d.hh>
-# include <mln/core/image/image_if.hh>
-# include <mln/core/image/extended.hh>
-# include <mln/core/routine/extend.hh>
-
-# include <mln/core/alias/window2d.hh>
-# include <mln/core/alias/neighb2d.hh>
-# include <mln/make/double_neighb2d.hh>
-# include <mln/core/site_set/p_centered.hh>
-
-# include <mln/literal/origin.hh>
-# include <mln/literal/black.hh>
-# include <mln/literal/white.hh>
-
-# include <mln/value/int_u8.hh>
-# include <mln/value/int_u16.hh>
-# include <mln/io/pgm/load.hh>
-# include <mln/io/pgm/save.hh>
-
-# include <mln/value/rgb8.hh>
-# include <mln/io/ppm/load.hh>
-# include <mln/io/ppm/save.hh>
-
-# include <mln/accu/min_max.hh>
-
-# include <mln/fun/i2v/array.hh>
-# include <mln/fun/p2v/iota.hh>
-
-# include <mln/data/paste.hh>
-# include <mln/data/fill.hh>
-# include <mln/level/transform.hh>
-# include <mln/extension/fill.hh>
-
-# include <mln/morpho/closing_area.hh>
-# include <mln/opt/at.hh>
-
-
-# include <mln/debug/println.hh>
-
-# if 0
-# include <mln/core/concept/image.hh>
-# include <mln/core/concept/neighborhood.hh>
-# include <mln/util/pix.hh>
-# include <mln/morpho/includes.hh>
-# include <mln/level/sort_psites.hh>
-#endif
-
-# include "src/distance.hh"
-
-namespace mln
-{
- template <typename I, typename N, typename Ic, typename Nc>
- struct min_tree_
- {
- typedef mln_site(I) point;
- typedef p_array<point> S;
-
- // in:
- const I& f;
- const N& nbh;
- const Ic& ref;
- const Nc& nbhc;
-
- // aux:
- S s;
- mln_ch_value(I, bool) deja_vu;
- mln_ch_value(I, point) parent;
- mln_ch_value(I, bool) resp;
- mln_ch_value(I, point) zpar;
-
- // attached data:
- unsigned lambda;
- mln_ch_value(I, value::rgb8) color;
- //mln_ch_value(Ic, value::rgb8) values;
- //initialize(values, ref);
- //mln_ch_value(I, int) comp;
-
- min_tree_(const I& f, const N& nbh, const Ic& ref, const Nc& nbhc,
- int lambda)
- : f(f),
- nbh(nbh),
- ref(ref),
- nbhc(nbhc),
- lambda(lambda)
- {
- run();
- }
-
- void run()
- {
- // init
- {
- initialize(deja_vu, f);
- initialize(parent, f);
- initialize(resp, f);
- initialize(zpar, f);
- initialize(color, f);
- //initialize(comp, f);
-
- mln::data::fill(deja_vu, false);
- //mln::data::fill(resp, false);
- mln::data::fill(color, value::rgb8(0, 0, 0));
-
- s = level::sort_psites_increasing(f);
- }
-
- // first pass
- {
- mln_fwd_piter(S) p(s);
- mln_niter(N) n(nbh, p);
- for_all(p)
- {
- make_set(p);
- for_all(n)
- if (f.has(n) && deja_vu(n))
- do_union(n, p);
- deja_vu(p) = true;
- }
- }
-
- // second pass: canonization
- {
- mln_bkd_piter(S) p(s);
- for_all(p)
- {
- point q = parent(p);
- if (f(parent(q)) == f(q))
- {
- parent(p) = parent(q);
- resp(q) = false;
- }
- }
- }
-
- // third pass: Merging region with distance(color) < lambda
- {
- mln_fwd_piter(S) p(s);
- for_all(p)
- {
- point q = parent(p);
- if (resp(p) && distance(color(p), color(q)) < lambda)
- {
- resp(p) = false;
- update_data(q, color(p));
- }
- }
- }
-
- } // end of run()
-
- void make_set(const point& p)
- {
- parent(p) = p;
- zpar(p) = p;
- init_data(p);
- }
-
- void set_parent(const point& r, const point& p)
- {
- parent(r) = p;
- merge_data(r, p);
- }
-
- bool is_root(const point& p) const
- {
- return parent(p) == p;
- }
-
- bool is_node(const point& p) const
- {
- //return is_root(p) || f(parent(p)) != f(p);
- return (is_root(p) || resp(p));
- }
-
- point find_root(const point& x)
- {
- if (zpar(x) == x)
- return x;
- else
- return zpar(x) = find_root(zpar(x));
- }
-
- point find_representative(const point& x)
- {
- if (parent(x) == x || resp(x))
- return x;
- else
- return find_representative(parent(x));
- }
-
- void do_union(const point& n, const point& p)
- {
- point r = find_root(n);
- if (r != p)
- {
- set_parent(r, p);
- zpar(r) = p;
- }
- }
-
- void init_data(const point& p)
- {
- int red =0, green = 0, blue = 0;
-
- mln_niter(Nc) n(nbhc, p);
- for_all(n)
- {
- red += ref(n).red();
- green += ref(n).green();
- blue += ref(n).blue();
- }
-
- red /= 2;
- green /= 2;
- blue /= 2;
-
- color(p).red() = red;
- color(p).green() = green;
- color(p).blue() = blue;
-
- resp(p) = true;
- }
-
- void merge_data(const point& r, const point& p)
- {
- if (f(p) == f(r))
- {
- resp(p) = false;
- color(r) = (color(r) + color(p)) / 2;
- }
- }
-
- void update_data(const point& p, value::rgb8 val)
- {
- color(p) = (color(p) + val) / 2;
- if (parent(p) != p && !resp(p))
- update_data(parent(p), color(p));
- }
-
- };
-}
-
-namespace mln
-{
- image2d<value::int_u16> convert_to_grey(const image2d<value::rgb8>& data)
- {
- image2d<value::int_u16> output(data.domain());
- mln_piter_(image2d<value::int_u16>) p(output.domain());
- for_all(p)
- output(p) = (int) (data(p).red() * 0.3 + data(p).green() * 0.58 + data(p).blue()) * 0.12;
- return output;
- }
-} // end of mln
-
-namespace mln
-{
-
- struct colorize : Function_v2v< colorize >
- {
- typedef value::rgb8 result;
- colorize(unsigned max)
- : lut(max + 1)
- {
- lut[0] = literal::black;
- for (unsigned i = 1; i <= max; ++i)
- lut[i] = result(100 + std::rand() % 150,
- 100 + std::rand() % 150,
- 100 + std::rand() % 150);
- }
- result operator()(unsigned i) const
- {
- return lut[i];
- }
- std::vector<result> lut;
- };
-
- template <typename I>
- I display_edge(const I& ima, mln_value(I) bg, unsigned zoom)
- {
- unsigned nrows = ima.nrows() / 2 + 1;
- unsigned ncols = ima.ncols() / 2 + 1;
- I output(nrows * (zoom + 1) - 1,
- ncols * (zoom + 1) - 1);
- data::fill(output, bg);
-
- mln_VAR(edge, ima | is_edge);
- mln_piter(edge_t) p(edge.domain());
- for_all(p)
- if (p.row() % 2) // horizontal edge
- {
- unsigned row = (p.row() / 2 + 1) * (zoom + 1) - 1;
- unsigned col = (p.col() / 2) * (zoom + 1);
- for (unsigned i = 0; i < zoom; ++i)
- opt::at(output, row, col + i) = ima(p);
- }
- else // vertical edge
- {
- unsigned row = (p.row() / 2) * (zoom + 1);
- unsigned col = (p.col() / 2 + 1) * (zoom + 1) - 1;
- for (unsigned i = 0; i < zoom; ++i)
- opt::at(output, row + i, col) = ima(p);
- }
- return output;
- }
-
- template <typename I>
- I display_edge(const I& ima, unsigned zoom)
- {
- unsigned nrows = ima.nrows() / 2 + 1;
- unsigned ncols = ima.ncols() / 2 + 1;
- I output(nrows * (zoom + 1) - 1,
- ncols * (zoom + 1) - 1);
-
- mln_VAR( cell, ima | is_cell );
- mln_piter(cell_t) q(cell.domain());
- for_all(q)
- {
- unsigned row = (q.row() / 2) * (zoom + 1);
- unsigned col = (q.col() / 2) * (zoom + 1);
- for (unsigned i = 0; i < zoom; ++i)
- for (unsigned j = 0; j < zoom; ++j)
- opt::at(output, row + i, col + j) = ima(q);
- }
-
- mln_VAR( edge, ima | is_edge );
- mln_piter(edge_t) p(edge.domain());
- for_all(p)
- if (p.row() % 2) // horizontal edge
- {
- unsigned row = (p.row() / 2 + 1) * (zoom + 1) - 1;
- unsigned col = (p.col() / 2) * (zoom + 1);
- for (unsigned i = 0; i < zoom; ++i)
- opt::at(output, row, col + i) = ima(p);
- }
- else // vertical edge
- {
- unsigned row = (p.row() / 2) * (zoom + 1);
- unsigned col = (p.col() / 2 + 1) * (zoom + 1) - 1;
- for (unsigned i = 0; i < zoom; ++i)
- opt::at(output, row + i, col) = ima(p);
- }
- return output;
- }
-
-
- namespace morpho
- {
-
- template <typename I, typename N>
- mln_concrete(I)
- dilation(const I& input, const N& nbh)
- {
- typedef mln_value(I) V;
-
- mln_concrete(I) output;
- initialize(output, input);
-
- mln_piter(I) p(input.domain());
- mln_niter(N) n(nbh, p);
- for_all(p)
- {
- for_all(n)
- if (input.has(n) && input(n) != value::rgb8(0,0,0))
- output(p) = input(n);
- }
- return output;
- }
- } // mln::morpho
-
-} // mln
-
-
-
-template <typename T>
-mln::image2d<T>
-image2cells(const mln::image2d<T>& input)
-{
- mln::image2d<T> output(2 * input.nrows() - 1,
- 2 * input.ncols() - 1);
- for (unsigned row = 0; row < input.nrows(); ++row)
- for (unsigned col = 0; col < input.ncols(); ++col)
- mln::opt::at(output, 2 * row, 2 * col) =
- mln::opt::at(input, row, col);
- return output;
-}
-
-
-template <typename T>
-mln::image2d<T>
-cells2image(const mln::image2d<T>& input)
-{
- mln::image2d<T> output((input.nrows() + 1) / 2,
- (input.ncols() + 1) / 2);
- for (unsigned row = 0; row < input.nrows(); row += 2)
- for (unsigned col = 0; col < input.ncols(); col += 2)
- mln::opt::at(output, row / 2, col / 2) =
- mln::opt::at(input, row, col);
- return output;
-}
-
-
-template <typename I, typename N, typename Ic, typename Nc>
-unsigned min_tree(const I& f, const N& nbh, const Ic& ref, const Nc& nbhc,
- int lambda)
-{
- using namespace mln;
-
- min_tree_<I,N,Ic,Nc> run(f, nbh, ref, nbhc, lambda);
-
-
- mln_piter(I) p(f.domain());
- unsigned nnodes = 0;
- for_all(p)
- {
- if (run.is_node(p))
- ++nnodes;
- }
-
-#if 1
- colorize colors(nnodes);
- image2d<value::rgb8> tmp(ref.domain());
- data::fill(tmp, ref);
-
-
- mln_piter(I) q(f.domain());
- unsigned int i = 0;
- for_all(q)
- {
- if (run.is_node(q))
- {
- tmp(q) = colors(i);
- i++;
- }
- }
- mln_piter(I) r(f.domain());
- for_all(r)
- {
- if (!run.is_node(r))
- tmp(r) = tmp(run.find_representative(r));
- }
-
- image2d<value::rgb8> to_display(tmp.domain());
-
- data::fill(to_display, value::rgb8(255, 255, 255));
- data::paste((tmp | is_edge), to_display);
- data::paste(morpho::dilation(to_display, c4()), to_display);
-
- io::ppm::save(display_edge(tmp, literal::white, 3),
- "edge.ppm");
- io::ppm::save(tmp, "full.ppm");
- io::ppm::save(cells2image(to_display), "colorize.ppm");
-#endif
-
-#if 1
- // io::ppm::save(display_edge(run.values, literal::white, 3), "tmp_tree_colored.pgm");
-#endif
-
- return nnodes;
-}
-
-
-template <typename I>
-I
-do_it(I& input, int lambda, unsigned& nbasins)
-{
- using namespace mln;
-
- /// Graph creation
- I graph;
- create_graph(input, graph, value::rgb8(0, 0, 0));
-
- // Initialization
- image2d<value::int_u16> ima = convert_to_grey(graph);
-
- // Neigbhorhood
- // e2c
- bool e2c_h[] = { 0, 1, 0,
- 0, 0, 0,
- 0, 1, 0 };
- bool e2c_v[] = { 0, 0, 0,
- 1, 0, 1,
- 0, 0, 0 };
-
- mln_VAR(e2c, make::double_neighb2d(is_row_odd, e2c_h, e2c_v));
-
- bool e2e_h[] = { 0, 0, 1, 0, 0,
- 0, 1, 0, 1, 0,
- 0, 0, 0, 0, 0,
- 0, 1, 0, 1, 0,
- 0, 0, 1, 0, 0 };
-
- bool e2e_v[] = { 0, 0, 0, 0, 0,
- 0, 1, 0, 1, 0,
- 1, 0, 0, 0, 1,
- 0, 1, 0, 1, 0,
- 0, 0, 0, 0, 0 };
- mln_VAR(e2e, make::double_neighb2d(is_row_odd, e2e_h, e2e_v));
-
- // Algorithm
- distance(extend((graph | is_edge).rw(), pw::value(graph)), e2c, ima);
-
- io::pgm::save(ima, "edge.pgm");
-
- nbasins = min_tree((ima | is_edge), e2e, graph, e2c, lambda);
-
- return graph;
-}
-
-void usage(char* argv[])
-{
- std::cerr << "usage: " << argv[0] << " input.pgm lambda" << std::endl;
- std::cerr << " lambda >= 0" << std::endl;
- abort();
-}
-
-int main(int argc, char* argv[])
-{
- using namespace mln;
-
- if (argc != 3)
- usage(argv);
-
- int lambda = atoi(argv[2]);
- if (lambda < 0)
- usage(argv);
-
- image2d<value::rgb8> ima;
- io::ppm::load(ima, argv[1]);
-
- unsigned nbasins;
- image2d<value::rgb8> output = do_it(ima, lambda, nbasins);
-
- //io::ppm::save(output, argv[3]);
-}
Index: inim/color/reference2.cc
--- inim/color/reference2.cc (revision 3756)
+++ inim/color/reference2.cc (working copy)
@@ -1,408 +0,0 @@
-# include <mln/core/var.hh>
-
-# include <mln/core/image/image2d.hh>
-# include <mln/core/image/image_if.hh>
-# include <mln/core/image/extended.hh>
-# include <mln/core/routine/extend.hh>
-
-# include <mln/core/alias/window2d.hh>
-# include <mln/core/alias/neighb2d.hh>
-# include <mln/make/double_neighb2d.hh>
-# include <mln/core/site_set/p_centered.hh>
-
-# include <mln/literal/origin.hh>
-# include <mln/literal/black.hh>
-# include <mln/literal/white.hh>
-
-# include <mln/value/int_u8.hh>
-# include <mln/io/pgm/load.hh>
-# include <mln/io/pgm/save.hh>
-
-# include <mln/value/rgb8.hh>
-# include <mln/io/ppm/load.hh>
-# include <mln/io/ppm/save.hh>
-
-# include <mln/accu/min_max.hh>
-# include <mln/accu/mean.hh>
-
-# include <mln/fun/i2v/array.hh>
-# include <mln/fun/p2v/iota.hh>
-
-# include <mln/data/paste.hh>
-# include <mln/data/fill.hh>
-# include <mln/level/transform.hh>
-# include <mln/extension/fill.hh>
-
-# include <mln/morpho/meyer_wst.hh>
-# include <mln/morpho/closing_volume.hh>
-
-# include <mln/linear/convolve.hh>
-# include <mln/make/w_window2d.hh>
-
-# include <mln/opt/at.hh>
-
-# include <mln/debug/println.hh>
-
-namespace mln
-{
- namespace morpho
- {
- template <typename I, typename N>
- mln_concrete(I)
- closing_volume(const I& input, const Neighborhood<N>& nbh, std::size_t lambda)
- {
- mln_concrete(I) output;
- initialize(output, input);
- closing_volume(input, nbh, lambda, output);
- return output;
- }
- }
-}
-
-namespace mln
-{
- template <typename I, typename O>
- void
- LoG_17x17(const I& input, const O& output)
- {
- mln_precondition(exact(output).domain() == exact(input).domain());
- int ws[] = { +0, 0, 0, 0, 0, 0,-1,-1,-1,-1,-1, 0, 0, 0, 0, 0, 0,
- +0, 0, 0, 0,-1,-1,-1,-1,-1,-1,-1,-1,-1, 0, 0, 0, 0,
- +0, 0,-1,-1,-1,-2,-3,-3,-3,-3,-3,-2,-1,-1,-1, 0, 0,
- +0, 0,-1,-1,-2,-3,-3,-3,-3,-3,-3,-3,-2,-1,-1, 0, 0,
- +0,-1,-1,-2,-3,-3,-3,-2,-3,-2,-3,-3,-3,-2,-1,-1, 0,
- +0,-1,-2,-3,-3,-3, 0, 2, 4, 2, 0,-3,-3,-3,-2,-1, 0,
- -1,-1,-3,-3,-3, 0, 4,10,12,10, 4, 0,-3,-3,-3,-1,-1,
- -1,-1,-3,-3,-2, 2,10,18,21,18,10, 2,-2,-3,-3,-1,-1,
- -1,-1,-3,-3,-3, 4,12,21,24,21,12, 4,-3,-3,-3,-1,-1,
- -1,-1,-3,-3,-2, 2,10,18,21,18,10, 2,-2,-3,-3,-1,-1,
- -1,-1,-3,-3,-3, 0, 4,10,12,10, 4, 0,-3,-3,-3,-1,-1,
- +0,-1,-2,-3,-3,-3, 0, 2, 4, 2, 0,-3,-3,-3,-2,-1, 0,
- +0,-1,-1,-2,-3,-3,-3,-2,-3,-2,-3,-3,-3,-2,-1,-1, 0,
- +0, 0,-1,-1,-2,-3,-3,-3,-3,-3,-3,-3,-2,-1,-1, 0, 0,
- +0, 0,-1,-1,-1,-2,-3,-3,-3,-3,-3,-2,-1,-1,-1, 0, 0,
- +0, 0, 0, 0,-1,-1,-1,-1,-1,-1,-1,-1,-1, 0, 0, 0, 0,
- +0, 0, 0, 0, 0, 0,-1,-1,-1,-1,-1, 0, 0, 0, 0, 0, 0 };
- linear::convolve(input, make::w_window2d(ws), output);
- }
-} // !mln
-
-namespace mln
-{
- image2d<value::int_u8> convert_to_grey(const image2d<value::rgb8>& data)
- {
- image2d<value::int_u8> output(data.domain());
- mln_piter_(image2d<value::int_u8>) p(output.domain());
- for_all(p)
- output(p) = (int) (data(p).red() * 0.3 + data(p).green() * 0.58 + data(p).blue()) * 0.12;
- return output;
- }
-} // !mln
-
-// Functions
-
-inline
-bool is_row_odd(const mln::point2d& p)
-{
- return p.row() % 2;
-}
-
-inline
-bool is_cell(const mln::point2d& p)
-{
- return p.row() % 2 == 0 && p.col() % 2 == 0;
-}
-
-inline
-bool is_edge(const mln::point2d& p)
-{
- return p.row() % 2 + p.col() % 2 == 1;
-}
-
-inline
-bool is_point(const mln::point2d& p)
-{
- return p.row() % 2 && p.col() % 2;
-}
-
-inline
-bool is_not_edge(const mln::point2d& p)
-{
- return ! is_edge(p);
-}
-
-
-
-namespace mln
-{
-
- namespace border
- {
-
- template <typename I>
- void
- fill(I& ima, const mln_value(I)& v)
- {
- const int nrows = ima.nrows();
- const int ncols = ima.ncols();
- for (int r = -1; r <= nrows; ++r)
- {
- opt::at(ima, r, -1) = v;
- opt::at(ima, r, ncols) = v;
- }
- for (int c = -1; c <= ncols; ++c)
- {
- opt::at(ima, -1, c) = v;
- opt::at(ima, nrows, c) = v;
- }
- }
-
- } // mln::border
-
- namespace accu
- {
-
- template <typename I, typename L, typename A, typename V>
- inline
- void
- compute(const Image<I>& input_,
- const Image<L>& label_,
- const Accumulator<A>&,
- V& v)
- {
- trace::entering("accu::compute");
-
- const I& input = exact(input_);
- const L& label = exact(label_);
-
- const unsigned n = v.size();
- std::vector<A> a(n);
-
- mln_piter(I) p(input.domain());
- for_all(p)
- a[label(p)].take(input(p));
-
- for (unsigned l = 1; l < n; ++l)
- v(l) = a[l].to_result();
-
- trace::exiting("accu::compute");
- }
-
- } // mln::accu
-
- namespace morpho
- {
-
- template <typename I, typename N>
- mln_concrete(I)
- gradient(const I& input, const N& nbh)
- {
- mln_concrete(I) output;
- initialize(output, input);
- accu::min_max<mln_value(I)> mm;
-
- mln_piter(I) p(input.domain());
- mln_niter(N) n(nbh, p);
- for_all(p)
- {
- mm.init();
- for_all(n) if (input.has(n))
- mm.take(input(n));
- output(p) = mm.second() - mm.first();
- }
- return output;
- }
-
- template <typename I, typename N>
- mln_concrete(I)
- dilation(const I& input, const N& nbh)
- {
- typedef mln_value(I) V;
-
- mln_concrete(I) output;
- initialize(output, input);
-
- mln_piter(I) p(input.domain());
- mln_niter(N) n(nbh, p);
- for_all(p)
- {
- for_all(n)
- if (input.has(n) && input(n) != value::rgb8(0,0,0))
- output(p) = input(n);
- }
- return output;
- }
- } // mln::morpho
-
-
- struct colorize : Function_v2v< colorize >
- {
- typedef value::rgb8 result;
- colorize(unsigned max)
- : lut(max + 1)
- {
- lut[0] = literal::black;
- for (unsigned i = 1; i <= max; ++i)
- lut[i] = result(100 + std::rand() % 150,
- 100 + std::rand() % 150,
- 100 + std::rand() % 150);
- }
- result operator()(unsigned i) const
- {
- return lut[i];
- }
- std::vector<result> lut;
- };
-
-
- template <typename I>
- I display_edge(const I& ima, mln_value(I) bg, unsigned zoom)
- {
- unsigned nrows = ima.nrows() / 2 + 1;
- unsigned ncols = ima.ncols() / 2 + 1;
- I output(nrows * (zoom + 1) - 1,
- ncols * (zoom + 1) - 1);
- data::fill(output, bg);
- mln_VAR( edge, ima | is_edge );
- mln_piter(edge_t) p(edge.domain());
- for_all(p)
- if (p.row() % 2) // horizontal edge
- {
- unsigned row = (p.row() / 2 + 1) * (zoom + 1) - 1;
- unsigned col = (p.col() / 2) * (zoom + 1);
- for (unsigned i = 0; i < zoom; ++i)
- opt::at(output, row, col + i) = ima(p);
- }
- else // vertical edge
- {
- unsigned row = (p.row() / 2) * (zoom + 1);
- unsigned col = (p.col() / 2 + 1) * (zoom + 1) - 1;
- for (unsigned i = 0; i < zoom; ++i)
- opt::at(output, row + i, col) = ima(p);
- }
- return output;
- }
-
-} // mln
-
-
-
-template <typename T>
-mln::image2d<T>
-image2cells(const mln::image2d<T>& input)
-{
- mln::image2d<T> output(2 * input.nrows() - 1,
- 2 * input.ncols() - 1);
- for (int row = 0; row < input.nrows(); ++row)
- for (int col = 0; col < input.ncols(); ++col)
- mln::opt::at(output, 2 * row, 2 * col) = mln::opt::at(input, row, col);
- return output;
-}
-
-
-template <typename T>
-mln::image2d<T>
-cells2image(const mln::image2d<T>& input)
-{
- mln::image2d<T> output((input.nrows() + 1) / 2,
- (input.ncols() + 1) / 2);
- for (int row = 0; row < input.nrows(); row += 2)
- for (int col = 0; col < input.ncols(); col += 2)
- mln::opt::at(output, row / 2, col / 2) = mln::opt::at(input, row, col);
- return output;
-}
-
-
-
-
-template <typename I>
-mln_concrete(I)
-do_it(I& input, int lambda, unsigned& nbasins)
-{
- using namespace mln;
-
- /******************/
- /* Initialisation */
- /******************/
-
- image2d<value::int_u8> ima = image2cells(convert_to_grey(input));
-
- /**************************/
- /* Neighborhood defintion */
- /**************************/
-
- // e2c
- bool e2c_h[] = { 0, 1, 0,
- 0, 0, 0,
- 0, 1, 0 };
- bool e2c_v[] = { 0, 0, 0,
- 1, 0, 1,
- 0, 0, 0 };
- mln_VAR( e2c, make::double_neighb2d(is_row_odd, e2c_h, e2c_v) );
-
- // e2e
- bool e2e_h[] = { 0, 0, 1, 0, 0,
- 0, 1, 0, 1, 0,
- 0, 0, 0, 0, 0,
- 0, 1, 0, 1, 0,
- 0, 0, 1, 0, 0 };
- bool e2e_v[] = { 0, 0, 0, 0, 0,
- 0, 1, 0, 1, 0,
- 1, 0, 0, 0, 1,
- 0, 1, 0, 1, 0,
- 0, 0, 0, 0, 0 };
- mln_VAR( e2e, make::double_neighb2d(is_row_odd, e2e_h, e2e_v) );
-
- // cell
- mln_VAR(cell, ima | is_cell);
-
- // edge
- mln_VAR(edge, extend((ima | is_edge).rw(), pw::value(ima)));
-
- // FIXME until laplacian is working use gradient / closing_area / wst
-
- data::paste(morpho::gradient(edge, e2c), edge);
- data::paste(morpho::closing_volume(edge, e2e, lambda), edge);
- data::fill(edge, morpho::meyer_wst(edge, e2e, nbasins));
-
- // Fill regions (with colorize) (won't work with laplacian...)
-
- colorize colors(nbasins);
-
- image2d<value::rgb8> cells(ima.domain());
- data::fill(cells, literal::white);
- data::paste(level::transform(edge, colors), cells);
- io::ppm::save(display_edge(cells, literal::white, 3), "tmp_edge.ppm");
-
- // Move the color of an edge which is non black in the cell
- data::paste(morpho::dilation(cells, c4()), cells);
-
- return cells2image(cells);
-}
-
-void usage(char* argv[])
-{
- std::cerr << "usage: " << argv[0] << " input.pgm lambda output.ppm" << std::endl;
- std::cerr << " lambda >= 0" << std::endl;
- abort();
-}
-
-int main(int argc, char* argv[])
-{
- using namespace mln;
-
- if (argc != 4)
- usage(argv);
-
- int lambda = atoi(argv[2]);
- if (lambda < 0)
- usage(argv);
-
- image2d<value::rgb8> ima;
- io::ppm::load(ima, argv[1]);
-
- unsigned nbasins;
- image2d<value::rgb8> output = do_it(ima, lambda, nbasins);
-
- io::ppm::save(output, argv[3]);
-}
Index: inim/color/src/graph.hh
--- inim/color/src/graph.hh (revision 3756)
+++ inim/color/src/graph.hh (working copy)
@@ -1,62 +0,0 @@
-/*! \file src/graph.hh
- *
- */
-
-#ifndef SRC_GRAPH_HH
-# define SRC_GRAPH_HH
-
-# include <mln/value/int_u8.hh>
-# include <mln/value/int_u16.hh>
-# include <mln/value/rgb8.hh>
-
-# include <mln/data/fill.hh>
-# include <mln/opt/at.hh>
-
-# include <mln/core/image/image2d.hh>
-
-
-// Neighborhood functions
-inline
-bool is_row_odd(const mln::point2d& p)
-{
- return p.row() % 2;
-}
-inline
-bool is_cell(const mln::point2d& p)
-{
- return p.row() % 2 == 0 && p.col() % 2 == 0;
-}
-inline
-bool is_edge(const mln::point2d& p)
-{
- return (p.row() % 2 + p.col() % 2) == 1;
-}
-inline
-bool is_point(const mln::point2d& p)
-{
- return p.row() % 2 && p.col() % 2;
-}
-inline
-bool is_not_edge(const mln::point2d& p)
-{
- return ! is_edge(p);
-}
-
-// Graph image creation function
-// FIXME: add exact conversion....
-// FIXME: check that the input image is in 2 dimension
-template <typename I>
-void
-create_graph(const I& ima, I& graph, mln_value(I) val)
-{
- graph = I(ima.nrows() * 2 -1, ima.ncols() * 2 - 1);
-
- mln::data::fill(graph, val);
-
- mln_piter(I) p(ima.domain());
- for_all(p)
- mln::opt::at(graph, p.row() * 2, p.col() * 2) = ima(p);
-}
-
-
-#endif // !SRC_GRAPH_HH
Index: inim/color/src/io.hh
--- inim/color/src/io.hh (revision 3756)
+++ inim/color/src/io.hh (working copy)
@@ -1,57 +0,0 @@
-/*! \file src/io.hh
- *
- * Contains various method to load/save an image
- */
-
-#ifndef SRC_IO_HH
-# define SRC_IO_HH
-
-#include <mln/core/image/image2d.hh>
-
-#include <mln/value/int_u16.hh>
-#include <mln/value/int_s16.hh>
-
-# include <mln/io/pgm/load.hh>
-# include <mln/io/pgm/save.hh>
-# include <mln/io/ppm/load.hh>
-# include <mln/io/ppm/save.hh>
-
-namespace IO
-{
-
- template <typename I>
- void load(I& ima, const std::string& file)
- {
- mln::io::ppm::load(ima, file);
- }
-
- template <>
- void load(mln::image2d<mln::value::int_u16>& ima,
- const std::string& file)
- {
- mln::io::pgm::load(ima, file);
- }
-
- template <typename I>
- void save(I& ima, const std::string& file)
- {
- mln::io::ppm::save(ima, file);
- }
-
- template <>
- void save(mln::image2d<mln::value::int_u16>& ima,
- const std::string& file)
- {
- mln::io::pgm::save(ima, file);
- }
-
- template <>
- void save(mln::image2d<mln::value::int_s16>& ima,
- const std::string& file)
- {
- mln::io::pgm::save(ima, file);
- }
-
-} // !IO
-
-#endif // !SRC_IO_HH
Index: inim/color/src/distance.hh
--- inim/color/src/distance.hh (revision 3756)
+++ inim/color/src/distance.hh (working copy)
@@ -1,52 +0,0 @@
-/*! \file src/distance.hh
- *
- */
-
-#ifndef SRC_DISTANCE_HH
-# define SRC_DISTANCE_HH
-
-# include "graph.hh"
-
-# include <cmath>
-
-
-/// Manhatan distance
-inline
-unsigned distance(const mln::value::rgb8& lhs,
- const mln::value::rgb8& rhs)
-{
- return abs(lhs.red() - rhs.red()) +
- abs(lhs.green() - rhs.green()) +
- abs(lhs.blue() - rhs.blue());
-}
-
-
-/// Store the distance between two points on edge
-/// FIXME documentation
-template <typename I, typename N, typename O>
-void distance(const I& rgb_graph,
- const N& nbh,
- O& gl_graph)
-{
- mln_piter(I) p(rgb_graph.domain());
- mln_niter(N) n(nbh, p);
-
- for_all(p)
- {
- mln::value::rgb8 v1;
- mln::value::rgb8 v2;
-
- n.start();
- assert(n.is_valid() && rgb_graph.has(n));
- v1 = rgb_graph(n);
- n.next();
- assert(n.is_valid() && rgb_graph.has(n));
- v2 = rgb_graph(n);
-
- gl_graph(p) = distance(v1, v2);
- }
-}
-
-
-
-#endif // !SRC_DISTANCE_HH
Index: inim/color/src/convert.hh
--- inim/color/src/convert.hh (revision 3756)
+++ inim/color/src/convert.hh (working copy)
@@ -1,37 +0,0 @@
-/*! \file src/convert.hh
- *
- * Method that convert an rgb image 2d into gray level
- */
-
-#ifndef SRC_CONVERT_HH
-# define SRC_CONVERT_HH
-
-# include <mln/value/int_u8.hh>
-# include <mln/value/int_u16.hh>
-# include <mln/value/int_s16.hh>
-# include <mln/value/rgb8.hh>
-
-# include <mln/core/image/image2d.hh>
-
-// Convert function
-void convert_to_gl(mln::image2d<mln::value::int_u16>& ima,
- const mln::image2d<mln::value::rgb8>& data)
-{
- mln_piter_(mln::image2d<mln::value::int_u16>) p(ima.domain());
- for_all(p)
- ima(p) = (int) (data(p).red() * 0.3 +
- data(p).green() * 0.58 +
- data(p).blue() * 0.12);
-}
-
-void convert_to_gl(mln::image2d<mln::value::int_s16>& ima,
- const mln::image2d<mln::value::rgb8>& data)
-{
- mln_piter_(mln::image2d<mln::value::int_s16>) p(ima.domain());
- for_all(p)
- ima(p) = (int) (data(p).red() * 0.3 +
- data(p).green() * 0.58 +
- data(p).blue() * 0.12);
-}
-
-#endif // !SRC_CONVERT_HH
Index: inim/color/min_tree_color_v2.cc
--- inim/color/min_tree_color_v2.cc (revision 3756)
+++ inim/color/min_tree_color_v2.cc (working copy)
@@ -1,533 +0,0 @@
-# include <mln/core/var.hh>
-
-# include <mln/core/image/image2d.hh>
-# include <mln/core/image/image_if.hh>
-# include <mln/core/image/extended.hh>
-# include <mln/core/routine/extend.hh>
-
-# include <mln/core/alias/window2d.hh>
-# include <mln/core/alias/neighb2d.hh>
-# include <mln/make/double_neighb2d.hh>
-# include <mln/core/site_set/p_centered.hh>
-
-
-# include <mln/literal/black.hh>
-
-# include <mln/value/int_u8.hh>
-# include <mln/value/int_u16.hh>
-# include <mln/io/pgm/load.hh>
-# include <mln/io/pgm/save.hh>
-
-# include <mln/value/rgb8.hh>
-# include <mln/io/ppm/load.hh>
-# include <mln/io/ppm/save.hh>
-
-# include <mln/accu/min_max.hh>
-
-# include <mln/fun/i2v/array.hh>
-# include <mln/fun/p2v/iota.hh>
-
-# include <mln/data/paste.hh>
-# include <mln/data/fill.hh>
-# include <mln/level/transform.hh>
-# include <mln/extension/fill.hh>
-
-# include <mln/morpho/closing_area.hh>
-# include <mln/opt/at.hh>
-
-
-# include <mln/debug/println.hh>
-
-# include "src/distance.hh"
-
-namespace mln
-{
- template <typename I, typename N, typename Ic, typename Nc>
- struct min_tree_
- {
- typedef mln_site(I) point;
- typedef p_array<point> S;
-
- // in:
- const I& f;
- const N& nbh;
- const Ic& ref;
- const Nc& nbhc;
-
- // aux:
- S s;
- mln_ch_value(I, bool) deja_vu;
- mln_ch_value(I, point) parent;
- mln_ch_value(I, bool) resp;
- mln_ch_value(I, point) zpar;
-
- // attached data:
- unsigned lambda;
- mln_ch_value(I, value::rgb8) color;
- //mln_ch_value(Ic, value::rgb8) values;
- //initialize(values, ref);
- //mln_ch_value(I, int) comp;
-
- min_tree_(const I& f, const N& nbh, const Ic& ref, const Nc& nbhc,
- int lambda)
- : f(f),
- nbh(nbh),
- ref(ref),
- nbhc(nbhc),
- lambda(lambda)
- {
- run();
- }
-
- void run()
- {
- // init
- {
- initialize(deja_vu, f);
- initialize(parent, f);
- initialize(resp, f);
- initialize(zpar, f);
- initialize(color, f);
-
- mln::data::fill(deja_vu, false);
- mln::data::fill(color, value::rgb8(255, 255, 255));
-
- s = level::sort_psites_increasing(f);
- }
-
- // first pass
- {
- mln_fwd_piter(S) p(s);
- mln_niter(N) n(nbh, p);
- for_all(p)
- {
- make_set(p);
- for_all(n)
- if (f.has(n) && deja_vu(n))
- do_union(n, p);
- deja_vu(p) = true;
- }
- }
-
- // second pass: canonization
- {
- mln_bkd_piter(S) p(s);
- for_all(p)
- {
- point q = parent(p);
- if (f(parent(q)) == f(q))
- {
- parent(p) = parent(q);
- resp(q) = false;
- }
- }
- }
-
- // third pass: Merging region with distance(color) < lambda
- {
- mln_fwd_piter(S) p(s);
- for_all(p)
- {
- point q = parent(p);
- if (resp(p) && distance(color(p), color(q)) < lambda)
- {
- resp(p) = false;
- update_data(q, color(p));
- }
- }
- }
-
- } // end of run()
-
- void make_set(const point& p)
- {
- parent(p) = p;
- zpar(p) = p;
- init_data(p);
- }
-
- void set_parent(const point& r, const point& p)
- {
- parent(r) = p;
- merge_data(r, p);
- }
-
- bool is_root(const point& p) const
- {
- return parent(p) == p;
- }
-
- bool is_node(const point& p) const
- {
- //return is_root(p) || f(parent(p)) != f(p);
- return (is_root(p) || resp(p));
- }
-
- point find_root(const point& x)
- {
- if (zpar(x) == x)
- return x;
- else
- return zpar(x) = find_root(zpar(x));
- }
-
- point find_representative(const point& x)
- {
- if (parent(x) == x || resp(x))
- return x;
- else
- return find_representative(parent(x));
- }
-
- void do_union(const point& n, const point& p)
- {
- point r = find_root(n);
- if (r != p)
- {
- set_parent(r, p);
- zpar(r) = p;
- }
- }
-
- void init_data(const point& p)
- {
- int red =0, green = 0, blue = 0;
-
- mln_niter(Nc) n(nbhc, p);
- for_all(n)
- {
- red += ref(n).red();
- green += ref(n).green();
- blue += ref(n).blue();
- }
-
- red /= 2;
- green /= 2;
- blue /= 2;
-
- color(p).red() = red;
- color(p).green() = green;
- color(p).blue() = blue;
-
- resp(p) = true;
- }
-
- void merge_data(const point& r, const point& p)
- {
- if (f(p) == f(r))
- {
- resp(p) = false;
- color(r) = (color(r) + color(p)) / 2;
- }
- }
-
- void update_data(const point& p, value::rgb8 val)
- {
- color(p) = (color(p) + val) / 2;
- if (parent(p) != p && !resp(p))
- update_data(parent(p), color(p));
- }
-
- };
-}
-
-namespace mln
-{
- image2d<value::int_u16> convert_to_grey(const image2d<value::rgb8>& data)
- {
- image2d<value::int_u16> output(data.domain());
- mln_piter_(image2d<value::int_u16>) p(output.domain());
- for_all(p)
- output(p) = (int) (data(p).red() * 0.3 + data(p).green() * 0.58 + data(p).blue()) * 0.12;
- return output;
- }
-} // end of mln
-
-namespace mln
-{
-
- struct colorize : Function_v2v< colorize >
- {
- typedef value::rgb8 result;
- colorize(unsigned max)
- : lut(max + 1)
- {
- lut[0] = literal::black;
- for (unsigned i = 1; i <= max; ++i)
- lut[i] = result(100 + std::rand() % 150,
- 100 + std::rand() % 150,
- 100 + std::rand() % 150);
- }
- result operator()(unsigned i) const
- {
- return lut[i];
- }
- std::vector<result> lut;
- };
-
- template <typename I>
- I display_edge(const I& ima, mln_value(I) bg, unsigned zoom)
- {
- unsigned nrows = ima.nrows() / 2 + 1;
- unsigned ncols = ima.ncols() / 2 + 1;
- I output(nrows * (zoom + 1) - 1,
- ncols * (zoom + 1) - 1);
- data::fill(output, bg);
-
- mln_VAR(edge, ima | is_edge);
- mln_piter(edge_t) p(edge.domain());
- for_all(p)
- if (p.row() % 2) // horizontal edge
- {
- unsigned row = (p.row() / 2 + 1) * (zoom + 1) - 1;
- unsigned col = (p.col() / 2) * (zoom + 1);
- for (unsigned i = 0; i < zoom; ++i)
- opt::at(output, row, col + i) = ima(p);
- }
- else // vertical edge
- {
- unsigned row = (p.row() / 2) * (zoom + 1);
- unsigned col = (p.col() / 2 + 1) * (zoom + 1) - 1;
- for (unsigned i = 0; i < zoom; ++i)
- opt::at(output, row + i, col) = ima(p);
- }
- return output;
- }
-
- template <typename I>
- I display_edge(const I& ima, unsigned zoom)
- {
- unsigned nrows = ima.nrows() / 2 + 1;
- unsigned ncols = ima.ncols() / 2 + 1;
- I output(nrows * (zoom + 1) - 1,
- ncols * (zoom + 1) - 1);
-
- mln_VAR( cell, ima | is_cell );
- mln_piter(cell_t) q(cell.domain());
- for_all(q)
- {
- unsigned row = (q.row() / 2) * (zoom + 1);
- unsigned col = (q.col() / 2) * (zoom + 1);
- for (unsigned i = 0; i < zoom; ++i)
- for (unsigned j = 0; j < zoom; ++j)
- opt::at(output, row + i, col + j) = ima(q);
- }
-
- mln_VAR( edge, ima | is_edge );
- mln_piter(edge_t) p(edge.domain());
- for_all(p)
- if (p.row() % 2) // horizontal edge
- {
- unsigned row = (p.row() / 2 + 1) * (zoom + 1) - 1;
- unsigned col = (p.col() / 2) * (zoom + 1);
- for (unsigned i = 0; i < zoom; ++i)
- opt::at(output, row, col + i) = ima(p);
- }
- else // vertical edge
- {
- unsigned row = (p.row() / 2) * (zoom + 1);
- unsigned col = (p.col() / 2 + 1) * (zoom + 1) - 1;
- for (unsigned i = 0; i < zoom; ++i)
- opt::at(output, row + i, col) = ima(p);
- }
- return output;
- }
-
-
- namespace morpho
- {
-
- template <typename I, typename N>
- mln_concrete(I)
- dilation(const I& input, const N& nbh)
- {
- typedef mln_value(I) V;
-
- mln_concrete(I) output;
- initialize(output, input);
-
- mln_piter(I) p(input.domain());
- mln_niter(N) n(nbh, p);
- for_all(p)
- {
- for_all(n)
- if (input.has(n) && input(n) != value::rgb8(0,0,0))
- output(p) = input(n);
- }
- return output;
- }
- } // mln::morpho
-
-} // mln
-
-
-
-template <typename T>
-mln::image2d<T>
-image2cells(const mln::image2d<T>& input)
-{
- mln::image2d<T> output(2 * input.nrows() - 1,
- 2 * input.ncols() - 1);
- for (unsigned row = 0; row < input.nrows(); ++row)
- for (unsigned col = 0; col < input.ncols(); ++col)
- mln::opt::at(output, 2 * row, 2 * col) =
- mln::opt::at(input, row, col);
- return output;
-}
-
-
-template <typename T>
-mln::image2d<T>
-cells2image(const mln::image2d<T>& input)
-{
- mln::image2d<T> output((input.nrows() + 1) / 2,
- (input.ncols() + 1) / 2);
- for (unsigned row = 0; row < input.nrows(); row += 2)
- for (unsigned col = 0; col < input.ncols(); col += 2)
- mln::opt::at(output, row / 2, col / 2) =
- mln::opt::at(input, row, col);
- return output;
-}
-
-
-template <typename I, typename N, typename Ic, typename Nc>
-unsigned min_tree(const I& f, const N& nbh, const Ic& ref, const Nc& nbhc,
- int lambda)
-{
- using namespace mln;
-
- min_tree_<I,N,Ic,Nc> run(f, nbh, ref, nbhc, lambda);
-
-
- mln_piter(I) p(f.domain());
- unsigned nnodes = 0;
- for_all(p)
- {
- if (run.is_node(p))
- ++nnodes;
- }
-
- colorize colors(nnodes);
- image2d<value::rgb8> tmp(ref.domain());
- data::fill(tmp, literal::black);
- image2d<value::rgb8> tmp2(ref.domain());
- data::fill(tmp, ref);
-
- mln_piter(I) q(f.domain());
- unsigned int i = 0;
- for_all(q)
- {
- if (run.is_node(q))
- {
- tmp(q) = run.color(q);
- tmp2(q) = colors(i);
- i++;
- }
- }
-
- mln_piter(I) r(f.domain());
- for_all(r)
- {
- if (!run.is_node(r))
- {
- tmp(r) = tmp(run.find_representative(r));
- tmp2(r) = tmp2(run.find_representative(r));
- }
- }
-
- image2d<value::rgb8> to_display(tmp.domain());
- image2d<value::rgb8> to_display2(tmp2.domain());
-
- data::fill(to_display, literal::black);
- data::paste((tmp | is_edge), to_display);
- data::paste(morpho::dilation(to_display, c4()), to_display);
-
- data::fill(to_display2, literal::black);
- data::paste((tmp2 | is_edge), to_display2);
- data::paste(morpho::dilation(to_display2, c4()), to_display2);
-
-
- io::ppm::save(display_edge(tmp, literal::black, 3), "edge.ppm");
- io::ppm::save(tmp, "full.ppm");
- io::ppm::save(cells2image(to_display), "colorize.ppm");
-
- io::ppm::save(display_edge(tmp2, literal::black, 3), "edge2.ppm");
- io::ppm::save(cells2image(to_display2), "colorize2.ppm");
-
- return nnodes;
-}
-
-
-template <typename I>
-I
-do_it(I& input, int lambda, unsigned& nbasins)
-{
- using namespace mln;
-
- /// Graph creation
- I graph;
- create_graph(input, graph, value::rgb8(0, 0, 0));
-
- // Initialization
- image2d<value::int_u16> ima = convert_to_grey(graph);
-
- // Neigbhorhood
- // e2c
- bool e2c_h[] = { 0, 1, 0,
- 0, 0, 0,
- 0, 1, 0 };
- bool e2c_v[] = { 0, 0, 0,
- 1, 0, 1,
- 0, 0, 0 };
-
- mln_VAR(e2c, make::double_neighb2d(is_row_odd, e2c_h, e2c_v));
-
- bool e2e_h[] = { 0, 0, 1, 0, 0,
- 0, 1, 0, 1, 0,
- 0, 0, 0, 0, 0,
- 0, 1, 0, 1, 0,
- 0, 0, 1, 0, 0 };
-
- bool e2e_v[] = { 0, 0, 0, 0, 0,
- 0, 1, 0, 1, 0,
- 1, 0, 0, 0, 1,
- 0, 1, 0, 1, 0,
- 0, 0, 0, 0, 0 };
- mln_VAR(e2e, make::double_neighb2d(is_row_odd, e2e_h, e2e_v));
-
- // Algorithm
- distance(extend((graph | is_edge).rw(), pw::value(graph)), e2c, ima);
-
- io::pgm::save(ima, "edge.pgm");
-
- nbasins = min_tree((ima | is_edge), e2e, graph, e2c, lambda);
-
- return graph;
-}
-
-void usage(char* argv[])
-{
- std::cerr << "usage: " << argv[0] << " input.pgm lambda" << std::endl;
- std::cerr << " lambda >= 0" << std::endl;
- abort();
-}
-
-int main(int argc, char* argv[])
-{
- using namespace mln;
-
- if (argc != 3)
- usage(argv);
-
- int lambda = atoi(argv[2]);
- if (lambda < 0)
- usage(argv);
-
- image2d<value::rgb8> ima;
- io::ppm::load(ima, argv[1]);
-
- unsigned nbasins;
- image2d<value::rgb8> output = do_it(ima, lambda, nbasins);
-
- //io::ppm::save(output, argv[3]);
-}
Index: inim/color/laplacien.cc
--- inim/color/laplacien.cc (revision 3756)
+++ inim/color/laplacien.cc (working copy)
@@ -1,130 +0,0 @@
-#include <mln/core/image/image2d.hh>
-#include <mln/core/image/image_if.hh>
-
-# include <mln/core/alias/neighb2d.hh>
-# include <mln/make/double_neighb2d.hh>
-
-#include <mln/value/rgb8.hh>
-#include <mln/value/int_u16.hh>
-#include <mln/value/int_s16.hh>
-
-#include <mln/linear/gaussian.hh>
-#include <mln/morpho/erosion.hh>
-
-#include <mln/core/var.hh>
-#include <mln/debug/println.hh>
-#include <mln/opt/at.hh>
-
-#include "src/io.hh"
-#include "src/graph.hh"
-#include "src/convert.hh"
-
-
-void usage(char* argv[])
-{
- std::cerr << "usage: " << argv[0] << " input.ppm output.pgm" << std::endl;
- abort();
-}
-
-/// FIXME Put these elsewhere
-typedef mln::image2d<mln::value::rgb8> Icolor;
-typedef mln::image2d<mln::value::int_u16> Igray;
-
-void process(Icolor& graph, const Icolor& input)
-{
- using namespace mln;
-
- // Neighborhood definition
-
-// bool e2c_h[] = { 0, 1, 0,
-// 0, 0, 0,
-// 0, 1, 0 };
-// bool e2c_v[] = { 0, 0, 0,
-// 1, 0, 1,
-// 0, 0, 0 };
-
-// bool e2e_h[] = { 0, 0, 1, 0, 0,
-// 0, 1, 0, 1, 0,
-// 0, 0, 0, 0, 0,
-// 0, 1, 0, 1, 0,
-// 0, 0, 1, 0, 0 };
-// bool e2e_v[] = { 0, 0, 0, 0, 0,
-// 0, 1, 0, 1, 0,
-// 1, 0, 0, 0, 1,
-// 0, 1, 0, 1, 0,
-// 0, 0, 0, 0, 0 };
-
-// bool e2p_h[] = { 0, 0, 1,
-// 0, 0, 0,
-// 1, 0, 0 };
-// bool e2p_v[] = { 1, 0, 0,
-// 0, 0, 0,
-// 0, 0, 1 };
- //mln_VAR(e2c, make::double_neighb2d(is_row_odd, e2c_h, e2c_v));
-
-
- // convert the image into grey level
- Igray gray_graph(graph.bbox());
- convert_to_gl(gray_graph, graph);
-
- Igray gray_input(input.bbox());
- convert_to_gl(gray_input, input);
-
-
- //data::paste(morpho::dilation((gray_graph | is_cell), e2c.win()), gray_graph);
-// Igray save(gray_graph.bbox());
-// data::paste(gray_graph | is_cell, save);
-// IO::save(save, "tmp3.ppm");
-
- // Create the laplacian image
- //Igray laplacian(gray_input.bbox());
- image2d<int> laplacian(gray_input.bbox());
- linear::gaussian(gray_input, 2.0f, laplacian);
- //IO::save(laplacian, "tmp1.ppm");
- linear::laplacian(gray_input, 2.0f, laplacian);
- debug::println(laplacian);
- //IO::save(laplacian, "tmp2.ppm");
-
- // Display edge on the output images
-// debug::println(laplacian);
-
-// mln_piter_(Igray) p(laplacian.domain());
-// for_all(p)
-// if (laplacian(p) == 0u)
-// {
-// std::cout << "I'm here" << std::endl;
-// opt::at(graph, p.row() * 2, p.col() * 2) = value::rgb<8>(255, 0, 0);
-// }
-
-}
-
-
-
-int main(int argc, char* argv[])
-{
- using namespace mln;
-
- // Initialisation
- if (argc != 3)
- usage(argv);
-
- std::string input_file(argv[1]);
- std::string output_file(argv[2]);
-
-
- Icolor input;
-
- // Load the image
- IO::load(input, input_file);
-
- // create a graph image from the input
- Icolor graph;
- create_graph(input, graph);
-
- // Process
- process(graph, input);
-
-
- // Save
- IO::save(graph, output_file);
-}
Index: inim/color/README
--- inim/color/README (revision 3756)
+++ inim/color/README (working copy)
@@ -1,83 +0,0 @@
--*- outline -*-
-
-* Fichiers sources:
-
-Les fichiers sources se trouvent dans milena/sandbox/ballas/color/.
-
-** Les méthodes de références:
-
-*** reference.cc:
- Utilisation de la seconde dérivée de gaussienne.
- Les passages par 0 sont mis en rouges.
-
-*** reference2.cc:
- Utilisation d'un gradient puis d'un filtre de clôture de volumes.
-
- Variante testée (non retenue):
- - un filtre de clôture d'aires.
-
-** min_tree:
-
-Les approches développées avec le min tree essayent de prendre en compte
-la couleur de l'image initial.
-
-Ici, on "expand" l'image pour pouvoir stocker les points et les edges directement
-sur l'image. Puis sur chaque edge, on stocke la distance séparant les deux
-pixels voisins cet edge. On construit ensuite un min tree sur ces edges.
-Ce min tree est ensuite filtrer afin d'éviter la sur-segmentation
-
-
-*** min_tree_area.cc:
- Dans cette version, un filtre d'aire est appliqué aux edges constituant
-le min tree. Si l'aire des edges d'une région du min tree est inférieure à un
-lambda donné, on fusionne la région avec sa région supérieure.
-
-*** min_tree_volume.cc
- Dans cette version, un filtre de volume est appliqué aux edges constituant
-le min tree.
-
-*** min_tree_color.cc
- Dans cette version, on filtre en fonction de la couleur moyenne.
-Si la distance entre la couleur moyenne constituant 2 régions est inférieure
-à un lambda donné, on fusionne les régions.
-
-
-* Organisation des répertoires:
-
-Les images de tests se trouve dans le répertoire ~ballas/pub/result/
-
-Chaque sous-répertoire contient des tests sur une image en particulier
-Cette image est stockée dans le répertoire sous le nom input.ppm.
-
-Chaque sous-répertoire contiennent des répertoires avec les résultats
-en fonction des méthodes utilisées:
-- ref1 contient les résultats de la méthode reference.cc
-- ref2 contient les résultats de la méthode reference2.cc
-- area contient les résultats de la méthode min_tree_area.cc
-- volume contient les résultats de la méthode min_tree_volume.cc
-- color contient les résultats de la méthode min_tree_color.cc
-
-Les résultats sont organisés de la manière suivante dans les répertoires
-area, volume et color.
-** edge.pgm:
- Image affichant les edges calculés avant le passage de min tree.
- Ces edges contiennent la distance entre les deux pixels voisins.
- Les pixels sont noir par défaut dans cette image.
-** edge.ppm:
- Image affichant les edges calcules après l'application du filtre sur le
- min tree.
- Ces edges contiennent la distance entre les deux pixels voisins.
- Les pixels sont noir par défaut dans cette image.
-** full.ppm:
- Superposition de l'image edge.ppm et de l'image de départ.
-** colorize.ppm:
- Image contenant les pixels coloriés à partir des edges de l'image.
- On utilise une dilatation pour colorier les pixels, ce qui altère la
- forme des lettres.
-
-Les résultats sont organisés de la manière suivante dans les répertoires
-ref1 et ref2.
-** lambda_x.ppm:
- x est le lambda utilisé pour le filtre.
- Dans ref1, nous avons une image avec les contours, alors que dans ref2,
- nous une image découpée en zones.
Index: inim/nature/gradient.cc
--- inim/nature/gradient.cc (revision 3756)
+++ inim/nature/gradient.cc (working copy)
@@ -1,60 +0,0 @@
-// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE)
-//
-// This file is part of the Olena Library. This library is free
-// software; you can redistribute it and/or modify it under the terms
-// of the GNU General Public License version 2 as published by the
-// Free Software Foundation.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this library; see the file COPYING. If not, write to
-// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
-// Boston, MA 02111-1307, USA.
-//
-// As a special exception, you may use this file as part of a free
-// software library without restriction. Specifically, if other files
-// instantiate templates or use macros or inline functions from this
-// file, or you compile this file and link it with other files to
-// produce an executable, this file does not by itself cause the
-// resulting executable to be covered by the GNU General Public
-// License. This exception does not however invalidate any other
-// reasons why the executable file might be covered by the GNU General
-// Public License.
-
-#include <mln/core/image/image2d.hh>
-#include <mln/win/rectangle2d.hh>
-
-#include <mln/io/pgm/load.hh>
-#include <mln/io/pgm/save.hh>
-
-#include <mln/value/int_u8.hh>
-#include <mln/morpho/gradient.hh>
-
-
-int main(int argc, const char * argv[])
-{
- using namespace mln;
- using value::int_u8;
-
- if (argc < 2) {
- std::cerr << "usage: " << argv[0] << " in.pgm [other_files.pgm]" << std::endl;
- return 1;
- }
-
- for (int i = 1; i < argc; ++i)
- {
- image2d<int_u8> ima;
- io::pgm::load(ima, argv[i]);
-
- win::rectangle2d rect(5, 5);
- border::thickness = 5;
-
- std::string name(argv[i]);
- name.erase(name.length() - 4);
- io::pgm::save(morpho::gradient(ima, rect), name.append("_grad.pgm"));
- }
-}
Index: inim/nature/erosion.cc
--- inim/nature/erosion.cc (revision 3756)
+++ inim/nature/erosion.cc (working copy)
@@ -1,60 +0,0 @@
-// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE)
-//
-// This file is part of the Olena Library. This library is free
-// software; you can redistribute it and/or modify it under the terms
-// of the GNU General Public License version 2 as published by the
-// Free Software Foundation.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this library; see the file COPYING. If not, write to
-// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
-// Boston, MA 02111-1307, USA.
-//
-// As a special exception, you may use this file as part of a free
-// software library without restriction. Specifically, if other files
-// instantiate templates or use macros or inline functions from this
-// file, or you compile this file and link it with other files to
-// produce an executable, this file does not by itself cause the
-// resulting executable to be covered by the GNU General Public
-// License. This exception does not however invalidate any other
-// reasons why the executable file might be covered by the GNU General
-// Public License.
-
-#include <mln/core/image/image2d.hh>
-#include <mln/win/rectangle2d.hh>
-
-#include <mln/io/pgm/load.hh>
-#include <mln/io/pgm/save.hh>
-
-#include <mln/value/int_u8.hh>
-#include <mln/morpho/gradient.hh>
-
-
-int main(int argc, const char * argv[])
-{
- using namespace mln;
- using value::int_u8;
-
- if (argc < 2) {
- std::cerr << "usage: " << argv[0] << " in.pgm [other_files.pgm]" << std::endl;
- return 1;
- }
-
- for (int i = 1; i < argc; ++i)
- {
- image2d<int_u8> ima;
- io::pgm::load(ima, argv[i]);
-
- win::hline2d f(31);
- border::thickness = 16;
-
- std::string name(argv[i]);
- name.erase(name.length() - 4);
- io::pgm::save(morpho::erosion(ima, f), name.append("_eroded.pgm"));
- }
-}
Index: inim/nature/mco.cc
--- inim/nature/mco.cc (revision 3756)
+++ inim/nature/mco.cc (working copy)
@@ -1,48 +0,0 @@
-#include <iostream>
-
-#include <mln/core/image/image2d.hh>
-#include <mln/core/image/cast_image.hh>
-#include <mln/value/int_u16.hh>
-#include "co_occurence.hh"
-#include <mln/core/alias/dpoint2d.hh>
-#include <mln/io/pgm/save.hh>
-#include <mln/io/pgm/load.hh>
-#include <mln/estim/min_max.hh>
-
-int main(int argc, const char * argv[])
-{
- using namespace mln;
- using namespace value;
-
- if (argc < 2) {
- std::cerr << "usage: " << argv[0] << " in.pgm [other_files.pgm]" << std::endl;
- return 1;
- }
-
- dpoint2d d(0, 1);
-
- for (int i = 1; i < argc; ++i)
- {
- image2d<int_u8> ima;
- io::pgm::load(ima, argv[i]);
-
- std::string name(argv[i]);
- name.erase(name.length() - 4);
-
- image2d<unsigned> co (co_occurence(ima, d));
-
- // Normalization
- unsigned m, M;
- estim::min_max(co, m, M);
- std::cout << "max : " << M << std::endl;
- double norm = 255./M;
- mln_piter_ (image2d<unsigned>) p (co.domain());
- for_all(p)
- {
- // std::cout << co(p) << " ; ";
- co(p) *= norm;
- }
-
- io::pgm::save(cast_image<int_u<8> >(co), name.append("_mco.pgm"));
- }
-}
Index: inim/nature/closing.cc
--- inim/nature/closing.cc (revision 3756)
+++ inim/nature/closing.cc (working copy)
@@ -1,61 +0,0 @@
-// Copyright (C) 2007, 2008, 2009 EPITA Research and Development
-// Laboratory (LRDE)
-//
-// This file is part of the Olena Library. This library is free
-// software; you can redistribute it and/or modify it under the terms
-// of the GNU General Public License version 2 as published by the
-// Free Software Foundation.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this library; see the file COPYING. If not, write to
-// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
-// Boston, MA 02111-1307, USA.
-//
-// As a special exception, you may use this file as part of a free
-// software library without restriction. Specifically, if other files
-// instantiate templates or use macros or inline functions from this
-// file, or you compile this file and link it with other files to
-// produce an executable, this file does not by itself cause the
-// resulting executable to be covered by the GNU General Public
-// License. This exception does not however invalidate any other
-// reasons why the executable file might be covered by the GNU General
-// Public License.
-
-#include <mln/core/image/image2d.hh>
-#include <mln/win/rectangle2d.hh>
-
-#include <mln/io/pgm/load.hh>
-#include <mln/io/pgm/save.hh>
-
-#include <mln/value/int_u8.hh>
-#include <mln/morpho/closing/structural.hh>
-
-
-int main(int argc, const char * argv[])
-{
- using namespace mln;
- using value::int_u8;
-
- if (argc < 2) {
- std::cerr << "usage: " << argv[0] << " in.pgm [other_files.pgm]" << std::endl;
- return 1;
- }
-
- for (int i = 1; i < argc; ++i)
- {
- image2d<int_u8> ima;
- io::pgm::load(ima, argv[i]);
-
- win::rectangle2d rect(5, 5);
- border::thickness = 11;
-
- std::string name(argv[i]);
- name.erase(name.length() - 4);
- io::pgm::save(morpho::closing::structural(ima, rect), name.append("_closed.pgm"));
- }
-}
Index: inim/nature/nature.cc
--- inim/nature/nature.cc (revision 3756)
+++ inim/nature/nature.cc (working copy)
@@ -1,499 +0,0 @@
-// Copyright (C) 2007, 2008, 2009 EPITA Research and Development
-// Laboratory (LRDE)
-//
-// This file is part of the Olena Library. This library is free
-// software; you can redistribute it and/or modify it under the terms
-// of the GNU General Public License version 2 as published by the
-// Free Software Foundation.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this library; see the file COPYING. If not, write to
-// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
-// Boston, MA 02111-1307, USA.
-//
-// As a special exception, you may use this file as part of a free
-// software library without restriction. Specifically, if other files
-// instantiate templates or use macros or inline functions from this
-// file, or you compile this file and link it with other files to
-// produce an executable, this file does not by itself cause the
-// resulting executable to be covered by the GNU General Public
-// License. This exception does not however invalidate any other
-// reasons why the executable file might be covered by the GNU General
-// Public License.
-
-#include <mln/core/image/image2d.hh>
-#include <mln/core/image/cast_image.hh>
-#include <mln/core/image/thru.hh>
-#include <mln/core/alias/neighb2d.hh>
-
-#include <mln/io/ppm/load.hh>
-#include <mln/io/pgm/save.hh>
-#include <mln/io/pbm/save.hh>
-
-#include <mln/histo/compute.hh>
-
-#include <mln/level/transform.hh>
-#include <mln/data/paste.hh>
-#include <mln/level/to_enc.hh>
-
-#include <mln/value/rgb8.hh>
-#include <mln/value/hsi.hh>
-
-#include <mln/fun/v2v/rgb_to_hsi.hh>
-#include <mln/fun/meta/hue.hh>
-#include <mln/fun/meta/sat.hh>
-#include <mln/fun/meta/inty.hh>
-
-#include <mln/win/hline2d.hh>
-#include <mln/win/vline2d.hh>
-
-#include <mln/morpho/hit_or_miss.hh>
-#include <mln/morpho/gradient.hh>
-#include <mln/morpho/opening/structural.hh>
-
-#include <mln/binarization/threshold.hh>
-
-#include <mln/estim/mean.hh>
-
-#include <mln/transform/fft.hh>
-
-#include <mln/opt/at.hh>
-
-#include "co_occurence.hh"
-
-#include <math.h>
-
-using namespace mln;
-using namespace value;
-
-enum doctype
- {
- TEXT,
- SCREENSHOT,
- PHOTO,
- DRAWING,
- NB_DOCTYPE
- };
-
-template <typename T>
-unsigned nb_peaks (histo::data<T> &h)
-{
- // First, we compute the maximum, ignoring the first column because it
- // contains nonsense points
-
- unsigned max = 0;
- mln_viter(mln::value::set<T>) v(h.vset());
-
- for_all(v)
- if (((T)v).to_enc() && (h(v) > max))
- max = h(v);
-
- // We take the first value into account
- if (h[0] / 6 > max)
- max = h[0] / 6;
-
- // Now we count the number of peaks over max / 4
- unsigned cpt = 0;
- for_all(v)
- if (h(v) >= max / 4)
- cpt ++;
-
- return cpt;
-}
-
-
-int main (int argc, const char * argv [])
-{
- if (argc != 2) {
- std::cerr << "usage: " << argv[0] << " in.pgm" << std::endl;
- return 1;
- }
-
- unsigned score[NB_DOCTYPE];
- for (unsigned i = 0; i < NB_DOCTYPE; ++i)
- score[i] = 0;
-
- border::thickness = 21;
-
- image2d<rgb8> input;
- io::ppm::load(input, argv[1]);
-
- // First, we get the HSI histograms and corresponding greyscale versions of the picture
-
- image2d<hsi_f> hsi = level::transform(input, fun::v2v::f_rgb_to_hsi_f);
-
- thru<mln::meta::hue<hsi_f>, image2d<hsi_f> > hue(hsi);
- thru<mln::meta::sat<hsi_f>, image2d<hsi_f> > sat(hsi);
- thru<mln::meta::inty<hsi_f>, image2d<hsi_f> > inty(hsi);
-
- cast_image_<float01_8, thru<mln::meta::hue<hsi_f>, image2d<hsi_f> > > qhue(hue); // quantified hue
- cast_image_<float01_8, thru<mln::meta::sat<hsi_f>, image2d<hsi_f> > > qsat(sat); // quantified sat
- cast_image_<float01_8, thru<mln::meta::inty<hsi_f>, image2d<hsi_f> > > qinty(inty); // quantified inty
-
- histo::data<float01_8> hhue = histo::compute(qhue);
- histo::data<float01_8> hsat = histo::compute(qsat);
- histo::data<float01_8> hinty = histo::compute(qinty);
-
-
- // Compute the number of peaks in the histogram to give a first intuition
-
- unsigned n = nb_peaks(hhue) * 3;
-
- if (n > 100)
- n = 100;
-
- score[PHOTO] += n;
- score[SCREENSHOT] += 20 + 80 - n * 80 / 100;
- score[TEXT] += 100 - n;
- score[DRAWING] += 20 + 80 - n * 80 / 100;
-
- std::cout << "Test 1 : peaks number[" << nb_peaks(hhue) << "]" << std::endl
- << "Photo : " << score[PHOTO] << std::endl
- << "Screenshot : " << score[SCREENSHOT] << std::endl
- << "Text : " << score[TEXT] << std::endl
- << "Drawing : " << score[DRAWING] << std::endl << std::endl;
-
-
- // Now we compute the co-occurence matrice
-
- dpoint2d d(0, 1);
- image2d<int_u8> uinty (qinty.domain());
- {
- image2d<unsigned char> tmp = level::transform(qinty, fun::v2v::enc< float01_8 >());
- data::paste(tmp, uinty);
- /* mln_piter_(image2d<unsigned char>) p(tmp.domain());
- for_all(p)
- uinty(p) = tmp(p);
- */
- }
-
- image2d<unsigned> mco (co_occurence(uinty, d));
-
- // If there is a plain background, there will be a massive peak in the diagonal of the matrix
- unsigned max = 0;
- for (unsigned i = 0; i < mco.nrows(); i++)
- if (opt::at(mco, i, i) > max)
- max = opt::at(mco, i, i);
-
- for (unsigned i = 0; i < mco.nrows() - 1; i++) {
- if (opt::at(mco, i + 1, i) > max)
- max = opt::at(mco, i + 1, i);
- if (opt::at(mco, i, i + 1) > max)
- max = opt::at(mco, i, i + 1);
- }
-
- max = max * 100 / input.nelements();
-
- score[PHOTO] += 100 - max;
- score[TEXT] += max * 2;
-
- score[SCREENSHOT] += 50 + max / 2;
- score[DRAWING] += 50 + max / 2;
-
- std::cout << "Test 2 : co-occurence matrix diag_max[" << max << "]" << std::endl
- << "Photo : +" << 100 - max << std::endl;
-
- std::cout << "Screenshot : +" << 50 + max / 2 << std::endl;
-
- std::cout << "Text : +" << max * 2 << std::endl;
-
- std::cout << "Drawing : +" << 50 + max / 2 << std::endl << std::endl;
-
-
-
-
- // A good way to detect screenshots : rectangle detection
-
- // First, we compute the gradient
-
- win::rectangle2d rect(5, 5);
- image2d<int_u8> grad = morpho::gradient(uinty, rect);
-
- // Then, we apply a lot of hit or miss filters !
-
- // Compute the mean
- int_u8 mean = estim::mean(grad);
-
- image2d<bool> imab = binarization::threshold(grad, 10);
-
- window2d winout;
- window2d winin;
-
- static const bool blmatout [] = {0, 0, 0, 0, 0,
- 0, 1, 0, 0, 0,
- 0, 1, 0, 0, 0,
- 0, 1, 1, 1, 0,
- 0, 0, 0, 0, 0};
-
- convert::from_to(blmatout, winout);
-
- static const bool blmatin [] = {0, 0, 1, 0, 0,
- 0, 0, 1, 0, 0,
- 0, 0, 1, 1, 1,
- 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0};
-
- convert::from_to(blmatin, winin);
-
- image2d<bool> bottom_left = morpho::hit_or_miss(imab, winout, winin);
-
-
- static const bool brmatout [] = {0, 0, 0, 0, 0,
- 0, 0, 0, 1, 0,
- 0, 0, 0, 1, 0,
- 0, 1, 1, 1, 0,
- 0, 0, 0, 0, 0};
-
- static const bool brmatin [] = {0, 0, 1, 0, 0,
- 0, 0, 1, 0, 0,
- 1, 1, 1, 0, 0,
- 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0};
-
-
- convert::from_to(brmatout, winout);
- convert::from_to(brmatin, winin);
- image2d<bool> bottom_right = morpho::hit_or_miss(imab, winout, winin);
-
- static const bool urmatout [] = {0, 0, 0, 0, 0,
- 0, 1, 1, 1, 0,
- 0, 0, 0, 1, 0,
- 0, 0, 0, 1, 0,
- 0, 0, 0, 0, 0};
-
- static const bool urmatin [] = {0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0,
- 1, 1, 1, 0, 0,
- 0, 0, 1, 0, 0,
- 0, 0, 1, 0, 0};
-
-
- convert::from_to(urmatout, winout);
- convert::from_to(urmatin, winin);
- image2d<bool> up_right = morpho::hit_or_miss(imab, winout, winin);
-
- static const bool ulmatout [] = {0, 0, 0, 0, 0,
- 0, 1, 1, 1, 0,
- 0, 1, 0, 0, 0,
- 0, 1, 0, 0, 0,
- 0, 0, 0, 0, 0};
-
- static const bool ulmatin [] = {0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0,
- 0, 0, 1, 1, 1,
- 0, 0, 1, 0, 0,
- 0, 0, 1, 0, 0};
-
-
- convert::from_to(ulmatout, winout);
- convert::from_to(ulmatin, winin);
- image2d<bool> up_left = morpho::hit_or_miss(imab, winout, winin);
-
-
- static const bool umatout [] = {0, 0, 0, 0, 0,
- 1, 1, 1, 1, 1,
- 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0};
-
- static const bool umatin [] = {0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0,
- 0, 1, 1, 1, 0,
- 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0};
-
-
- convert::from_to(umatout, winout);
- convert::from_to(umatin, winin);
- image2d<bool> up = morpho::hit_or_miss(imab, winout, winin);
-
-
- static const bool bmatout [] = {0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0,
- 1, 1, 1, 1, 1,
- 0, 0, 0, 0, 0};
-
- static const bool bmatin [] = {0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0,
- 0, 1, 1, 1, 0,
- 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0};
-
-
- convert::from_to(bmatout, winout);
- convert::from_to(bmatin, winin);
- image2d<bool> bottom = morpho::hit_or_miss(imab, winout, winin);
-
-
- static const bool lmatout [] = {0, 1, 0, 0, 0,
- 0, 1, 0, 0, 0,
- 0, 1, 0, 0, 0,
- 0, 1, 0, 0, 0,
- 0, 1, 0, 0, 0};
-
- static const bool lmatin [] = {0, 0, 0, 0, 0,
- 0, 0, 1, 0, 0,
- 0, 0, 1, 0, 0,
- 0, 0, 1, 0, 0,
- 0, 0, 0, 0, 0};
-
-
- convert::from_to(lmatout, winout);
- convert::from_to(lmatin, winin);
- image2d<bool> left = morpho::hit_or_miss(imab, winout, winin);
-
-
- static const bool rmatout [] = {0, 0, 0, 1, 0,
- 0, 0, 0, 1, 0,
- 0, 0, 0, 1, 0,
- 0, 0, 0, 1, 0,
- 0, 0, 0, 1, 0};
-
- static const bool rmatin [] = {0, 0, 0, 0, 0,
- 0, 0, 1, 0, 0,
- 0, 0, 1, 0, 0,
- 0, 0, 1, 0, 0,
- 0, 0, 0, 0, 0};
-
-
- convert::from_to(rmatout, winout);
- convert::from_to(rmatin, winin);
- image2d<bool> right = morpho::hit_or_miss(imab, winout, winin);
-
- image2d<bool> inter (up_left + up_right + bottom_right + bottom_left + up + bottom + left + right);
-
- image2d<bool> final = morpho::opening::structural(inter, win::hline2d(20));
- final += morpho::opening::structural(inter, win::vline2d(20));
-
- // Now we count blank points in our result
-
- unsigned cpt = 0;
- mln_piter_(image2d<bool>) p (final.domain());
- for_all(p)
- cpt += final(p);
-
- // compute the percentage of blank points
-
- cpt = 1000 * cpt / final.domain().nsites();
-
- if (cpt > 50)
- cpt = 50;
-
- score[PHOTO] += 50 - cpt;
- score[SCREENSHOT] += cpt * 5;
- score[TEXT] += 50 + cpt * max / 10;
- score[DRAWING] += 2 * (50 - cpt);
-
- std::cout << "Test 3 : rectangle detection[" << cpt << "]" << std::endl
- << "Photo : +" << 50 - cpt << std::endl
- << "Screenshot : +" << cpt * 8 << std::endl
- << "Text : +" << 50 + cpt * max / 10 << std::endl
- << "Drawing : +" << 2 * (50 - cpt) << std::endl << std::endl;
-
-
- // Last but not least : text detection thanks to FFT
-
- transform::fft<double> fourier(morpho::opening::structural(uinty, win::hline2d(20)));
- fourier.transform();
-
- std::string name(argv[1]);
- name.erase(name.length() - 4);
- image2d<int_u8> fft = fourier.transformed_image_log_magn<int_u8>(true);
- mln_piter_(image2d<int_u8>) q (fft.domain());
- max = 0;
- for_all(q)
- if (fft(q) > max)
- max = fft(q);
-
- image2d<bool> fftb = binarization::threshold(fft, max * 4 / 10);
-
- // Find the line that best fits the points
-
- unsigned
- center_r = fft.nrows() / 2,
- center_c = fft.ncols() / 2;
-
- double arg = 0, coeff = 0;
-
- for_all(q)
- if (fftb(q))
- {
- double dist =
- (center_c - q.col()) * (center_c - q.col()) +
- (center_r - q.row()) * (center_r - q.row());
-
- if (!dist)
- continue;
-
- double angle = acos (abs(center_r - q.row()) / sqrt(dist));
- while (angle > M_PI)
- angle -= M_PI;
- while (angle < 0)
- angle += M_PI;
-
- arg = (arg * coeff + dist * angle) / (coeff + dist);
-
- coeff += dist;
-
- }
-
- // std::cout << "arg : " << arg << " coeff : " << coeff << std::endl;
- double a = tan(arg);
-
- // Now compute the mean distance of the points to the line
-
- double b = center_c - a * center_r;
- double dist = 0;
- coeff = 0;
-
- for_all(q)
- if (fftb(q))
- {
- double d = abs(a * q.row() - q.col() + b) / sqrt(a * a + 1);
- dist += d * d;
- coeff ++;
- }
-
- dist /= coeff;
-
- dist = dist / (log(fftb.nelements()) / log(10));
-
- score[PHOTO] += dist * 25;
- score[SCREENSHOT] += dist * 25;
- score[TEXT] += (1 + cos(arg)) * 2 * (4 - dist) * 50;
- score[DRAWING] += dist * 25;
-
- std::cout << "Test 4 : Fourier distance[" << dist << "]" << std::endl
- << "Photo : +" << dist * 25 << std::endl
- << "Screenshot : +" << dist * 25 << std::endl
- << "Text : +" << (1 + cos(arg)) * (4 - dist) * 25 << std::endl
- << "Drawing : +" << dist * 25 << std::endl << std::endl;
-
-
- // io::pbm::save(binarization::threshold(fft, max * 4 / 10), name.append("_fft.pbm"));
-
- // Print the result !
-
- std::cout << "Photo : " << score[PHOTO] << std::endl
- << "Screenshot : " << score[SCREENSHOT] << std::endl
- << "Text : " << score[TEXT] << std::endl
- << "Drawing : " << score[DRAWING] << std::endl;
-
- max = 0;
- unsigned index = 0;
-
- for (unsigned i = 0; i < NB_DOCTYPE; ++i)
- if (score[i] > max)
- {
- max = score[i];
- index = i;
- }
-
- return index;
-}
Index: inim/nature/opening.cc
--- inim/nature/opening.cc (revision 3756)
+++ inim/nature/opening.cc (working copy)
@@ -1,61 +0,0 @@
-// Copyright (C) 2007, 2008, 2009 EPITA Research and Development
-// Laboratory (LRDE)
-//
-// This file is part of the Olena Library. This library is free
-// software; you can redistribute it and/or modify it under the terms
-// of the GNU General Public License version 2 as published by the
-// Free Software Foundation.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this library; see the file COPYING. If not, write to
-// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
-// Boston, MA 02111-1307, USA.
-//
-// As a special exception, you may use this file as part of a free
-// software library without restriction. Specifically, if other files
-// instantiate templates or use macros or inline functions from this
-// file, or you compile this file and link it with other files to
-// produce an executable, this file does not by itself cause the
-// resulting executable to be covered by the GNU General Public
-// License. This exception does not however invalidate any other
-// reasons why the executable file might be covered by the GNU General
-// Public License.
-
-#include <mln/core/image/image2d.hh>
-#include <mln/win/rectangle2d.hh>
-
-#include <mln/io/pgm/load.hh>
-#include <mln/io/pgm/save.hh>
-
-#include <mln/value/int_u8.hh>
-#include <mln/morpho/opening/structural.hh>
-
-
-int main(int argc, const char * argv[])
-{
- using namespace mln;
- using value::int_u8;
-
- if (argc < 2) {
- std::cerr << "usage: " << argv[0] << " in.pgm [other_files.pgm]" << std::endl;
- return 1;
- }
-
- for (int i = 1; i < argc; ++i)
- {
- image2d<int_u8> ima;
- io::pgm::load(ima, argv[i]);
-
- win::rectangle2d rect(3, 3);
- border::thickness = 11;
-
- std::string name(argv[i]);
- name.erase(name.length() - 4);
- io::pgm::save(morpho::opening::structural(ima, rect), name.append("_opened.pgm"));
- }
-}
Index: inim/nature/fft.cc
--- inim/nature/fft.cc (revision 3756)
+++ inim/nature/fft.cc (working copy)
@@ -1,61 +0,0 @@
-// -*- c++ -*-
-// Copyright (C) 2004 EPITA Research and Development Laboratory
-//
-// This file is part of the Olena Library. This library is free
-// software; you can redistribute it and/or modify it under the terms
-// of the GNU General Public License version 2 as published by the
-// Free Software Foundation.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this library; see the file COPYING. If not, write to
-// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-// Boston, MA 02110-1301, USA.
-//
-// As a special exception, you may use this file as part of a free
-// software library without restriction. Specifically, if other files
-// instantiate templates or use macros or inline functions from this
-// file, or you compile this file and link it with other files to
-// produce an executable, this file does not by itself cause the
-// resulting executable to be covered by the GNU General Public
-// License. This exception does not however invalidate any other
-// reasons why the executable file might be covered by the GNU General
-// Public License.
-
-#include <mln/transform/fft.hh>
-#include <mln/value/int_u8.hh>
-#include <mln/io/pgm/load.hh>
-#include <mln/io/pgm/save.hh>
-
-using namespace mln;
-using namespace transform;
-using namespace value;
-
-int main(int argc, const char * argv[])
-{
- using namespace mln;
- using value::int_u8;
-
- if (argc < 2) {
- std::cerr << "usage: " << argv[0] << " in.pgm [other_files.pgm]" << std::endl;
- return 1;
- }
-
- for (int i = 1; i < argc; ++i)
- {
- image2d<int_u8> ima;
- io::pgm::load(ima, argv[i]);
-
- fft<double> fourier(ima);
-
- fourier.transform();
-
- std::string name(argv[i]);
- name.erase(name.length() - 4);
- io::pgm::save(fourier.transformed_image_log_magn<int_u8>(true), name.append("_fft.pgm"));
- }
-}
Index: inim/nature/co_occurence.hh
--- inim/nature/co_occurence.hh (revision 3756)
+++ inim/nature/co_occurence.hh (working copy)
@@ -1,77 +0,0 @@
-// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
-//
-// This file is part of the Olena Library. This library is free
-// software; you can redistribute it and/or modify it under the terms
-// of the GNU General Public License version 2 as published by the
-// Free Software Foundation.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this library; see the file COPYING. If not, write to
-// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
-// Boston, MA 02111-1307, USA.
-//
-// As a special exception, you may use this file as part of a free
-// software library without restriction. Specifically, if other files
-// instantiate templates or use macros or inline functions from this
-// file, or you compile this file and link it with other files to
-// produce an executable, this file does not by itself cause the
-// resulting executable to be covered by the GNU General Public
-// License. This exception does not however invalidate any other
-// reasons why the executable file might be covered by the GNU General
-// Public License.
-
-#ifndef MLN_CO_OCCURENCE_HH
-# define MLN_CO_OCCURENCE_HH
-
-/*! \file ??
- *
- * \brief FIXME
- */
-
-# include <mln/core/concept/image.hh>
-# include <mln/core/dpoint.hh>
-# include <mln/core/image/image2d.hh>
-# include <mln/data/fill.hh>
-# include <mln/opt/at.hh>
-
-
-namespace mln
-{
-
-
- template <typename I, typename D>
- // image2d<unsigned> co_occurence (const Image<I>&, const Dpoint<D>&);
- image2d<unsigned> co_occurence (const Image<I>&, const Gdpoint<D>&);
-
-# ifndef MLN_INCLUDE_ONLY
-
- template <typename I, typename D>
- image2d<unsigned> co_occurence (const Image<I> &ima_, const Gdpoint<D> &dp_)
- {
- mln::metal::equal<mln_psite(I), mln_psite(D)>::check();
- // FIXME : check thaat Image<I> is quant low
-
- const I &ima = exact(ima_);
- const D &dp = exact(dp_);
- image2d<unsigned> mco(mln_card(mln_value(I)), mln_card(mln_value(I)), 0);
- data::fill(mco, 0);
-
-
- mln_piter(I) p(ima.domain());
- for_all(p)
- if (ima.domain().has(p + dp))
- opt::at(mco, ima(p), ima(p + dp))++;
-
- return mco;
- }
-
-#endif // MLN_INCLUDE_ONLY
-
-}
-
-#endif // MLN_CO_OCCURENCE_HH
Index: inim/nature/hom.cc
--- inim/nature/hom.cc (revision 3756)
+++ inim/nature/hom.cc (working copy)
@@ -1,316 +0,0 @@
-// Copyright (C) 2007, 2008, 2009 EPITA Research and Development
-// Laboratory (LRDE)
-//
-// This file is part of the Olena Library. This library is free
-// software; you can redistribute it and/or modify it under the terms
-// of the GNU General Public License version 2 as published by the
-// Free Software Foundation.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this library; see the file COPYING. If not, write to
-// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
-// Boston, MA 02111-1307, USA.
-//
-// As a special exception, you may use this file as part of a free
-// software library without restriction. Specifically, if other files
-// instantiate templates or use macros or inline functions from this
-// file, or you compile this file and link it with other files to
-// produce an executable, this file does not by itself cause the
-// resulting executable to be covered by the GNU General Public
-// License. This exception does not however invalidate any other
-// reasons why the executable file might be covered by the GNU General
-// Public License.
-
-
-#include <mln/core/image/image2d.hh>
-
-#include <mln/win/rectangle2d.hh>
-
-#include <mln/io/pgm/load.hh>
-#include <mln/io/pbm/save.hh>
-
-#include <mln/value/int_u8.hh>
-#include <mln/value/int_u16.hh>
-
-# include <mln/core/alias/window2d.hh>
-
-#include <mln/level/transform.hh>
-#include <mln/binarization/threshold.hh>
-#include <mln/estim/mean.hh>
-#include <mln/morpho/hit_or_miss.hh>
-#include <mln/morpho/dilation.hh>
-#include <mln/morpho/opening/structural.hh>
-
-#include <mln/win/hline2d.hh>
-#include <mln/win/vline2d.hh>
-
-
-int main(int argc, const char * argv[])
-{
- using namespace mln;
- using namespace value;
-
- if (argc < 2) {
- std::cerr << "usage: " << argv[0] << " in.pgm [other_files.pgm]" << std::endl;
- return 1;
- }
-
- for (int i = 1; i < argc; ++i)
- {
- typedef int_u8 int_t;
-
- border::thickness = 21;
-
- image2d<int_t> ima;
- io::pgm::load(ima, argv[i]);
-
- // Compute the mean
- int_t mean = estim::mean(ima);
-
-
- image2d<bool> imab = binarization::threshold(ima, 10);
-
-
-
- window2d winout;
- window2d winin;
-
-// static const bool matout [] = {0, 0, 0, 0, 0, 0, 0,
-// 0, 0, 1, 0, 0, 0, 0,
-// 0, 0, 1, 0, 0, 0, 0,
-// 0, 0, 1, 0, 0, 0, 0,
-// 0, 0, 1, 1, 1, 1, 0,
-// 0, 0, 0, 0, 0, 0, 0,
-// 0, 0, 0, 0, 0, 0, 0};
-
- static const bool blmatout [] = {0, 0, 0, 0, 0,
- 0, 1, 0, 0, 0,
- 0, 1, 0, 0, 0,
- 0, 1, 1, 1, 0,
- 0, 0, 0, 0, 0};
-
-// static const bool blmatout [] = {0, 0, 0,
-// 1, 0, 0,
-// 1, 1, 0};
-
-
- convert::from_to(blmatout, winout);
-
-// static const bool matin [] = {0, 0, 0, 1, 0, 0, 0,
-// 0, 0, 0, 1, 0, 0, 0,
-// 0, 0, 0, 1, 0, 0, 0,
-// 0, 0, 0, 1, 1, 1, 1,
-// 0, 0, 0, 0, 0, 0, 0,
-// 0, 0, 0, 0, 0, 0, 0,
-// 0, 0, 0, 0, 0, 0, 0};
-
- static const bool blmatin [] = {0, 0, 1, 0, 0,
- 0, 0, 1, 0, 0,
- 0, 0, 1, 1, 1,
- 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0};
-
-// static const bool blmatin [] = {0, 1, 0,
-// 0, 1, 1,
-// 0, 0, 0};
-
- convert::from_to(blmatin, winin);
- image2d<bool> bottom_left = morpho::hit_or_miss(imab, winout, winin);
-
-
-// static const bool brmatout [] = {0, 0, 0,
-// 0, 0, 1,
-// 0, 1, 1};
-
-// static const bool brmatin [] = {0, 1, 0,
-// 1, 1, 0,
-// 0, 0, 0};
-
- static const bool brmatout [] = {0, 0, 0, 0, 0,
- 0, 0, 0, 1, 0,
- 0, 0, 0, 1, 0,
- 0, 1, 1, 1, 0,
- 0, 0, 0, 0, 0};
-
- static const bool brmatin [] = {0, 0, 1, 0, 0,
- 0, 0, 1, 0, 0,
- 1, 1, 1, 0, 0,
- 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0};
-
-
- convert::from_to(brmatout, winout);
- convert::from_to(brmatin, winin);
- image2d<bool> bottom_right = morpho::hit_or_miss(imab, winout, winin);
-
-// static const bool urmatout [] = {0, 1, 1,
-// 0, 0, 1,
-// 0, 0, 0};
-
-// static const bool urmatin [] = {0, 0, 0,
-// 1, 1, 0,
-// 0, 1, 0};
-
- static const bool urmatout [] = {0, 0, 0, 0, 0,
- 0, 1, 1, 1, 0,
- 0, 0, 0, 1, 0,
- 0, 0, 0, 1, 0,
- 0, 0, 0, 0, 0};
-
- static const bool urmatin [] = {0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0,
- 1, 1, 1, 0, 0,
- 0, 0, 1, 0, 0,
- 0, 0, 1, 0, 0};
-
-
- convert::from_to(urmatout, winout);
- convert::from_to(urmatin, winin);
- image2d<bool> up_right = morpho::hit_or_miss(imab, winout, winin);
-
-
-// static const bool ulmatout [] = {1, 1, 0,
-// 1, 0, 0,
-// 0, 0, 0};
-
-// static const bool ulmatin [] = {0, 0, 0,
-// 0, 1, 1,
-// 0, 1, 0};
-
- static const bool ulmatout [] = {0, 0, 0, 0, 0,
- 0, 1, 1, 1, 0,
- 0, 1, 0, 0, 0,
- 0, 1, 0, 0, 0,
- 0, 0, 0, 0, 0};
-
- static const bool ulmatin [] = {0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0,
- 0, 0, 1, 1, 1,
- 0, 0, 1, 0, 0,
- 0, 0, 1, 0, 0};
-
-
- convert::from_to(ulmatout, winout);
- convert::from_to(ulmatin, winin);
- image2d<bool> up_left = morpho::hit_or_miss(imab, winout, winin);
-
-
- static const bool umatout [] = {0, 0, 0, 0, 0,
- 1, 1, 1, 1, 1,
- 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0};
-
- static const bool umatin [] = {0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0,
- 0, 1, 1, 1, 0,
- 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0};
-
-
- convert::from_to(umatout, winout);
- convert::from_to(umatin, winin);
- image2d<bool> up = morpho::hit_or_miss(imab, winout, winin);
-
-
- static const bool bmatout [] = {0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0,
- 1, 1, 1, 1, 1,
- 0, 0, 0, 0, 0};
-
- static const bool bmatin [] = {0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0,
- 0, 1, 1, 1, 0,
- 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0};
-
-
- convert::from_to(bmatout, winout);
- convert::from_to(bmatin, winin);
- image2d<bool> bottom = morpho::hit_or_miss(imab, winout, winin);
-
-
- static const bool lmatout [] = {0, 1, 0, 0, 0,
- 0, 1, 0, 0, 0,
- 0, 1, 0, 0, 0,
- 0, 1, 0, 0, 0,
- 0, 1, 0, 0, 0};
-
- static const bool lmatin [] = {0, 0, 0, 0, 0,
- 0, 0, 1, 0, 0,
- 0, 0, 1, 0, 0,
- 0, 0, 1, 0, 0,
- 0, 0, 0, 0, 0};
-
-
- convert::from_to(lmatout, winout);
- convert::from_to(lmatin, winin);
- image2d<bool> left = morpho::hit_or_miss(imab, winout, winin);
-
-
- static const bool rmatout [] = {0, 0, 0, 1, 0,
- 0, 0, 0, 1, 0,
- 0, 0, 0, 1, 0,
- 0, 0, 0, 1, 0,
- 0, 0, 0, 1, 0};
-
- static const bool rmatin [] = {0, 0, 0, 0, 0,
- 0, 0, 1, 0, 0,
- 0, 0, 1, 0, 0,
- 0, 0, 1, 0, 0,
- 0, 0, 0, 0, 0};
-
-
- convert::from_to(rmatout, winout);
- convert::from_to(rmatin, winin);
- image2d<bool> right = morpho::hit_or_miss(imab, winout, winin);
-
-
-
-
- std::string name(argv[i]);
- name.erase(name.length() - 4);
- io::pbm::save( imab, name.append("_bin.pbm"));
-
- name = argv[i];
- name.erase(name.length() - 4);
- // image2d<bool> final(right.domain());
- // data::fill(final, false);
- // mln_piter_(image2d<bool>) p(final.domain());
- // for_all(p)
- // final(p) = up_left(p) || up_right(p) || bottom_right(p) || bottom_left(p) || up(p) || bottom(p) || left(p) || right(p);
-
- image2d<bool> inter (up_left + up_right + bottom_right + bottom_left + up + bottom + left + right);
-
- static const bool vert [] = {0, 0, 0, 1, 0, 0, 0,
- 0, 0, 0, 1, 0, 0, 0,
- 0, 0, 0, 1, 0, 0, 0,
- 0, 0, 0, 1, 0, 0, 0,
- 0, 0, 0, 1, 0, 0, 0,
- 0, 0, 0, 1, 0, 0, 0,
- 0, 0, 0, 1, 0, 0, 0};
-
- static const bool hori [] = {0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0,
- 1, 1, 1, 1, 1, 1, 1,
- 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0};
-
- convert::from_to(vert, winin);
- convert::from_to(hori, winout);
-
- image2d<bool> final = morpho::opening::structural(inter, win::hline2d(20));
- final += morpho::opening::structural(inter, win::vline2d(20));
-
- io::pbm::save( final,
- name.append("_hom.pbm"));
- }
-}
Index: inim/nature/proj.hh
--- inim/nature/proj.hh (revision 3756)
+++ inim/nature/proj.hh (working copy)
@@ -1,64 +0,0 @@
-// Copyright (C) 2008 EPITA Research and Development Laboratory
-//
-// This file is part of the Olena Library. This library is free
-// software; you can redistribute it and/or modify it under the terms
-// of the GNU General Public License version 2 as published by the
-// Free Software Foundation.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this library; see the file COPYING. If not, write to
-// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
-// Boston, MA 02111-1307, USA.
-//
-// As a special exception, you may use this file as part of a free
-// software library without restriction. Specifically, if other files
-// instantiate templates or use macros or inline functions from this
-// file, or you compile this file and link it with other files to
-// produce an executable, this file does not by itself cause the
-// resulting executable to be covered by the GNU General Public
-// License. This exception does not however invalidate any other
-// reasons why the executable file might be covered by the GNU General
-// Public License.
-
-#ifndef MLN_PROJ_HH
-# define MLN_PROJ_HH
-
-#include <mln/io/pgm/save.hh>
-#include <mln/data/paste.hh>
-#include <mln/accu/mean.hh>
-#include <mln/literal/white.hh>
-#include <mln/core/image/image2d.hh>
-#include <mln/core/image/image1d.hh>
-#include <mln/data/fill.hh>
-#include <mln/opt/at.hh>
-
-namespace mln
-{
- template <typename T>
- image1d<float>
- proj_nat(const image2d<T>& input)
- {
- image1d<float> out(geom::nrows(input));
- data::fill(out, 0);
-
- mln_piter(image2d<T>) p(input.domain());
- for_all(p) // 2d
- opt::at(out, p.row()) += input(p);
-
- mln_piter(image1d<T>) p2(out.domain());
- unsigned count = geom::ncols(input);
- for_all(p2) {
- out(p2) /= count;
- }
- return out;
- }
-
-} // end of namespace mln
-
-#endif /* MLN_PROJ_HH */
-
Index: inim/nature/test.sh
--- inim/nature/test.sh (revision 3756)
+++ inim/nature/test.sh (working copy)
@@ -1,11 +0,0 @@
-#! /bin/sh
-
-for i in $@;
-do
- echo $i;
- echo "";
- ./nature $i;
- echo "";
- echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
- echo "";
-done;
Index: inim/nature/Makefile
--- inim/nature/Makefile (revision 3756)
+++ inim/nature/Makefile (working copy)
@@ -1,24 +0,0 @@
-SRC=$(wildcard *.cc)
-OBJ=$(SRC:.cc=.o)
-EXEC=$(SRC:.cc=)
-CC=g++
-CXXFLAGS=-Wall -W -I ../abraham -I ../.. -O3 -DNDEBUG
-
-fft: fft.o
- $(CC) $(CXXFLAGS) $< -o $@ -l fftw3
-
-nature: nature.o
- $(CC) $(CXXFLAGS) $< -o $@ -l fftw3
-
-all: $(EXEC)
-
-clean:
- rm -rf *.o
- rm -rf *~
-
-distclean: clean
- rm -rf $(EXEC)
-
-proj: proj.cc proj.hh
-
-.PHONY: clean distclean
Index: inim/nature/histo_hsi.cc
--- inim/nature/histo_hsi.cc (revision 3756)
+++ inim/nature/histo_hsi.cc (working copy)
@@ -1,181 +0,0 @@
-// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
-//
-// This file is part of the Olena Library. This library is free
-// software; you can redistribute it and/or modify it under the terms
-// of the GNU General Public License version 2 as published by the
-// Free Software Foundation.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this library; see the file COPYING. If not, write to
-// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
-// Boston, MA 02111-1307, USA.
-//
-// As a special exception, you may use this file as part of a free
-// software library without restriction. Specifically, if other files
-// instantiate templates or use macros or inline functions from this
-// file, or you compile this file and link it with other files to
-// produce an executable, this file does not by itself cause the
-// resulting executable to be covered by the GNU General Public
-// License. This exception does not however invalidate any other
-// reasons why the executable file might be covered by the GNU General
-// Public License.
-
-#include <iterator>
-#include <string>
-
-#include <mln/core/image/image2d.hh>
-#include <mln/core/image/cast_image.hh>
-#include <mln/core/image/thru.hh>
-#include <mln/core/alias/window2d.hh>
-#include <mln/core/alias/neighb2d.hh>
-#include <mln/core/site_set/p_set.hh>
-
-#include <mln/value/rgb8.hh>
-#include <mln/value/hsi.hh>
-
-#include <mln/fun/v2v/rgb_to_hsi.hh>
-#include <mln/level/to_enc.hh>
-#include <mln/fun/meta/hue.hh>
-#include <mln/fun/meta/sat.hh>
-#include <mln/fun/meta/inty.hh>
-
-#include <mln/level/compare.hh>
-
-#include <mln/io/ppm/load.hh>
-#include <mln/io/pbm/save.hh>
-#include <mln/io/pgm/save.hh>
-
-#include <mln/accu/histo.hh>
-#include <mln/histo/compute.hh>
-#include <mln/level/transform.hh>
-#include <mln/data/fill.hh>
-
-using namespace mln;
-using namespace value;
-
-typedef int_u16 u_t;
-
-
-template <typename I>
-void save_histo(Image<I> &i, std::string &name)
-{
- I& ima = exact(i);
-
- histo::data<float01_8> h = histo::compute(ima);
-
- // Compute histo max
- unsigned max = 0;
- mln_viter(mln::value::set<float01_8>) v(h.vset());
-
- for_all(v)
- if (h(v) > max)
- max = h(v);
-
- std::cout << std::endl;
-
- image2d<bool> output(max, mln_card(float01_8), 0);
- std::cout << max << "x" << mln_card(float01_8) << std::endl;
- data::fill(output, true);
-
- for_all(v)
- for (size_t i = 0; i < h(v); ++i)
- {
- // std::cout << max - i - 1 << ", " << (unsigned) (((float01_8)v).to_enc()) << " ; " ;
- if (output.has(point2d(max - i - 1, ((float01_8)v).to_enc() )))
- output(point2d(max - i - 1, ((float01_8)v).to_enc() )) = false;
- }
-
- io::pbm::save(output, name);
-}
-
-int main (int argc, const char* argv [])
-{
- if (argc < 2) {
- std::cerr << "usage: " << argv[0] << " in.ppm [other_files.ppm]" << std::endl;
- return 1;
- }
-
- for (int i = 1; i < argc; ++i)
- {
-
- image2d<rgb8> input;
- io::ppm::load(input, argv[i]);
-
- image2d<hsi_f> hsi = level::transform(input, fun::v2v::f_rgb_to_hsi_f);
- thru<mln::meta::hue<hsi_f>, image2d<hsi_f> > h(hsi);
- cast_image_<float01_8, thru<mln::meta::hue<hsi_f>, image2d<hsi_f> > > hue(h);
-
- std::string n(argv[i]);
- n.erase(n.length() - 4);
- image2d<int_u8> henc;
- level::transform(hue, fun::v2v::enc< float01_8 >(), henc);
- io::pgm::save(henc, n.append("_hue.pgm"));
-
- image2d<hsi_f>::piter p(hsi.domain());
- float m = 0;
- for_all(p)
- {
- if (h(p) > m)
- m = h(p);
- }
- std::cout << std::endl << m << std::endl;
-
-
-
- std::string name(argv[i]);
- name.erase(name.length() - 4);
- save_histo(hue, name.append("_hue.pbm"));
-
-
- thru<mln::meta::sat<hsi_f>, image2d<hsi_f> > s(hsi);
- cast_image_<float01_8, thru<mln::meta::sat<hsi_f>, image2d<hsi_f> > > sat(s);
-
- n = argv[i];
- n.erase(n.length() - 4);
- image2d<int_u8> senc;
- level::transform(sat, fun::v2v::enc< float01_8 >(), senc);
- io::pgm::save(senc, n.append("_sat.pgm"));
-
- m = 0;
- for_all(p)
- {
- if (s(p) > m)
- m = s(p);
- }
- std::cout << std::endl << m << std::endl;
-
-
- name = argv[i];
- name.erase(name.length() - 4);
- save_histo(sat, name.append("_sat.pbm"));
-
- thru<mln::meta::inty<hsi_f>, image2d<hsi_f> > l(hsi);
- cast_image_<float01_8, thru<mln::meta::inty<hsi_f>, image2d<hsi_f> > > inty(l);
-
- n = argv[i];
- n.erase(n.length() - 4);
- image2d<int_u8> ienc;
- level::transform(inty, fun::v2v::enc< float01_8 >(), ienc);
- io::pgm::save(ienc, n.append("_inty.pgm"));
-
-
- m = 0;
- for_all(p)
- {
- if (l(p) > m)
- m = l(p);
- }
- std::cout << std::endl << m << std::endl;
-
-
- name = argv[i];
- name.erase(name.length() - 4);
- save_histo(inty, name.append("_inty.pbm"));
-
- }
-}
Index: inim/nature/proj.cc
--- inim/nature/proj.cc (revision 3756)
+++ inim/nature/proj.cc (working copy)
@@ -1,68 +0,0 @@
-// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE)
-//
-// This file is part of the Olena Library. This library is free
-// software; you can redistribute it and/or modify it under the terms
-// of the GNU General Public License version 2 as published by the
-// Free Software Foundation.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this library; see the file COPYING. If not, write to
-// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
-// Boston, MA 02111-1307, USA.
-//
-// As a special exception, you may use this file as part of a free
-// software library without restriction. Specifically, if other files
-// instantiate templates or use macros or inline functions from this
-// file, or you compile this file and link it with other files to
-// produce an executable, this file does not by itself cause the
-// resulting executable to be covered by the GNU General Public
-// License. This exception does not however invalidate any other
-// reasons why the executable file might be covered by the GNU General
-// Public License.
-
-#include <mln/core/image/image2d.hh>
-#include <mln/core/image/image1d.hh>
-#include <mln/win/rectangle2d.hh>
-#include <mln/core/image/cast_image.hh>
-
-#include <mln/io/pgm/load.hh>
-#include <mln/io/pgm/save.hh>
-
-#include <mln/value/int_u8.hh>
-#include <mln/morpho/opening.hh>
-
-#include "proj.hh"
-
-int main(int argc, const char * argv[])
-{
- using namespace mln;
- using value::int_u8;
-
- if (argc < 2) {
- std::cerr << "usage: " << argv[0] << " in.pgm [other_files.pgm]" << std::endl;
- return 1;
- }
-
- for (int i = 1; i < argc; ++i)
- {
- image2d<int_u8> ima;
- io::pgm::load(ima, argv[i]);
-
- std::string name(argv[i]);
- name.erase(name.length() - 4);
- image1d<float> toto = proj_nat(ima);
- image2d<int_u8> tata (toto.domain().nsites(), 1);
- mln_piter_(image1d<int_u8>) p(toto.domain());
-
- for_all(p) {
- tata(point2d(p[0], 0)) = toto(p);
- }
-
- io::pgm::save(tata, name.append("_proj.pgm"));
- }
-}
1
0
05 May '09
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2009-05-05 Fabien Freling <fabien.freling(a)lrde.epita.fr>
Update inter_pixel files to match coding style.
* mln/world/inter_pixel/full.hh: Move this...
* mln/world/inter_pixel/full2image.hh: ...here...
* mln/world/inter_pixel/image2full.hh: ...and here.
* mln/world/inter_pixel/neighb2d.hh: Update to match coding style.
---
full2image.hh | 75 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
image2full.hh | 74 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
neighb2d.hh | 9 ++++++
3 files changed, 158 insertions(+)
Index: trunk/milena/mln/world/inter_pixel/full.hh (deleted)
===================================================================
Index: trunk/milena/mln/world/inter_pixel/neighb2d.hh
===================================================================
--- trunk/milena/mln/world/inter_pixel/neighb2d.hh (revision 3755)
+++ trunk/milena/mln/world/inter_pixel/neighb2d.hh (revision 3756)
@@ -47,6 +47,12 @@
typedef neighb< win::multiple<window2d, dim2::is_row_odd> > dbl_neighb2d;
+ const dbl_neighb2d& e2c();
+ const dbl_neighb2d& e2e();
+
+
+# ifndef MLN_INCLUDE_ONLY
+
const dbl_neighb2d& e2c()
{
static bool e2c_h[] = { 0, 1, 0,
@@ -75,6 +81,9 @@
return nbh;
}
+# endif // ! MLN_INCLUDE_ONLY
+
+
} // end of namespace mln::world::inter_pixel
} // end of namespace mln::world
Index: trunk/milena/mln/world/inter_pixel/full2image.hh
===================================================================
--- trunk/milena/mln/world/inter_pixel/full2image.hh (revision 0)
+++ trunk/milena/mln/world/inter_pixel/full2image.hh (revision 3756)
@@ -0,0 +1,75 @@
+// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This 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_FULL_HH
+# define MLN_WORLD_INTER_PIXEL_FULL_HH
+
+/// \file mln/world/inter_pixel/full.hh
+///
+/// FIXME: insert comment.
+
+# include <mln/core/image/image2d.hh>
+
+namespace mln
+{
+
+ namespace world
+ {
+
+ namespace inter_pixel
+ {
+
+ template <typename T>
+ image2d<T>
+ full2image(const image2d<T>& input);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename T>
+ image2d<T>
+ full2image(const image2d<T>& input)
+ {
+ image2d<T> output((input.nrows() + 1) / 2,
+ (input.ncols() + 1) / 2);
+ for (int row = 0; row < input.nrows(); row += 2)
+ for (int col = 0; col < input.ncols(); col += 2)
+ opt::at(output, row / 2, col / 2) =
+ opt::at(input, row, col);
+ return output;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+
+ } // end of namespace mln::world::inter_pixel
+
+ } // end of namespace mln::world
+
+} // end of namespace mln
+
+#endif // ! MLN_WORLD_INTER_PIXEL_FULL
Index: trunk/milena/mln/world/inter_pixel/image2full.hh
===================================================================
--- trunk/milena/mln/world/inter_pixel/image2full.hh (revision 0)
+++ trunk/milena/mln/world/inter_pixel/image2full.hh (revision 3756)
@@ -0,0 +1,74 @@
+// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This 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_FULL_HH
+# define MLN_WORLD_INTER_PIXEL_FULL_HH
+
+/// \file mln/world/inter_pixel/full.hh
+///
+/// FIXME: insert comment.
+
+# include <mln/core/image/image2d.hh>
+
+namespace mln
+{
+
+ namespace world
+ {
+
+ namespace inter_pixel
+ {
+
+ template <typename T>
+ image2d<T>
+ image2full(const image2d<T>& input);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename T>
+ image2d<T>
+ image2full(const image2d<T>& input)
+ {
+ image2d<T> output(2 * input.nrows() - 1,
+ 2 * input.ncols() - 1);
+ for (int row = 0; row < input.nrows(); ++row)
+ for (int col = 0; col < input.ncols(); ++col)
+ opt::at(output, 2 * row, 2 * col) = opt::at(input, row, col);
+ return output;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+
+ } // end of namespace mln::world::inter_pixel
+
+ } // end of namespace mln::world
+
+} // end of namespace mln
+
+#endif // ! MLN_WORLD_INTER_PIXEL_FULL
1
0
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2009-05-05 Edwin Carlinet <carlinet(a)lrde.epita.fr>
Fixes about aharpness attribute.
* morpho/attribute/sharpness.hh: Sharpness attribute fixes.
* morpho/tree/data.hh: Add leaves precondition.
---
attribute/sharpness.hh | 8 ++++++--
tree/data.hh | 1 +
2 files changed, 7 insertions(+), 2 deletions(-)
Index: trunk/milena/mln/morpho/tree/data.hh
===================================================================
--- trunk/milena/mln/morpho/tree/data.hh (revision 3754)
+++ trunk/milena/mln/morpho/tree/data.hh (revision 3755)
@@ -415,6 +415,7 @@
++nroots_;
}
}
+ mln_assertion(leaves_.nsites() > 0);
}
template <typename I, typename S>
Index: trunk/milena/mln/morpho/attribute/sharpness.hh
===================================================================
--- trunk/milena/mln/morpho/attribute/sharpness.hh (revision 3754)
+++ trunk/milena/mln/morpho/attribute/sharpness.hh (revision 3755)
@@ -177,8 +177,12 @@
double
sharpness<I>::to_result() const
{
- double d = (double) volume_.to_result() /
- (double)(volume_.area() * (height_.to_result() + 1));
+ double d = 0;
+ if (height_.to_result() != 0)
+ {
+ d = (double) volume_.to_result() /
+ (double)((volume_.area() - 1) * (height_.to_result() + 1) + 1);
+ }
mln_postcondition(d >= 0 && d <= 1);
return d;
}
1
0
milena r3754: Tidy source code of new functions, renamed trait::fun to trait::function
by Frederic Bour 05 May '09
by Frederic Bour 05 May '09
05 May '09
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2009-05-05 Frederic Bour <bour(a)lrde.epita.fr>
Tidy source code of new functions, renamed trait::fun to trait::function.
* mln/core/image/thru_morpher.hh,
* mln/core/image/thrubin_morpher.hh,
* mln/fun/accu_result.hh,
* mln/fun/binary.hh: tidied.
* mln/fun/component/comp.hh: Splitted into multiples files:
* mln/fun/component/comp_count.hh: New,
* mln/fun/component/ithcomp.hh: New,
* mln/fun/component/scomp.hh: New. Static i'th component extraction.
* mln/fun/math/cos.hh,
* mln/fun/math/inf.hh,
* mln/fun/math/sup.hh,
* mln/fun/point/col.hh,
* mln/fun/point/row.hh,
* mln/fun/point/sli.hh,
* mln/fun/spe/binary.hh,
* mln/fun/spe/unary.hh,
* mln/fun/unary.hh: tidied.
* mln/trait/fun.hh: Removed. Renamed to:
* mln/trait/functions.hh: New.
* sandbox/fred/tests/fun.cc: Small update.
---
mln/core/image/thru_morpher.hh | 4
mln/core/image/thrubin_morpher.hh | 2
mln/fun/accu_result.hh | 18 +-
mln/fun/binary.hh | 4
mln/fun/component/comp.hh | 75 -----------
mln/fun/component/comp_count.hh | 99 ++++++++++++++
mln/fun/component/ithcomp.hh | 83 ++++++++++++
mln/fun/component/scomp.hh | 90 +++++++++++++
mln/fun/math/cos.hh | 6
mln/fun/math/inf.hh | 6
mln/fun/math/sup.hh | 6
mln/fun/point/col.hh | 8 -
mln/fun/point/row.hh | 4
mln/fun/spe/binary.hh | 4
mln/fun/spe/unary.hh | 4
mln/fun/unary.hh | 2
mln/trait/functions.hh | 253 ++++++++++++++++++++++++++++++++++++++
sandbox/fred/tests/fun.cc | 17 +-
18 files changed, 578 insertions(+), 107 deletions(-)
Index: trunk/milena/mln/trait/fun.hh (deleted)
===================================================================
Index: trunk/milena/mln/trait/functions.hh
===================================================================
--- trunk/milena/mln/trait/functions.hh (revision 0)
+++ trunk/milena/mln/trait/functions.hh (revision 3754)
@@ -0,0 +1,253 @@
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR F PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_TRAIT_FUNCTIONS_HH
+# define MLN_TRAIT_FUNCTIONS_HH
+
+# include <mln/metal/bexpr.hh>
+# include <mln/metal/if.hh>
+# include <mln/fun/param.hh>
+# include <mln/trait/next/solve.hh>
+
+# define mln_trait_fun_is_assignable(Fun) typename mln::trait::function::is_assignable< Fun >::ret
+# define mln_trait_fun_is_assignable_(Fun) mln::trait::function::is_assignable< Fun >::ret
+# define mln_trait_fun_is_assignable__1comma(A, B) typename mln::trait::function::is_assignable< A, B >::ret
+# define mln_trait_fun_is_assignable__1comma_(A, B) mln::trait::function::is_assignable< A, B >::ret
+
+# define mln_trait_fun_is_parametrable(Fun) typename mln::trait::function::is_parametrable< Fun >::ret
+# define mln_trait_fun_is_parametrable_(Fun) mln::trait::function::is_parametrable< Fun >::ret
+
+# define mln_trait_fun_lvalue(Fun) typename mln::trait::function::get_lvalue< Fun >::ret
+# define mln_trait_fun_param(Fun) typename mln::trait::function::get_param< Fun >::ret
+# define mln_trait_fun_storage(Fun) typename mln::trait::function::get_storage< Fun >::ret
+
+namespace mln
+{
+
+ namespace trait
+ {
+
+ namespace function
+ {
+
+ namespace internal
+ {
+
+ namespace introspect
+ {
+
+ template <typename T>
+ struct except_void_t
+ {
+ typedef void ret;
+ };
+
+ template <>
+ struct except_void_t<void>;
+
+ // Lvalue solver
+
+ template <typename T, typename V>
+ struct has_lvalue_t
+ {
+ typedef metal::false_ ret;
+ typedef void type;
+ };
+
+ template <typename T>
+ struct has_lvalue_t<T, typename except_void_t<typename T::lvalue>::ret>
+ {
+ typedef metal::true_ ret;
+ typedef typename T::lvalue type;
+ };
+
+ // Parameter solver
+ template <typename T, typename V>
+ struct param_solver;
+
+ template <typename T, typename V>
+ struct param_flag_solver
+ {
+ typedef typename mln::fun::parameter<T> ret;
+ };
+
+ template <typename T>
+ struct param_flag_solver<T, typename except_void_t<typename mln::fun::parameter<typename T::flag>::param>::ret>
+ {
+ typedef mln::fun::parameter<typename T::flag> ret;
+ };
+
+ template <typename T, typename V>
+ struct param_def_solver
+ {
+ typedef typename param_flag_solver<T, V>::ret ret;
+ };
+
+ template <typename T>
+ struct param_def_solver<T, typename except_void_t<typename mln::fun::parameter<typename T::def>::param>::ret>
+ {
+ typedef mln::fun::parameter<typename T::def> ret;
+ };
+
+ template <typename T, typename V>
+ struct param_solver : param_def_solver<T, V>
+ {
+ };
+
+ template <typename T>
+ struct param_solver<T, typename except_void_t<typename T::param>::ret>
+ {
+ typedef T ret;
+ };
+
+ template <typename T, typename V>
+ struct has_param_t
+ {
+ typedef metal::false_ ret;
+ typedef void type;
+ };
+
+ template <typename T>
+ struct has_param_t<T, typename except_void_t<typename param_solver<T,void>::ret::param>::ret>
+ {
+ typedef metal::true_ ret;
+ typedef typename param_solver<T,void>::ret::param type;
+ };
+
+ template <typename T, typename V>
+ struct storage_solver;
+
+ template <typename T, typename V>
+ struct storage_flag_solver
+ {
+ typedef typename mln::fun::parameter<T> ret;
+ };
+
+ template <typename T>
+ struct storage_flag_solver<T, typename except_void_t<typename mln::fun::parameter<typename T::flag>::storage>::ret>
+ {
+ typedef mln::fun::parameter<typename T::flag> ret;
+ };
+
+ template <typename T, typename V>
+ struct storage_def_solver
+ {
+ typedef typename storage_flag_solver<T, V>::ret ret;
+ };
+
+ template <typename T>
+ struct storage_def_solver<T, typename except_void_t<typename mln::fun::parameter<typename T::def>::storage>::ret>
+ {
+ typedef mln::fun::parameter<typename T::def> ret;
+ };
+
+ template <typename T, typename V>
+ struct storage_solver : storage_def_solver<T, V>
+ {
+ };
+
+ template <typename T>
+ struct storage_solver<T, typename except_void_t<typename T::storage>::ret>
+ {
+ typedef T ret;
+ };
+
+ template <typename T, typename V>
+ struct has_storage_t
+ {
+ typedef has_param_t<T, V> has_param;
+
+ typedef metal::false_ ret;
+ typedef typename has_param::type type;
+
+ template <typename U>
+ static inline
+ const U& compute(const U& t)
+ {
+ return t;
+ }
+
+ };
+
+ template <typename T>
+ struct has_storage_t<T, typename except_void_t<typename param_solver<T,void>::ret::storage>::ret>
+ {
+ typedef metal::true_ ret;
+ typedef typename param_solver<T,void>::ret def;
+
+ typedef typename def::storage type;
+
+ template <typename U>
+ static inline
+ type compute(const U& p)
+ {
+ return def::compute(p);
+ };
+
+ };
+
+ } // end of namespace mln::trait::fun::internal::introspect
+
+ } // end of namespace mln::trait::fun::internal
+
+ template <typename F>
+ struct is_assignable
+ {
+ typedef typename internal::introspect::has_lvalue_t<F, void>::ret ret;
+ };
+
+ template <typename F>
+ struct is_parametrable
+ {
+ typedef typename internal::introspect::has_param_t<F, void>::ret ret;
+ };
+
+ template <typename F>
+ struct get_lvalue
+ {
+ typedef typename internal::introspect::has_lvalue_t<F, void>::type ret;
+ };
+
+ template <typename F>
+ struct get_param
+ {
+ typedef typename internal::introspect::has_param_t<F, void>::type ret;
+ };
+
+ template <typename F>
+ struct get_storage
+ {
+ typedef typename internal::introspect::has_storage_t<F, void>::type ret;
+ };
+
+ } // end of namespace mln::trait::fun
+
+ } // end of namespace mln::trait
+
+} // end of namespace mln
+
+#endif // ! MLN_TRAIT_FUN_HH
Index: trunk/milena/mln/core/image/thru_morpher.hh
===================================================================
--- trunk/milena/mln/core/image/thru_morpher.hh (revision 3753)
+++ trunk/milena/mln/core/image/thru_morpher.hh (revision 3754)
@@ -32,7 +32,7 @@
# include <mln/core/internal/image_value_morpher.hh>
# include <mln/core/concept/meta_function.hh>
# include <mln/metal/bexpr.hh>
-# include <mln/trait/fun.hh>
+# include <mln/trait/functions.hh>
///
/// \file mln/core/image/thru_morpher.hh
@@ -58,7 +58,7 @@
{
typedef thru_image_write<I, F> write;
typedef thru_image_read<I, F> read;
- typedef mlc_if(mlc_and(typename trait::fun::is_assignable<F>::ret,
+ typedef mlc_if(mlc_and(mln_trait_fun_is_assignable(F),
mlc_and(mlc_not(mlc_is_const(I)),
mlc_equal(mln_trait_image_pw_io(I),
trait::image::pw_io::read_write))),
Index: trunk/milena/mln/core/image/thrubin_morpher.hh
===================================================================
--- trunk/milena/mln/core/image/thrubin_morpher.hh (revision 3753)
+++ trunk/milena/mln/core/image/thrubin_morpher.hh (revision 3754)
@@ -32,7 +32,7 @@
# include <mln/core/internal/image_value_morpher.hh>
# include <mln/core/concept/meta_function.hh>
# include <mln/metal/bexpr.hh>
-# include <mln/trait/fun.hh>
+# include <mln/trait/functions.hh>
/// \file mln/core/image/thrubin_morpher.hh
///
Index: trunk/milena/mln/fun/spe/binary.hh
===================================================================
--- trunk/milena/mln/fun/spe/binary.hh (revision 3753)
+++ trunk/milena/mln/fun/spe/binary.hh (revision 3754)
@@ -30,7 +30,7 @@
# include <mln/core/concept/function.hh>
# include <mln/trait/next/solve.hh>
-# include <mln/trait/fun.hh>
+# include <mln/trait/functions.hh>
/// \todo Implements parameter support
@@ -99,7 +99,7 @@
template <typename U>
void init(const U& value)
{
- storage_ = mln::trait::fun::internal::introspect::has_storage_t<def, void>::compute(value);
+ storage_ = mln::trait::function::internal::introspect::has_storage_t<def, void>::compute(value);
}
protected:
Index: trunk/milena/mln/fun/spe/unary.hh
===================================================================
--- trunk/milena/mln/fun/spe/unary.hh (revision 3753)
+++ trunk/milena/mln/fun/spe/unary.hh (revision 3754)
@@ -30,7 +30,7 @@
# include <mln/core/concept/function.hh>
# include <mln/trait/next/solve.hh>
-# include <mln/trait/fun.hh>
+# include <mln/trait/functions.hh>
namespace mln
{
@@ -239,7 +239,7 @@
template <typename U>
void init(const U& value)
{
- storage_ = mln::trait::fun::internal::introspect::has_storage_t<def, void>::compute(value);
+ storage_ = mln::trait::function::internal::introspect::has_storage_t<def, void>::compute(value);
};
protected:
Index: trunk/milena/mln/fun/point/row.hh
===================================================================
--- trunk/milena/mln/fun/point/row.hh (revision 3753)
+++ trunk/milena/mln/fun/point/row.hh (revision 3754)
@@ -55,10 +55,10 @@
{
template <typename G, typename C>
- struct set_precise_unary_<mln::fun::row, mln::point<G,C> >
+ struct set_precise_unary_<fun::row, point<G,C> >
{
typedef set_precise_unary_ ret;
- typedef mln::point<G,C> argument;
+ typedef point<G,C> argument;
typedef typename argument::coord result;
typedef argument& lvalue;
Index: trunk/milena/mln/fun/point/col.hh
===================================================================
--- trunk/milena/mln/fun/point/col.hh (revision 3753)
+++ trunk/milena/mln/fun/point/col.hh (revision 3754)
@@ -42,7 +42,9 @@
namespace fun
{
- struct col : unary<col> {};
+ struct col : unary<col>
+ {
+ };
} // end of namespace mln::fun
@@ -55,10 +57,10 @@
{
template <typename G, typename C>
- struct set_precise_unary_<mln::fun::col, mln::point<G, C> >
+ struct set_precise_unary_<fun::col, point<G, C> >
{
typedef set_precise_unary_ ret;
- typedef mln::point<G,C> argument;
+ typedef point<G,C> argument;
typedef typename argument::coord result;
typedef argument& lvalue;
Index: trunk/milena/mln/fun/math/cos.hh
===================================================================
--- trunk/milena/mln/fun/math/cos.hh (revision 3753)
+++ trunk/milena/mln/fun/math/cos.hh (revision 3754)
@@ -82,10 +82,10 @@
};
- }
+ } // end of namespace mln::trait::next
- }
+ } // end of namespace mln
-}
+} // end of namespace mln
#endif /* ! MLN_FUN_MATH_COS_HH */
\ No newline at end of file
Index: trunk/milena/mln/fun/math/sup.hh
===================================================================
--- trunk/milena/mln/fun/math/sup.hh (revision 3753)
+++ trunk/milena/mln/fun/math/sup.hh (revision 3754)
@@ -60,11 +60,11 @@
}
};
- }
+ } // end of namespace mln::trait::next
- }
+ } // end of namespace mln::trait
-}
+} // end of namespace mln
#endif /* ! MLN_FUN_MATH_SUP_HH */
Index: trunk/milena/mln/fun/math/inf.hh
===================================================================
--- trunk/milena/mln/fun/math/inf.hh (revision 3753)
+++ trunk/milena/mln/fun/math/inf.hh (revision 3754)
@@ -60,11 +60,11 @@
}
};
- }
+ } // end of namespace mln::trait::next
- }
+ } // end of namespace mln::trait
-}
+} // end of namespace mln
#endif /* ! MLN_FUN_MATH_INF_HH */
Index: trunk/milena/mln/fun/unary.hh
===================================================================
--- trunk/milena/mln/fun/unary.hh (revision 3753)
+++ trunk/milena/mln/fun/unary.hh (revision 3754)
@@ -83,7 +83,7 @@
template <typename U>
void init(const U& value)
{
- storage_ = mln::trait::fun::internal::introspect::has_storage_t<flag, void>::compute(value);
+ storage_ = mln::trait::function::internal::introspect::has_storage_t<flag, void>::compute(value);
};
unary()
Index: trunk/milena/mln/fun/binary.hh
===================================================================
--- trunk/milena/mln/fun/binary.hh (revision 3753)
+++ trunk/milena/mln/fun/binary.hh (revision 3754)
@@ -31,7 +31,7 @@
# include <mln/core/concept/meta_function.hh>
# include <mln/fun/spe/binary.hh>
# include <mln/trait/next/solve.hh>
-# include <mln/trait/fun.hh>
+# include <mln/trait/functions.hh>
namespace mln
{
@@ -60,7 +60,7 @@
template <typename U>
void init(const U& value)
{
- storage_ = mln::trait::fun::internal::introspect::has_storage_t<flag, void>::compute(value);
+ storage_ = mln::trait::function::internal::introspect::has_storage_t<flag, void>::compute(value);
};
binary()
Index: trunk/milena/mln/fun/component/scomp.hh
===================================================================
--- trunk/milena/mln/fun/component/scomp.hh (revision 0)
+++ trunk/milena/mln/fun/component/scomp.hh (revision 3754)
@@ -0,0 +1,90 @@
+// Copyright (C) 2007, 2008, 2009 EPITA Research and Development
+// Laboratory (LRDE)
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_FUN_COMPONENT_SCOMP_HH
+# define MLN_FUN_COMPONENT_SCOMP_HH
+
+/// \file mln/fun/component/scomp.hh
+///
+/// Meta function to retrieve/modify the i'th component, where i is
+/// statically defined.
+
+# include <mln/fun/unary.hh>
+# include <mln/fun/component/comp.hh>
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ template <unsigned ith>
+ struct scomp : unary< scomp<ith> >
+ {
+ };
+
+ } // end of namespace mln::fun
+
+# ifndef MLN_INCLUDE_ONLY
+
+ namespace trait
+ {
+
+ namespace next
+ {
+
+ template <unsigned ith, typename T>
+ struct set_unary_<fun::scomp<ith>, mln::Object, T>
+ {
+ typedef set_unary_ ret;
+ typedef mln_trait_nunary(fun::comp, T) comp_t;
+
+ typedef T argument;
+ typedef mln_result(comp_t) result;
+ typedef mln_lvalue(comp_t) lvalue;
+
+ static result read(const argument& v)
+ {
+ return comp_t::read(ith, v);
+ }
+
+ static void write(lvalue l, const result& r)
+ {
+ comp_t::write(ith, l, r);
+ }
+ };
+
+ } // end of namespace mln::trait::next
+
+ } // end of namespace mln::trait
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+#endif // MLN_FUN_COMPONENT_COMP_HH
Index: trunk/milena/mln/fun/component/ithcomp.hh
===================================================================
--- trunk/milena/mln/fun/component/ithcomp.hh (revision 0)
+++ trunk/milena/mln/fun/component/ithcomp.hh (revision 3754)
@@ -0,0 +1,83 @@
+// Copyright (C) 2007, 2008, 2009 EPITA Research and Development
+// Laboratory (LRDE)
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_FUN_COMPONENT_ITHCOMP_HH
+# define MLN_FUN_COMPONENT_ITHCOMP_HH
+
+/// \file mln/fun/component/ithcomp.hh
+///
+/// Meta function to retrieve/modify the i'th component with a binary
+/// function f(i, vec).
+
+# include <mln/fun/binary.hh>
+# include <mln/fun/component/comp.hh>
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ struct ithcomp : binary<ithcomp>
+ {
+ };
+
+ } // end of namespace mln::fun
+
+# ifndef MLN_INCLUDE_ONLY
+
+ namespace trait
+ {
+
+ namespace next
+ {
+
+ template <typename I, typename T>
+ struct set_binary_<mln::fun::ithcomp, mln::value::Integer, I, mln::Object, T>
+ {
+ typedef set_binary_ ret;
+ typedef I argument1;
+ typedef T argument2;
+ typedef mln_trait_nunary(mln::fun::comp, T) comp_t;
+ typedef mln_result(comp_t) result;
+
+ static result read(const argument1& i, const argument2& v)
+ {
+ return comp_t::read(i, v);
+ }
+ };
+
+ } // end of namespace mln::trait::next
+
+ } // end of namespace mln::trait
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+#endif // MLN_FUN_COMPONENT_ITHCOMP_HH
Index: trunk/milena/mln/fun/component/comp_count.hh
===================================================================
--- trunk/milena/mln/fun/component/comp_count.hh (revision 0)
+++ trunk/milena/mln/fun/component/comp_count.hh (revision 3754)
@@ -0,0 +1,99 @@
+// Copyright (C) 2007, 2008, 2009 EPITA Research and Development
+// Laboratory (LRDE)
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_FUN_COMPONENT_COMP_COUNT_HH
+# define MLN_FUN_COMPONENT_COMP_COUNT_HH
+
+/// \file mln/fun/component/comp_count.hh
+///
+/// Meta function to retrieve the number of components a vector has.
+
+# include <mln/fun/unary.hh>
+# include <mln/value/rgb.hh>
+# include <mln/value/int_u.hh>
+# include <mln/algebra/vec.hh>
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ struct comp_count : unary<comp_count>
+ {
+ };
+
+ } // end of namespace mln::fun
+
+# ifndef MLN_INCLUDE_ONLY
+
+ namespace trait
+ {
+
+ namespace next
+ {
+
+ template <unsigned n>
+ struct set_precise_unary_<mln::fun::comp_count, mln::value::rgb<n> >
+ {
+ typedef set_precise_unary_ ret;
+
+ typedef mln::value::rgb<n> argument;
+ typedef unsigned result;
+ typedef argument& lvalue;
+
+ static result read(const argument&)
+ {
+ return 3;
+ }
+ };
+
+ template <unsigned n, typename T>
+ struct set_precise_unary_<mln::fun::comp_count, mln::algebra::vec<n,T> >
+ {
+ typedef set_precise_unary_ ret;
+
+ typedef mln::algebra::vec<n,T> argument;
+ typedef unsigned result;
+ typedef argument& lvalue;
+
+ static result read(const argument&)
+ {
+ return n;
+ }
+ };
+
+ } // end of namespace mln::trait::next
+
+ } // end of namespace mln::trait
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+#endif // MLN_FUN_COMPONENT_COMP_COUNT_HH
Index: trunk/milena/mln/fun/component/comp.hh
===================================================================
--- trunk/milena/mln/fun/component/comp.hh (revision 3753)
+++ trunk/milena/mln/fun/component/comp.hh (revision 3754)
@@ -33,10 +33,7 @@
///
/// Meta function to retrieve/modify a component.
-# include <mln/fun/unary.hh>
-# include <mln/fun/binary.hh>
-# include <mln/fun/param.hh>
-# include <mln/trait/next/solve.hh>
+# include <mln/fun/unary_param.hh>
# include <mln/value/rgb.hh>
# include <mln/value/int_u.hh>
# include <mln/algebra/vec.hh>
@@ -47,24 +44,12 @@
namespace fun
{
- struct comp : binary<comp> {};
-
- struct pcomp;
-
- template <>
- struct parameter<pcomp>
- {
- typedef unsigned param;
- };
-
- struct pcomp : unary<pcomp>
+ struct comp : unary_param<comp,unsigned>
{
- pcomp() : unary<pcomp>(0) {};
- pcomp(unsigned i = 0) : unary<pcomp>(i) {};
+ comp() : unary_param<comp,unsigned>(0) {};
+ comp(unsigned i) : unary_param<comp,unsigned>(i) {};
};
- struct comp_count : unary<comp_count> {};
-
} // end of namespace mln::fun
# ifndef MLN_INCLUDE_ONLY
@@ -75,57 +60,10 @@
namespace next
{
- template <typename E, typename T>
- struct set_binary_<mln::fun::comp, mln::value::Integer, E, mln::Object, T>
- {
- typedef set_binary_ ret;
- typedef E argument1;
- typedef T argument2;
- typedef mln_trait_nunary(mln::fun::pcomp, T) pcomp_t;
- typedef mln_result(pcomp_t) result;
-
- static result read(const argument1& i, const argument2& v)
- {
- pcomp_t c;
- return c.read(i, v);
- }
- };
-
- template <unsigned n>
- struct set_precise_unary_<mln::fun::comp_count, mln::value::rgb<n> >
- {
- typedef set_precise_unary_ ret;
-
- typedef mln::value::rgb<n> argument;
- typedef unsigned result;
- typedef argument& lvalue;
-
- static result read(const argument&)
- {
- return n;
- }
- };
-
- template <unsigned n, typename T>
- struct set_precise_unary_<mln::fun::comp_count, mln::algebra::vec<n,T> >
- {
- typedef set_precise_unary_ ret;
-
- typedef mln::algebra::vec<n,T> argument;
- typedef unsigned result;
- typedef argument& lvalue;
-
- static result read(const argument&)
- {
- return n;
- }
- };
-
template <unsigned n>
- struct set_precise_unary_<mln::fun::pcomp, mln::value::rgb<n> >
+ struct set_precise_unary_<mln::fun::comp, mln::value::rgb<n> >
{
typedef set_precise_unary_ ret;
-// typedef mln::fun::pcomp flag;
typedef mln::value::rgb<n> argument;
typedef mln::value::int_u<n> result;
@@ -143,10 +81,9 @@
};
template <unsigned n, typename T>
- struct set_precise_unary_<mln::fun::pcomp, mln::algebra::vec<n,T> >
+ struct set_precise_unary_<mln::fun::comp, mln::algebra::vec<n,T> >
{
typedef set_precise_unary_ ret;
- typedef mln::fun::pcomp flag;
typedef mln::algebra::vec<n,T> argument;
typedef T result;
Index: trunk/milena/mln/fun/accu_result.hh
===================================================================
--- trunk/milena/mln/fun/accu_result.hh (revision 3753)
+++ trunk/milena/mln/fun/accu_result.hh (revision 3754)
@@ -30,8 +30,6 @@
# include <mln/fun/unary.hh>
# include <mln/core/concept/accumulator.hh>
-# include <mln/math/acos.hh>
-# include <mln/math/cos.hh>
namespace mln
{
@@ -39,8 +37,12 @@
// accu_result: return result of given accumulator.
namespace fun
{
- struct accu_result : unary<accu_result> {};
- }
+
+ struct accu_result : unary<accu_result>
+ {
+ };
+
+ } // end of namespace mln::fun
namespace trait
{
@@ -48,7 +50,7 @@
namespace next
{
template <typename E>
- struct set_unary_<mln::fun::accu_result, mln::Accumulator, E>
+ struct set_unary_<fun::accu_result, Accumulator, E>
{
typedef set_unary_ ret;
typedef typename E::result result;
@@ -60,10 +62,10 @@
}
};
- }
+ } // end of namespace mln::trait::next
- }
+ } // end of namespace mln::trait
-}
+} // end of namespace mln
#endif /* ! MLN_FUN_ACCU_RESULT_HH */
\ No newline at end of file
Index: trunk/milena/sandbox/fred/tests/fun.cc
===================================================================
--- trunk/milena/sandbox/fred/tests/fun.cc (revision 3753)
+++ trunk/milena/sandbox/fred/tests/fun.cc (revision 3754)
@@ -4,19 +4,23 @@
#include <mln/fun/math/norm.hh>
#include <mln/fun/component/red.hh>
#include <mln/fun/component/comp.hh>
+#include <mln/fun/component/ithcomp.hh>
+#include <mln/fun/component/scomp.hh>
#include <mln/value/rgb8.hh>
#include <iostream>
#define dbg_print(val) std::cout << #val << "\n\t -> \t" << (val) << std::endl
+
int main()
{
mln::fun::abs abs;
mln::fun::cos cos;
// mln::fun::inc inc;
mln::fun::red red;
- mln::fun::comp comp;
- mln::fun::pcomp comp1(1);
+ mln::fun::ithcomp ithcomp;
+ mln::fun::comp comp(1);
+ mln::fun::scomp<1> comp1;
mln::fun::norm::l1 l1;
mln::fun::norm::l2 l2;
@@ -86,10 +90,11 @@
dbg_print(red(rgb) = 0);
mln_invariant(red(rgb) == 0);
dbg_print(rgb);
- dbg_print(comp(0, rgb));
- dbg_print(comp(1, rgb));
- dbg_print(comp(2, rgb));
- comp1(rgb) = 2;
+ dbg_print(ithcomp(0, rgb));
+ dbg_print(ithcomp(1, rgb));
+ dbg_print(ithcomp(2, rgb));
+ dbg_print(comp1(rgb) = 2);
+ dbg_print(comp(rgb));
}
// NORM
1
0
* headers.mk: update distributed file list.
* mln/core/clock_neighb.hh: fix ambiguity between window type and
window typedef.
* mln/trait/next/solve.hh,
* mln/fun/i2v/all_to.hh: update doc.
* mln/fun/point/sli.hh: fix invalid trait specialization.
* mln/fun/v2v/hsi_to_rgb.hh: move parts of rgb_to_hsi.hh here.
* mln/fun/v2v/hsl_to_rgb.hh: move parts of rgb_to_hsl.hh here.
* mln/fun/v2w2v/all.hh,
* mln/fun/v2w_w2v/all.hh,
* mln/fun/vv2b/all.hh: update includes.
* mln/trait/next/solve_proxy.hh: add missing forward declaration.
* tests/fun/v2v/wrap.cc: change l2l to v2v.
* tests/unit_test/unit-tests.mk: update test list.
* doc/outputs/site_set_create.txt: add reference file for doc
generation.
---
milena/ChangeLog | 31 +++++
milena/doc/outputs/site_set_create.txt | 6 +
milena/headers.mk | 9 ++
milena/mln/core/clock_neighb.hh | 2 +-
milena/mln/fun/i2v/all_to.hh | 10 +-
milena/mln/fun/point/sli.hh | 2 +-
milena/mln/fun/v2v/hsi_to_rgb.hh | 124 +++++++++++++++++
milena/mln/fun/v2v/hsl_to_rgb.hh | 139 ++++++++++++++++++++
.../fun/v2v/wrap.cc => mln/fun/v2w2v/all.hh} | 56 ++++----
.../fun/v2v/wrap.cc => mln/fun/v2w_w2v/all.hh} | 50 ++++----
.../{tests/fun/v2v/wrap.cc => mln/fun/vv2b/all.hh} | 55 ++++----
milena/mln/trait/next/solve.hh | 15 +--
milena/mln/trait/next/solve_proxy.hh | 9 +-
milena/tests/fun/v2v/wrap.cc | 8 +-
milena/tests/unit_test/unit-tests.mk | 18 +++
15 files changed, 432 insertions(+), 102 deletions(-)
create mode 100644 milena/doc/outputs/site_set_create.txt
create mode 100644 milena/mln/fun/v2v/hsi_to_rgb.hh
create mode 100644 milena/mln/fun/v2v/hsl_to_rgb.hh
copy milena/{tests/fun/v2v/wrap.cc => mln/fun/v2w2v/all.hh} (67%)
copy milena/{tests/fun/v2v/wrap.cc => mln/fun/v2w_w2v/all.hh} (72%)
copy milena/{tests/fun/v2v/wrap.cc => mln/fun/vv2b/all.hh} (67%)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 85607ae..1757f3b 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,36 @@
2009-05-05 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
+ Small fixes.
+
+ * headers.mk: update distributed file list.
+
+ * mln/core/clock_neighb.hh: fix ambiguity between window type and
+ window typedef.
+
+ * mln/trait/next/solve.hh,
+ * mln/fun/i2v/all_to.hh: update doc.
+
+ * mln/fun/point/sli.hh: fix invalid trait specialization.
+
+ * mln/fun/v2v/hsi_to_rgb.hh: move parts of rgb_to_hsi.hh here.
+
+ * mln/fun/v2v/hsl_to_rgb.hh: move parts of rgb_to_hsl.hh here.
+
+ * mln/fun/v2w2v/all.hh,
+ * mln/fun/v2w_w2v/all.hh,
+ * mln/fun/vv2b/all.hh: update includes.
+
+ * mln/trait/next/solve_proxy.hh: add missing forward declaration.
+
+ * tests/fun/v2v/wrap.cc: change l2l to v2v.
+
+ * tests/unit_test/unit-tests.mk: update test list.
+
+ * doc/outputs/site_set_create.txt: add reference file for doc
+ generation.
+
+2009-05-05 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
+
Improve graph support.
* headers.mk: update distributed file list.
diff --git a/milena/doc/outputs/site_set_create.txt b/milena/doc/outputs/site_set_create.txt
new file mode 100644
index 0000000..1cfac41
--- /dev/null
+++ b/milena/doc/outputs/site_set_create.txt
@@ -0,0 +1,6 @@
+\{
+(0,0), (0,1), (0,2), (0,3), (1,0), (1,1), (1,2), (1,3), (2,0), (2,1), (2,2), (2,3), (3,0), (3,1), (3,2), (3,3),
+\}
+\{
+(-2,-2), (-2,-1), (-2,0), (-2,1), (-2,2), (-1,-2), (-1,-1), (-1,0), (-1,1), (-1,2), (0,-2), (0,-1), (0,0), (0,1), (0,2), (1,-2), (1,-1), (1,0), (1,1), (1,2), (2,-2), (2,-1), (2,0), (2,1), (2,2),
+\}
diff --git a/milena/headers.mk b/milena/headers.mk
index 6631c1d..7d75826 100644
--- a/milena/headers.mk
+++ b/milena/headers.mk
@@ -51,6 +51,7 @@ mln/literal/origin.hh \
mln/literal/grays.hh \
mln/literal/all.hh \
mln/literal/colors.hh \
+mln/literal/identity.hh \
mln/literal/black.hh \
mln/literal/one.hh \
mln/literal/min.hh \
@@ -240,6 +241,7 @@ mln/fun/spe/binary.hh \
mln/fun/spe/unary.hh \
mln/fun/unary_param.hh \
mln/fun/v2w_w2v/norm.hh \
+mln/fun/v2w_w2v/all.hh \
mln/fun/p2v/ternary.hh \
mln/fun/p2v/iota.hh \
mln/fun/p2v/elifs.hh \
@@ -275,10 +277,14 @@ mln/fun/v2v/wrap.hh \
mln/fun/v2v/enc.hh \
mln/fun/v2v/projection.hh \
mln/fun/v2v/convert.hh \
+mln/fun/v2v/hsl_to_rgb.hh \
+mln/fun/v2v/hsi_to_rgb.hh \
mln/fun/v2v/essential.hh \
+mln/fun/v2w2v/all.hh \
mln/fun/v2w2v/cos.hh \
mln/fun/unary.hh \
mln/fun/vv2b/implies.hh \
+mln/fun/vv2b/all.hh \
mln/fun/vv2b/le.hh \
mln/fun/vv2b/gt.hh \
mln/fun/vv2b/ge.hh \
@@ -423,6 +429,7 @@ mln/accu/site_set/all.hh \
mln/accu/site_set/essential.hh \
mln/accu/stat/variance.hh \
mln/accu/stat/deviation.hh \
+mln/accu/stat/var.hh \
mln/accu/max.hh \
mln/accu/lor.hh \
mln/accu/rank.hh \
@@ -471,6 +478,7 @@ mln/accu/image/all.hh \
mln/accu/image/set_value.hh \
mln/accu/image/take.hh \
mln/accu/image/take_as_init.hh \
+mln/accu/image/take_n_times.hh \
mln/accu/image/essential.hh \
mln/accu/center.hh \
mln/accu/line.hh \
@@ -1233,6 +1241,7 @@ mln/border/duplicate.hh \
mln/border/find.hh \
mln/border/thickness.hh \
mln/border/all.hh \
+mln/border/resize_equal.hh \
mln/border/mirror.hh \
mln/border/get.hh \
mln/border/equalize.hh \
diff --git a/milena/mln/core/clock_neighb.hh b/milena/mln/core/clock_neighb.hh
index 1474978..caa238c 100644
--- a/milena/mln/core/clock_neighb.hh
+++ b/milena/mln/core/clock_neighb.hh
@@ -62,7 +62,7 @@ namespace mln
typedef mln_psite(D) site;
/// Window associated type.
- typedef window<dpsite> window;
+ typedef mln::window<dpsite> window;
/// Site_Iterator type to browse the psites of a generic
/// neighborhood w.r.t. the ordering of delta-psites.
diff --git a/milena/mln/fun/i2v/all_to.hh b/milena/mln/fun/i2v/all_to.hh
index 84f9859..c554e8f 100644
--- a/milena/mln/fun/i2v/all_to.hh
+++ b/milena/mln/fun/i2v/all_to.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2009 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -28,10 +29,9 @@
#ifndef MLN_FUN_I2V_ALL_TO_HH
# define MLN_FUN_I2V_ALL_TO_HH
-/*! \file mln/fun/i2v/all_to.hh
- *
- * \brief FIXME.
- */
+/// \file mln/fun/i2v/all_to.hh
+///
+/// FIXME.
# include <mln/core/concept/function.hh>
diff --git a/milena/mln/fun/point/sli.hh b/milena/mln/fun/point/sli.hh
index 2a22727..f899e21 100644
--- a/milena/mln/fun/point/sli.hh
+++ b/milena/mln/fun/point/sli.hh
@@ -55,7 +55,7 @@ namespace mln
{
template <typename G, typename C>
- struct set_precise_unary_<mln::fun::col, mln::point<G, C> >
+ struct set_precise_unary_<mln::fun::sli, mln::point<G, C> >
{
typedef set_precise_unary_ ret;
typedef mln::point<G,C> argument;
diff --git a/milena/mln/fun/v2v/hsi_to_rgb.hh b/milena/mln/fun/v2v/hsi_to_rgb.hh
new file mode 100644
index 0000000..9e5358c
--- /dev/null
+++ b/milena/mln/fun/v2v/hsi_to_rgb.hh
@@ -0,0 +1,124 @@
+// Copyright (C) 2008, 2009 EPITA Research and Development Laboratory
+// (LRDE)
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License.
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_FUN_V2V_HSI_TO_RGB_HH
+# define MLN_FUN_V2V_HSI_TO_RGB_HH
+
+/// \file mln/fun/v2v/hsi_to_rgb.hh
+///
+/// Convert a rgb value to hsi.
+
+#include <cmath>
+
+#include <mln/value/rgb8.hh>
+#include <mln/math/round.hh>
+
+#include <mln/value/hsi.hh>
+
+
+namespace mln
+{
+
+
+ namespace fun
+ {
+
+ namespace v2v
+ {
+
+ /// \brief Convert a hsi value to rgb.
+ ///
+ /// \ingroup modfunv2v
+ //
+ template <typename T_rgb>
+ struct f_hsi_to_rgb_ : public Function_v2v< f_hsi_to_rgb_<T_rgb> >
+ {
+ typedef T_rgb result;
+
+ template <typename T_hsi>
+ T_rgb operator()(const T_hsi& hsi) const;
+
+ };
+
+ typedef f_hsi_to_rgb_<value::rgb8> f_hsi_to_rgb_3x8_t;
+
+ extern f_hsi_to_rgb_3x8_t f_hsi_to_rgb_3x8;
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ /// Global variable.
+ /// \{
+ f_hsi_to_rgb_3x8_t f_hsi_to_rgb_3x8;
+ /// \}
+
+ template <typename T_rgb>
+ template <typename T_hsi>
+ inline
+ T_rgb
+ f_hsi_to_rgb_<T_rgb>::operator()(const T_hsi& hsi) const
+ {
+ typedef typename T_rgb::red_t red_t;
+ typedef typename T_rgb::green_t green_t;
+ typedef typename T_rgb::blue_t blue_t;
+
+ static math::round<red_t> to_r;
+ static math::round<green_t> to_g;
+ static math::round<blue_t> to_b;
+
+ static const float
+ sqrt3_3 = std::sqrt(3) / 3,
+ inv_sqrt6 = 1 / std::sqrt(6),
+ inv_sqrt2 = 1 / std::sqrt(2);
+
+ float
+ h = hsi.hue() / 180.0 * 3.1415,
+ alpha = hsi.sat() * std::cos(h),
+ beta = hsi.sat() * std::sin(h);
+
+
+ red_t r = to_r(sqrt3_3 * hsi.inty() + 2 * inv_sqrt6 * beta);
+ green_t g =
+ to_g(sqrt3_3 * hsi.inty() + inv_sqrt2 * alpha - inv_sqrt6 * beta);
+ blue_t b =
+ to_b(sqrt3_3 * hsi.inty() - inv_sqrt2 * alpha - inv_sqrt6 * beta);
+
+ T_rgb rgb(r, g, b);
+
+ return rgb;
+ }
+
+# endif // !MLN_INCLUDE_ONLY
+
+ } // end of namespace fun::v2v
+
+ } // end of namespace fun
+
+} // end of namespace mln
+
+#endif // ! MLN_FUN_V2V_HSI_TO_RGB_HH
diff --git a/milena/mln/fun/v2v/hsl_to_rgb.hh b/milena/mln/fun/v2v/hsl_to_rgb.hh
new file mode 100644
index 0000000..a2e6958
--- /dev/null
+++ b/milena/mln/fun/v2v/hsl_to_rgb.hh
@@ -0,0 +1,139 @@
+// Copyright (C) 2008, 2009 EPITA Research and Development Laboratory
+// (LRDE)
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License.
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_FUN_V2V_HSL_TO_RGB_HH
+# define MLN_FUN_V2V_HSL_TO_RGB_HH
+
+/// \file mln/fun/v2v/hsl_to_rgb.hh
+///
+/// Convert hsl values to rgb.
+
+
+# include <cmath>
+
+# include <mln/math/round.hh>
+# include <mln/math/max.hh>
+# include <mln/math/min.hh>
+
+# include <mln/trait/value_.hh>
+
+# include <mln/value/rgb.hh>
+
+
+
+namespace mln
+{
+
+ // Forward declarations
+ namespace value
+ {
+ template <typename H, typename S, typename L> class hsl_;
+ typedef hsl_<float, float, float> hsl_f;
+ }
+
+ namespace fun
+ {
+
+ namespace v2v
+ {
+
+ /// \brief Convert hsl values to rgb.
+ ///
+ /// \ingroup modfunv2v
+ //
+ template <typename T_rgb>
+ struct f_hsl_to_rgb_ : public Function_v2v< f_hsl_to_rgb_<T_rgb> >
+ {
+ typedef T_rgb result;
+
+ template <typename T_hsl>
+ T_rgb operator()(const T_hsl& hsl) const;
+
+ };
+
+ typedef f_hsl_to_rgb_< value::rgb<8> > f_hsl_to_rgb_3x8_t;
+ typedef f_hsl_to_rgb_< value::rgb<16> > f_hsl_to_rgb_3x16_t;
+
+ extern f_hsl_to_rgb_3x8_t f_hsl_to_rgb_3x8;
+ extern f_hsl_to_rgb_3x16_t f_hsl_to_rgb_3x16;
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ /// Global variables.
+ /// \{
+ f_hsl_to_rgb_3x8_t f_hsl_to_rgb_3x8;
+ f_hsl_to_rgb_3x16_t f_hsl_to_rgb_3x16;
+ /// \}
+
+
+ template <typename T_rgb>
+ template <typename T_hsl>
+ inline
+ T_rgb
+ f_hsl_to_rgb_<T_rgb>::operator()(const T_hsl& hsl) const
+ {
+ typedef typename T_rgb::red_t red_t;
+ typedef typename T_rgb::green_t green_t;
+ typedef typename T_rgb::blue_t blue_t;
+
+ static math::round<red_t> to_r;
+ static math::round<green_t> to_g;
+ static math::round<blue_t> to_b;
+
+ static const float
+ sqrt3_3 = std::sqrt(3) / 3,
+ inv_sqrt6 = 1 / std::sqrt(6),
+ inv_sqrt2 = 1 / std::sqrt(2);
+
+ float
+ h = hsl.hue() / 180.0 * 3.1415,
+ alpha = hsl.sat() * std::cos(h),
+ beta = hsl.sat() * std::sin(h);
+
+
+ red_t r = to_r(sqrt3_3 * hsl.lum() + 2 * inv_sqrt6 * beta);
+ green_t g =
+ to_g(sqrt3_3 * hsl.lum() + inv_sqrt2 * alpha - inv_sqrt6 * beta);
+ blue_t b =
+ to_b(sqrt3_3 * hsl.lum() - inv_sqrt2 * alpha - inv_sqrt6 * beta);
+
+ T_rgb rgb(r, g, b);
+
+ return rgb;
+ }
+
+# endif // !MLN_INCLUDE_ONLY
+
+ } // end of namespace fun::v2v
+
+ } // end of namespace fun
+
+} // end of namespace mln
+
+#endif // ! MLN_FUN_V2V_HSL_TO_RGB_HH
diff --git a/milena/tests/fun/v2v/wrap.cc b/milena/mln/fun/v2w2v/all.hh
similarity index 67%
copy from milena/tests/fun/v2v/wrap.cc
copy to milena/mln/fun/v2w2v/all.hh
index 78d339a..234b963 100644
--- a/milena/tests/fun/v2v/wrap.cc
+++ b/milena/mln/fun/v2w2v/all.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -25,34 +26,33 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-/// \file tests/fun/l2l/wrap.cc
-///
-/// Test on mln::fun::l2l::wrap.
+#ifndef MLN_FUN_V2W2V_ALL_HH
+# define MLN_FUN_V2W2V_ALL_HH
-#include <mln/fun/l2l/wrap.hh>
+namespace mln
+{
-#include <mln/value/int_u8.hh>
-#include <mln/value/label_16.hh>
+ namespace fun
+ {
+ /*! \defgroup modfunv2w2v v2w2v functions
+ *
+ * \brief All bijective functions.
+ *
+ * \ingroup modfun
+ */
-int main()
-{
- using namespace mln;
-
- fun::l2l::wrap<value::int_u8> f;
-
- value::label_16
- l0 = 0,
- l1 = 1,
- l255 = 255,
- l256 = 256,
- l510 = 510,
- l511 = 511;
-
- mln_assertion(f(l0) == 0u);
- mln_assertion(f(l1) == 1u);
- mln_assertion(f(l255) == 255u);
- mln_assertion(f(l256) == 1u);
- mln_assertion(f(l510) == 255u);
- mln_assertion(f(l511) == 1u);
-}
+ /// Namespace of bijective functions.
+ namespace v2w2v
+ {
+
+ } // end of namespace mln::fun::v2w2v
+
+ } // end of namespace mln::fun
+
+} // end of namespace mln
+
+
+# include <mln/fun/v2w2v/cos.hh>
+
+#endif // ! MLN_FUN_V2W2V_ALL_HH
diff --git a/milena/tests/fun/v2v/wrap.cc b/milena/mln/fun/v2w_w2v/all.hh
similarity index 72%
copy from milena/tests/fun/v2v/wrap.cc
copy to milena/mln/fun/v2w_w2v/all.hh
index 78d339a..516368e 100644
--- a/milena/tests/fun/v2v/wrap.cc
+++ b/milena/mln/fun/v2w_w2v/all.hh
@@ -25,34 +25,34 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-/// \file tests/fun/l2l/wrap.cc
+#ifndef MLN_FUN_V2W_W2V_ALL_HH
+# define MLN_FUN_V2W_W2V_ALL_HH
+
+/// \file mln/fun/v2w_w2v/all.hh
///
-/// Test on mln::fun::l2l::wrap.
+/// File that includes all bijective functions.
+
+namespace mln
+{
-#include <mln/fun/l2l/wrap.hh>
+ namespace fun
+ {
-#include <mln/value/int_u8.hh>
-#include <mln/value/label_16.hh>
+ /*! \defgroup modfunv2w_w2v v2w_w2v functions
+ *
+ * \brief All bijective function.
+ *
+ * \ingroup modfun
+ */
+ /// Namespace of functions from value to value.
+ namespace v2w_w2v {}
-int main()
-{
- using namespace mln;
-
- fun::l2l::wrap<value::int_u8> f;
-
- value::label_16
- l0 = 0,
- l1 = 1,
- l255 = 255,
- l256 = 256,
- l510 = 510,
- l511 = 511;
-
- mln_assertion(f(l0) == 0u);
- mln_assertion(f(l1) == 1u);
- mln_assertion(f(l255) == 255u);
- mln_assertion(f(l256) == 1u);
- mln_assertion(f(l510) == 255u);
- mln_assertion(f(l511) == 1u);
+ }
}
+
+
+# include <mln/fun/v2w_w2v/norm.hh>
+
+#endif // ! MLN_FUN_V2W_W2V_ALL_HH
+
diff --git a/milena/tests/fun/v2v/wrap.cc b/milena/mln/fun/vv2b/all.hh
similarity index 67%
copy from milena/tests/fun/v2v/wrap.cc
copy to milena/mln/fun/vv2b/all.hh
index 78d339a..8e8257c 100644
--- a/milena/tests/fun/v2v/wrap.cc
+++ b/milena/mln/fun/vv2b/all.hh
@@ -25,34 +25,39 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-/// \file tests/fun/l2l/wrap.cc
+#ifndef MLN_FUN_VV2B_ALL_HH
+# define MLN_FUN_VV2B_ALL_HH
+
+/// \file mln/fun/v2w_w2v/all.hh
///
-/// Test on mln::fun::l2l::wrap.
+/// File that includes all functions mapping two values to a logical value.
+
+namespace mln
+{
-#include <mln/fun/l2l/wrap.hh>
+ namespace fun
+ {
-#include <mln/value/int_u8.hh>
-#include <mln/value/label_16.hh>
+ /*! \defgroup modfunvv2b vv2b functions
+ *
+ * \brief All functions mapping two values to a logical value.
+ *
+ * \ingroup modfun
+ */
+ /// Namespace of functions from value to value.
+ namespace vv2b {}
-int main()
-{
- using namespace mln;
-
- fun::l2l::wrap<value::int_u8> f;
-
- value::label_16
- l0 = 0,
- l1 = 1,
- l255 = 255,
- l256 = 256,
- l510 = 510,
- l511 = 511;
-
- mln_assertion(f(l0) == 0u);
- mln_assertion(f(l1) == 1u);
- mln_assertion(f(l255) == 255u);
- mln_assertion(f(l256) == 1u);
- mln_assertion(f(l510) == 255u);
- mln_assertion(f(l511) == 1u);
+ }
}
+
+
+# include <mln/fun/vv2b/eq.hh>
+# include <mln/fun/vv2b/ge.hh>
+# include <mln/fun/vv2b/gt.hh>
+# include <mln/fun/vv2b/implies.hh>
+# include <mln/fun/vv2b/le.hh>
+# include <mln/fun/vv2b/lt.hh>
+
+#endif // ! MLN_FUN_VV2B_ALL_HH
+
diff --git a/milena/mln/trait/next/solve.hh b/milena/mln/trait/next/solve.hh
index 3184ddd..e19c758 100644
--- a/milena/mln/trait/next/solve.hh
+++ b/milena/mln/trait/next/solve.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2006, 2008 EPITA Research and Development Laboratory
+// Copyright (C) 2006, 2008, 2009 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -28,14 +29,10 @@
#ifndef MLN_TRAIT_NEXT_SOLVE_HH
# define MLN_TRAIT_NEXT_SOLVE_HH
-/*!
- * \file mln/trait/next/solve.hh
- *
- * \brief FIXME
- *
- *
- */
-
+/// \file mln/trait/next/solve.hh
+///
+/// FIXME
+
# include <mln/core/category.hh>
# include <mln/metal/equal.hh>
# include <mln/metal/if.hh>
diff --git a/milena/mln/trait/next/solve_proxy.hh b/milena/mln/trait/next/solve_proxy.hh
index 0d123a5..1e1e7b6 100644
--- a/milena/mln/trait/next/solve_proxy.hh
+++ b/milena/mln/trait/next/solve_proxy.hh
@@ -28,10 +28,10 @@
#ifndef MLN_TRAIT_NEXT_SOLVE_PROXY_HH
# define MLN_TRAIT_NEXT_SOLVE_PROXY_HH
-/*! \file mln/trait/next/solve_proxy.hh
- *
- * \brief Proxy support for "next" trait solver.
- */
+/// \file mln/trait/next/solve_proxy.hh
+///
+/// Proxy support for "next" trait solver.
+
# include <mln/core/concept/object.hh>
# include <mln/core/concept/proxy.hh>
@@ -50,6 +50,7 @@ namespace mln
// Needed by mln_trait_nbinary.
template < typename Name, typename L_, typename R_ >
struct solve_binary;
+ template < typename Name, typename T_ > struct solve_unary;
diff --git a/milena/tests/fun/v2v/wrap.cc b/milena/tests/fun/v2v/wrap.cc
index 78d339a..54c7c14 100644
--- a/milena/tests/fun/v2v/wrap.cc
+++ b/milena/tests/fun/v2v/wrap.cc
@@ -25,11 +25,11 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-/// \file tests/fun/l2l/wrap.cc
+/// \file tests/fun/v2v/wrap.cc
///
-/// Test on mln::fun::l2l::wrap.
+/// Test on mln::fun::v2v::wrap.
-#include <mln/fun/l2l/wrap.hh>
+#include <mln/fun/v2v/wrap.hh>
#include <mln/value/int_u8.hh>
#include <mln/value/label_16.hh>
@@ -39,7 +39,7 @@ int main()
{
using namespace mln;
- fun::l2l::wrap<value::int_u8> f;
+ fun::v2v::wrap<value::int_u8> f;
value::label_16
l0 = 0,
diff --git a/milena/tests/unit_test/unit-tests.mk b/milena/tests/unit_test/unit-tests.mk
index b276d8b..6869395 100644
--- a/milena/tests/unit_test/unit-tests.mk
+++ b/milena/tests/unit_test/unit-tests.mk
@@ -49,6 +49,7 @@ mln_literal_origin \
mln_literal_grays \
mln_literal_all \
mln_literal_colors \
+mln_literal_identity \
mln_literal_black \
mln_literal_one \
mln_literal_min \
@@ -235,6 +236,7 @@ mln_fun_spe_binary \
mln_fun_spe_unary \
mln_fun_unary_param \
mln_fun_v2w_w2v_norm \
+mln_fun_v2w_w2v_all \
mln_fun_p2v_ternary \
mln_fun_p2v_iota \
mln_fun_p2v_elifs \
@@ -270,10 +272,14 @@ mln_fun_v2v_wrap \
mln_fun_v2v_enc \
mln_fun_v2v_projection \
mln_fun_v2v_convert \
+mln_fun_v2v_hsl_to_rgb \
+mln_fun_v2v_hsi_to_rgb \
mln_fun_v2v_essential \
+mln_fun_v2w2v_all \
mln_fun_v2w2v_cos \
mln_fun_unary \
mln_fun_vv2b_implies \
+mln_fun_vv2b_all \
mln_fun_vv2b_le \
mln_fun_vv2b_gt \
mln_fun_vv2b_ge \
@@ -418,6 +424,7 @@ mln_accu_site_set_all \
mln_accu_site_set_essential \
mln_accu_stat_variance \
mln_accu_stat_deviation \
+mln_accu_stat_var \
mln_accu_max \
mln_accu_lor \
mln_accu_rank \
@@ -466,6 +473,7 @@ mln_accu_image_all \
mln_accu_image_set_value \
mln_accu_image_take \
mln_accu_image_take_as_init \
+mln_accu_image_take_n_times \
mln_accu_image_essential \
mln_accu_center \
mln_accu_line \
@@ -1199,6 +1207,7 @@ mln_border_duplicate \
mln_border_find \
mln_border_thickness \
mln_border_all \
+mln_border_resize_equal \
mln_border_mirror \
mln_border_get \
mln_border_equalize \
@@ -1258,6 +1267,7 @@ mln_literal_origin_SOURCES = mln_literal_origin.cc
mln_literal_grays_SOURCES = mln_literal_grays.cc
mln_literal_all_SOURCES = mln_literal_all.cc
mln_literal_colors_SOURCES = mln_literal_colors.cc
+mln_literal_identity_SOURCES = mln_literal_identity.cc
mln_literal_black_SOURCES = mln_literal_black.cc
mln_literal_one_SOURCES = mln_literal_one.cc
mln_literal_min_SOURCES = mln_literal_min.cc
@@ -1444,6 +1454,7 @@ mln_fun_spe_binary_SOURCES = mln_fun_spe_binary.cc
mln_fun_spe_unary_SOURCES = mln_fun_spe_unary.cc
mln_fun_unary_param_SOURCES = mln_fun_unary_param.cc
mln_fun_v2w_w2v_norm_SOURCES = mln_fun_v2w_w2v_norm.cc
+mln_fun_v2w_w2v_all_SOURCES = mln_fun_v2w_w2v_all.cc
mln_fun_p2v_ternary_SOURCES = mln_fun_p2v_ternary.cc
mln_fun_p2v_iota_SOURCES = mln_fun_p2v_iota.cc
mln_fun_p2v_elifs_SOURCES = mln_fun_p2v_elifs.cc
@@ -1479,10 +1490,14 @@ mln_fun_v2v_wrap_SOURCES = mln_fun_v2v_wrap.cc
mln_fun_v2v_enc_SOURCES = mln_fun_v2v_enc.cc
mln_fun_v2v_projection_SOURCES = mln_fun_v2v_projection.cc
mln_fun_v2v_convert_SOURCES = mln_fun_v2v_convert.cc
+mln_fun_v2v_hsl_to_rgb_SOURCES = mln_fun_v2v_hsl_to_rgb.cc
+mln_fun_v2v_hsi_to_rgb_SOURCES = mln_fun_v2v_hsi_to_rgb.cc
mln_fun_v2v_essential_SOURCES = mln_fun_v2v_essential.cc
+mln_fun_v2w2v_all_SOURCES = mln_fun_v2w2v_all.cc
mln_fun_v2w2v_cos_SOURCES = mln_fun_v2w2v_cos.cc
mln_fun_unary_SOURCES = mln_fun_unary.cc
mln_fun_vv2b_implies_SOURCES = mln_fun_vv2b_implies.cc
+mln_fun_vv2b_all_SOURCES = mln_fun_vv2b_all.cc
mln_fun_vv2b_le_SOURCES = mln_fun_vv2b_le.cc
mln_fun_vv2b_gt_SOURCES = mln_fun_vv2b_gt.cc
mln_fun_vv2b_ge_SOURCES = mln_fun_vv2b_ge.cc
@@ -1627,6 +1642,7 @@ mln_accu_site_set_all_SOURCES = mln_accu_site_set_all.cc
mln_accu_site_set_essential_SOURCES = mln_accu_site_set_essential.cc
mln_accu_stat_variance_SOURCES = mln_accu_stat_variance.cc
mln_accu_stat_deviation_SOURCES = mln_accu_stat_deviation.cc
+mln_accu_stat_var_SOURCES = mln_accu_stat_var.cc
mln_accu_max_SOURCES = mln_accu_max.cc
mln_accu_lor_SOURCES = mln_accu_lor.cc
mln_accu_rank_SOURCES = mln_accu_rank.cc
@@ -1675,6 +1691,7 @@ mln_accu_image_all_SOURCES = mln_accu_image_all.cc
mln_accu_image_set_value_SOURCES = mln_accu_image_set_value.cc
mln_accu_image_take_SOURCES = mln_accu_image_take.cc
mln_accu_image_take_as_init_SOURCES = mln_accu_image_take_as_init.cc
+mln_accu_image_take_n_times_SOURCES = mln_accu_image_take_n_times.cc
mln_accu_image_essential_SOURCES = mln_accu_image_essential.cc
mln_accu_center_SOURCES = mln_accu_center.cc
mln_accu_line_SOURCES = mln_accu_line.cc
@@ -2408,6 +2425,7 @@ mln_border_duplicate_SOURCES = mln_border_duplicate.cc
mln_border_find_SOURCES = mln_border_find.cc
mln_border_thickness_SOURCES = mln_border_thickness.cc
mln_border_all_SOURCES = mln_border_all.cc
+mln_border_resize_equal_SOURCES = mln_border_resize_equal.cc
mln_border_mirror_SOURCES = mln_border_mirror.cc
mln_border_get_SOURCES = mln_border_get.cc
mln_border_equalize_SOURCES = mln_border_equalize.cc
--
1.5.6.5
1
0