URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2008-02-14 Etienne FOLIO <folio(a)lrde.epita.fr>
First work on naive dt.
* sandbox/folio/dt_naive.cc: Test file, in progress
* sandbox/folio/dt_naive.hh: Algorithm
---
dt_naive.cc | 49 +++++++++++++++++++++++++
dt_naive.hh | 117 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 166 insertions(+)
Index: trunk/milena/sandbox/folio/dt_naive.hh
===================================================================
--- trunk/milena/sandbox/folio/dt_naive.hh (revision 0)
+++ trunk/milena/sandbox/folio/dt_naive.hh (revision 1724)
@@ -0,0 +1,117 @@
+// Copyright (C) 2007 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 DISTANCE_NAIVE_HH_
+# define DISTANCE_NAIVE_HH_
+
+/*! \file TODO
+ *
+ * \brief Defines a function that creates a distance map corresponding to a
+ * given image.
+ */
+
+# include <mln/core/concept/image.hh>
+# include <mln/core/math/sqr.hh>
+# include <mln/core/math/sqrt.hh>
+# include <mln/core/level/fill.hh>
+
+namespace mln
+{
+ namespace dist
+ {
+ /*! Calculates the distance map corresponding to a given image
+ *
+ * \param[in] img The binary reference image.
+ * \param[in] objColor The object's color.
+ * \param[in] bgColor The background color.
+ * \return New distance map image.
+ *
+ * \pre \p img has to be initialized.
+ *
+ * \todo
+ */
+ template <typename I, typename J>
+ Image<J>&
+ dt_naive(const Image<I>& img,
+ const mln_value(I)& objColor,
+ const mln_value(I)& bgColor);
+
+# ifndef MLN_INCLUDE_ONLY
+
+ namespace impl
+ {
+ template <typename J>
+ inline void
+ dt_naive_calc(mln_value(J)& res,
+ const mln_point(I)& ref,
+ const mln_point(I)& test)
+ {
+ mln_value(J) sum = 0;
+
+ for (unsigned i = 0; i < I::pset::dim; ++i)
+ sum += math::sqr(ref[i] - test[i]);
+
+ res = math::sqrt(sum);
+ }
+ }
+
+ // Facade.
+ template <typename I, typename J>
+ inline Image<J>&
+ dt_naive(const Image<I>& img,
+ const mln_value(I)& objColor,
+ const mln_value(I)& bgColor)
+ {
+ Image<J> res(img.domain());
+ mln_piter(I) p(img.domain());
+ mln_piter(I) q(img.domain());
+
+ level::fill(res, literal::zero);
+
+ for_all(p)
+ {
+ if (img(p) == bgColor)
+ continue;
+
+ for_all(q)
+ {
+ if (img(q) == objColor)
+ continue;
+
+ dt_naive_calc(res(q), p, q));
+ }
+ }
+
+ return res;
+ }
+
+# endif // !MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::dist
+} // end of namespace mln
+
+#endif /* !DISTANCE_NAIVE_HH_ */
Index: trunk/milena/sandbox/folio/dt_naive.cc
===================================================================
--- trunk/milena/sandbox/folio/dt_naive.cc (revision 0)
+++ trunk/milena/sandbox/folio/dt_naive.cc (revision 1724)
@@ -0,0 +1,49 @@
+// 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.
+
+/*! \file tests/linear_gaussian.cc
+ *
+ * \brief Test on mln::linear::gaussian.
+ */
+
+#include "dt_naive.hh"
+
+int main()
+{
+ using namespace mln;
+
+ image2d< value::int_u8 > lena;
+ io::pgm::load(lena, MLN_IMG_DIR "/lena.pgm");
+
+// image2d<float> tmp(lena.domain());
+// linear::gaussian(lena, 5.1f, tmp);
+
+// image2d< value::int_u_sat<8> > out(lena.domain());
+// level::transform(tmp, math::round<int>(), out);
+// io::pgm::save(out, "out.pgm");
+ }
+}
https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
from Roland Levillain <roland(a)lrde.epita.fr>
Typos and aesthetic changes in documentation of graph-related
entities.
* mln/core/p_graph_piter.hh,
* mln/core/graph_window_piter.hh,
* tests/core/graph_elt_window.cc:
Fix Doxygen comments.
* mln/core/graph_psite.hh: Likewise.
(graph_psite<P>::operator[]): s/util::node_id/unsigned/.
s/id/i/.
mln/core/graph_psite.hh | 8 ++++----
mln/core/graph_window_piter.hh | 4 ++--
mln/core/p_graph_piter.hh | 8 ++++----
tests/core/graph_elt_window.cc | 4 ++--
4 files changed, 12 insertions(+), 12 deletions(-)
Index: mln/core/graph_psite.hh
--- mln/core/graph_psite.hh (revision 1718)
+++ mln/core/graph_psite.hh (working copy)
@@ -74,9 +74,9 @@
util::node_id id() const;
private:
- // The p_graph this point site belongs to.
+ /// The p_graph this point site belongs to.
const p_graph<P>& pg_;
- // The id of the node this psite is pointing towards.
+ /// The id of the node this psite is pointing towards.
util::node_id id_;
};
@@ -131,9 +131,9 @@
template<typename P>
inline
mln_coord(P)
- graph_psite<P>::operator[](util::node_id id) const
+ graph_psite<P>::operator[](unsigned i) const
{
- return to_point()[id];
+ return to_point()[i];
}
template<typename P>
Index: mln/core/graph_window_piter.hh
--- mln/core/graph_window_piter.hh (revision 1718)
+++ mln/core/graph_window_piter.hh (working copy)
@@ -96,9 +96,9 @@
const psite& p_ref_;
/// An internal iterator on the set of nodes of the underlying graph.
util::node_id id_;
- // The psite corresponding to this iterator.
+ /// The psite corresponding to this iterator.
psite psite_;
- // The point corresponding to this iterator.
+ /// The point corresponding to this iterator.
point p_;
};
Index: mln/core/p_graph_piter.hh
--- mln/core/p_graph_piter.hh (revision 1718)
+++ mln/core/p_graph_piter.hh (working copy)
@@ -93,13 +93,13 @@
operator psite() const;
protected:
- // The p_graph this point site belongs to.
+ /// The p_graph this point site belongs to.
const p_graph<P>& pg_;
- // The id of the node this psite is pointing towards.
+ /// The id of the node this psite is pointing towards.
unsigned id_;
- // The psite corresponding to this iterator.
+ /// The psite corresponding to this iterator.
psite psite_;
- // The point corresponding to this iterator.
+ /// The point corresponding to this iterator.
point p_;
};
Index: tests/core/graph_elt_window.cc
--- tests/core/graph_elt_window.cc (revision 1718)
+++ tests/core/graph_elt_window.cc (working copy)
@@ -27,7 +27,7 @@
/*! \file tests/core/graph_elt_window.cc
*
- * \brief Tests on mln::win::graph_elt_window.
+ * \brief Tests on mln::graph_elt_window.
*/
#include <vector>
@@ -77,6 +77,6 @@
p_graph<p_t> pg(g);
// Graph point site.
graph_psite<p_t> psite(pg, 0);
- // ``Sliding'' window (in fact, neighborhood) of a psite of PG.
+ // ``Sliding'' window of a psite of PG.
graph_elt_window<p_t> win;
}
https://svn.lrde.epita.fr/svn/oln/trunk/milena
This error was triggered by the corresponding test (tests/core/h_vec).
Index: ChangeLog
from Roland Levillain <roland(a)lrde.epita.fr>
Initialize the last component of h_vec's to 1 in default ctor. .
* mln/core/h_vec.hh (h_vec<d,C>::h_vec): Initialize the last
component to the unit (1) to prevent unitialized vectors from
triggering division-by-zero errors.
h_vec.hh | 5 +++++
1 file changed, 5 insertions(+)
Index: mln/core/h_vec.hh
--- mln/core/h_vec.hh (revision 1716)
+++ mln/core/h_vec.hh (working copy)
@@ -110,6 +110,11 @@
inline
h_vec<d,C>::h_vec()
{
+ /* Safety measure: set the last component to the unit (1). This
+ way, converting an unitialized h_vec to a vector won't trigger
+ division-by-zero errors if this last component were randomly
+ initialized to 0. */
+ this->data_[d] = literal::one;
}
template <unsigned d, typename C>
https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
from Nicolas Ballas <ballas(a)lrde.epita.fr>
Fix documentation.
* mln/util/graph.hh, mln/util/internal/graph_base.hh: fix documentation
graph_base.hh | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
Index: mln/util/graph.hh
Index: mln/util/internal/graph_base.hh
--- mln/util/internal/graph_base.hh (revision 1715)
+++ mln/util/internal/graph_base.hh (working copy)
@@ -50,12 +50,12 @@
Conversion to and from unsigned would still be useful, but it
might be safer to turn them into explicit ones. */
- /// \bref The type used to identify nodes.
+ /// \brief The type used to identify nodes.
///
/// Used internally as a key to manipulate nodes.
typedef unsigned node_id;
- /// \bref The type used to identify edges.
+ /// \brief The type used to identify edges.
///
/// Used internally as a key to manipulate edges.
typedef unsigned edge_id;
@@ -82,7 +82,7 @@
template<>
struct node<void>
{
- std::list<node_id> edges;
+ std::list<edge_id> edges;
};