https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena/sandbox
Index: ChangeLog
from Alexandre Abraham <abraham(a)lrde.epita.fr>
Add a .cc file, correct some little things.
* markov/markov.cc: New.
* markov/markov.hh: .
markov.cc | 52 +++++++++++++++++++++++++++++++++
markov.hh | 95 ++++++++++++++++++++++++++++++++------------------------------
2 files changed, 102 insertions(+), 45 deletions(-)
Index: markov/markov.cc
--- markov/markov.cc (revision 0)
+++ markov/markov.cc (revision 0)
@@ -0,0 +1,52 @@
+// 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/io/pgm/load.hh>
+#include <mln/io/pbm/save.hh>
+
+#include <mln/value/int_u8.hh>
+
+#include "markov.hh"
+
+int main(int argc, const char * argv[])
+{
+ using namespace mln;
+ using value::int_u8;
+
+ if (argc != 3) {
+ std::cerr << "usage: " << argv[0] << " in.pgm temperature" << std::endl;
+ return 1;
+ }
+
+ image2d<int_u8> ima;
+ io::pgm::load(ima, argv[1]);
+
+ int temperature = atoi(argv[2]);
+ io::pgm::save(markov(ima, temperature), name.append("_markoved.pbm"));
+}
Index: markov/markov.hh
--- markov/markov.hh (revision 2876)
+++ markov/markov.hh (working copy)
@@ -3,6 +3,8 @@
# include <cmath>
+namespace mln
+{
inline
const neighb2d& neighb_h1()
@@ -32,11 +34,13 @@
// u voisinage
}
- template <typename I, typename G, typename R, typename E> // I == int_u8
-markov(const Image2d<I>& ima, unsigned start_temp)
+ template <typename I, typename G, typename R> // I == int_u8
+ markov(const Image<I>& ima_, unsigned start_temp)
{
+ exact(I) &ima = ima_;
+
double espilon = 0.001;
- Image2d<bool> out(ima.domain()); // FIXME: generalize, we might not do a binarisation
+ mln_ch_value(I, bool) out(ima.domain()); // FIXME: generalize, we might not do a binarisation
G temp(start_temp);
R v_random(0, 1);
@@ -46,13 +50,12 @@
while (temp.value() < epsilon)
{
- qiterator p(ima);
+ mln_piter p(ima.domain());
for_all(p)
{
bool v = v_random.get();
-
u = compute_energy(ima, out(p), p);
up = compute_energy(ima, v, p);
@@ -68,4 +71,6 @@
return out;
}
+} // end of namespace mln
+
#endif /* !MARKOV_HH_ */
URL: https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena/sandbox
ChangeLog:
2008-11-14 Matthieu Garrigues <garrigues(a)lrde.epita.fr>
[Markov] Add temperator generator.
* markov/T_gen.hh: New.
---
T_gen.hh | 76 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 76 insertions(+)
Index: branches/cleanup-2008/milena/sandbox/markov/T_gen.hh
===================================================================
--- branches/cleanup-2008/milena/sandbox/markov/T_gen.hh (revision 0)
+++ branches/cleanup-2008/milena/sandbox/markov/T_gen.hh (revision 2874)
@@ -0,0 +1,76 @@
+// 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.
+
+
+
+#ifndef MLN_TEMPERATURE_GENERATOR_HH
+# define MLN_TEMPERATURE_GENERATOR_HH
+
+class temperature_generator
+{
+public:
+
+ temperature_generator(float t0, float alpha) : t_(t0), alpha_(alpha) {}
+
+ operator float()
+ {
+ float tmp = t_;
+ t_ *= alpha_;
+ return tmp;
+ }
+
+private:
+ float t_;
+ float alpha_;
+};
+
+// Example.
+// #include <iostream>
+// int main()
+// {
+// temperature_generator temp_gen(100, 0.9);
+// float t;
+
+// t = temp_gen;
+// std::cout << t << std::endl;
+// t = temp_gen;
+// std::cout << t << std::endl;
+// t = temp_gen;
+// std::cout << t << std::endl;
+// t = temp_gen;
+// std::cout << t << std::endl;
+// t = temp_gen;
+// std::cout << t << std::endl;
+// t = temp_gen;
+// std::cout << t << std::endl;
+// t = temp_gen;
+// std::cout << t << std::endl;
+// t = temp_gen;
+// std::cout << t << std::endl;
+// }
+
+#endif // ! MLN_TEMPERATURE_GENERATOR_HH
From: Maxime van Noppen <yabo(a)lrde.epita.fr>
To: olena-patches(a)lrde.epita.fr
Subject: r2873: Create the sandbox for the Markov project
URL: https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena/sandbox
ChangeLog:
2008-11-14 Maxime van Noppen <yabo(a)lrde.epita.fr>
Create the sandbox for the Markov project.
* markov: New.
---
0 files changed
https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Add set compute with an accumulator.
* tests/set/compute.cc: New.
* tests/set/Makefile.am: Update.
* tests/set/diff.cc: Upgrade doc style.
Fix clumsy include.
* mln/set/compute.hh: New.
* mln/set/all.hh: Update.
mln/set/all.hh | 11 +++-
mln/set/compute.hh | 112 ++++++++++++++++++++++++++++++++++++++++++++++++++
tests/set/Makefile.am | 2
tests/set/compute.cc | 44 +++++++++++++++++++
tests/set/diff.cc | 10 ++--
5 files changed, 170 insertions(+), 9 deletions(-)
Index: tests/set/compute.cc
--- tests/set/compute.cc (revision 0)
+++ tests/set/compute.cc (revision 0)
@@ -0,0 +1,44 @@
+// 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.
+
+/// \file tests/set/compute.cc
+///
+/// Tests on mln::set::compute.
+
+#include <mln/core/site_set/p_set.hh>
+#include <mln/core/alias/point2d.hh>
+#include <mln/accu/count.hh>
+#include <mln/set/compute.hh>
+
+
+int main()
+{
+ using namespace mln;
+
+ p_set<point2d> s;
+ mln_assertion(set::compute(accu::meta::count(), s) == 0);
+}
Index: tests/set/Makefile.am
--- tests/set/Makefile.am (revision 2869)
+++ tests/set/Makefile.am (working copy)
@@ -3,12 +3,14 @@
include $(top_srcdir)/milena/tests/tests.mk
check_PROGRAMS = \
+ compute \
diff \
inter \
is_subset_of \
sym_diff \
uni
+compute_SOURCES = compute.cc
diff_SOURCES = diff.cc
inter_SOURCES = inter.cc
is_subset_of_SOURCES = is_subset_of.cc
Index: tests/set/diff.cc
--- tests/set/diff.cc (revision 2869)
+++ tests/set/diff.cc (working copy)
@@ -1,4 +1,5 @@
// 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
@@ -25,13 +26,12 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-/*! \file tests/set/diff.cc
- *
- * \brief Tests on mln::set::diff.
- */
+/// \file tests/set/diff.cc
+///
+/// Tests on mln::set::diff.
#include <mln/core/site_set/p_set.hh>
-#include <mln/core/alias/dpoint2d.hh>
+#include <mln/core/alias/point2d.hh>
#include <mln/set/diff.hh>
Index: mln/set/all.hh
--- mln/set/all.hh (revision 2869)
+++ mln/set/all.hh (working copy)
@@ -1,4 +1,5 @@
// 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
@@ -28,10 +29,9 @@
#ifndef MLN_SET_ALL_HH
# define MLN_SET_ALL_HH
-/*! \file mln/set/all.hh
- *
- * \brief File that includes all set-related routines.
- */
+/// \file mln/set/all.hh
+///
+/// File that includes all set-related routines.
namespace mln
@@ -42,6 +42,8 @@
}
+
+# include <mln/set/compute.hh>
# include <mln/set/diff.hh>
# include <mln/set/inter.hh>
# include <mln/set/get.hh>
@@ -50,4 +52,5 @@
# include <mln/set/sym_diff.hh>
# include <mln/set/uni.hh>
+
#endif // ! MLN_SET_ALL_HH
Index: mln/set/compute.hh
--- mln/set/compute.hh (revision 0)
+++ mln/set/compute.hh (revision 0)
@@ -0,0 +1,112 @@
+// 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.
+
+#ifndef MLN_SET_COMPUTE_HH
+# define MLN_SET_COMPUTE_HH
+
+/// \file mln/set/compute.hh
+///
+/// Compute an accumulator on a site set.
+
+# include <mln/core/concept/meta_accumulator.hh>
+# include <mln/core/concept/site_set.hh>
+
+
+namespace mln
+{
+
+ namespace set
+ {
+
+ /*! Compute an accumulator onto the sites of a site set.
+ *
+ * \param[in] a An accumulator.
+ * \param[in] s A site set.
+ * \return The accumulator result.
+ */
+ template <typename A, typename S>
+ mln_result(A)
+ compute(const Accumulator<A>& a, const Site_Set<S>& s);
+
+
+ /*! Compute an accumulator onto the sites of a site set.
+ *
+ * \param[in] a A meta-accumulator.
+ * \param[in] s A site set.
+ * \return The accumulator result.
+ */
+ template <typename A, typename S>
+ mln_accu_with(A, mln_site(S))::result
+ compute(const Meta_Accumulator<A>& a, const Site_Set<S>& s);
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename A, typename S>
+ inline
+ mln_result(A)
+ compute(const Accumulator<A>& a_, const Site_Set<S>& s_)
+ {
+ trace::entering("set::compute");
+
+ A a = exact(a_);
+ const S& s = exact(s_);
+
+ mln_piter(S) p(s);
+ for_all(p)
+ a.take(p);
+
+ trace::exiting("set::compute");
+ return a.to_result();
+ }
+
+ template <typename A, typename S>
+ mln_accu_with(A, mln_site(S))::result
+ compute(const Meta_Accumulator<A>& a_, const Site_Set<S>& s_)
+ {
+ trace::entering("set::compute");
+
+ mln_accu_with(A, mln_site(S)) a = accu::unmeta(exact(a_), mln_site(S)());
+ const S& s = exact(s_);
+
+ mln_piter(S) p(s);
+ for_all(p)
+ a.take(p);
+
+ trace::exiting("set::compute");
+ return a.to_result();
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::set
+
+} // end of namespace mln
+
+
+#endif // ! MLN_SET_COMPUTE_HH
#43: Fix the initialization of all global constants.
------------------------+---------------------------------------------------
Reporter: garrigues | Owner: Olena Team
Type: defect | Status: closed
Priority: major | Milestone: Olena 1.0
Component: Milena | Version: 1.0
Resolution: fixed | Keywords:
------------------------+---------------------------------------------------
Comment (by lazzara):
Fixed in branches/cleanup-2008 with revision #2818 and #2865.
The associated test is named "global_vars" and is available in
milena/tests.
--
Ticket URL: <https://trac.lrde.org/olena/ticket/43#comment:4>
Olena <http://olena.lrde.epita.fr>
Olena, a generic and efficient C++ image processing library.
https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Update unary logical not.
* mln/fun/v2b/lnot.hh: New.
* mln/fun/v2b/all.hh: Update.
* mln/logical/not.hh: Rely on level transform.
fun/v2b/all.hh | 19 ++++++--------
fun/v2b/lnot.hh | 75 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
logical/not.hh | 70 +++++++++++-----------------------------------------
3 files changed, 99 insertions(+), 65 deletions(-)
Index: mln/fun/v2b/all.hh
--- mln/fun/v2b/all.hh (revision 2868)
+++ mln/fun/v2b/all.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2008 EPITA Research and Development Laboratory
+// 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
@@ -28,10 +28,9 @@
#ifndef MLN_FUN_V2B_ALL_HH
# define MLN_FUN_V2B_ALL_HH
-/*! \file mln/fun/v2b/all.hh
- *
- * \brief File that includes all functions from point to value.
- */
+/// \file mln/fun/v2b/all.hh
+///
+/// File that includes all functions from value to logic value.
namespace mln
@@ -40,15 +39,15 @@
namespace fun
{
- /// Namespace of functions from point to value.
- namespace v2b
- {
- }
- }
+ /// Namespace of functions from value to logic value.
+ namespace v2b {}
}
+}
+# include <mln/fun/v2b/lnot.hh>
# include <mln/fun/v2b/threshold.hh>
+
#endif // ! MLN_FUN_V2B_ALL_HH
Index: mln/fun/v2b/lnot.hh
--- mln/fun/v2b/lnot.hh (revision 0)
+++ mln/fun/v2b/lnot.hh (revision 0)
@@ -0,0 +1,75 @@
+// 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.
+
+#ifndef MLN_FUN_V2B_LNOT_HH
+# define MLN_FUN_V2B_LNOT_HH
+
+/// \file mln/fun/v2b/lnot.hh
+///
+/// Functor that computes "logical not" on a value.
+
+# include <mln/core/concept/function.hh>
+
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ namespace v2b
+ {
+
+ /// Functor computing logical-not on a value.
+ template <typename V>
+ struct lnot : public Function_v2b< lnot<V> >
+ {
+ typedef V result;
+ V operator()(const V& v) const;
+ };
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename V>
+ inline
+ V
+ lnot<V>::operator()(const V& v) const
+ {
+ return ! v;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::fun::v2b
+
+ } // end of namespace mln::fun
+
+} // end of namespace mln
+
+
+#endif // ! MLN_FUN_V2B_LNOT_HH
Index: mln/logical/not.hh
--- mln/logical/not.hh (revision 2868)
+++ mln/logical/not.hh (working copy)
@@ -1,4 +1,5 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// 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
@@ -28,18 +29,12 @@
#ifndef MLN_LOGICAL_NOT_HH
# define MLN_LOGICAL_NOT_HH
-/*! \file mln/logical/not.hh
- *
- * \brief Point-wise "logical not" of a binary image.
- *
- * \todo Add static assertion and save one iterator in in-place version.
- */
-
-# include <mln/core/concept/image.hh>
+/// \file mln/logical/not.hh
+///
+/// Point-wise "logical not" of a binary image.
-
-// Specializations are in:
-# include <mln/logical/not.spe.hh>
+# include <mln/logical/includes.hh>
+# include <mln/fun/v2b/lnot.hh>
namespace mln
@@ -73,58 +68,21 @@
void not_inplace(Image<I>& input);
-# ifndef MLN_INCLUDE_ONLY
-
- namespace impl
- {
-
- namespace generic
- {
- template <typename I, typename O>
- inline
- void not_(const I& input, O& output)
- {
- trace::entering("logical::impl::generic::not_");
-
- mln_piter(I) p(input.domain());
- for_all(p)
- output(p) = ! input(p);
- trace::exiting("logical::impl::generic::not_");
- }
-
- template <typename I>
- inline
- void not_inplace(I& inout)
- {
- trace::entering("logical::impl::generic::not_");
-
- mln_piter(I) p(inout.domain());
- for_all(p)
- inout(p) = ! inout(p);
-
- trace::exiting("logical::impl::generic::not_");
- }
- }
-
- } // end of namespace mln::logical::impl
-
-
- // Facades.
+# ifndef MLN_INCLUDE_ONLY
template <typename I>
inline
mln_concrete(I) not_(const Image<I>& input)
{
- trace::entering("logical::not");
+ trace::entering("logical::not_");
mln_precondition(exact(input).has_data());
- mln_concrete(I) output;
- initialize(output, input);
- impl::not_(mln_trait_image_speed(I)(), exact(input), output);
+ fun::v2b::lnot<mln_value(I)> f;
+ mln_concrete(I) output = level::transform(input, f);
- trace::exiting("logical::not");
+ trace::exiting("logical::not_");
return output;
}
@@ -135,7 +93,9 @@
trace::entering("logical::not_inplace");
mln_precondition(exact(input).has_data());
- impl::not_inplace(mln_trait_image_speed(I)(), exact(input));
+
+ fun::v2b::lnot<mln_value(I)> f;
+ level::transform_inplace(input, f);
trace::exiting("logical::not_inplace");
}