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_ */