LRE
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
List overview
Download
Olena-patches
July 2009
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
olena-patches@lrde.epita.fr
6 participants
160 discussions
Start a n
N
ew thread
r4316: Tries about segmentation based on distance between I.Z
by Edwin Carlinet
URL:
https://svn.lrde.epita.fr/svn/oln/trunk/milena/sandbox
ChangeLog: 2009-07-22 Edwin Carlinet <carlinet(a)lrde.epita.fr> Tries about segmentation based on distance between I.Z. * edwin/exec/zi.cc: New. --- zi.cc | 217 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 217 insertions(+) Index: trunk/milena/sandbox/edwin/exec/zi.cc =================================================================== --- trunk/milena/sandbox/edwin/exec/zi.cc (revision 0) +++ trunk/milena/sandbox/edwin/exec/zi.cc (revision 4316) @@ -0,0 +1,217 @@ +// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE) +// +// This file is part of Olena. +// +// Olena is free software: you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation, version 2 of the License. +// +// Olena 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 Olena. If not, see <
http://www.gnu.org/licenses/
>. +// +// As a special exception, you may use this file as part of a free +// software project 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/core/alias/neighb2d.hh> +#include <mln/core/var.hh> + +#include <mln/accu/stat/mean.hh> +#include <mln/accu/center.hh> + +#include <mln/value/int_u8.hh> +#include <mln/value/label_16.hh> +#include <mln/value/label_8.hh> +#include <mln/util/graph.hh> + +#include <mln/io/pbm/load.hh> +#include <mln/io/ppm/load.hh> +#include <mln/io/pgm/save.hh> + +#include <mln/labeling/blobs.hh> +#include <mln/labeling/compute.hh> +#include <mln/labeling/relabel.hh> + +#include <mln/transform/influence_zone_geodesic.hh> +#include <mln/morpho/watershed/flooding.hh> + +#include <mln/make/influence_zone_adjacency_graph.hh> +#include <mln/make/edge_image.hh> +#include <mln/make/vertex_image.hh> + +#include <mln/math/max.hh> +#include <mln/norm/l1.hh> + +#include "color_distance.hh" +#include <iostream> + +namespace mln +{ + + namespace convert + { + + // C-binary function to vv2v. (convert::to_fun...en binaire) + + template <typename R, typename V1, typename V2> + struct cfun_vv2v : Function_vv2v< cfun_vv2v<R, V1, V2> > + { + typedef R result; + + cfun_vv2v( R(*f_)(V1,V2) ) : + f (f_) + { + } + + R operator() (V1 arg1, V2 arg2) const + { + return f(arg1, arg2); + } + + R (*f) (V1, V2); + }; + + + template <typename R, typename V1, typename V2> + inline + cfun_vv2v<R, V1, V2> + tofun(R (*from) (V1, V2)) + { + cfun_vv2v<R, V1, V2> f(from); + return f; + } + + } + + template <typename P> + inline + value::int_u8 + doublelol(const P& p1, const P& p2) + { + return convert::to<value::int_u8>(norm::l1_distance(p1.to_vec(), p2.to_vec())); + } + +} + + + +void usage(char** argv) +{ + std::cout << "Usage: " << argv[0] << " in:mask.pbm in:source.ppm [out:zi.pgm]" + << "Compute the SKIZ from a binary image (saved in iz.pgm)." + << "" + << std::endl; + + + abort(); +} + + + +int main(int argc, char** argv) +{ + using namespace mln; + using value::int_u8; + + if (argc < 3) + usage(argv); + + const char* finput = argv[1]; + const char* fsource = argv[2]; + const char* foutput = argc > 3 ? argv[3] : "zi.pgm"; + + // Image loadin' + image2d<bool> input; + io::pbm::load(input, finput); + + image2d<value::rgb8> source; + io::ppm::load(source, fsource); + + + // I.Z + typedef value::label_8 L; + + typedef image2d<L> I; + I labels, iz, out; + L nlabel; + + labels = labeling::blobs(input, c4(), nlabel); + iz = transform::influence_zone_geodesic(labels, c4()); + + io::pgm::save(iz, foutput); + + // I.Z Graph + util::graph izg = make::influence_zone_adjacency_graph(iz, c4(), nlabel); + + // -- Color distance + // util::array<value::rgb8> mean_colors; + // convert::from_to(labeling::compute(accu::stat::mean<value::rgb8>(), source, labels, nlabel), + // mean_colors); + + // typedef vertex_image<void, value::rgb8, util::graph> V; + // V v_ima = make::vertex_image(izg, mean_colors); + + // typedef edge_image<void, value::int_u8, util::graph> E; + // E e_ima = make::edge_image(v_ima, convert::tofun(dist_mean)); + // -- Color distance + + util::array<mln_psite_(I)> mass_centers; + convert::from_to(labeling::compute(accu::center<mln_psite_(I)>(), labels, nlabel), + mass_centers); + + typedef vertex_image<void, mln_psite_(I), util::graph> V; + V v_ima = make::vertex_image(izg, mass_centers); + + typedef edge_image<void, value::int_u8, util::graph> E; + E e_ima = make::edge_image(v_ima, convert::tofun(doublelol<mln_psite_(I)>)); + + + // WST. + typedef mln_ch_value_(V, L) v_ima_labels_t; + v_ima_labels_t v_ima_labels; + initialize(v_ima_labels, v_ima); + + typedef mln_ch_value_(E, L) e_ima_wst_t; + L nbasins; + e_ima_wst_t e_ima_wst = + morpho::watershed::flooding(e_ima, E::nbh_t (), nbasins); + + { // Label nodes with edge wst labels. + mln_vertex_iter_(util::graph) v(izg); + mln_vertex_nbh_edge_iter_(util::graph) n(v); + for_all(v) + for_all(n) + { + if (e_ima_wst(n)) + { + v_ima_labels(v) = e_ima_wst(n); + break; + } + } + } + + // Relabeling + util::array<L> tr(nlabel); + mln_piter_(V) v(v_ima.domain()); + for_all(v) + { + std::cout << v.id() << " : " << v_ima_labels(v) << std::endl; + tr[v.id()] = v_ima_labels(v); + } + + labeling::relabel_inplace(iz, nlabel, tr); + + io::pgm::save(iz, "zi_wst.pgm"); +} +
15 years, 5 months
1
0
0
0
4315: Augment ICDAR module code.
by Thierry Geraud
https://svn.lrde.epita.fr/svn/oln/trunk/milena/sandbox
Index: ChangeLog from Thierry Geraud <thierry.geraud(a)lrde.epita.fr> Augment ICDAR module code. * modules/icdar/words.cc: Cosmetic change. * modules/icdar/lines.cc: Augment. lines.cc | 173 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++------- words.cc | 1 2 files changed, 155 insertions(+), 19 deletions(-) Index: modules/icdar/words.cc --- modules/icdar/words.cc (revision 4314) +++ modules/icdar/words.cc (working copy) @@ -222,4 +222,3 @@ io::ppm::save(labeling::colorize(output, n_words), "ws_large.ppm"); } - Index: modules/icdar/lines.cc --- modules/icdar/lines.cc (revision 4314) +++ modules/icdar/lines.cc (working copy) @@ -53,6 +53,7 @@ #include <mln/morpho/closing/structural.hh> #include <mln/core/alias/neighb2d.hh> #include <mln/morpho/watershed/flooding.hh> +#include <mln/labeling/wrap.hh> #include <mln/algebra/vec.hh> #include <mln/accu/stat/var.hh> @@ -60,6 +61,13 @@ #include <mln/make/vertex_image.hh> #include <mln/make/edge_image.hh> +#include <mln/morpho/elementary/dilation.hh> +#include <mln/data/transform.hh> +#include <mln/core/image/imorph/tr_image.hh> +#include <mln/core/routine/duplicate.hh> +#include <mln/labeling/colorize.hh> + + void usage(char* argv[]) { @@ -105,25 +113,120 @@ } - struct bloup : Function_vv2v<bloup> +// struct bloup : Function_vv2v<bloup> +// { +// typedef float result; + +// template <typename Var, typename V> +// float dist(const Var& var, const V& v) const +// { +// mln_precondition(var.is_valid()); +// V v_ = v - var.mean(); +// return v_.t() * var.variance()._1() * v_; +// } + +// template <typename Var> +// float operator()(const Var& var1, const Var& var2) const +// { +// return std::min(dist(var1, var2.mean()), dist(var2, var1.mean())); +// } +// }; + + + struct pass : Function_vv2v<pass> { - typedef float result; + typedef bool result; - template <typename Var, typename V> - float dist(const Var& var, const V& v) const + template <typename A> + bool operator()(const A& a1, const A& a2) const + { + if (! a1.is_valid() || ! a2.is_valid()) + return false; + A l, r; + if (a1.mean()[1] < a2.mean()[1]) + { + l = a1; + r = a2; + } + else { - mln_precondition(var.is_valid()); - V v_ = v - var.mean(); - return v_.t() * var.variance()._1() * v_; + l = a2; + r = a1; + } + float + // vertical std deviations + vs_l = std::sqrt(l.variance()(0, 0)), + vs_r = std::sqrt(r.variance()(0, 0)), + // vertical distance + vd = std::abs(l.mean()[0] - r.mean()[0]), + // horizontal std deviations + hs_l = std::sqrt(l.variance()(1, 1)), + hs_r = std::sqrt(r.variance()(1, 1)), + // horizontal means (column coordinates) + hm_l = l.mean()[1], + hm_r = r.mean()[1]; + + bool + v_criterion = (vd < 5 * std::sqrt(vs_l * vs_r)), // FIXME: say 4? + h_criterion = (hm_r - 1 * hs_r > hm_l + 1 * hs_l); // FIXME: say 1.5? + + return v_criterion && h_criterion; } + }; + - template <typename Var> - float operator()(const Var& var1, const Var& var2) const + template <typename L> + inline + L find_root_(util::array<L>& parent, L l) { - return std::min(dist(var1, var2.mean()), dist(var2, var1.mean())); + if (parent[l] == l) + return l; + return parent[l] = find_root_(parent, parent[l]); } + + + template <unsigned n> + struct over_; + + template <unsigned n> + struct sub_ : Function_v2v< sub_<n> > + { + typedef point2d result; + point2d operator()(const point2d& p) const + { + return point2d(p.row() / n, p.col() / n); + } + over_<n> inv() const; }; + template <unsigned n> + struct over_ : Function_v2v< over_<n> > + { + typedef point2d result; + point2d operator()(const point2d& p) const + { + return point2d(p.row() * n, p.col() * n); + } + sub_<n> inv() const + { + return sub_<n>(); + } + }; + + template <unsigned n> + over_<n> sub_<n>::inv() const + { + return over_<n>(); + } + + + template <typename S, typename I, typename F> + tr_image<S,I,F> + transform(const Site_Set<S>& s, const Image<I>& ima, const Function_v2v<F>& t) + { + tr_image<S,I,F> tmp(exact(s), exact(ima), exact(t)); + return tmp; + } } // local @@ -184,6 +287,8 @@ L n_basins; image2d<L> ws = morpho::watershed::flooding(clo, c4(), n_basins); + io::pgm::save(labeling::wrap(ws), "temp_ws.pgm"); + std::cout << "n basins = " << n_basins << std::endl; local::superimpose_save(small, ws, "temp_small_ws.ppm"); @@ -197,25 +302,57 @@ n_basins, (pw::cst(255) - pw::value(small)) | small.domain()); - for (unsigned l = 1; l <= n_basins; ++l) - std::cout << l << ' ' << arr[l].n_items() << ' ' << arr[l].mean() << std::endl; + // for (unsigned l = 1; l <= n_basins; ++l) + // std::cout << l << ' ' << arr[l].n_items() << ' ' << arr[l].mean() << std::endl; typedef util::graph G; G gr = make::region_adjacency_graph(ws, c8(), n_basins); vertex_image<void,A,G> v_ima = make::vertex_image(gr, arr); - edge_image<void,float,G> e_ima = make::edge_image(v_ima, - local::bloup()); + edge_image<void,bool,G> e_ima = make::edge_image(v_ima, + local::pass()); - { - typedef edge_image<void,float,G> I; + + util::array<L> parent(n_basins.next()); + for (L l = 0; l <= n_basins; ++l) + parent[l] = l; + + typedef edge_image<void,bool,G> I; mln_piter_(I) e(e_ima.domain()); for_all(e) { - std::cout << e.element().v1() << '-' << e.element().v2() << " : " << e_ima(e) << std::endl; - } + if (! e_ima(e)) + continue; + + unsigned + l1 = e.element().v1(), + l2 = e.element().v2(); + if (l1 > l2) + std::swap(l1, l2); + parent[l1] = l2; + + // std::cout << e.element().v1() << '-' << e.element().v2() << " : " + // << (e_ima(e) ? "OK" : "ko") << std::endl; } + // for (L l = 1; l <= n_basins; ++l) + // { + // parent[l] = local::find_root_(parent, l); + // std::cout << l << " -> " << parent[l] << std::endl; + // } + + io::pgm::save(labeling::wrap(data::transform(ws, parent)), "temp_relab.pgm"); + + + ws = morpho::elementary::dilation(ws, c8()); + + image2d<L> ws_(input.domain()); + data::fill(ws_, local::transform(input.domain(), ws, local::over_<4>())); + + io::ppm::save(labeling::colorize(rgb8(), ws_), argv[2]); + + + trace::exiting("main"); }
15 years, 5 months
1
0
0
0
4314: Add 2010 code for page segmentation.
by Thierry Geraud
https://svn.lrde.epita.fr/svn/oln/trunk/milena/sandbox
Index: ChangeLog from Thierry Geraud <thierry.geraud(a)lrde.epita.fr> Add 2010 code for page segmentation. * inim/2010/page: New directory. * inim/2010/page/AUTHORS: New. * inim/2010/page/check_size_functor.hh: New. * inim/2010/page/white.hxx: New. * inim/2010/page/main.cc: New. * inim/2010/page/binarization: New. * inim/2010/page/binarization/binarization.hxx: New. * inim/2010/page/binarization/grayscale.hxx: New. * inim/2010/page/binarization/functors.hh: New. * inim/2010/page/binarization/integral-image.hh: New. * inim/2010/page/binarization/binarization.hh: New. * inim/2010/page/binarization/grayscale.hh: New. * inim/2010/page/binarization/functors.hxx: New. * inim/2010/page/binarization/integral-image.hxx: New. * inim/2010/page/README: New. * inim/2010/page/Makefile: New. * inim/2010/page/white.hh: New. AUTHORS | 3 Makefile | 43 +++++++ README | 51 ++++++++ binarization/binarization.hh | 36 ++++++ binarization/binarization.hxx | 72 ++++++++++++ binarization/functors.hh | 23 +++ binarization/functors.hxx | 33 +++++ binarization/grayscale.hh | 32 +++++ binarization/grayscale.hxx | 15 ++ binarization/integral-image.hh | 34 +++++ binarization/integral-image.hxx | 57 +++++++++ check_size_functor.hh | 30 +++++ main.cc | 89 +++++++++++++++ white.hh | 36 ++++++ white.hxx | 233 ++++++++++++++++++++++++++++++++++++++++ 15 files changed, 787 insertions(+) Index: inim/2010/page/AUTHORS --- inim/2010/page/AUTHORS (revision 0) +++ inim/2010/page/AUTHORS (revision 0) @@ -0,0 +1,3 @@ +hameli_a +denuzi_l +da-mot_s Index: inim/2010/page/check_size_functor.hh --- inim/2010/page/check_size_functor.hh (revision 0) +++ inim/2010/page/check_size_functor.hh (revision 0) @@ -0,0 +1,30 @@ +#ifndef CHECK_SIZE_FUNCTOR_HH_ +# define CHECK_SIZE_FUNCTOR_HH_ + +# include <mln/core/concept/function.hh> + +template <typename P, typename L> +class CheckBoxSize : public mln::Function_v2b< CheckBoxSize<P, L> > +{ +public: + + CheckBoxSize(mln::util::array< mln::box<P> > boxes) + : boxes_ (boxes) + { + } + + bool operator() (L label) const + { + bool condition = + boxes_[label].len(1) >= 200 || + boxes_[label].len(0) >= 200; + return condition; + } + +private: + + mln::util::array< mln::box<P> > boxes_; + +}; + +#endif /* !CHECK_SIZE_FUNCTOR_HH_ */ Index: inim/2010/page/white.hxx --- inim/2010/page/white.hxx (revision 0) +++ inim/2010/page/white.hxx (revision 0) @@ -0,0 +1,233 @@ +#ifndef WHITE_HXX +# define WHITE_HXX + +# include <white.hh> + +namespace whitespace +{ + + template <typename P> + bool is_box_ok (const box<P>& box) + { + return (box.len(0) < 50 && box.len(1) < 30) + && (box.len(0) >= 5 || box.len(1) >= 5); + } + + template <typename I> + util::array< box<mln_psite(I)> > find_connected_components (I& ima) + { +// std::cout << "Computing connected components..." << std::endl; + typedef value::label_16 V; + V num_labels; + mln_ch_value(I, V) labels = labeling::blobs (ima, c8(), num_labels); + +// std::cout << "Computing connected components bounding boxes..." << std::endl; + typedef util::array< box<mln_psite(I)> > A; + A components = + labeling::compute (accu::shape::bbox<mln_psite(I)>(), + labels, num_labels); + +// std::cout << "Writing components image..." << std::endl; + I out (ima.domain()); + mln_fwd_eiter(A) it (components); + A final_components; + for_all (it) + if (is_box_ok (it.element())) + { + final_components.append (it.element()); + data::fill((out | it.element()).rw(), literal::one); + } +// io::pbm::save(out, "out.pbm"); + return final_components; + } + + template <typename P> + bool find_pivot (util::array< box<P> > components, + box<P> bound, + box<P>& pivot) + { + bool found = false; + P bound_min = bound.pmin(); + P bound_max = bound.pmax(); + unsigned int best_dist = 0xffffffff; //bound_max[0] + bound_max[1]; + unsigned int bound_middle_x = (bound_max[0] + bound_min[0]) / 2; + unsigned int bound_middle_y = (bound_max[1] + bound_min[1]) / 2; + + mln_eiter(util::array< box<P> >) it (components); + for_all (it) + { + P it_min = it.element().pmin(); + P it_max = it.element().pmax(); + + if (((bound.pmin()[0] <= it_max[0] && + it_max[0] <= bound.pmax()[0]) || + (bound.pmin()[0] <= it_min[0] && + it_min[0] <= bound.pmax()[0])) && + ((bound.pmin()[1] <= it_max[1] && + it_max[1] <= bound.pmax()[1]) || + (bound.pmin()[1] <= it_min[1] && + it_min[1] <= bound.pmax()[1]))) +// if (inter (it.element(), bound).nsites() != 0) + { + found = true; + unsigned int dist = abs(bound_middle_x - it_min[0]) + + abs(it_max[0] - bound_middle_x) + + abs(bound_middle_y - it_min[1]) + + abs(it_max[1] - bound_middle_y); + if (dist < best_dist) + { + best_dist = dist; + pivot = it.element(); + } + } + } + return found; + } + +// Determinate whether the given box must be considered to search for +// whitespace + template <typename P> + bool searchable_for_whitespace (box<P> pbox, util::array< box<P> > others) + { + if (pbox.nsites() < 4000) + return false; + + if (pbox.len (1) < 2 || pbox.len (0) < 10) + return false; + + typedef util::array< box<P> > A; + mln_fwd_eiter(A) it (others); + + for_all(it) + { + unsigned int box_area = (pbox.pmax()[0] - pbox.pmin()[0]) * + (pbox.pmax()[1] - pbox.pmin()[1]); + + unsigned int left_inter_x = std::max(pbox.pmin()[0], it.element().pmin()[0]); + unsigned int right_inter_x = std::min(pbox.pmax()[0], it.element().pmax()[0]); + unsigned int top_inter_x = std::min(pbox.pmax()[1], it.element().pmax()[1]); + unsigned int bottom_inter_x = std::max(pbox.pmin()[1], it.element().pmin()[1]); + + if ((right_inter_x >= left_inter_x) && (top_inter_x >= bottom_inter_x)) + { + unsigned int inter_area = (right_inter_x - left_inter_x) * + (top_inter_x - bottom_inter_x); + + if (inter_area >= 0.8 * box_area) + return false; + } + } + return true; + } + +// Returns a lower value for high quality rectangles +// For use with a minimal heap + template <typename P> + value::int_u32 quality (box<P> pbox) + { + // Not 0xffffffff because int_u32 constructor + // takes int instead of uint + return (0x7fffffff - pbox.nsites()); + } + + template <typename P> + util::array< box<P> > + find_whitespaces (util::array< box<P> > components, + box<P> bound) + { + typedef util::fibonacci_heap<value::int_u32, box<P> > H; + H h; + util::array< box<P> > res; + h.push (quality(bound), bound); + box<P> b; + box<P> pivot; + while (h.is_valid()) + { + b = h.pop_front(); + if (find_pivot (components, b, pivot)) + { + P pmin = b.pmin(); + P pmax = b.pmax(); + box<P> tmp_box; + for (int i = 0; i < P::dim; ++i) + { + if (pivot.pmax()[i] < b.pmax()[i]) + { + pmin[i] = pivot.pmax()[i] + 1; + tmp_box = box<P>(pmin, pmax); + if (searchable_for_whitespace (tmp_box, res)) + h.push (quality(tmp_box), tmp_box); + pmin[i] = b.pmin()[i]; + } + if (pivot.pmin()[i] > b.pmin()[i]) + { + pmax[i] = pivot.pmin()[i] - 1; + tmp_box = box<P>(pmin, pmax); + if (searchable_for_whitespace (tmp_box, res)) + h.push (quality(tmp_box), tmp_box); + pmax[i] = b.pmax()[i]; + } + } + } + else + // Found a white rectangle \o/ + { + res.append (b); + } + } + return res; + } + + void whitespace_compute (image2d<bool>& ima, + image2d<bool>& cleaned) + { + typedef mln_psite_(image2d<bool>) P; + +// image2d<bool> ima = io::pbm::load (argv[1]); + border::fill (ima, true); + + util::array< box<P> > components = + whitespace::find_connected_components(ima); +// std::cout << "Computing whitespace zones..." << std::endl; + util::array< box<P> > final_components = + whitespace::find_whitespaces (components,ima.domain()); + + +// std::cout << "Merging whitespace zones..." << std::endl; + image2d<bool> zones (ima.domain()); + data::fill (zones, literal::one); + mln_fwd_eiter_(util::array< box<P> >) it (final_components); + for_all (it) + data::fill ((zones | it.element()).rw(), literal::zero); + border::fill (zones, false); + +// std::cout << "Writing whitespace image..." << std::endl; +// io::pbm::save(zones, "zones.pbm"); + +// std::cout << "Cleaning object zones..." << std::endl; + typedef value::label_16 V; + V num_labels; + image2d<V> labels = + labeling::blobs (zones, c8(), num_labels); +// io::pgm::save (labeling::wrap(labels), "labels.pgm"); + + util::array< box<P> > boxes = + labeling::compute (accu::shape::bbox<P>(), labels, num_labels); + + labeling::relabel_inplace (labels, num_labels, + CheckBoxSize<P, V>(boxes)); + labeling::pack_inplace (labels, num_labels); +// io::pgm::save (labeling::wrap(labels), "labels2.pgm"); + + image2d<value::int_u32> size_label = + labeling::compute_image (accu::math::sum<V, value::int_u32>(), + labels, labels, num_labels); + + cleaned = mln::binarization::threshold (size_label, 1); + +// std::cout << "Writing final image..." << std::endl; +// io::pbm::save (cleaned, "white.pbm"); + } +} // End of namespace whitespace + +#endif /* !WHITE_HXX */ Index: inim/2010/page/main.cc --- inim/2010/page/main.cc (revision 0) +++ inim/2010/page/main.cc (revision 0) @@ -0,0 +1,89 @@ +#include <string> +#include <iostream> + +#include <sys/types.h> +#include <sys/stat.h> + +#include <mln/io/ppm/load.hh> +#include <mln/io/pbm/save.hh> +#include <mln/io/pgm/save.hh> +#include <mln/value/int_u8.hh> +#include <mln/core/image/image2d.hh> + +#include <binarization.hh> +#include <grayscale.hh> +#include <white.hh> + +void usage (const std::string& name) +{ + std::cout << "Usage: " << name + << " [-w window_size] [-b] IN.ppm OUT.pbm" << std::endl; + exit (1); +} + +int +main (int argc, + char** argv) +{ + if (argc < 2) + usage(std::string(argv[0])); + + int i = 1; + unsigned int w_val = 51; + bool do_white = true; + + if (std::string(argv[i]) == "-w") + { + if (argc < i + 2) + usage(std::string(argv[0])); + + std::string str_w_val(argv[++i]); + std::istringstream ist(str_w_val); + + ist >> w_val; + ++i; + } + + if (i >= argc) + usage(std::string(argv[0])); + + if (std::string(argv[i]) == "-b") + { + do_white = false; + ++i; + } + + if (i >= argc) + usage(std::string(argv[0])); + + std::string infile(argv[i++]); + + if (i >= argc) + usage(std::string(argv[0])); + + std::string outfile(argv[i]); + + // The original image + mln::image2d<mln::value::rgb8> initial; + mln::io::ppm::load(initial, infile); + const mln::image2d<mln::value::rgb8>& loaded = initial; + + // Grayscale + mln::image2d<mln::value::int_u8> grays(loaded.domain()); + binarization::grayscale(loaded, grays); + + // Binarization + mln::image2d<bool> binarized(loaded.domain()); + binarization::sauvola_threshold(grays, binarized, w_val); + + + if (do_white) + { + // Whitespace + mln::image2d<bool> final(loaded.domain()); + whitespace::whitespace_compute(binarized, final); + mln::io::pbm::save (final, outfile); + } + else + mln::io::pbm::save (binarized, outfile); +} Index: inim/2010/page/binarization/binarization.hxx --- inim/2010/page/binarization/binarization.hxx (revision 0) +++ inim/2010/page/binarization/binarization.hxx (revision 0) @@ -0,0 +1,72 @@ +#ifndef BINARIZATION_HXX +# define BINARIZATION_HXX + +# include <binarization.hh> + +namespace binarization +{ + template<typename T1, typename T2> + void + sauvola_threshold(const image2d<T1>& src, + image2d<T2>& dst, + unsigned int w) + { + // Control the threshold value in the local window + // The higher, the lower the threshold form the local + // mean m(x, y). Badekas et al. said 0.34 was best. + const double k = 0.34; + // Maximum value of the standard deviation (128 for + // grayscale documents). + const double R = 128; + + + // TODO: Merge both calculus into one to improve speed + // Compute the sum of all intensities of src + IntegralImage<T1> simple(src, Identity<T1>()); + // Compute the sum of all squared intensities of src + IntegralImage<T1> squared(src, Square<T1>()); + + int w_2 = w >> 1; + + // Savaula Algorithm with I.I. + for(def::coord row = 0; row < static_cast<def::coord>(dst.nrows()); ++row) + for(def::coord col = 0; col < static_cast<def::coord>(dst.ncols()); ++col) + { + int row_min = std::max(0, row - w_2); + int col_min = std::max(0, col - w_2); + int row_max = std::min(static_cast<int>(dst.nrows() - 1), + row + w_2); + int col_max = std::min(static_cast<int>(dst.ncols() - 1), + col + w_2); + + double wh = (row_max - row_min + 1) * (col_max - col_min + 1); + + // Mean + double m_x_y_tmp = (simple(row_max, col_max) + + simple(row_min, col_min) + - simple(row_max, col_min) + - simple(row_min, col_max)); + + double m_x_y = m_x_y_tmp / wh; + + // Standard deviation + double s_x_y_tmp = (squared(row_max, col_max) + + squared(row_min, col_min) + - squared(row_max, col_min) + - squared(row_min, col_max)); + + double s_x_y = sqrt((s_x_y_tmp - (m_x_y_tmp * m_x_y_tmp) / wh)/(wh-1.0f)); + + // Thresholding + double t_x_y = m_x_y * (1.0 + k * ((s_x_y / R) - 1.0)); + + if (t_x_y > src(point2d(row, col))) + dst(point2d(row, col)) = true; + else + dst(point2d(row, col)) = false; + } + + } +} + +#endif /* !BINARIZATION_HXX */ Index: inim/2010/page/binarization/grayscale.hxx --- inim/2010/page/binarization/grayscale.hxx (revision 0) +++ inim/2010/page/binarization/grayscale.hxx (revision 0) @@ -0,0 +1,15 @@ +#ifndef GRAYSCALE_HXX +# define GRAYSCALE_HXX + +# include <grayscale.hh> + +namespace binarization +{ + void grayscale(const image2d<value::rgb8>& src, + image2d<value::int_u8>& dst) + { + dst = data::transform(src, lum()); + } +} + +#endif /* !GRAYSCALE_HXX */ Index: inim/2010/page/binarization/functors.hh --- inim/2010/page/binarization/functors.hh (revision 0) +++ inim/2010/page/binarization/functors.hh (revision 0) @@ -0,0 +1,23 @@ +#ifndef FUNCTORS_HH +# define FUNCTORS_HH + +namespace binarization +{ + template<typename T> + struct Square + { + Square(); + unsigned long long operator()(T val) const; + }; + + template<typename T> + struct Identity + { + Identity(); + unsigned long long operator()(T val) const; + }; +} + +# include "functors.hxx" + +#endif /* !FUNCTORS_HH */ Index: inim/2010/page/binarization/integral-image.hh --- inim/2010/page/binarization/integral-image.hh (revision 0) +++ inim/2010/page/binarization/integral-image.hh (revision 0) @@ -0,0 +1,34 @@ +#ifndef INTEGRAL_IMAGE_HH +# define INTEGRAL_IMAGE_HH + +# include <mln/core/image/image2d.hh> +# include <mln/value/int_u8.hh> +# include <mln/value/int_u32.hh> +# include <functors.hh> + +namespace binarization +{ + using namespace mln; + + template< typename T > + class IntegralImage + { + public: + template<class F> + IntegralImage(const image2d<T>& i, F func); + ~IntegralImage(); + +// const unsigned long long& operator()(int row, int col) const; + + unsigned long long operator()(int row, int col) const; + + private: + unsigned long long **img_; + int nrows_; + int ncols_; + }; +} + +# include "integral-image.hxx" + +#endif /* !INTEGRAL_IMAGE_HH */ Index: inim/2010/page/binarization/binarization.hh --- inim/2010/page/binarization/binarization.hh (revision 0) +++ inim/2010/page/binarization/binarization.hh (revision 0) @@ -0,0 +1,36 @@ +#ifndef BINARIZATION_HH +# define BINARIZATION_HH + +# include <algorithm> +# include <cmath> + +# include <mln/core/image/image2d.hh> +# include <mln/value/int_u8.hh> +# include <mln/value/int_u32.hh> + +# include <integral-image.hh> +# include <functors.hh> + +namespace binarization +{ + using namespace mln; + + /** + * Sauvola thresholding binarization + * using Integral Images. + * + * \param[in] src The source image + * \param[out] dst The destination image + * \param[in] w Value of the window size + */ + + template<typename T1, typename T2> + void + sauvola_threshold(const image2d<T1>& src, + image2d<T2>& dst, + unsigned int w); +} + +# include <binarization.hxx> + +#endif /* !BINARIZATION_HH */ Index: inim/2010/page/binarization/grayscale.hh --- inim/2010/page/binarization/grayscale.hh (revision 0) +++ inim/2010/page/binarization/grayscale.hh (revision 0) @@ -0,0 +1,32 @@ +#ifndef GRAYSCALE_HH +# define GRAYSCALE_HH + +# include <mln/core/image/image2d.hh> +# include <mln/value/rgb8.hh> +# include <mln/value/int_u8.hh> +# include <mln/data/transform.hh> +# include <mln/literal/colors.hh> + +namespace mln +{ + struct lum : Function_v2v<lum> + { + typedef value::int_u8 result; + result operator()(const value::rgb8& c) const + { + return (c.red() + c.green() + c.blue()) / 3; + } + }; +} + +namespace binarization +{ + using namespace mln; + + void grayscale(const image2d<value::rgb8>& src, + image2d<value::int_u8>& dst); +} + +# include <grayscale.hxx> + +#endif /* !GRAYSCALE_HH */ Index: inim/2010/page/binarization/functors.hxx --- inim/2010/page/binarization/functors.hxx (revision 0) +++ inim/2010/page/binarization/functors.hxx (revision 0) @@ -0,0 +1,33 @@ +#ifndef FUNCTORS_HXX +# define FUNCTORS_HXX + +# include <functors.hxx> + +namespace binarization +{ + template<typename T> + Square<T>::Square() + { } + + template<typename T> + unsigned long long + Square<T>::operator()(T val) const + { + return static_cast<unsigned long long>(val) * static_cast<unsigned long long>(val); + } + + template<typename T> + Identity<T>::Identity() + { } + + template<typename T> + unsigned long long + Identity<T>::operator()(T val) const + { + return static_cast<unsigned long long>(val); + } + + +} + +#endif /* !FUNCTORS_HXX */ Index: inim/2010/page/binarization/integral-image.hxx --- inim/2010/page/binarization/integral-image.hxx (revision 0) +++ inim/2010/page/binarization/integral-image.hxx (revision 0) @@ -0,0 +1,57 @@ +#ifndef INTEGRAL_IMAGE_HXX +# define INTEGRAL_IMAGE_HXX + +# include "integral-image.hh" + +namespace binarization +{ + template<typename T> + template<class F> + IntegralImage<T>::IntegralImage(const image2d<T>& i, F func) + : img_ (NULL), + nrows_ (i.nrows()), + ncols_ (i.ncols()) + { + img_ = static_cast<unsigned long long**>(malloc(sizeof (unsigned long long*) * nrows_)); + for (int n = 0; n < nrows_; ++n) + img_[n] = static_cast<unsigned long long*>(malloc(sizeof (unsigned long long) * ncols_)); + + // FIXME Overflow when super big image? + // unsigned long long not cool for portability + // Look for I.I. in the litterature + img_[0][0] = func(i(point2d(0, 0))); + + for (def::coord row = 1; row < static_cast<def::coord>(i.nrows()); ++row) + img_[row][0] = (*this)(row - 1, 0) + + func(i(point2d(row, 0))); + + for (def::coord col = 1; col < static_cast<def::coord>(i.ncols()); ++col) + img_[0][col] = (*this)(0, col - 1) + + func(i(point2d(0, col))); + + for (def::coord row = 1; row < static_cast<def::coord>(i.nrows()); ++row) + for (def::coord col = 1; col < static_cast<def::coord>(i.ncols()); ++col) + img_[row][col] = (*this)(row - 1, col) + + (*this)(row, col - 1) + - (*this)(row - 1, col - 1) + + func(i(point2d(row, col))); + } + + template< typename T > + IntegralImage<T>::~IntegralImage() + { + for (int n = 0; n < nrows_; ++n) + free(img_[n]); + free(img_); + } + + template< typename T > + unsigned long long + IntegralImage<T>::operator()(int row, + int col) const + { + return img_[row][col]; + } + +} +#endif /* !INTEGRAL_IMAGE_HXX */ Index: inim/2010/page/README --- inim/2010/page/README (revision 0) +++ inim/2010/page/README (revision 0) @@ -0,0 +1,51 @@ +Donc ce que l'on a fait consiste en troix parties: + - Niveaux de gris. + - Binarisation. + - Detection des colonnes de texte. + +- Niveaux de gris: + Pas besoin de trop d'explications ici je pense. + + void binarization::grayscale(const image2d<rgb8>& src, + image2d<int_u8>& dst) + +- Binarisation: + On a effectue une binarisation de Sauvola qui est un algo de seuillage + local (vs global comme Otsu) en se servant d'"Integral Images" pour que + ca trace un peu plus que l'algo de base. Cet Algo retourne une image + de booleens avec en blanc les elements de l'image et en noir le reste. + Il n'a pas de problèmes particulier si ce n'est que si l'image est trop + grosse (vraiment très grosse) avec pleins d'aplat de blanc, on + va dépasser la capacité maximale des unsigned long long utilisés pour les + Integral Images. Un lien vers le papier de référence sur Sauvola: +
http://pubs.iupr.org/DATA/2007-IUPR-11Sep_1129.pdf
+ + La fonction maintenant, avec `w` étant le parametre de taille + de la fenetre utilisée pour les calculs de seuillages locaux: + + void binarization::sauvola_threshold(const image2d<rgb8>& src, + image2d<bool>& dst, + unsigned int w); + + Pour info, Ocropus utilise le même algo sauf que pour déterminer les + parametres optimaux pour une image, ils font plusieurs binarisations + et segmentation jusqu'à ce qu'ils considérent que le résultat soit + bon. + + +- Whitespace: + + On procéde par la recherche des plus grandes zones blanches dans + l'image binarisées. C'est un algo itératif qui cherche à merger + des composantes connexes pour avoir les plus grands aplats de + couleur. Le résultat, c'est que à partir d'une image binarisée, + on va donner une autre image binarisée avec en blanc les colones + et paragraphe de texte et en noir le fond. + + void whitespace::whitespace_compute (image2d<bool>& src, + image2d<bool>& dst); + + +Hésitez pas à nous spammer pour toute forme de questions +la dessus! + Index: inim/2010/page/Makefile --- inim/2010/page/Makefile (revision 0) +++ inim/2010/page/Makefile (revision 0) @@ -0,0 +1,43 @@ +CXX=g++ +INCLUDES=-I. -I./binarization +CXX_FLAGS=-W -Wall -DNDEBUG -O3 -ffast-math +CXXFLAGS = -I. +OBJS= main.o +TARGET=hameli_a +DISTDIR=hameli_a +DISTFILE= Makefile README AUTHORS binarization \ + check_size_functor.hh main.cc \ + white.hh white.hxx + +all: $(TARGET) + +$(TARGET): $(OBJS) + $(CXX) $(DEBUG_FLAGS) $^ -o $@ + +clean: + rm -f *~ *.o + +distclean: clean + rm -rf $(TARGET) + rm -rf *_result + +dist: distclean + rm -rf $(DISTDIR) + mkdir $(DISTDIR) + chmod 755 $(DISTDIR) + cp -r -t $(DISTDIR) $(DISTFILE) + tar czf $(DISTDIR).tar.gz $(DISTDIR) + rm -rf $(DISTDIR) + +distcheck: dist + rm -rf _build + mkdir _build + cp $(DISTDIR).tar.gz _build + cd _build; tar xf $(DISTDIR).tar.gz + cd _build/$(DISTDIR) ; make + +%.o: %.cc + $(CXX) $(CXX_FLAGS) $(CXXFLAGS) $(INCLUDES) $(DEBUG_FLAGS) -c $< + +.PHONY: main.cc +# \ No newline at end of file Index: inim/2010/page/white.hh --- inim/2010/page/white.hh (revision 0) +++ inim/2010/page/white.hh (revision 0) @@ -0,0 +1,36 @@ +#ifndef WHITE_HH +# define WHITE_HH + +#include <cmath> +#include <iostream> +#include <mln/accu/math/sum.hh> +#include <mln/accu/shape/bbox.hh> +#include <mln/binarization/threshold.hh> +#include <mln/core/alias/neighb2d.hh> +#include <mln/core/image/image2d.hh> +#include <mln/data/fill.hh> +#include <mln/labeling/blobs.hh> +#include <mln/labeling/compute.hh> +#include <mln/labeling/compute_image.hh> +#include <mln/labeling/wrap.hh> +#include <mln/util/array.hh> +#include <mln/util/fibonacci_heap.hh> +#include <mln/value/int_u32.hh> +#include <mln/value/label_16.hh> +#include <mln/labeling/relabel.hh> +#include <mln/labeling/pack.hh> +#include <mln/border/fill.hh> +#include <mln/labeling/colorize.hh> +#include <check_size_functor.hh> + +namespace whitespace +{ + using namespace mln; + + void whitespace_compute (image2d<bool>& ima, + image2d<bool>& cleaned); +} + +# include <white.hxx> + +#endif /* !WHITE_HH */
15 years, 5 months
1
0
0
0
r4313: Fix bugs in segmentation with delta colormean method
by Edwin Carlinet
URL:
https://svn.lrde.epita.fr/svn/oln/trunk/milena/sandbox
ChangeLog: 2009-07-17 Edwin Carlinet <carlinet(a)lrde.epita.fr> Fix bugs in segmentation with delta colormean method. * edwin/exec/max_delta_colormean_obj.cc, * edwin/mln/morpho/tree/components_debug.hh: Minor fixes. --- exec/max_delta_colormean_obj.cc | 54 ++++++++++++++++++++++-------------- mln/morpho/tree/components_debug.hh | 2 - 2 files changed, 34 insertions(+), 22 deletions(-) Index: trunk/milena/sandbox/edwin/exec/max_delta_colormean_obj.cc =================================================================== --- trunk/milena/sandbox/edwin/exec/max_delta_colormean_obj.cc (revision 4312) +++ trunk/milena/sandbox/edwin/exec/max_delta_colormean_obj.cc (revision 4313) @@ -56,7 +56,7 @@ // debug #include <mln/morpho/tree/debug.hh> -#include <mln/morpho/tree/components.hh> +#include <mln/morpho/tree/components_debug.hh> using namespace mln; using value::int_u8; @@ -130,37 +130,49 @@ io::ppm::save(data::convert(value::rgb8(), means), "mean.ppm"); // Compute delta image. - mln_ch_value(typename T::function, int_u8) dist; + mln_ch_value(typename T::function, int_u8) dist, idist_dad, idist_bro; initialize(dist, tree.f()); + initialize(idist_dad, tree.f()); + initialize(idist_bro, tree.f()); mln_up_node_piter(T) n(tree); for_all(n) { int_u8 dist_dad, dist_bro; - value::rgb8 current, mean_bro; - ACC aux = accus(tree.parent(n)); - - aux.untake(accus(n)); + value::rgb8 current, cur_mean, bro_mean, dad_mean; + ACC aux; + ACC aux2 = accus(tree.parent(n)); // FIXME: add untake_n_times to accumlator concept - // Note: this is an approximation to avoid the real mean computation of bros. - unsigned m = accus(tree.parent(n)).count() - accus(n).count() - aux.count(); - value::rgb8 v = exact(source)(n); - - for (unsigned i = 0; i < m; i++) - aux.untake(v); - - current = convert::to<value::rgb8>(means(n)); - mean_bro = convert::to<value::rgb8>(aux.to_result()); - - dist_dad = dist_mean(convert::to<value::rgb8>(means(tree.parent(n))), - current); - dist_bro = dist_mean(convert::to<value::rgb8>(aux.to_result()), - current); + // FIXME: to optimize + { + mln_piter(T::nodes_t) child(tree.children(tree.parent(n))); + for_all(child) + if (child != n) + aux.take(accus(child)); + } + + cur_mean = convert::to<value::rgb8>(means(n)); - dist(n) = math::max(dist_bro, dist_dad); + bro_mean = convert::to<value::rgb8>(aux.to_result()); + dist_bro = aux.is_valid() ? dist_mean(bro_mean, cur_mean) : (int_u8) 0; + idist_bro(n) = dist_bro; + + aux.take(accus(n)); + aux2.untake(aux); + + dad_mean = convert::to<value::rgb8>(aux2.to_result()); + dist_dad = dist_mean(dad_mean, cur_mean); + idist_dad(n) = dist_dad; + + dist(n) = math::max(dist_bro, (int_u8) (dist_dad * 1.5)); } + morpho::tree::propagate_representative(tree, idist_bro); + morpho::tree::propagate_representative(tree, idist_dad); + io::pgm::save(idist_dad, "distance_dad.pgm"); + io::pgm::save(idist_bro, "distance_bro.pgm"); + return dist; } Index: trunk/milena/sandbox/edwin/mln/morpho/tree/components_debug.hh =================================================================== --- trunk/milena/sandbox/edwin/mln/morpho/tree/components_debug.hh (revision 4312) +++ trunk/milena/sandbox/edwin/mln/morpho/tree/components_debug.hh (revision 4313) @@ -277,7 +277,7 @@ std::stringstream fn; fn.fill('0'); fn << "debug/log_"; - fn.width(3); + fn.width(4); fn << std::right << cpt; std::ofstream out((fn.str() + ".log").c_str());
15 years, 5 months
1
0
0
0
4312: lrde-upload.sh: Update directory names and paths.
by Guillaume Lazzara
--- ChangeLog | 4 ++++ lrde-upload.sh | 12 ++++++------ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index b9b99a2..f0b1eba 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2009-07-17 Guillaume Lazzara <lazzara(a)lrde.epita.fr> + + * lrde-upload.sh: Update directory names and paths. + 2009-07-15 Guillaume Lazzara <lazzara(a)lrde.epita.fr> Improve devtools. diff --git a/lrde-upload.sh b/lrde-upload.sh index 053ce22..9a19946 100755 --- a/lrde-upload.sh +++ b/lrde-upload.sh @@ -22,7 +22,7 @@ REV=$VERSION-snapshot-$CURRENT_DATE mkdir -p $DEST # Delete tarballs older than 2 days. -find $DEST -maxdepth 1 -type f -mtime +2 -name 'olena-*-snapshot-*' \ +find $DEST -maxdepth 1 -type f -mtime +1 -name 'olena-*-snapshot-*' \ -exec rm -f {} \; # tar.gz @@ -44,7 +44,7 @@ rm -rf $DEST_DOC/white_paper_html.tmp # `make distcheck' sets umask to 077. Restoring permissions for all -chmod -R a+rx milena/doc/user +chmod -R a+rx milena/doc/user-refman-html chmod -R a+rx milena/doc/white_paper cp -pR milena/doc/user-refman-html $DEST_DOC/user_doc.tmp @@ -55,8 +55,8 @@ cp milena/doc/tutorial/tutorial.pdf $DEST_DOC/ cp milena/doc/user-refman.pdf $DEST_DOC/user_doc.pdf cp milena/doc/white_paper/white_paper.pdf $DEST_DOC/ -mv -f $DEST_DOC/user_doc $DEST_DOC/user_doc.old || true -mv -f $DEST_DOC/white_paper_html $DEST_DOC/white_paper_html.old || true +mv -f $DEST_DOC/user_doc $DEST_DOC/user_doc.old +mv -f $DEST_DOC/white_paper_html $DEST_DOC/white_paper_html.old mv -f $DEST_DOC/user_doc.tmp $DEST_DOC/user_doc mv -f $DEST_DOC/white_paper_html.tmp $DEST_DOC/white_paper_html @@ -66,5 +66,5 @@ rm -rf $DEST_DOC/white_paper_html.old # We want to be able to modify these files with both the `build' and # `doc' accounts. -chmod -R g+w $DEST/user_doc -chmod -R g+w $DEST/white_paper_html +chmod -R g+w $DEST_DOC/user_doc +chmod -R g+w $DEST_DOC/white_paper_html -- 1.5.6.5
15 years, 5 months
1
0
0
0
4311: doc/Doxyfile.in: Enable the Seach engine and set the example name patterns.
by Guillaume Lazzara
--- milena/ChangeLog | 5 +++++ milena/doc/Doxyfile.in | 5 +++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/milena/ChangeLog b/milena/ChangeLog index b87f3de..c1148cf 100644 --- a/milena/ChangeLog +++ b/milena/ChangeLog @@ -1,3 +1,8 @@ +2009-07-17 Guillaume Lazzara <lazzara(a)lrde.epita.fr> + + * doc/Doxyfile.in: Enable the Seach engine and set the example + name patterns. + 2009-07-17 Fabien Freling <fabien.freling(a)lrde.epita.fr> Update post-release after code freeze. diff --git a/milena/doc/Doxyfile.in b/milena/doc/Doxyfile.in index 7774897..00b1886 100644 --- a/milena/doc/Doxyfile.in +++ b/milena/doc/Doxyfile.in @@ -111,7 +111,7 @@ EXAMPLE_PATH = @top_srcdir@/milena/doc/examples \ @top_srcdir@/milena/doc/outputs \ @top_srcdir@/milena/doc/examples/split \ @top_srcdir@/milena/doc/outputs/split -EXAMPLE_PATTERNS = +EXAMPLE_PATTERNS = *.cc EXAMPLE_RECURSIVE = NO IMAGE_PATH = @top_srcdir@/milena/doc/img \ @top_srcdir@/milena/doc/figures \ @@ -120,6 +120,7 @@ INPUT_FILTER = FILTER_PATTERNS = FILTER_SOURCE_FILES = NO INPUT_ENCODING = ISO-8859-1 + #--------------------------------------------------------------------------- # configuration options related to source browsing #--------------------------------------------------------------------------- @@ -358,4 +359,4 @@ DOT_CLEANUP = YES #--------------------------------------------------------------------------- # Configuration::additions related to the search engine #--------------------------------------------------------------------------- -SEARCHENGINE = NO +SEARCHENGINE = YES -- 1.5.6.5
15 years, 5 months
1
0
0
0
milena r4310: Update post-release after code freeze
by Fabien Freling
URL:
https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog: 2009-07-17 Fabien Freling <fabien.freling(a)lrde.epita.fr> Update post-release after code freeze. * mln/core/alias/neighb3d.hh: Add preprocessor command #ifndef. * mln/io/dicom/load.hh: Remove dead code. * mln/io/plot/save.hh: Update save() method for 1D image. * mln/labeling/n_max.hh: Fix algorithm. * mln/world/inter_pixel/display_edge.hh: Add documentation and fix image dimensions. * mln/world/inter_pixel/immerse.hh: Minor update. --- core/alias/neighb3d.hh | 2 ++ io/dicom/load.hh | 6 +++--- io/plot/save.hh | 37 +++++++++++++++---------------------- labeling/n_max.hh | 29 ++++++++++++++++++++++------- world/inter_pixel/display_edge.hh | 37 ++++++++++++++++++++++++++++++------- world/inter_pixel/immerse.hh | 4 ++-- 6 files changed, 74 insertions(+), 41 deletions(-) Index: trunk/milena/mln/world/inter_pixel/immerse.hh =================================================================== --- trunk/milena/mln/world/inter_pixel/immerse.hh (revision 4309) +++ trunk/milena/mln/world/inter_pixel/immerse.hh (revision 4310) @@ -70,8 +70,8 @@ const I& input = exact(input_); mln_precondition(input.is_valid()); - mln_domain(I) b(2 * input.domain().pmin(), - 2 * input.domain().pmax()); + mln_domain(I) b((2 * input.domain().pmin()), + (2 * input.domain().pmax())); mln_concrete(I) output(b); mln_assertion(geom::nsites(output | is_pixel()) == input.domain().nsites()); Index: trunk/milena/mln/world/inter_pixel/display_edge.hh =================================================================== --- trunk/milena/mln/world/inter_pixel/display_edge.hh (revision 4309) +++ trunk/milena/mln/world/inter_pixel/display_edge.hh (revision 4310) @@ -28,12 +28,13 @@ /// \file /// -/// FIXME: insert comment. +/// Create an image for visualizing the values on edges of an +/// inter_pixel image. # include <mln/core/image/image2d.hh> # include <mln/core/image/dmorph/image_if.hh> # include <mln/data/fill.hh> -# include <mln/world/inter_pixel/dim2/is_edge.hh> +# include <mln/world/inter_pixel/is_separator.hh> # include <mln/opt/at.hh> namespace mln @@ -45,17 +46,36 @@ namespace inter_pixel { + /// \brief Create an image which is a copy of the input image with + /// a solid background color and highlighted edges. The image is + /// stretched according to the zoom ratio. + /// + /// \param[in] ima The input image providing edge values. + /// \param[in] bg The background color. + /// \param[in] zoom The zoom ratio. + /// \return A copy of the input image with highlighted edges. + /// + /// \pre \p ima has to be an unmorphed image. + /// + template <typename I> + inline + I display_edge(const I& ima, mln_value(I) bg, unsigned zoom); + +# ifndef MLN_INCLUDE_ONLY + + template <typename I> inline I display_edge(const I& ima, mln_value(I) bg, unsigned zoom) { box2d b = ima.bbox(); - // FIXME: Create a empty box of size 'zoom*zoom' is ima is null. - I output(make::box2d((b.pmin()[0] / 2) * (zoom + 1), (b.pmin()[1] / 2) * (zoom + 1), - (b.pmax()[0] / 2 + 1) * (zoom + 1) - 2, (b.pmax()[1] / 2 + 1) * (zoom + 1) - 2)); + I output(make::box2d(((b.pmin()[0] + 1) / 2) * (zoom + 1), + ((b.pmin()[1] + 1) / 2) * (zoom + 1), + ((b.pmax()[0] + 1) / 2 + 1) * (zoom + 1) - 2, + ((b.pmax()[1] + 1) / 2 + 1) * (zoom + 1) - 2)); data::fill(output, bg); - typedef image_if<const I, dim2::is_edge> edge_t; - edge_t edge = ima | dim2::is_edge(); + typedef image_if<const I, is_separator> edge_t; + edge_t edge = ima | is_separator(); mln_piter(edge_t) p(edge.domain()); for_all(p) if (p.row() % 2) // horizontal edge @@ -75,6 +95,9 @@ return output; } + +# endif // ! MLN_INCLUDE_ONLY + } // end of namespace mln::world::inter_pixel } // end of namespace mln::world Index: trunk/milena/mln/core/alias/neighb3d.hh =================================================================== --- trunk/milena/mln/core/alias/neighb3d.hh (revision 4309) +++ trunk/milena/mln/core/alias/neighb3d.hh (revision 4310) @@ -293,8 +293,10 @@ void from_to_(const bool (&values)[S], neighb3d& nbh) { +# ifndef NDEBUG const int h = unsigned(std::pow(float(S), float(1. / 3.))) / 2; mln_precondition((2 * h + 1) * (2 * h + 1) * (2 * h + 1) == S); +# endif // ! NDEBUG window3d win; from_to_(values, win); mln_precondition(win.is_neighbable_()); Index: trunk/milena/mln/io/dicom/load.hh =================================================================== --- trunk/milena/mln/io/dicom/load.hh (revision 4309) +++ trunk/milena/mln/io/dicom/load.hh (revision 4310) @@ -100,8 +100,8 @@ abort(); } - gdcm::File &file = r.GetFile(); - gdcm::DataSet& ds = file.GetDataSet(); + //gdcm::File &file = r.GetFile(); + //gdcm::DataSet& ds = file.GetDataSet(); gdcm::Image& image = r.GetImage(); @@ -118,7 +118,7 @@ unsigned int offset = 8 - (bits_allocated - bits_stored); unsigned int off_pow = 1; - for (int i = 0; i < offset; ++i) + for (unsigned int i = 0; i < offset; ++i) { off_pow *= 2; } Index: trunk/milena/mln/io/plot/save.hh =================================================================== --- trunk/milena/mln/io/plot/save.hh (revision 4309) +++ trunk/milena/mln/io/plot/save.hh (revision 4310) @@ -45,25 +45,18 @@ namespace plot { - /*! Save a Milena 1D image in a plot file. - * - * \param[in] ima A reference to the image to save. - * \param[out] filename The output file. - * \param[in] start_value The start index value of the plot - * (optional). - */ + /*! \brief Save a Milena 1D image in a plot file. + \param[in] ima A reference to the image to save. + \param[out] filename The output file. */ template <typename I> - void save(image1d<I>& ima, - const std::string& filename, - int start_value = 0); + void save(const image1d<I>& ima, + const std::string& filename); - /*! Save a Milena array in a plot file. - * - * \param[in] arr A reference to the array to save. - * \param[out] filename The output file. - * \param[in] start_value The start index value of the plot - * (optional). - */ + /*! \brief Save a Milena array in a plot file. + \param[in] arr A reference to the array to save. + \param[out] filename The output file. + \param[in] start_value The start index value of the plot + (optional). */ template <typename I> void save(util::array<I>& arr, const std::string& filename, @@ -75,21 +68,21 @@ template <typename I> inline - void save(image1d<I>& ima, const std::string& filename, - int start_value = 0) + void save(const image1d<I>& ima, const std::string& filename) { trace::entering("mln::io::plot::save"); std::ofstream file_out(filename.c_str()); - for (unsigned i = 0; i < ima.ninds(); ++i) - file_out << start_value + i << " " << ima.at_(i) << std::endl; + unsigned end = ima.bbox().pmax().ind(); + for (unsigned i = ima.bbox().pmin().ind(); i <= end; ++i) + file_out << i << " " << ima.at_(i) << std::endl; trace::exiting("mln::io::plot::save"); } template <typename I> inline - void save(util::array<I>& arr, const std::string& filename, + void save(const util::array<I>& arr, const std::string& filename, int start_value = 0) { trace::entering("mln::io::plot::save"); Index: trunk/milena/mln/labeling/n_max.hh =================================================================== --- trunk/milena/mln/labeling/n_max.hh (revision 4309) +++ trunk/milena/mln/labeling/n_max.hh (revision 4310) @@ -34,9 +34,13 @@ /// \file /// /// Construct from a count accumulator of a labeled image an array with -/// the ordered n biggest labels +/// the ordered n biggest labels. /// /// \return an array starting at index 1 +/// +/// \warning The biggest value is stocked at index 0. It generally represents +/// the background and should be ignored. However, it is still accessible +/// if necessary. namespace mln @@ -63,22 +67,33 @@ { trace::entering("mln::labeling::n_max"); - util::array<L> output(n + 1, 0); + mln_precondition(n < in_arr.nelements()); + util::array<L> output(n + 1, 0); + for (unsigned i = 0; i < n + 1; ++i) + output[i] = i; int swap = 0; - for (unsigned i = 0; i < in_arr.nelements(); ++i) + for (int j = n - 1; j > 0; --j) + { + if (in_arr[output[j]] < in_arr[output[j + 1]]) + { + swap = output[j]; + output[j] = output[j + 1]; + output[j + 1] = swap; + } + } + + for (unsigned i = n; i < in_arr.nelements(); ++i) { if (in_arr[i] > in_arr[output[n]]) { output[n] = i; - } - int j = n - 1; - while (j > 0 && in_arr[output[j]] < in_arr[output[j + 1]]) + for (unsigned j = n - 1; j > 0 && in_arr[output[j]] < in_arr[output[j + 1]]; --j) { swap = output[j]; output[j] = output[j + 1]; output[j + 1] = swap; - --j; + } } }
15 years, 5 months
1
0
0
0
4309: Cleanup changelogs.
by Guillaume Lazzara
--- ChangeLog | 4 ---- milena/ChangeLog | 6 +++++- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index af34e10..b9b99a2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,7 +1,3 @@ -2009-07-17 Guillaume Lazzara <lazzara(a)lrde.epita.fr> - - * mln/labeling/compute_image.hh: Fix an invalid assertion. - 2009-07-15 Guillaume Lazzara <lazzara(a)lrde.epita.fr> Improve devtools. diff --git a/milena/ChangeLog b/milena/ChangeLog index afd6cd2..b78f453 100644 --- a/milena/ChangeLog +++ b/milena/ChangeLog @@ -1,6 +1,10 @@ 2009-07-17 Guillaume Lazzara <lazzara(a)lrde.epita.fr> - * doc/Makefile.am: Fix fake-doc rule.. + * doc/Makefile.am: Fix fake-doc rule. + +2009-07-17 Guillaume Lazzara <lazzara(a)lrde.epita.fr> + + * mln/labeling/compute_image.hh: Fix an invalid assertion. 2009-07-16 Edwin Carlinet <carlinet(a)lrde.epita.fr> -- 1.5.6.5
15 years, 5 months
1
0
0
0
4308: doc/Makefile.am: Fix fake-doc rule.
by Guillaume Lazzara
--- milena/ChangeLog | 4 ++++ milena/doc/Makefile.am | 11 ++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/milena/ChangeLog b/milena/ChangeLog index 7e1b63d..afd6cd2 100644 --- a/milena/ChangeLog +++ b/milena/ChangeLog @@ -1,3 +1,7 @@ +2009-07-17 Guillaume Lazzara <lazzara(a)lrde.epita.fr> + + * doc/Makefile.am: Fix fake-doc rule.. + 2009-07-16 Edwin Carlinet <carlinet(a)lrde.epita.fr> Fix dependencies errors in accu/stat Makefile. diff --git a/milena/doc/Makefile.am b/milena/doc/Makefile.am index 1580c1f..61b949f 100644 --- a/milena/doc/Makefile.am +++ b/milena/doc/Makefile.am @@ -157,9 +157,16 @@ fix-refdata: cd examples && $(MAKE) $(AM_MAKEFLAGS) $@ +# Make sure the figures are the first files in EXTRA_DIST. +# Make the 'fake-doc' rule works correctly. +EXTRA_DIST = +$(srcdir)/figures/figures.mk: $(srcdir)/headers.stamp +include $(srcdir)/figures/figures.mk + + fig-convert: $(srcdir)/figures.stamp -EXTRA_DIST = figures.stamp +EXTRA_DIST += figures.stamp $(srcdir)/figures.stamp: $(FIGURES_SRCDIR)/*.p*m rm -f $@.tmp touch $@.tmp @@ -219,7 +226,6 @@ regen-am: @mv -f $(srcdir)/headers.stamp.tmp $(srcdir)/headers.stamp $(srcdir)/examples/examples.mk: $(srcdir)/headers.stamp -$(srcdir)/figures/figures.mk: $(srcdir)/headers.stamp $(srcdir)/outputs/outputs.mk: $(srcdir)/headers.stamp @@ -234,7 +240,6 @@ $(srcdir)/headers.stamp: $(srcdir)/generate_dist_files.sh include $(srcdir)/examples/examples.mk -include $(srcdir)/figures/figures.mk include $(srcdir)/outputs/outputs.mk -- 1.5.6.5
15 years, 5 months
1
0
0
0
4307: mln/labeling/compute_image.hh: Fix an invalid assertion.
by Guillaume Lazzara
--- ChangeLog | 4 ++++ milena/mln/labeling/compute_image.hh | 3 ++- 2 files changed, 6 insertions(+), 1 deletions(-) diff --git a/ChangeLog b/ChangeLog index b9b99a2..af34e10 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2009-07-17 Guillaume Lazzara <lazzara(a)lrde.epita.fr> + + * mln/labeling/compute_image.hh: Fix an invalid assertion. + 2009-07-15 Guillaume Lazzara <lazzara(a)lrde.epita.fr> Improve devtools. diff --git a/milena/mln/labeling/compute_image.hh b/milena/mln/labeling/compute_image.hh index 16a52d7..a96b3bc 100644 --- a/milena/mln/labeling/compute_image.hh +++ b/milena/mln/labeling/compute_image.hh @@ -118,6 +118,7 @@ namespace mln const mln_value(L)& nlabels) { const L& labels = exact(labels_); + (void) nlabels; typedef mln_ch_value(L, A) O; O output; @@ -126,7 +127,7 @@ namespace mln mln_piter(L) p(labels.domain()); for_all(p) { - mln_assertion(labels(p) < nlabels); + mln_assertion(labels(p) <= nlabels); output(p) = a[labels(p)]; } -- 1.5.6.5
15 years, 5 months
1
0
0
0
← Newer
1
2
3
4
5
6
7
8
...
16
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Results per page:
10
25
50
100
200