* 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