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
November 2008
----- 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
14 participants
266 discussions
Start a n
N
ew thread
milena r2759: Fix the gaussian_2nd_derivative coef normalisation
by Florian Lesaint
URL:
https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena
ChangeLog: 2008-11-02 Florian Lesaint <florian.lesaint(a)lrde.epita.fr> Fix the gaussian_2nd_derivative coef normalisation. and remove stretch since it can be a problem with float images. * linear/gaussian.hh: Here. --- gaussian.hh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) Index: branches/cleanup-2008/milena/mln/linear/gaussian.hh =================================================================== --- branches/cleanup-2008/milena/mln/linear/gaussian.hh (revision 2758) +++ branches/cleanup-2008/milena/mln/linear/gaussian.hh (revision 2759) @@ -329,6 +329,7 @@ float exp2b0 = exp(2.0 * b0); float scale0 = 1 + exp2b0 - 2 * cos0 * expb0; + scale0 *= scale0 * scale0; float scaleA = a1 * sin0 * expb0 * (1 + expb0 * (2 * cos0 * (1 + exp2b0) + exp2b0 - 6)) + a0 * expb0 * (2 * expb0 * (2 - cos0 * cos0) * (1 - exp2b0) - cos0 * (1 - exp2b0 * exp2b0)); @@ -337,6 +338,7 @@ float exp2b1 = exp(2.0 * b1); float scale1 = 1 + exp2b1 - 2 * cos1 * expb1; + scale1 *= scale1 * scale1; float scaleC = c1 * sin1 * expb1 * (1 + expb1 * (2 * cos1 * (1 + exp2b1) + exp2b1 - 6)) + c0 * expb1 * (2 * expb1 * (2 - cos1 * cos1) * (1 - exp2b1) - cos1 * (1 - exp2b1 * exp2b1)); @@ -393,8 +395,8 @@ /* Convert the result image to the user-requested datatype. FIXME: We are making an unnecessary copy in case the user expects a ntg::float_s image. */ - level::stretch(work_img, out); - //level::paste(work_img, out); + //level::stretch(work_img, out); + level::paste(work_img, out); }
16 years, 1 month
1
0
0
0
r2758: Big cleanup
by Maxime van Noppen
From: Maxime van Noppen <yabo(a)lrde.epita.fr> To: olena-patches(a)lrde.epita.fr Subject: r2758: Big cleanup URL:
https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena/sandbox
ChangeLog: 2008-11-01 Maxime van Noppen <yabo(a)lrde.epita.fr> Big cleanup. * max_tree.hh: Factorize code in generic methods. * v2.cc: Comment and clean code. --- max_tree.hh | 218 +++++++++++++++++++++++++----------------------------------- v2.cc | 111 +++++++++++++++++++++++------- 2 files changed, 177 insertions(+), 152 deletions(-) Index: branches/cleanup-2008/milena/sandbox/classif/max_tree.hh =================================================================== --- branches/cleanup-2008/milena/sandbox/classif/max_tree.hh (revision 2757) +++ branches/cleanup-2008/milena/sandbox/classif/max_tree.hh (revision 2758) @@ -37,21 +37,16 @@ mln_ch_value(I, point) new_parent; mln_ch_value(I, point) zpar; - // image of volumes - image3d<unsigned> vol; - image3d<unsigned> nb_represent; - image3d<double> density; - //tags image3d<bool> is_active; - image3d< algebra::vec<3, double> > mean_color; max_tree_(const I& f, const N& nbh) - : f(f), nbh(nbh), vol(f.domain()), nb_represent(f.domain()), density(f.domain()), - is_active(f.domain()), mean_color(f.domain()), new_parent(f.domain()) + : f(f), nbh(nbh), is_active(f.domain()), new_parent(f.domain()) { run(); level::fill(is_active, true); + + new_parent = parent; } void run() @@ -94,11 +89,11 @@ point active_parent(const point& p) { - if(is_root(p)) - return p; - point node = parent(p); - while (not is_active(node)) - node = parent(node); + point node = new_parent(p); + + while (not is_active(node) && not is_root(node)) + node = new_parent(node); + return node; } @@ -108,163 +103,169 @@ zpar(p) = p; } - void area() + image3d<unsigned> compute_nb_represent() { - 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); - } + image3d<unsigned> nb_represent(f.domain()); - void volume() - { - level::fill(vol, 0); level::fill(nb_represent, 0); - - { mln_fwd_piter(S) p(s); for_all(p) { - vol(p) += 1; nb_represent(p) += f(p); - if (not is_root(p)) - { nb_represent(parent(p)) += nb_represent(p); - vol(parent(p)) += vol(p); } - density(parent(p)) = (nb_represent(parent(p)) - nb_represent(p)) / (double) (vol(parent(p)) - vol(p)); - } - } - - { - mln_fwd_piter(S) p(s); - for_all(p) - { - std::cerr << " Color " << p << std::endl - << " vol = " << vol(p) << " vertices" << std::endl - << " nb_represent = " << nb_represent(p) << std::endl - << " f = " << f(p) << std::endl - << " density = " << density(p) << " representant / vertices " << std::endl << std::endl; - } - } + return nb_represent; } - void density_fusion(float ratio) + image3d<unsigned> compute_volume() { - assert(ratio < 1); + image3d<unsigned> volume(f.domain()); + level::fill(volume, 0); mln_fwd_piter(S) p(s); - for_all(p) - { - if (density(active_parent(p)) > (1 - ratio) * density(p) && - density(active_parent(p)) < (1 + ratio) * density(p)) - is_active(p) = false; - } - } - - void density_closing(float lambda) - { - assert(ratio < 1); - mln_fwd_piter(S) p(s); for_all(p) { - if (density(p) < lambda) - is_active(p) = false; + volume(p) += 1; + if (not is_root(p)) + volume(parent(p)) += volume(p); } + + return volume; } - void compute_mean_color() + image3d< algebra::vec<3, double> > compute_mean_color() { - level::fill(mean_color, make::vec(0, 0, 0)); + image3d< algebra::vec<3, double> > mean_color(f.domain()); + + update_parents(); mln_fwd_piter(S) p(s); for_all(p) mean_color(p) = make::vec(p[0], p[1], p[2]); for_all(p) - mean_color(parent(p)) = (mean_color(parent(p)) + mean_color(p)) / 2.; + mean_color(new_parent(p)) = (mean_color(new_parent(p)) + mean_color(p)) / 2.; - for_all(p) - if (mean_color(p)[0] < 10 && mean_color(p)[1] < 10 && mean_color(p)[2] < 10) - std::cerr << "Warning " << p << " == " << mean_color(p) << std::endl; + return mean_color; } - // Cut components with less represents than lambda - void volume_fusion(int lambda) + template<typename X> + void lumberjack(const X& ima, const mln_value(X)& lambda) { + unsigned progress = 0; + unsigned step = s.nsites() / 100; + mln_fwd_piter(S) p(s); + for_all(p) { - if (vol(p) < lambda) + if (ima(p) < lambda) is_active(p) = false; + + ++progress; + if (progress % step == 0) + { + std::cout << "." << std::flush; + progress = 0; } } - void nb_represent_fusion(int lambda) + std::cout << std::endl; + } + + template<typename X> + void nuclear_fusion(const X& ima, const mln_value(X)& lambda) { + unsigned progress = 0; + unsigned step = s.nsites() / 100; + + update_parents(); + mln_fwd_piter(S) p(s); for_all(p) { - if (nb_represent(p) < lambda) + if (fabs(1 - ima(new_parent(p)) / ima(p)) < lambda) is_active(p) = false; + + ++progress; + if (progress % step == 0) + { + std::cout << "." << std::flush; + progress = 0; } } + std::cout << std::endl; + } + void color_fusion(int lambda) { + unsigned progress = 0; + unsigned step = s.nsites() / 100; + + update_parents(); + mln_fwd_piter(S) p(s); for_all(p) { - if (parent(p)[0] - p[0] < lambda && - parent(p)[1] - p[1] < lambda && - parent(p)[2] - p[2] < lambda) + if (new_parent(p)[0] - p[0] < lambda && + new_parent(p)[1] - p[1] < lambda && + new_parent(p)[2] - p[2] < lambda) is_active(p) = false; - } - } - point active_parent(const point& p) + ++progress; + if (progress % step == 0) { - point node = parent(p); - - while (not is_active(node) && not is_root(node)) - node = parent(node); - - return node; + std::cout << "." << std::flush; + progress = 0; + } + } + std::cout << std::endl; } void update_parents() { + unsigned progress = 0; + unsigned step = s.nsites() / 100; + + std::cout << "Update parents"; + mln_fwd_piter(S) p(s); for_all(p) + { new_parent(p) = active_parent(p); + + ++progress; + if (progress % step == 0) + { + std::cout << "." << std::flush; + progress = 0; + } + } + std::cout << std::endl; } template < typename J > - void to_ppm(const J& ima, const std::string& file, unsigned f) + void to_ppm(const J& ima, const std::string& file, unsigned f, + const image3d< algebra::vec<3, double> >& mean_color) { + update_parents(); + J out(ima.domain()); level::fill(out, value::rgb8(0, 0, 0)); mln_piter(J) p(ima.domain()); for_all(p) { - point3d p3 = point3d(ima(p).red() / f, ima(p).green() / f, ima(p).blue() / f); - point3d node = new_parent(p3); + point3d node = new_parent(point3d(ima(p).red() / f, ima(p).green() / f, ima(p).blue() / f)); out(p) = value::rgb8(static_cast<unsigned char>(mean_color(node)[0] * f), static_cast<unsigned char>(mean_color(node)[1] * f), static_cast<unsigned char>(mean_color(node)[2] * f)); - //out(p) = value::rgb8(mean_color(node)[0] * f, mean_color(node)[1] * f, mean_color(node)[2] * f); } io::ppm::save(out, file); @@ -272,41 +273,9 @@ unsigned number_of_nodes() { - p_array<point> node; - - mln_fwd_piter(S) p(s); - for_all(p) - if (is_node(p)) - node.insert(p); - - std::cout << s.nsites() << std::endl; - std::cout << parent.domain().nsites() << std::endl; - std::cout << node.nsites() << std::endl; - return s.nsites(); } - void print_class_info() - { - int nb_class = 0; - - mln_fwd_piter(S) p(s); - - //std::cout.width(5); - std::cout.precision(2); - - std::cout << "Color\t\tId\t\tdensity\t\tvolume\t\tnb_represent" << std::endl; - - for_all(p) - { - if (is_active(p)) - { - std::cout << mean_color(p) << "\t\t" << nb_class << "\t\t" << density(p) << "\t\t" << vol(p) << "\t\t" << nb_represent(p) << std::endl; - ++nb_class; - } - } - } - bool is_root(const point& p) const { return parent(p) == p; @@ -334,7 +303,6 @@ zpar(r) = p; } } - }; Index: branches/cleanup-2008/milena/sandbox/classif/v2.cc =================================================================== --- branches/cleanup-2008/milena/sandbox/classif/v2.cc (revision 2757) +++ branches/cleanup-2008/milena/sandbox/classif/v2.cc (revision 2758) @@ -38,45 +38,100 @@ return histo; } +template <typename I> +image3d< double > +compute_density(const I& weight, const I& volume) +{ + image3d< double > density(volume.domain()); + + mln_piter(I) p(volume.domain()); + for_all(p) + density(p) = weight(p) / volume(p); + + return density; +} + template <typename I, typename J, typename N> unsigned -compute_max_tree(const I& ima, const J& histo, const N& nbh, - const unsigned f, float lambda, float ratio) +process_max_tree(const I& ima, const J& histo, const N& nbh, + double density_lambda, unsigned volume_lambda, + unsigned nb_represent_lambda, unsigned color_lambda, + unsigned div_factor) { max_tree_<J,N> run(histo, nbh); - run.volume(); + // FIXME: write a compute() method with functor argument + image3d<unsigned> nb_represent = run.compute_nb_represent(); + image3d<unsigned> volume = run.compute_volume(); + image3d< algebra::vec<3, double> > mean_color = run.compute_mean_color(); + image3d<double> density = compute_density(nb_represent, volume); - std::cout << "step 1 - nb_represent fusion" << std::endl; - //run.nb_represent_fusion(lambda); - std::cout << "step 2 - volume fusion" << std::endl; - //run.volume_fusion(lambda); - std::cout << "step 3 - color fusion" << std::endl; - //run.color_fusion(lambda); - std::cout << "step 3 - density fusion" << std::endl; - //run.density_fusion(ratio); + // Density closing + if (density_lambda > 0.00001) + { + std::cout << "Density cutting" << std::endl; + run.nuclear_fusion(density, density_lambda); + } - std::cout << "step Update parents" << std::endl; - run.update_parents(); + // Volume cutting + if (volume_lambda != 0) + { + std::cout << "Volume cutting" << std::endl; + run.lumberjack(volume, volume_lambda); + } + + // Represent cutting + if (nb_represent_lambda != 0) + { + std::cout << "nb_represent cutting" << std::endl; + run.lumberjack(nb_represent, nb_represent_lambda); + } + + // Color fusion + if (color_lambda != 0) + { + std::cout << "Color fusion" << std::endl; + run.color_fusion(color_lambda); // FIXME: factorize the code with a functor + } - std::cout << "step Compute mean color" << std::endl; + // Compute mean color of active nodes + std::cout << "Compute mean color" << std::endl; run.compute_mean_color(); - std::cout << "step Print class info" << std::endl; - run.print_class_info(); + // Print informations on the filtered max tree + { + int nb_class = 0; + + mln_piter(image3d<unsigned>) p(nb_represent.domain()); + + std::cerr.precision(2); + + std::cerr << "Color\t\tId\t\tdensity\t\tvolume\t\tnb_represent" << std::endl; + + for_all(p) + if (run.is_active(p)) + { + std::cerr << mean_color(p) << "\t\t" << nb_class << "\t\t" << density(p) << "\t\t" << volume(p) << "\t\t" << nb_represent(p) << std::endl; + ++nb_class; + } - std::cout << "step Output image" << std::endl; - run.to_ppm(ima, "out.ppm", f); + std::cout << "Number of classes : " << nb_class << std::endl; + } + + + // Write the image w.r.t. the max tree + run.to_ppm(ima, "out.ppm", div_factor, mean_color); } bool usage(int argc, char ** argv) { - if (argc != 5) + if (argc != 7) { - std::cout << "usage: " << argv[0] << " image div_factor lambda ratio" << std::endl; + std::cout << "usage: " << argv[0] << " image div_factor density_lambda volume_lambda nb_represent_lambda color_lambda" << std::endl; return false; } + return true; } @@ -86,10 +141,14 @@ return 1; image2d<value::rgb8> ima; + ima = io::ppm::load<value::rgb8>(argv[1]); - const int div_factor = atoi(argv[2]); - const float lambda = atof(argv[3]); - const float ratio = atof(argv[4]); + + int div_factor = atoi(argv[2]); + float density_lambda = atof(argv[3]); + unsigned volume_lambda = atoi(argv[4]); + unsigned nb_represent_lambda = atoi(argv[5]); + unsigned color_lambda = atoi(argv[6]); //make histo image3d<unsigned> histo = fill_histo(ima, div_factor); @@ -98,8 +157,6 @@ accu::mean<unsigned, unsigned, unsigned> mean; image2d<unsigned> phisto = proj(histo, mean); - //debug::println(phisto); - - // Compute max_tree - compute_max_tree(ima, histo, c6(), div_factor, lambda, ratio); + // Process max_tree + process_max_tree(ima, histo, c6(), density_lambda, volume_lambda, nb_represent_lambda, color_lambda, div_factor); }
16 years, 1 month
1
0
0
0
r2757: Merge the filter chain
by Maxime van Noppen
From: Maxime van Noppen <yabo(a)lrde.epita.fr> To: olena-patches(a)lrde.epita.fr Subject: r2757: Merge the filter chain URL:
https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena/sandbox
ChangeLog: 2008-11-01 Maxime van Noppen <yabo(a)lrde.epita.fr> Merge the filter chain. * max_tree.hh: Add a new_parent image to avoid computing them all * the time. * v2.cc: Define a filter chain order. --- max_tree.hh | 28 ++++++++++++++++++++-------- v2.cc | 21 ++++++++++++++++----- 2 files changed, 36 insertions(+), 13 deletions(-) Index: branches/cleanup-2008/milena/sandbox/classif/max_tree.hh =================================================================== --- branches/cleanup-2008/milena/sandbox/classif/max_tree.hh (revision 2756) +++ branches/cleanup-2008/milena/sandbox/classif/max_tree.hh (revision 2757) @@ -34,6 +34,7 @@ S s; mln_ch_value(I, bool) deja_vu; mln_ch_value(I, point) parent; + mln_ch_value(I, point) new_parent; mln_ch_value(I, point) zpar; // image of volumes @@ -47,7 +48,7 @@ max_tree_(const I& f, const N& nbh) : f(f), nbh(nbh), vol(f.domain()), nb_represent(f.domain()), density(f.domain()), - is_active(f.domain()), mean_color(f.domain()) + is_active(f.domain()), mean_color(f.domain()), new_parent(f.domain()) { run(); level::fill(is_active, true); @@ -231,6 +232,23 @@ } } + point active_parent(const point& p) + { + point node = parent(p); + + while (not is_active(node) && not is_root(node)) + node = parent(node); + + return node; + } + + void update_parents() + { + mln_fwd_piter(S) p(s); + for_all(p) + new_parent(p) = active_parent(p); + } + template < typename J > void to_ppm(const J& ima, const std::string& file, unsigned f) { @@ -241,13 +259,7 @@ for_all(p) { point3d p3 = point3d(ima(p).red() / f, ima(p).green() / f, ima(p).blue() / f); - - point3d node = p3; - if (not is_node(p3)) - node = parent(p3); - - while (not is_active(node)) - node = parent(node); + point3d node = new_parent(p3); out(p) = value::rgb8(static_cast<unsigned char>(mean_color(node)[0] * f), static_cast<unsigned char>(mean_color(node)[1] * f), Index: branches/cleanup-2008/milena/sandbox/classif/v2.cc =================================================================== --- branches/cleanup-2008/milena/sandbox/classif/v2.cc (revision 2756) +++ branches/cleanup-2008/milena/sandbox/classif/v2.cc (revision 2757) @@ -45,18 +45,29 @@ { max_tree_<J,N> run(histo, nbh); - //run.number_of_nodes(); run.volume(); - run.volume_fusion(lambda); - run.density_fusion(ratio); + std::cout << "step 1 - nb_represent fusion" << std::endl; + //run.nb_represent_fusion(lambda); + std::cout << "step 2 - volume fusion" << std::endl; + //run.volume_fusion(lambda); + std::cout << "step 3 - color fusion" << std::endl; + //run.color_fusion(lambda); + std::cout << "step 3 - density fusion" << std::endl; + //run.density_fusion(ratio); + + std::cout << "step Update parents" << std::endl; + run.update_parents(); + + std::cout << "step Compute mean color" << std::endl; run.compute_mean_color(); - run.to_ppm(ima, "out.ppm", f); + std::cout << "step Print class info" << std::endl; run.print_class_info(); - //std::cout << " Number of nodes : " << run.number_of_nodes() << std::endl; + std::cout << "step Output image" << std::endl; + run.to_ppm(ima, "out.ppm", f); } bool usage(int argc, char ** argv)
16 years, 1 month
1
0
0
0
cleanup-2008 2756: INIM: Classif: Work on density.
by Ugo Jardonnet
https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena/sandbox
Index: ChangeLog from Ugo Jardonnet <ugo.jardonnet(a)lrde.epita.fr> INIM: Classif: Work on density. * classif/max_tree.hh (density closing|fusion): Add. * classif/v2.cc: Add parameter. max_tree.hh | 40 +++++++++++++++++++++++++++++++++++++--- v2.cc | 36 +++++++++++------------------------- 2 files changed, 48 insertions(+), 28 deletions(-) Index: classif/max_tree.hh --- classif/max_tree.hh (revision 2755) +++ classif/max_tree.hh (working copy) @@ -91,6 +91,16 @@ } // end of run() + point active_parent(const point& p) + { + if(is_root(p)) + return p; + point node = parent(p); + while (not is_active(node)) + node = parent(node); + return node; + } + void make_set(const point& p) { parent(p) = p; @@ -124,13 +134,13 @@ vol(p) += 1; nb_represent(p) += f(p); - if (parent(p) != p) + if (not is_root(p)) { nb_represent(parent(p)) += nb_represent(p); vol(parent(p)) += vol(p); } - density(p) = nb_represent(p) / (double) vol(p); + density(parent(p)) = (nb_represent(parent(p)) - nb_represent(p)) / (double) (vol(parent(p)) - vol(p)); } } @@ -147,6 +157,31 @@ } } + void density_fusion(float ratio) + { + assert(ratio < 1); + + mln_fwd_piter(S) p(s); + for_all(p) + { + if (density(active_parent(p)) > (1 - ratio) * density(p) && + density(active_parent(p)) < (1 + ratio) * density(p)) + is_active(p) = false; + } + } + + void density_closing(float lambda) + { + assert(ratio < 1); + + mln_fwd_piter(S) p(s); + for_all(p) + { + if (density(p) < lambda) + is_active(p) = false; + } + } + void compute_mean_color() { level::fill(mean_color, make::vec(0, 0, 0)); @@ -214,7 +249,6 @@ while (not is_active(node)) node = parent(node); -write: out(p) = value::rgb8(static_cast<unsigned char>(mean_color(node)[0] * f), static_cast<unsigned char>(mean_color(node)[1] * f), static_cast<unsigned char>(mean_color(node)[2] * f)); Index: classif/v2.cc --- classif/v2.cc (revision 2755) +++ classif/v2.cc (working copy) @@ -40,45 +40,30 @@ template <typename I, typename J, typename N> unsigned -compute_max_tree(const I& ima, const J& histo, const N& nbh, const unsigned f, int lambda) +compute_max_tree(const I& ima, const J& histo, const N& nbh, + const unsigned f, float lambda, float ratio) { max_tree_<J,N> run(histo, nbh); -#if 0 - I out(ima.domain()); - mln_piter(I) p(ima.domain()); - for_all(p) - { - //color at ima(p) - point3d v = point3d(ima(p).red() / f, - ima(p).green() / f, - ima(p).blue() / f); - //node the class of color with same density as v - point3d pn = run.parent(v); - //out(p) = color pn - out(p) = value::rgb8(pn[0] * f, pn[1] * f, pn[2] * f); - } - io::ppm::save(out, "tmp.ppm"); -#endif //run.number_of_nodes(); - run.volume(); - run.nb_represent_fusion(lambda); + run.volume(); run.volume_fusion(lambda); - run.color_fusion(5); + run.density_fusion(ratio); run.compute_mean_color(); - run.print_class_info(); run.to_ppm(ima, "out.ppm", f); + run.print_class_info(); + //std::cout << " Number of nodes : " << run.number_of_nodes() << std::endl; } bool usage(int argc, char ** argv) { - if (argc != 4) + if (argc != 5) { - std::cout << "usage: " << argv[0] << " image div_factor lambda" << std::endl; + std::cout << "usage: " << argv[0] << " image div_factor lambda ratio" << std::endl; return false; } return true; @@ -92,7 +77,8 @@ image2d<value::rgb8> ima; ima = io::ppm::load<value::rgb8>(argv[1]); const int div_factor = atoi(argv[2]); - const int lambda = atoi(argv[3]); + const float lambda = atof(argv[3]); + const float ratio = atof(argv[4]); //make histo image3d<unsigned> histo = fill_histo(ima, div_factor); @@ -104,5 +90,5 @@ //debug::println(phisto); // Compute max_tree - compute_max_tree(ima, histo, c6(), div_factor, lambda); + compute_max_tree(ima, histo, c6(), div_factor, lambda, ratio); }
16 years, 1 month
1
0
0
0
r2754: Allow to chain filters
by Maxime van Noppen
From: Maxime van Noppen <yabo(a)lrde.epita.fr> To: olena-patches(a)lrde.epita.fr Subject: r2754: Allow to chain filters URL:
https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena/sandbox
ChangeLog: 2008-11-01 Maxime van Noppen <yabo(a)lrde.epita.fr> Allow to chain filters. * max_tree.hh: Here. * v2.cc: Chain filters. --- max_tree.hh | 24 +++++++++++++++++++----- v2.cc | 5 +++++ 2 files changed, 24 insertions(+), 5 deletions(-) Index: branches/cleanup-2008/milena/sandbox/classif/max_tree.hh =================================================================== --- branches/cleanup-2008/milena/sandbox/classif/max_tree.hh (revision 2753) +++ branches/cleanup-2008/milena/sandbox/classif/max_tree.hh (revision 2754) @@ -50,6 +50,7 @@ is_active(f.domain()), mean_color(f.domain()) { run(); + level::fill(is_active, true); } void run() @@ -165,8 +166,6 @@ // Cut components with less represents than lambda void volume_fusion(int lambda) { - level::fill(is_active, true); - mln_fwd_piter(S) p(s); for_all(p) { @@ -177,8 +176,6 @@ void nb_represent_fusion(int lambda) { - level::fill(is_active, true); - mln_fwd_piter(S) p(s); for_all(p) { @@ -187,6 +184,18 @@ } } + void color_fusion(int lambda) + { + mln_fwd_piter(S) p(s); + for_all(p) + { + if (parent(p)[0] - p[0] < lambda && + parent(p)[1] - p[1] < lambda && + parent(p)[2] - p[2] < lambda) + is_active(p) = false; + } + } + template < typename J > void to_ppm(const J& ima, const std::string& file, unsigned f) { @@ -237,11 +246,16 @@ mln_fwd_piter(S) p(s); + //std::cout.width(5); + std::cout.precision(2); + + std::cout << "Color\t\tId\t\tdensity\t\tvolume\t\tnb_represent" << std::endl; + for_all(p) { if (is_active(p)) { - std::cout << "Class " << nb_class << " : " << p << std::endl; + std::cout << mean_color(p) << "\t\t" << nb_class << "\t\t" << density(p) << "\t\t" << vol(p) << "\t\t" << nb_represent(p) << std::endl; ++nb_class; } } Index: branches/cleanup-2008/milena/sandbox/classif/v2.cc =================================================================== --- branches/cleanup-2008/milena/sandbox/classif/v2.cc (revision 2753) +++ branches/cleanup-2008/milena/sandbox/classif/v2.cc (revision 2754) @@ -62,8 +62,13 @@ //run.number_of_nodes(); run.volume(); + run.nb_represent_fusion(lambda); + run.volume_fusion(lambda); + run.color_fusion(5); + run.compute_mean_color(); + run.print_class_info(); run.to_ppm(ima, "out.ppm", f); //std::cout << " Number of nodes : " << run.number_of_nodes() << std::endl;
16 years, 1 month
1
0
0
0
r2753: Add some debug infos and some filters on max trees
by Maxime van Noppen
From: Maxime van Noppen <yabo(a)lrde.epita.fr> To: olena-patches(a)lrde.epita.fr Subject: r2753: Add some debug infos and some filters on max trees URL:
https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena/sandbox
ChangeLog: 2008-11-01 Maxime van Noppen <yabo(a)lrde.epita.fr> Add some debug infos and some filters on max trees. * max_tree.hh, * v2.cc: Here. --- max_tree.hh | 40 ++++++++++++++++++++++++++++++++++------ v2.cc | 2 +- 2 files changed, 35 insertions(+), 7 deletions(-) Index: branches/cleanup-2008/milena/sandbox/classif/max_tree.hh =================================================================== --- branches/cleanup-2008/milena/sandbox/classif/max_tree.hh (revision 2752) +++ branches/cleanup-2008/milena/sandbox/classif/max_tree.hh (revision 2753) @@ -156,9 +156,14 @@ for_all(p) mean_color(parent(p)) = (mean_color(parent(p)) + mean_color(p)) / 2.; + + for_all(p) + if (mean_color(p)[0] < 10 && mean_color(p)[1] < 10 && mean_color(p)[2] < 10) + std::cerr << "Warning " << p << " == " << mean_color(p) << std::endl; } - void simple_filter_1(int lambda) + // Cut components with less represents than lambda + void volume_fusion(int lambda) { level::fill(is_active, true); @@ -170,6 +175,18 @@ } } + void nb_represent_fusion(int lambda) + { + level::fill(is_active, true); + + mln_fwd_piter(S) p(s); + for_all(p) + { + if (nb_represent(p) < lambda) + is_active(p) = false; + } + } + template < typename J > void to_ppm(const J& ima, const std::string& file, unsigned f) { @@ -183,12 +200,7 @@ point3d node = p3; if (not is_node(p3)) - { - if (is_active(parent(p3))) - goto write; - node = parent(p3); - } while (not is_active(node)) node = parent(node); @@ -219,6 +231,22 @@ return s.nsites(); } + void print_class_info() + { + int nb_class = 0; + + mln_fwd_piter(S) p(s); + + for_all(p) + { + if (is_active(p)) + { + std::cout << "Class " << nb_class << " : " << p << std::endl; + ++nb_class; + } + } + } + bool is_root(const point& p) const { return parent(p) == p; Index: branches/cleanup-2008/milena/sandbox/classif/v2.cc =================================================================== --- branches/cleanup-2008/milena/sandbox/classif/v2.cc (revision 2752) +++ branches/cleanup-2008/milena/sandbox/classif/v2.cc (revision 2753) @@ -62,7 +62,7 @@ //run.number_of_nodes(); run.volume(); - run.simple_filter_1(lambda); + run.nb_represent_fusion(lambda); run.compute_mean_color(); run.to_ppm(ima, "out.ppm", f);
16 years, 1 month
1
0
0
0
← Newer
1
...
24
25
26
27
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
Results per page:
10
25
50
100
200