
https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena/sandbox Index: ChangeLog from Ugo Jardonnet <ugo.jardonnet@lrde.epita.fr> INIM: Classif: Start working on max_tree version. * classif/max_tree.hh: max_tree struct. * classif/iccvg04.cc: minor fix. * classif/display.hh: Put display here. * classif/v2.cc: STart max_tree. display.hh | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ iccvg04.cc | 30 ----------------------- max_tree.hh | 15 +++++++++++ v2.cc | 25 +++++++++---------- 4 files changed, 104 insertions(+), 42 deletions(-) Index: classif/max_tree.hh --- classif/max_tree.hh (revision 2705) +++ classif/max_tree.hh (working copy) @@ -13,6 +13,7 @@ # include <mln/value/int_u8.hh> # include <mln/io/pgm/load.hh> # include <mln/core/site_set/p_array.hh> +# include <mln/debug/println.hh> using namespace mln; @@ -83,6 +84,20 @@ zpar(p) = p; } + void area() + { + image2d<value::int_u16> area(f.domain()); + level::fill(area, 1); + mln_fwd_piter(S) p(s); + for_all(p) + { + if (parent(p) == p) + continue; + area(parent(p)) += area(p); + } + debug::println(area); + } + bool is_root(const point& p) const { return parent(p) == p; Index: classif/iccvg04.cc --- classif/iccvg04.cc (revision 2705) +++ classif/iccvg04.cc (working copy) @@ -36,6 +36,7 @@ #include <stdlib.h> #include "proj.hh" +#include "display.hh" using namespace mln; @@ -70,35 +71,6 @@ } } -template <typename I> -void display(const I& ima, const char * dir) -{ - mkdir(dir, 0777); - chdir(dir); - - image2d< mln_value(I) > out(geom::nrows(ima), geom::ncols(ima)); - - for (int s = 0; s < geom::nslis(ima); ++s) - { - // image2d< value::int_u8 > out(geom::nrows(ima), geom::ncols(ima)); - for (int r = 0; r < geom::nrows(ima); ++r) - { - for (int c = 0; c < geom::ncols(ima); ++c) - { - out(point2d(r, c)) = ima(point3d(s, r, c)); - } - } - - std::ostringstream is; - is << "out_" << s << ".pgm"; - - io::pgm::save(out, is.str()); - } - - chdir(".."); -} - - template <typename I, typename J, typename K> void classify_image(const I& ima, const J& histo, const K& ws, int nbasins, int f) Index: classif/display.hh --- classif/display.hh (revision 0) +++ classif/display.hh (revision 0) @@ -0,0 +1,76 @@ +// 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/all.hh> +#include <mln/value/all.hh> +#include <mln/core/image/image3d.hh> + +#include <sys/stat.h> +#include <sstream> +#include <string.h> +#include <stdlib.h> + + +namespace mln +{ + + template <typename I> + void display(const I& ima, const char * dir) + { + mkdir(dir, 0777); + chdir(dir); + + image2d< mln_value(I) > out(geom::nrows(ima), geom::ncols(ima)); + + for (int s = 0; s < geom::nslis(ima); ++s) + { + // image2d< value::int_u8 > out(geom::nrows(ima), geom::ncols(ima)); + for (int r = 0; r < geom::nrows(ima); ++r) + { + for (int c = 0; c < geom::ncols(ima); ++c) + { + out(point2d(r, c)) = ima(point3d(s, r, c)); + } + } + + std::ostringstream is; + is << "out_" << s << ".pgm"; + + io::pgm::save(out, is.str()); + } + + chdir(".."); + } + +} // end of namespace mln + +#endif /* MLN__DISPLAY_HH */ + Index: classif/v2.cc --- classif/v2.cc (revision 2705) +++ classif/v2.cc (working copy) @@ -14,7 +14,9 @@ #include <mln/arith/revert.hh> #include <mln/core/alias/neighb3d.hh> -#include "min_tree.hh" +#include "max_tree.hh" +#include "proj.hh" +#include "display.hh" using namespace mln; @@ -38,17 +40,11 @@ template <typename I, typename N> unsigned -compute_min_tree(const I& ima, const N& nbh) +compute_max_tree(const I& ima, const J& histo, const N& nbh) { - min_tree_<I,N> run(ima, nbh); + max_tree_<I,N> run(ima, nbh); - mln_piter(I) p(ima.domain()); - unsigned nnodes = 0; - for_all(p) - if (run.is_node(p)) - ++nnodes; - return nnodes; } bool usage(int argc, char ** argv) @@ -72,9 +68,12 @@ //make histo image3d<unsigned> histo = fill_histo(ima,div_factor); - //revert histo - image3d<unsigned> rhisto = arith::revert(histo); + //proj + accu::mean<unsigned, unsigned, unsigned> mean; + image2d<unsigned> phisto = proj(histo, mean); + + //debug::println(phisto); - // Compute min_tree - compute_min_tree(rhisto, c6()); + // Compute max_tree + max_tree_<I,N> run(ima, nbh); }