
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena ChangeLog: 2008-01-09 Guillaume Duhamel <guillaume.duhamel@lrde.epita.fr> Update extract character. * sandbox/nivault/extract_character.cc: Update. --- extract_character.cc | 80 ++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 76 insertions(+), 4 deletions(-) Index: trunk/milena/sandbox/nivault/extract_character.cc =================================================================== --- trunk/milena/sandbox/nivault/extract_character.cc (revision 1643) +++ trunk/milena/sandbox/nivault/extract_character.cc (revision 1644) @@ -25,8 +25,11 @@ // reasons why the executable file might be covered by the GNU General // Public License. +# include <vector> + # include <mln/core/image2d.hh> # include <mln/io/pbm/load.hh> +# include <mln/io/pgm/save.hh> # include <mln/debug/println.hh> # include <mln/logical/not.hh> # include <mln/logical/or.hh> @@ -34,12 +37,30 @@ # include <mln/morpho/erosion.hh> # include <mln/morpho/dilation.hh> +# include <mln/morpho/complementation.hh> +# include <mln/morpho/closing.hh> +# include <mln/morpho/opening.hh> # include <mln/make/w_window2d.hh> # include <mln/win/rectangle2d.hh> # include <mln/win/vline2d.hh> # include <mln/win/hline2d.hh> +# include <mln/win/disk2d.hh> # include <mln/level/fill.hh> +# include <mln/labeling/blobs.hh> +# include <mln/core/neighb2d.hh> + +# include <mln/accu/mean.hh> +# include <mln/accu/bbox.hh> +# include <mln/accu/p.hh> +# include <mln/accu/count.hh> + +# include <mln/value/scalar.hh> +# include <mln/make/voronoi.hh> +# include <mln/geom/seeds2tiling.hh> +# include <mln/core/mesh_p.hh> +# include <mln/draw/mesh.hh> +# include <mln/level/stretch.hh> using namespace mln; @@ -48,22 +69,73 @@ { using value::int_u8; + typedef image2d<bool> I; + typedef image2d<unsigned> I_LABEL; if (argc != 3) { std::cerr << "Usage : " << argv[0] << " input.pbm output.pbm" << std::endl; exit(1); } + std::string path_input = argv[1]; std::string path_output = argv[2]; image2d<bool> input = io::pbm::load (path_input); - image2d<bool> output = clone(input); - output = logical::not_(output); + /// Inversion video. + morpho::complementation_inplace(input); + + + /// FIXME : Some code was deleted here :-) (Remove noise) +// win::disk2d win (2); +// I output = morpho::closing(input, win); +// io::pbm::save (output, path_output); + +/// Labeling. + unsigned nb_labels; + I_LABEL label_image = labeling::blobs(input, c4(), nb_labels); + std::cout << "nb_labels = " << nb_labels << std::endl; + + + /// Extraction of informations in the image (BoundingBox, Cardinality, ... ). + +// std::vector< accu::mean_ <point2d> > vec_mean (nb_labels + 1); +// std::vector< accu::p<accu::mean<point2d> >::ret > vec_mean (nb_labels + 1); + std::vector< accu::bbox <point2d> > vec_bbox (nb_labels + 1); + std::vector< accu::count_<point2d> > vec_card (nb_labels + 1); + + + mln_piter_(I_LABEL) p (label_image.domain ()); + for_all (p) + { +// vec_mean[label_image(p)].take (p); + vec_bbox[label_image(p)].take (p); + vec_card[label_image(p)].take (p); + } + +// for (unsigned i = 0; i <= nb_labels; ++i) +// { +// if (vec_card[i].to_result () > 200) +// ; +// std::cout << i << " = " << vec_card[i].to_result () << std::endl; +// std::cout << i << " = " << vec_bbox[i].to_result () << std::endl; +// } + +// std::cout << path_output << " generated" << std::endl; + + + /// Generation of the graph. +// I_LABEL zi_image = geom::seeds2tiling(label_image, c4 ()); +// mesh_p<point2d> m = make::voronoi(label_image, zi_image, c4()); + +// I_LABEL gr_image (label_image.domain ()); +// draw::mesh(gr_image, m, 255, 128); + +// image2d<int_u8> out (label_image.domain ()); +// level::stretch (zi_image, out); - io::pbm::save (output, path_output); +// io::pgm::save(out, "out.pgm"); - std::cout << path_output << " generated" << std::endl; }