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
2025
January
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
----- 2025 -----
January 2025
----- 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
9625 discussions
Start a n
N
ew thread
3062: Handle data mutability in pw::image.
by Thierry Geraud
https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog from Thierry Geraud <thierry.geraud(a)lrde.epita.fr> Handle data mutability in pw::image. * mln/trait/images.hh: Upgrade doc style. * mln/core/site_set/p_array.hh (operator int, operator unsigned): New in p_indexed_psite. * mln/core/concept/function.hh (is_mutable): New. * mln/fun/l2l/relabel.hh: Likewise. * mln/fun/i2v/array.hh: Likewise. * mln/fun/internal/array_base.hh: Likewise. * mln/pw/image.hh (value_io, pw_io): Allow mutability. * tests/pw/image.cc: Add a test on a mutable image. mln/core/concept/function.hh | 1 + mln/core/site_set/p_array.hh | 18 ++++++++++++++++++ mln/fun/i2v/array.hh | 4 ++++ mln/fun/internal/array_base.hh | 1 + mln/fun/l2l/relabel.hh | 3 +-- mln/pw/image.hh | 26 ++++++++++++++++++-------- mln/trait/images.hh | 18 +++++++++--------- tests/pw/image.cc | 19 ++++++++++++++++++- 8 files changed, 70 insertions(+), 20 deletions(-) Index: mln/trait/images.hh --- mln/trait/images.hh (revision 3061) +++ mln/trait/images.hh (working copy) @@ -1,4 +1,5 @@ // Copyright (C) 2007, 2008 EPITA Research and Development Laboratory +// (LRDE) // // This file is part of the Olena Library. This library is free // software; you can redistribute it and/or modify it under the terms @@ -28,14 +29,13 @@ #ifndef MLN_TRAIT_IMAGES_HH # define MLN_TRAIT_IMAGES_HH -/*! \file mln/trait/images.hh - * - * \brief Some base trait types for images. - * - * \todo Split this file into many. - * - * \todo the 'nature' prop is not set yet in image types. - */ +/// \file mln/trait/images.hh +/// +/// Some base trait types for images. +/// +/// \todo Split this file into many. +/// +/// \todo the 'nature' prop is not set yet in image types. # include <iostream> # include <string> @@ -113,7 +113,7 @@ template <typename T> struct image1d; template <typename T> struct image2d; template <typename T> struct image3d; - namespace pw { template <typename F, typename S> struct image; } + namespace pw { template <typename F, typename S> class image; } template <typename P, typename T> class rle_image; template <typename P, typename T> class sparse_image; Index: mln/core/site_set/p_array.hh --- mln/core/site_set/p_array.hh (revision 3061) +++ mln/core/site_set/p_array.hh (working copy) @@ -1,4 +1,5 @@ // Copyright (C) 2007, 2008 EPITA Research and Development Laboratory +// (LRDE) // // This file is part of the Olena Library. This library is free // software; you can redistribute it and/or modify it under the terms @@ -206,6 +207,8 @@ bool is_valid() const; operator util::index() const; + operator int() const; // To interoperate, e.g., with fun::i2v expecting an int. + operator unsigned() const; // To avoid ambiguity when an unsigned is expected. void update_() const; @@ -586,6 +589,21 @@ return i_; } + template <typename S> + inline + p_indexed_psite<S>::operator int() const + { + return i_; + } + + template <typename S> + inline + p_indexed_psite<S>::operator unsigned() const + { + mln_precondition(i_ >= 0); + return i_; + } + // p_indexed_fwd_piter<S>. Index: mln/core/concept/function.hh --- mln/core/concept/function.hh (revision 3061) +++ mln/core/concept/function.hh (working copy) @@ -100,6 +100,7 @@ struct Function_v2v : public Function<E> { typedef Function_v2v<void> category; + typedef metal::false_ is_mutable; // Meaning: no mutable result by default. protected: Function_v2v(); Function_v2v(const Function_v2v&); Index: mln/pw/image.hh --- mln/pw/image.hh (revision 3061) +++ mln/pw/image.hh (working copy) @@ -44,7 +44,7 @@ { // Fwd decl. - namespace pw { template <typename F, typename S> struct image; } + namespace pw { template <typename F, typename S> class image; } @@ -93,10 +93,14 @@ typedef trait::image::value_storage::disrupted value_storage; typedef trait::image::value_browsing::site_wise_only value_browsing; typedef trait::image::value_alignement::irrelevant value_alignement; - typedef trait::image::value_io::read_only value_io; + typedef mlc_if(typename F::is_mutable, + trait::image::value_io::read_write, + trait::image::value_io::read_only) value_io; // site / domain - typedef trait::image::pw_io::read pw_io; + typedef mlc_if(typename F::is_mutable, + trait::image::pw_io::read_write, + trait::image::pw_io::read) pw_io; typedef /* FIXME: depends on S */ undef localization; typedef /* FIXME: depends on S */ undef dimension; @@ -115,9 +119,11 @@ /// FIXME /// template <typename F, typename S> - struct image : + class image : public internal::image_primary<mln_result(F), S, image<F,S> > { + public: + /// Skeleton. typedef image< tag::function_<F>, tag::pset_<S> > skeleton; @@ -129,7 +135,7 @@ typedef mln_result(F) rvalue; /// Return type of read-write access. - typedef rvalue lvalue; + typedef mlc_if(typename F::is_mutable, mln_result(F)&, mln_result(F)) lvalue; /// Constructor without argument. image(); @@ -149,12 +155,15 @@ /// Read-only access of pixel value at point site \p p. mln_result(F) operator()(const mln_psite(S)& p) const; - /// Read-write access is present but return a temporary value. - mln_result(F) operator()(const mln_psite(S)&); + /// Read-write access returns either a temporary value (copy) or + /// a reference in the case of a mutable function (container). + lvalue operator()(const mln_psite(S)&); }; } // end of namespace mln::pw + + template <typename F, typename S> void init_(tag::function_t, Function_v2v<F>& target, const mln::pw::image<F,S>& model); @@ -163,6 +172,7 @@ void init_(tag::image_t, mln::pw::image<F,S>& target, const J& model); + # ifndef MLN_INCLUDE_ONLY // init_ @@ -264,7 +274,7 @@ template <typename F, typename S> inline - mln_result(F) + typename image<F,S>::lvalue image<F,S>::operator()(const mln_psite(S)& p) { mln_precondition(this->data_->pset_.has(p)); Index: mln/fun/l2l/relabel.hh --- mln/fun/l2l/relabel.hh (revision 3061) +++ mln/fun/l2l/relabel.hh (working copy) @@ -106,8 +106,7 @@ /// Always prefer using from_to instead of this constructor. relabel(const std::vector<L>& from); - /// \} - + typedef metal::true_ is_mutable; }; } // end of namespace mln::fun::l2l Index: mln/fun/i2v/array.hh --- mln/fun/i2v/array.hh (revision 3061) +++ mln/fun/i2v/array.hh (working copy) @@ -31,6 +31,9 @@ /// \file mln/fun/i2v/array.hh /// /// Function mapping an Id i to a value v. +/// +/// \todo Change design so that there is no multiple inheritance: +/// array<T> : internal::array_base<T, E==array<T> > : Function_i2v<E> # include <vector> # include <algorithm> @@ -107,6 +110,7 @@ /// \} + typedef metal::true_ is_mutable; }; } // end of namespace mln::fun::i2v Index: mln/fun/internal/array_base.hh --- mln/fun/internal/array_base.hh (revision 3061) +++ mln/fun/internal/array_base.hh (working copy) @@ -53,6 +53,7 @@ public: typedef T result; + typedef metal::true_ is_mutable; void resize(unsigned n); void resize(unsigned n, const T& val); Index: tests/pw/image.cc --- tests/pw/image.cc (revision 3061) +++ tests/pw/image.cc (working copy) @@ -31,7 +31,9 @@ /// Tests on mln::pw::image. #include <mln/fun/p2b/chess.hh> +#include <mln/fun/i2v/array.hh> #include <mln/core/alias/box2d.hh> +#include <mln/core/site_set/p_array.hh> #include <mln/pw/image.hh> #include <mln/core/var.hh> @@ -41,8 +43,10 @@ using namespace mln; mln_VAR(ima, fun::p2b::chess() | make::box2d(8, 8)); - mln_piter_(ima_t) p(ima.domain()); + // trait::image::print(ima); + unsigned i = 0; + mln_piter_(ima_t) p(ima.domain()); for_all(p) { if (p.row() % 2) @@ -52,4 +56,17 @@ ++i; } mln_assertion(i == 64); + + // A mutable pw::image. + { + p_array<int> arr; // Sites are ints (why not?) + arr.insert(51); // Site 51. + mln_VAR(ima, fun::i2v::array<int>(1) | arr); // An array psite converts to int so that works :-) + // trait::image::print(ima); + + p_array<int>::psite p(ima.domain(), 0); // index 0 means the 1st element of arr + ima(p) = 7; + mln_assertion(ima(p) == 7); + } + }
16Â years, 1Â month
1
0
0
0
3061: Spot differences between step2 and n_cmpt5.
by Ugo Jardonnet
https://svn.lrde.epita.fr/svn/oln/trunk/milena/sandbox
Index: ChangeLog from Ugo Jardonnet <ugo.jardonnet(a)lrde.epita.fr> Spot differences between step2 and n_cmpt5. * jardonnet/n_cmpt/prob.pgm: Test case. * jardonnet/n_cmpt/fused_filter.cc: Version using boolean image. * jardonnet/n_cmpt/ref_filter.cc: Version using set. * jardonnet/n_cmpt/n_cmpt5.hh: Minor change. * jardonnet/n_cmpt/fused: Log. * jardonnet/n_cmpt/ref: Log. * jardonnet/n_cmpt/Makefile: Add related rules. * jardonnet/n_cmpt/diff_ref_fused_on_small: diff. igr/Makefile | 2 igr/src/igr.cc | 8 - n_cmpt/Makefile | 26 ++-- n_cmpt/diff_ref_fused_on_small | 13 ++ n_cmpt/fused | 26 ++++ n_cmpt/fused_filter.cc | 252 +++++++++++++++++++++++++++++++++++++++++ n_cmpt/n_cmpt5.hh | 14 +- n_cmpt/prob.pgm | 5 n_cmpt/ref | 22 +++ n_cmpt/ref_filter.cc | 224 ++++++++++++++++++++++++++++++++++++ test/big_chess.cc | 21 ++- 11 files changed, 586 insertions(+), 27 deletions(-) Index: jardonnet/test/big_chess.cc --- jardonnet/test/big_chess.cc (revision 3060) +++ jardonnet/test/big_chess.cc (working copy) @@ -8,9 +8,12 @@ #include <mln/core/image/image2d.hh> #include <mln/value/int_u8.hh> +#include <mln/value/rgb8.hh> #include <mln/io/pgm/load.hh> #include <mln/level/paste.hh> -#include <mln/io/pgm/save.hh> + +#include <mln/io/ppm/load.hh> +#include <mln/io/ppm/save.hh> #include <mln/fun/p2b/big_chess.hh> @@ -19,9 +22,9 @@ bool usage(int argc, char ** argv) { - if (argc != 3) + if (argc != 4) { - std::cout << argv[0] << " ima1.pgm ima2.pgm" << std::endl; + std::cout << argv[0] << " ima1.pgm ima2.pgm div" << std::endl; return false; } return true; @@ -52,14 +55,16 @@ if (not usage(argc,argv)) return 1; - typedef image2d<int_u8> I; + typedef image2d<rgb8> I; I ima1; I ima2; - io::pgm::load(ima1, argv[1]); - io::pgm::load(ima2, argv[2]); + io::ppm::load(ima1, argv[1]); + io::ppm::load(ima2, argv[2]); + + int div = atoi(argv[3]); - fun::p2b::big_chess<box2d> fun(ima1.domain(), 4); + fun::p2b::big_chess<box2d> fun(ima1.domain(), div); image_if< I, fun::p2b::big_chess<box2d> > visio = ima1 | fun; @@ -67,5 +72,5 @@ level::paste(visio, ima2); - io::pgm::save(ima2, "out.ppm"); + io::ppm::save(ima2, "out.ppm"); } Index: jardonnet/n_cmpt/prob.pgm --- jardonnet/n_cmpt/prob.pgm (revision 0) +++ jardonnet/n_cmpt/prob.pgm (revision 0) @@ -0,0 +1,5 @@ +P5 +# CREATOR: GIMP PNM Filter Version 1.1 +24 22 +255 +��������`fijjqy~���������������~^chhhpy}���������������^cighpx|��������������~\chghox|�������������}[bgfgowz}~�����������|Ybgfgowz|}~����������~X`ggipx{}~������������}T\bdhovy{|~�����ex���|QYacfkruy{|wyz��zUy���zP[ccekqtxyxou{�`Vz���yR[bdekquy{xnrwx{jXYy���xS\bdekrvyyoousvYZZx���yR[cceksv{soqsv~�Z[Zx���zRYadekru�jmpsz��ZZWv���{PW_bejm~�gnqv���[][u���yNVacdil��emrz}~`b`w���|QZcefln��dksy{~{ccbz���~S[cedim�fhnvy{�cbcz���RZbccfp��nipv{��a`ay����S[bbcds��}imv���`_`{����T\bacas���mp����aad~����QZaab_u���z{��� \ No newline at end of file Index: jardonnet/n_cmpt/fused_filter.cc --- jardonnet/n_cmpt/fused_filter.cc (revision 0) +++ jardonnet/n_cmpt/fused_filter.cc (revision 0) @@ -0,0 +1,252 @@ +#include <mln/core/image/image2d.hh> +#include <mln/value/int_u8.hh> +#include <mln/io/pgm/load.hh> +#include <mln/debug/println.hh> + +#include <mln/core/site_set/p_array.hh> +#include <mln/level/sort_psites.hh> +#include <mln/core/alias/neighb2d.hh> +#include <mln/morpho/tree/data.hh> + +#include <mln/accu/count.hh> +#include <mln/util/set.hh> + +#include <mln/labeling/regional_minima.hh> +#include <mln/morpho/tree/compute_attribute_image.hh> +#include <mln/morpho/closing_area.hh> +#include <mln/level/fill.hh> + +#include <mln/debug/iota.hh> + +#include <mln/pw/all.hh> +#include <mln/core/image/image_if.hh> + +namespace mln +{ + + template <typename I> + void println_par(const I& par) + { + int nr = par.nrows(), nc = par.ncols(); + for (int r = 0; r < nr; ++r) + { + for (int c = 0; c < nc; ++c) + if (par.at(r,c) == point2d(r,c)) + std::cout << "( ) "; + else + std::cout << par.at(r,c) << ' '; + std::cout << std::endl; + } + } + + template <typename P> + inline + mln_value(P) find_root__(P& par, const mln_value(P)& x) + { + if (par(x) == x) + return x; + else + return par(x) = find_root__(par, par(x)); + } + + + template <typename I, typename A, typename N> + mln_ch_value(I, util::set<unsigned>) + compute_labels(const I& f, const A& a, const N& nbh, + unsigned n_objects, + bool echo = false) + { + if (echo) + debug::println("f =", f); + + typedef p_array<mln_psite(I)> S; + S s = level::sort_psites_increasing(a); + // s maps increasing attributes. + + mln_ch_value(I, mln_site(I)) par; + mln_ch_value(I, bool) deja_vu; + mln_ch_value(I, util::set<unsigned>) labels; + unsigned nbassins, current_n; + + // init fused image + mln_ch_value(I, bool) fused; + initialize(fused, a); + mln::level::fill(fused, false); + + // iota + mln_ch_value(I,value::int_u<16>) iota(a.domain()); + debug::iota(iota); + + // labels + mln_ch_value(I, unsigned) regmin = labeling::regional_minima(a, nbh, + nbassins); + + { + // Initialization. + mln_piter(A) p(f.domain()); + + // parent + initialize(par, f); + for_all(p) + par(p) = p; + + // deja_vu + initialize(deja_vu, f); + level::fill(deja_vu, false); + + + if (n_objects >= nbassins) + { + std::cerr << "The number of expected objects is higher than the number of regional minima!" << std::endl; + std::abort(); + } + + if (echo) + debug::println("regmin(f) =", regmin); + + initialize(labels, f); + for_all(p) + if (regmin(p) != 0) // p in a reg min of the attribute image + { + labels(p).insert(regmin(p)); + fused(p) = true; + } + } + + current_n = nbassins; + + // First pass. + mln_site(I) r; + mln_fwd_piter(S) p(s); + mln_niter(N) n(nbh, p); + for_all(p) + { + std::cout << p << std::endl; + for_all(n) + { + if (a.domain().has(n) && deja_vu(n)) + { + std::cout << " " << n << std::endl; + r = find_root__(par, n); + if (r != p) + { + par(r) = p; // Union. + + + /////TMP + if (labels(r).is_empty()) + // No-op. + ; + else + if (labels(p).is_empty()) + labels(p) = labels(r); + else + if (labels(p) == labels(r)) + { + // No-op. + // Should only happen if p and r are minima + } + else + labels(p).insert(labels(r)); + + ///// + + if (p == point2d(1,0) && r == point2d(2,0)) + { + std::cerr << "fused(r) " << fused(r) << std::endl; + std::cerr << "regmin(p) == 0 " << (regmin(p) == 0) << std::endl; + std::cerr << "fused(p) " << fused(p) << std::endl; + std::cerr << "current_n > n_objects " << (current_n > n_objects) << std::endl; + } + + // min_v != 0 <=> volume(p) == 1 ? + if (fused(r) && + regmin(p) == 0 &&// p is not a minima + fused(p) &&// p already belong to a cmpt (fused for an another n) + current_n > n_objects) // union is still allowed + { + std::cerr << p << " <- " << r + << labels(p) << labels(r) << std::endl; + + current_n--; + std::cout << "dec" << std::endl; + } + + //mln_invariant(fused(r) || a(r) == a(p)); + // DOESNT WORK + + // Union made if + if (current_n >= n_objects || // union is still allowed or + not fused(r) || // r not fused or + not fused(p) || // p not fused or + regmin(p) != 0) // p is a minima + { + //par(r) = p; + fused(p) = fused(r); + //iota(p) = iota(r); + +// std::cout << "volume " << a(p) << " - " << current_n << std::endl; +// debug::println(iota | pw::value(fused) == pw::cst(true)); +// std::cout << "---------------------" << std::endl; + } + } + } + } + deja_vu(p) = true; + } + return labels; + } + + +} // end of namespace mln + + +void usage(char* argv[]) +{ + std::cerr << "usage: " << argv[0] << " input.pgm n echo" << std::endl; + std::cerr << "n: number of expected objects (n > 0)" << std::endl; + std::cerr << "echo: 0 (silent) or 1 (verbose)" << std::endl; + std::cerr << "merge using sets of labels from regional minima and save the highest label image" << std::endl; + std::abort(); +} + + +int main(int argc, char* argv[]) +{ + using namespace mln; + using value::int_u8; + + if (argc != 4) + usage(argv); + + typedef image2d<int_u8> I; + I f; + // input image + io::pgm::load(f, argv[1]); + + // n + int n = std::atoi(argv[2]); + if (n <= 0) + usage(argv); + + // echo + int echo = std::atoi(argv[3]); + if (echo != 0 && echo != 1) + usage(argv); + + typedef p_array<point2d> S; + S s = level::sort_psites_decreasing(f); + + // Children go towards lower levels so leafs are regional minima. + // We get a min-tree so that we can perform morphological closings. + + morpho::tree::data<I,S> t(f, s, c4()); + accu::count< util::pix<I> > attr; + + image2d<unsigned> a = morpho::tree::compute_attribute_image(attr, t); + + + image2d< util::set<unsigned> > labels = compute_labels(f, a, c4(), n, echo); + if (echo) + debug::println("labels =", labels); +} Index: jardonnet/n_cmpt/n_cmpt5.hh --- jardonnet/n_cmpt/n_cmpt5.hh (revision 3060) +++ jardonnet/n_cmpt/n_cmpt5.hh (working copy) @@ -39,6 +39,10 @@ # include <mln/morpho/tree/data.hh> # include <mln/morpho/tree/compute_attribute_image.hh> +# include <mln/pw/all.hh> + +# include <mln/core/image/image_if.hh> + namespace mln { @@ -133,6 +137,9 @@ } } + mln_ch_value(I,value::int_u<16>) iota(ima.domain()); + debug::iota(iota); + // UNION FIND ON VOLUME mln_fwd_piter(S) p(sp); mln_niter(N) n(nbh, p); @@ -175,6 +182,7 @@ } mln_invariant(fused(r) || volume(r) == volume(p)); + //Note at the end of level every fake component have been processed. // Union made if if (cmpts >= lambda || // union is still allowed or @@ -194,6 +202,7 @@ if (fused(r)) fused(p) = true; + iota(p) = iota(r); // If I try to fuse with something never fused I am on a plateau. // not fused(r) => ( volume(r) == volume(p) ) @@ -208,6 +217,8 @@ std::cerr << "volume " << volume(p) << " - " << cmpts << std::endl; //debug::println(fused); + + debug::println(iota | pw::value(fused) == pw::cst(true)); } } } @@ -215,9 +226,6 @@ deja_vu(p) = true; } - mln_ch_value(I,value::int_u<16>) iota(ima.domain()); - debug::iota(iota); - std::cout << std::endl; std::cout << "cmpts : " << cmpts << std::endl; Index: jardonnet/n_cmpt/ref_filter.cc --- jardonnet/n_cmpt/ref_filter.cc (revision 0) +++ jardonnet/n_cmpt/ref_filter.cc (revision 0) @@ -0,0 +1,224 @@ +#include <mln/core/image/image2d.hh> +#include <mln/value/int_u8.hh> +#include <mln/io/pgm/load.hh> +#include <mln/debug/println.hh> + +#include <mln/core/site_set/p_array.hh> +#include <mln/level/sort_psites.hh> +#include <mln/core/alias/neighb2d.hh> +#include <mln/morpho/tree/data.hh> + +#include <mln/accu/count.hh> +#include <mln/util/set.hh> + +#include <mln/labeling/regional_minima.hh> +#include <mln/morpho/tree/compute_attribute_image.hh> +#include <mln/morpho/closing_area.hh> +#include <mln/level/fill.hh> + + +namespace mln +{ + + template <typename I> + void println_par(const I& par) + { + int nr = par.nrows(), nc = par.ncols(); + for (int r = 0; r < nr; ++r) + { + for (int c = 0; c < nc; ++c) + if (par.at(r,c) == point2d(r,c)) + std::cout << "( ) "; + else + std::cout << par.at(r,c) << ' '; + std::cout << std::endl; + } + } + + template <typename P> + inline + mln_value(P) find_root__(P& par, const mln_value(P)& x) + { + if (par(x) == x) + return x; + else + return par(x) = find_root__(par, par(x)); + } + + + template <typename I, typename A, typename N> + mln_ch_value(I, util::set<unsigned>) + compute_labels(const I& f, const A& a, const N& nbh, + unsigned n_objects, + bool echo = false) + { + if (echo) + debug::println("f =", f); + + typedef p_array<mln_psite(I)> S; + S s = level::sort_psites_increasing(a); + // s maps increasing attributes. + + mln_ch_value(I, mln_site(I)) par; + mln_ch_value(I, bool) deja_vu; + mln_ch_value(I, util::set<unsigned>) labels; + unsigned nbassins, current_n; + + // Initialization. + { + mln_piter(A) p(f.domain()); + + // parent + initialize(par, f); + for_all(p) + par(p) = p; + + // deja_vu + initialize(deja_vu, f); + level::fill(deja_vu, false); + + // labels + mln_ch_value(I, unsigned) regmin = labeling::regional_minima(a, nbh, + nbassins); + if (n_objects >= nbassins) + { + std::cerr << "The number of expected objects is higher than the number of regional minima!" << std::endl; + std::abort(); + } + + if (echo) + debug::println("regmin(f) =", regmin); + + initialize(labels, f); + for_all(p) + if (regmin(p) != 0) // p in a reg min of the attribute image + labels(p).insert(regmin(p)); + } + + debug::println(labels); + + current_n = nbassins; + + // First pass. + { + mln_site(I) r; + mln_fwd_piter(S) p(s); + mln_niter(N) n(nbh, p); + for_all(p) + { + std::cout << p << std::endl; + for_all(n) + if (a.domain().has(n) && deja_vu(n)) + { + std::cout << " " << n << std::endl; + r = find_root__(par, n); + if (r != p) + { + par(r) = p; // Union. + + if (labels(r).is_empty()) + // No-op. + ; + else + if (labels(p).is_empty()) + labels(p) = labels(r); + else + if (labels(p) == labels(r)) + { + // No-op. + // Should only happen if p and r are minima + } + else + { + labels(p).insert(labels(r)); + --current_n; + + if (current_n >= n_objects) + std::cerr << p << " <- " << r + << labels(p) << labels(r) << std::endl; + + if (current_n == n_objects && echo) + { + // Filtering. +// mln_concrete(I) g; +// initialize(g, f); +// mln_bkd_piter(S) p(s); +// for_all(p) +// if (par(p) == p) +// g(p) = f(p); +// else +// g(p) = g(par(p)); +// debug::println("g =", g); + + // Testing. +// unsigned n_result; +// mln_ch_value(I, unsigned) g_regmin; +// g_regmin = labeling::regional_minima(g, nbh, n_result); +// debug::println("regmin(g) =", g_regmin); + +// mln_invariant(n_result == n_objects); + } + } + } + } + deja_vu(p) = true; + } + } + + mln_invariant(current_n == 1); // All labels are merged into a single set. + + return labels; + } + + +} // mln + + +void usage(char* argv[]) +{ + std::cerr << "usage: " << argv[0] << " input.pgm n echo" << std::endl; + std::cerr << "n: number of expected objects (n > 0)" << std::endl; + std::cerr << "echo: 0 (silent) or 1 (verbose)" << std::endl; + std::cerr << "merge using sets of labels from regional minima and save the highest label image" << std::endl; + std::abort(); +} + + +int main(int argc, char* argv[]) +{ + using namespace mln; + using value::int_u8; + + if (argc != 4) + usage(argv); + + typedef image2d<int_u8> I; + I f; + // input image + io::pgm::load(f, argv[1]); + + // n + int n = std::atoi(argv[2]); + if (n <= 0) + usage(argv); + + // echo + int echo = std::atoi(argv[3]); + if (echo != 0 && echo != 1) + usage(argv); + + typedef p_array<point2d> S; + S s = level::sort_psites_decreasing(f); + + // Children go towards lower levels so leafs are regional minima. + // We get a min-tree so that we can perform morphological closings. + + morpho::tree::data<I,S> t(f, s, c4()); + accu::count< util::pix<I> > attr; + + image2d<unsigned> a = morpho::tree::compute_attribute_image(attr, t); + + image2d< util::set<unsigned> > labels = compute_labels(f, a, c4(), n, echo); + if (echo) + debug::println("labels =", labels); +} Index: jardonnet/n_cmpt/fused --- jardonnet/n_cmpt/fused (revision 0) +++ jardonnet/n_cmpt/fused (revision 0) @@ -0,0 +1,26 @@ +(11, 2) <- (11, 1){18, 22}{18} +fused(r) 1 +regmin(p) == 0 1 +fused(p) 0 +current_n > n_objects 1 +(11, 8) <- (13, 8){14, 21}{14} +(12, 1) <- (12, 0){16, 18, 22}{16} +(13, 2) <- (14, 2){15, 16, 18, 22}{15} +(17, 8) <- (18, 8){11, 14, 21}{11} +(20, 8) <- (21, 8){7, 11, 14, 21}{7} +(10, 20) <- (14, 19){13, 19, 20}{13, 19} +(17, 1) <- (18, 1){9, 15, 16, 18, 22}{9} +(11, 20) <- (11, 21){13, 17, 19, 20}{17} +(21, 12) <- (20, 13){6, 7, 11, 14, 21}{6} +(4, 10) <- (3, 11){2, 6, 7, 11, 14, 21}{2} +(11, 17) <- (8, 21){2, 6, 7, 11, 13, 14, 17, 19, 20, 21}{13, 17, 19, 20} +(16, 22) <- (16, 23){2, 6, 7, 11, 12, 13, 14, 17, 19, 20, 21}{12} +(4, 20) <- (6, 20){1, 2, 6, 7, 11, 12, 13, 14, 17, 19, 20, 21}{1} +(4, 23) <- (5, 23){1, 2, 6, 7, 11, 12, 13, 14, 17, 19, 20, 21, 23}{23} +(21, 20) <- (21, 21){1, 2, 5, 6, 7, 11, 12, 13, 14, 17, 19, 20, 21, 23}{5} +(0, 17) <- (0, 18){1, 2, 5, 6, 7, 11, 12, 13, 14, 17, 19, 20, 21, 23, 25}{25} +(20, 21) <- (13, 22){1, 2, 5, 6, 7, 8, 11, 12, 13, 14, 17, 19, 20, 21, 23, 25}{1, 2, 5, 6, 7, 11, 12, 13, 14, 17, 19, 20, 21, 23, 25} +(21, 22) <- (21, 23){1, 2, 4, 5, 6, 7, 8, 11, 12, 13, 14, 17, 19, 20, 21, 23, 25}{4} +(19, 22) <- (19, 23){1, 2, 4, 5, 6, 7, 8, 10, 11, 12, 13, 14, 17, 19, 20, 21, 23, 25}{10} +(5, 5) <- (18, 4){1, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 25}{9, 15, 16, 18, 22} +(5, 2) <- (7, 1){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}{1, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 25} Index: jardonnet/n_cmpt/ref --- jardonnet/n_cmpt/ref (revision 0) +++ jardonnet/n_cmpt/ref (revision 0) @@ -0,0 +1,22 @@ +(11, 2) <- (11, 1){18, 22}{18} +(1, 0) <- (2, 0){3, 24}{24} +(11, 8) <- (13, 8){14, 21}{14} +(12, 1) <- (12, 0){16, 18, 22}{16} +(13, 2) <- (14, 2){15, 16, 18, 22}{15} +(17, 8) <- (18, 8){11, 14, 21}{11} +(20, 8) <- (21, 8){7, 11, 14, 21}{7} +(12, 18) <- (18, 17){13, 19}{13} +(10, 20) <- (14, 19){13, 19, 20}{13, 19} +(17, 1) <- (18, 1){9, 15, 16, 18, 22}{9} +(11, 20) <- (11, 21){13, 17, 19, 20}{17} +(21, 12) <- (20, 13){6, 7, 11, 14, 21}{6} +(4, 10) <- (3, 11){2, 6, 7, 11, 14, 21}{2} +(11, 17) <- (8, 21){2, 6, 7, 11, 13, 14, 17, 19, 20, 21}{13, 17, 19, 20} +(16, 22) <- (16, 23){2, 6, 7, 11, 12, 13, 14, 17, 19, 20, 21}{12} +(4, 20) <- (6, 20){1, 2, 6, 7, 11, 12, 13, 14, 17, 19, 20, 21}{1} +(4, 23) <- (5, 23){1, 2, 6, 7, 11, 12, 13, 14, 17, 19, 20, 21, 23}{23} +(21, 20) <- (21, 21){1, 2, 5, 6, 7, 11, 12, 13, 14, 17, 19, 20, 21, 23}{5} +(0, 17) <- (0, 18){1, 2, 5, 6, 7, 11, 12, 13, 14, 17, 19, 20, 21, 23, 25}{25} +(20, 21) <- (13, 22){1, 2, 5, 6, 7, 8, 11, 12, 13, 14, 17, 19, 20, 21, 23, 25}{1, 2, 5, 6, 7, 11, 12, 13, 14, 17, 19, 20, 21, 23, 25} +(21, 22) <- (21, 23){1, 2, 4, 5, 6, 7, 8, 11, 12, 13, 14, 17, 19, 20, 21, 23, 25}{4} +(19, 22) <- (19, 23){1, 2, 4, 5, 6, 7, 8, 10, 11, 12, 13, 14, 17, 19, 20, 21, 23, 25}{10} Index: jardonnet/n_cmpt/Makefile --- jardonnet/n_cmpt/Makefile (revision 3060) +++ jardonnet/n_cmpt/Makefile (working copy) @@ -1,21 +1,31 @@ -n_cmpt: n_cmpt.hh n_cmpt.cc - g++ -I../../.. -Wall -W -Wextra n_cmpt.cc -DNDEBUG -O1 -o n_cmpt +n_cmpt6: n_cmpt6.hh n_cmpt6.cc + g++ -I../../.. -Wall -W -Wextra n_cmpt6.cc -DNDEBUG -O1 -o n_cmpt6 -n_cmpt2: n_cmpt2.hh n_cmpt2.cc - g++ -I../../.. -Wall -W -Wextra n_cmpt2.cc -DNDEBUG -O1 -o n_cmpt2 +n_cmpt5: n_cmpt5.hh n_cmpt5.cc + g++ -I../../.. -Wall -W -Wextra n_cmpt5.cc -DNDEBUG -O1 -o n_cmpt5 + +n_cmpt4: n_cmpt4.hh n_cmpt4.cc + g++ -I../../.. -Wall -W -Wextra n_cmpt4.cc -DNDEBUG -O1 -o n_cmpt4 n_cmpt3: n_cmpt3.hh n_cmpt3.cc g++ -I../../.. -Wall -W -Wextra n_cmpt3.cc -DNDEBUG -O1 -o n_cmpt3 -n_cmpt4: n_cmpt4.hh n_cmpt4.cc - g++ -I../../.. -Wall -W -Wextra n_cmpt4.cc -DNDEBUG -O1 -o n_cmpt4 +n_cmpt2: n_cmpt2.hh n_cmpt2.cc + g++ -I../../.. -Wall -W -Wextra n_cmpt2.cc -DNDEBUG -O1 -o n_cmpt2 + +n_cmpt: n_cmpt.hh n_cmpt.cc + g++ -I../../.. -Wall -W -Wextra n_cmpt.cc -DNDEBUG -O1 -o n_cmtp -n_cmpt5: n_cmpt5.hh n_cmpt5.cc - g++ -I../../.. -Wall -W -Wextra n_cmpt5.cc -DNDEBUG -O1 -o n_cmpt5 nwst: nwst.hh nwst.cc g++ -I../../.. -Wall -W -Wextra nwst.cc -DNDEBUG -O1 -o nwst +ref_filter: ref_filter.cc + g++ -I../../.. -Wall -W -Wextra ref_filter.cc -DNDEBUG -O1 -o ref_filter + +ref_seg: ref_seg.cc + g++ -I../../.. -Wall -W -Wextra ref_seg.cc -DNDEBUG -O1 -o ref_seg + debug: n_cmpt.hh n_cmpt.cc g++ -I../../.. -Wall -W -Wextra n_cmpt.cc -g -g3 -o n_cmpt Index: jardonnet/n_cmpt/diff_ref_fused_on_small --- jardonnet/n_cmpt/diff_ref_fused_on_small (revision 0) +++ jardonnet/n_cmpt/diff_ref_fused_on_small (revision 0) @@ -0,0 +1,13 @@ +60d59 +< (1, 0) <- (2, 0) +92d90 +< (12, 18) <- (18, 17) +174d171 +< (62, 51) <- (56, 57) +198d194 +< (57, 46) <- (60, 52) +200d195 +< (49, 47) <- (47, 54) +252a248,249 +> (18, 46) <- (18, 47) +> (46, 61) <- (41, 63) Index: jardonnet/igr/src/igr.cc --- jardonnet/igr/src/igr.cc (revision 3060) +++ jardonnet/igr/src/igr.cc (working copy) @@ -24,11 +24,6 @@ #include <mln/value/hsi.hh> -#include <mln/core/image/thru.hh> - -//FIXME: Alexandre' sandbox -#include <mln/fun/meta/inty.hh> - using namespace mln; using namespace value; @@ -67,7 +62,7 @@ mln_piter_(image2d<rgb8>) p(g_ima.domain()); for_all(p) { - g_ima(p) = hsi(p).inty() * 255; + g_ima(p) = hsi(p).inty(); } io::pgm::save(g_ima, "g_ima.ppm"); @@ -88,7 +83,6 @@ /////////////////// image2d<int_u8> o_ima = morpho::closing_volume(mg_ima, c4(), lambda); - io::pgm::save(o_ima, "o_ima.ppm"); Index: jardonnet/igr/Makefile --- jardonnet/igr/Makefile (revision 3060) +++ jardonnet/igr/Makefile (working copy) @@ -6,7 +6,7 @@ CXXC?=g++ -LFLAGS=-I../../abraham/ -I../../../ +LFLAGS= -I../../../ CFLAGS=-W -Wall -Wextra -O1 -DNDEBUG PROJ=igr-reco
16Â years, 1Â month
1
0
0
0
3060: Add an opt::at function.
by Nicolas Ballas
https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog from Nicolas Ballas <ballas(a)lrde.epita.fr> Add an opt::at function. * mln/core/image/cast_image.hh: Fix properties. * mln/opt: New directory. * mln/opt/at.hh: New function opt::at. * mln/level/paste.spe.hh: Fix a bug. * tests/opt, * tests/opt/at.cc: New tests. mln/core/image/cast_image.hh | 1 mln/level/paste.spe.hh | 2 mln/opt/at.hh | 337 +++++++++++++++++++++++++++++++++++++++++++ tests/opt/at.cc | 157 ++++++++++++++++++++ 4 files changed, 496 insertions(+), 1 deletion(-) Index: mln/core/image/cast_image.hh --- mln/core/image/cast_image.hh (revision 3059) +++ mln/core/image/cast_image.hh (working copy) @@ -99,6 +99,7 @@ trait::image::quant::high, trait::image::quant::low) quant; + typedef trait::image::category::value_morpher category; typedef trait::image::value_io::read_only value_io; typedef trait::image::pw_io::read pw_io; typedef trait::image::value_access::indirect value_access; Index: mln/opt/at.hh --- mln/opt/at.hh (revision 0) +++ mln/opt/at.hh (revision 0) @@ -0,0 +1,337 @@ +// Copyright (C) 2008 EPITA Research and Development Laboratory +// (LRDE) +// +// This file is part of the Olena Library. This library is free +// software; you can redistribute it and/or modify it under the terms +// of the GNU General Public License version 2 as published by the +// Free Software Foundation. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this library; see the file COPYING. If not, write to +// the Free Software Foundation, 51 Franklin Street, Fifth Floor, +// Boston, MA 02111-1307, USA. +// +// As a special exception, you may use this file as part of a free +// software library without restriction. Specifically, if other files +// instantiate templates or use macros or inline functions from this +// file, or you compile this file and link it with other files to +// produce an executable, this file does not by itself cause the +// resulting executable to be covered by the GNU General Public +// License. This exception does not however invalidate any other +// reasons why the executable file might be covered by the GNU General +// Public License. + +#ifndef MLN_OPT_AT_HH +# define MLN_OPT_AT_HH + +/// \file mln/opt/at.hh +/// +/// FIXME + +# include <mln/core/concept/image.hh> +# include <mln/trait/images.hh> +# include <mln/trace/all.hh> + +# include <mln/core/alias/point1d.hh> +# include <mln/core/alias/point2d.hh> +# include <mln/core/alias/point3d.hh> + +namespace mln +{ + + namespace opt + { + + /// One dimension + template <typename I> + mln_rvalue(I) at(const Image<I>& ima, int ind); + + template <typename I> + mln_lvalue(I) at(Image<I>& ima, int ind); + + + /// Two dimensions + template <typename I> + mln_rvalue(I) at(const Image<I>& ima, int row, int col); + + template <typename I> + mln_lvalue(I) at(Image<I>& ima, int row, int col); + + /// Three dimensions + template <typename I> + mln_rvalue(I) at(const Image<I>& ima, int sli, int row, int col); + + template <typename I> + mln_lvalue(I) at(Image<I>& ima, int sli, int row, int col); + + +# ifndef MLN_INCLUDE_ONLY + + + /// One dimension + namespace impl + { + + template <typename I> + inline + mln_rvalue(I) at_1d_impl(trait::image::category::domain_morpher, + const Image<I>& ima, int ind) + { + point1d p(ind); + return exact(ima)(p); + } + + template <typename I> + inline + mln_rvalue(I) at_1d_impl(trait::image::category::morpher, + const Image<I>& ima, int ind) + { + // FIXME: what about morpher that modify the image value? + // (through a function for instance) + return at(*exact(ima).delegatee_(), ind); + } + + template <typename I> + inline + mln_rvalue(I) at_1d_impl(trait::image::category::primary, + const Image<I>& ima, int ind) + { + return exact(ima).at(ind); + } + + + template <typename I> + inline + mln_lvalue(I) at_1d_impl(trait::image::category::domain_morpher, + Image<I>& ima, int ind) + { + mlc_is(mln_trait_image_pw_io(I), + trait::image::pw_io::read_write)::check(); + + point1d p(ind); + return exact(ima)(p); + } + + template <typename I> + inline + mln_lvalue(I) at_1d_impl(trait::image::category::morpher, + Image<I>& ima, int ind) + { + // FIXME: what about morpher that modify the image value? + // (through a function for instance) + return at(*exact(ima).delegatee_(), ind); + } + + template <typename I> + inline + mln_lvalue(I) at_1d_impl(trait::image::category::primary, + Image<I>& ima, int ind) + { + return exact(ima).at(ind); + } + + } // end of namespace mln::opt::impl + + template <typename I> + inline + mln_rvalue(I) at(const Image<I>& ima, int ind) + { + mlc_is(mln_trait_image_dimension(I), + trait::image::dimension::one_d)::check(); + + return impl::at_1d_impl(mln_trait_image_category(I)(), ima, ind); + } + + template <typename I> + mln_lvalue(I) at(Image<I>& ima, int ind) + { + mlc_is(mln_trait_image_dimension(I), + trait::image::dimension::one_d)::check(); + + return impl::at_1d_impl(mln_trait_image_category(I)(), ima, ind); + } + + + + /// Two dimensions + namespace impl + { + + template <typename I> + inline + mln_rvalue(I) at_2d_impl(trait::image::category::domain_morpher, + const Image<I>& ima, int row, int col) + { + point2d p(row, col); + return exact(ima)(p); + } + + template <typename I> + inline + mln_rvalue(I) at_2d_impl(trait::image::category::morpher, + const Image<I>& ima, int row, int col) + { + // FIXME: what about morpher that modify the image value? + // (through a function for instance) + return at(*exact(ima).delegatee_(), row, col); + } + + template <typename I> + inline + mln_rvalue(I) at_2d_impl(trait::image::category::primary, + const Image<I>& ima, int row, int col) + { + return exact(ima).at(row, col); + } + + + template <typename I> + inline + mln_lvalue(I) at_2d_impl(trait::image::category::domain_morpher, + Image<I>& ima, int row, int col) + { + mlc_is(mln_trait_image_pw_io(I), + trait::image::pw_io::read_write)::check(); + + point2d p(row, col); + return exact(ima)(p); + } + + template <typename I> + inline + mln_lvalue(I) at_2d_impl(trait::image::category::morpher, + Image<I>& ima, int row, int col) + { + // FIXME: what about morpher that modify the image value? + // (through a function for instance) + return at(*exact(ima).delegatee_(), row, col); + } + + template <typename I> + inline + mln_lvalue(I) at_2d_impl(trait::image::category::primary, + Image<I>& ima, int row, int col) + { + return exact(ima).at(row, col); + } + + } // end of namespace mln::opt::impl + + template <typename I> + inline + mln_rvalue(I) at(const Image<I>& ima, int row, int col) + { + mlc_is(mln_trait_image_dimension(I), + trait::image::dimension::two_d)::check(); + + return impl::at_2d_impl(mln_trait_image_category(I)(), ima, row, col); + } + + template <typename I> + mln_lvalue(I) at(Image<I>& ima, int row, int col) + { + mlc_is(mln_trait_image_dimension(I), + trait::image::dimension::two_d)::check(); + + return impl::at_2d_impl(mln_trait_image_category(I)(), ima, row, col); + } + + + /// Three dimensions + namespace impl + { + + template <typename I> + inline + mln_rvalue(I) at_3d_impl(trait::image::category::domain_morpher, + const Image<I>& ima, int sli, int row, int col) + { + point3d p(sli, row, col); + return exact(ima)(p); + } + + template <typename I> + inline + mln_rvalue(I) at_3d_impl(trait::image::category::morpher, + const Image<I>& ima, int sli, int row, int col) + { + // FIXME: what about morpher that modify the image value? + // (through a function for instance) + return at(*exact(ima).delegatee_(), sli, row, col); + } + + template <typename I> + inline + mln_rvalue(I) at_3d_impl(trait::image::category::primary, + const Image<I>& ima, int sli, int row, int col) + { + return exact(ima).at(sli, row, col); + } + + + template <typename I> + inline + mln_lvalue(I) at_3d_impl(trait::image::category::domain_morpher, + Image<I>& ima, int sli, int row, int col) + { + mlc_is(mln_trait_image_pw_io(I), + trait::image::pw_io::read_write)::check(); + + point3d p(sli, row, col); + return exact(ima)(p); + } + + template <typename I> + inline + mln_lvalue(I) at_3d_impl(trait::image::category::morpher, + Image<I>& ima, int sli, int row, int col) + { + // FIXME: what about morpher that modify the image value? + // (through a function for instance) + return at(*exact(ima).delegatee_(), sli, row, col); + } + + template <typename I> + inline + mln_lvalue(I) at_3d_impl(trait::image::category::primary, + Image<I>& ima, int sli, int row, int col) + { + return exact(ima).at(sli, row, col); + } + + } // end of namespace mln::opt::impl + + template <typename I> + inline + mln_rvalue(I) at(const Image<I>& ima, int sli, int row, int col) + { + mlc_is(mln_trait_image_dimension(I), + trait::image::dimension::three_d)::check(); + + return impl::at_3d_impl(mln_trait_image_category(I)(), + ima, sli, row, col); + } + + template <typename I> + mln_lvalue(I) at(Image<I>& ima, int sli, int row, int col) + { + mlc_is(mln_trait_image_dimension(I), + trait::image::dimension::three_d)::check(); + + return impl::at_3d_impl(mln_trait_image_category(I)(), + ima, sli, row, col); + } + +# endif // ! MLN_INCLUDE_ONLY + + } // end of namespace mln::opt + +} // end of namespace mln + + +#endif // ! MLN_OPT_AT_HH Index: mln/level/paste.spe.hh --- mln/level/paste.spe.hh (revision 3059) +++ mln/level/paste.spe.hh (working copy) @@ -143,7 +143,7 @@ const I& input = exact(input_); - level::fill_with_value(output_, input.val()); + level::fill_with_value((output_ | input.domain()).rw(), input.val()); trace::exiting("level::impl::paste_singleton"); } Index: tests/opt/at.cc --- tests/opt/at.cc (revision 0) +++ tests/opt/at.cc (revision 0) @@ -0,0 +1,157 @@ +// Copyright (C) 2008 EPITA Research and Development Laboratory +// (LRDE) +// +// This file is part of the Olena Library. This library is free +// software; you can redistribute it and/or modify it under the terms +// of the GNU General Public License version 2 as published by the +// Free Software Foundation. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this library; see the file COPYING. If not, write to +// the Free Software Foundation, 51 Franklin Street, Fifth Floor, +// Boston, MA 02111-1307, USA. +// +// As a special exception, you may use this file as part of a free +// software library without restriction. Specifically, if other files +// instantiate templates or use macros or inline functions from this +// file, or you compile this file and link it with other files to +// produce an executable, this file does not by itself cause the +// resulting executable to be covered by the GNU General Public +// License. This exception does not however invalidate any other +// reasons why the executable file might be covered by the GNU General +// Public License. + +/// \file tests/opt/at.cc +/// +/// Tests on mln::opt::at. + +#include <mln/core/image/image1d.hh> +#include <mln/core/image/sub_image.hh> +#include <mln/core/image/cast_image.hh> + +/*#include <mln/core/image/image2d.hh> +#include <mln/core/image/image3d.hh> +#include <mln/pw/image.hh> +#include <mln/core/image/flat_image.hh> +#include <mln/core/image/image_if.hh> +#include <mln/core/image/extension_val.hh>*/ + +#include <mln/level/fill.hh> +#include <mln/level/paste.hh> +#include <mln/level/compare.hh> + +#include <mln/opt/at.hh> + +#include <mln/debug/iota.hh> +#include <mln/debug/println.hh> +#include <mln/trace/all.hh> + + +int main() +{ + using namespace mln; + const unsigned size = 50; + + /// One dimensions tests... + { + image1d<short> ima(size); + debug::iota(ima); + const image1d<short> cima = ima; + + point1d p(5); + mln_assertion(cima(p) == opt::at(cima, 5)); + + opt::at(ima, 5) = 12; + mln_assertion(cima(p) == 12); + } + { + typedef image1d<short> I; + typedef sub_image< image1d<short>, box1d > II; + + I ima(size); + II sub_ima(ima, make::box1d(4, 10)); + const II csub_ima(ima, make::box1d(4, 10)); + point1d p(5); + + level::fill(ima, 51); + mln_assertion(csub_ima(p) == opt::at(csub_ima, 5)); + opt::at(sub_ima, 5) = 12; + mln_assertion(sub_ima(p) == 12); + } + { + typedef image1d<unsigned short> I; + typedef cast_image_<int, I> II; + + I in(size, size); + II cast(in); + const II ccast(in); + point1d p(5); + + level::fill(in, 51); + mln_assertion(ccast(p) == opt::at(ccast, 5)); + // FIXME + //opt::at(cast, 5) = 12; + //mln_assertion(cast(p) == 12); + } + + /// Two dimensions tests... + { + image2d<short> ima(size, size); + debug::iota(ima); + const image2d<short> cima = ima; + + point2d p(5, 5); + mln_assertion(cima(p) == opt::at(cima, 5, 5)); + + opt::at(ima, 5, 5) = 12; + mln_assertion(cima(p) == 12); + } + { + typedef image2d<short> I; + typedef sub_image< image2d<short>, box2d > II; + + I ima(size, size); + II sub_ima(ima, make::box2d(4,4, 10, 10)); + const II csub_ima(ima, make::box2d(4, 4, 10, 10)); + point2d p(5, 5); + + level::fill(ima, 51); + mln_assertion(csub_ima(p) == opt::at(csub_ima, 5, 5)); + opt::at(sub_ima, 5, 5) = 12; + mln_assertion(sub_ima(p) == 12); + } + { + typedef image2d<unsigned short> I; + typedef cast_image_<int, I> II; + + I in(size, size); + II cast(in); + const II ccast(in); + point2d p(5,5); + + level::fill(in, 51); + mln_assertion(ccast(p) == opt::at(ccast, 5, 5)); + // FIXME + //opt::at(cast, 5) = 12; + //mln_assertion(cast(p) == 12); + } + + + /// Three dimensions tests... + { + image3d<short> ima(size, size, size); + debug::iota(ima); + const image3d<short> cima = ima; + + point3d p(5, 5, 5); + mln_assertion(cima(p) == opt::at(cima, 5, 5, 5)); + + opt::at(ima, 5, 5, 5) = 12; + mln_assertion(cima(p) == 12); + } +}
16Â years, 1Â month
1
0
0
0
Re: [Olena-patches] 3059: Make use of milena/generate_dist_headers.sh.
by Alexandre Duret-Lutz
>>> "z" == Guillaume Lazzara <z(a)lrde.epita.fr> writes: z> * bootstrap: update here. Je ne l'ai pas vu dans la tarball ? -- Alexandre Duret-Lutz
16Â years, 1Â month
1
0
0
0
3059: Make use of milena/generate_dist_headers.sh.
by Guillaume Lazzara
* bootstrap: update here. --- ChangeLog | 6 ++++++ bootstrap | 20 ++------------------ 2 files changed, 8 insertions(+), 18 deletions(-) diff --git a/ChangeLog b/ChangeLog index 64a4638..e34918b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2008-12-16 Guillaume Lazzara <z(a)lrde.epita.fr> + + Make use of milena/generate_dist_headers.sh. + + * bootstrap: update here. + 2008-12-09 Guillaume Lazzara <z(a)lrde.epita.fr> Update call to build_unit_test.sh diff --git a/bootstrap b/bootstrap index f0ebe78..c0ee7e8 100755 --- a/bootstrap +++ b/bootstrap @@ -108,22 +108,6 @@ run () ) } -# Generate milena/headers.mk -# ------------------------------ -# List all the headers in order to make them part of distribution. -dist_headers () -{ - cd "milena" - echo "nobase_include_HEADERS = \\" > headers.mk - echo "generating headers.mk" - find mln -type f | sed -e 's/$/ \\/g' >> headers.mk - - last_line=`tail -n 1 headers.mk | sed -e 's/\\\//g'` # remove '\' in last line - sed '$d' < headers.mk > headers.mk.tmp # remove last line - mv headers.mk.tmp headers.mk - echo $last_line >> headers.mk # put the cleaned last line back. - cd - -} # Failures do matter. set -e @@ -135,8 +119,8 @@ require automake 1.9.4 # Generate unit test files. run milena/tests/unit_test ./build_unit_test.sh $PWD/milena/mln -# Generate headers distribution config file. -dist_headers +# Generate milena/dist_headers.mk +run milena ./generate_dist_headers.sh # Tell what's going on. set -x -- 1.5.6.5
16Â years, 1Â month
1
0
0
0
3058: Generate the distributed header list thanks to a specific script.
by Guillaume Lazzara
* generate_dist_headers.sh: generate the list of distributed headers. * Makefile.am: include generate_dist_headers.sh in the distribution tarball. * headers.mk: Add comment saying that it is generated. * doc/tutorial/samples/fill-subdomain-shorter.cc: fix a warning. --- milena/ChangeLog | 13 +++++++++++++ milena/Makefile.am | 2 ++ .../doc/tutorial/samples/fill-subdomain-shorter.cc | 2 +- milena/generate_dist_headers.sh | 18 ++++++++++++++++++ milena/headers.mk | 2 ++ 5 files changed, 36 insertions(+), 1 deletions(-) create mode 100755 milena/generate_dist_headers.sh diff --git a/milena/ChangeLog b/milena/ChangeLog index 495e558..1255d74 100644 --- a/milena/ChangeLog +++ b/milena/ChangeLog @@ -1,5 +1,18 @@ 2008-12-16 Guillaume Lazzara <z(a)lrde.epita.fr> + Generate the distributed header list thanks to a specific script. + + * generate_dist_headers.sh: generate the list of distributed headers. + + * Makefile.am: include generate_dist_headers.sh in the distribution + tarball. + + * headers.mk: Add comment saying that it is generated. + + * doc/tutorial/samples/fill-subdomain-shorter.cc: fix a warning. + +2008-12-16 Guillaume Lazzara <z(a)lrde.epita.fr> + Quick cleanup in io. * milena/tests/io/off/load_bin.cc, diff --git a/milena/Makefile.am b/milena/Makefile.am index 64d0365..485c4bd 100644 --- a/milena/Makefile.am +++ b/milena/Makefile.am @@ -35,3 +35,5 @@ img/small.pbm \ img/lena.ppm \ img/small.pgm +EXTRA_DIST += \ +generate_dist_headers.sh diff --git a/milena/doc/tutorial/samples/fill-subdomain-shorter.cc b/milena/doc/tutorial/samples/fill-subdomain-shorter.cc index da3ce7b..7526682 100644 --- a/milena/doc/tutorial/samples/fill-subdomain-shorter.cc +++ b/milena/doc/tutorial/samples/fill-subdomain-shorter.cc @@ -28,6 +28,6 @@ int main() initialize(ima2, ima); level::fill(ima2, literal::black); - level::fill((ima2 | pw::value(lab) == pw::cst(2u)).rw(), literal::red); + level::fill((ima2 | (pw::value(lab) == pw::cst(2u))).rw(), literal::red); // \} } diff --git a/milena/generate_dist_headers.sh b/milena/generate_dist_headers.sh new file mode 100755 index 0000000..bb5bb30 --- /dev/null +++ b/milena/generate_dist_headers.sh @@ -0,0 +1,18 @@ +#/bin/sh +# +# Generate milena/headers.mk +# ------------------------------ +# List all the headers in order to make them part of distribution. + +echo "## Generated by ./generate_dist_headers, do not modify ##" > headers.mk +echo "" >> headers.mk +echo "nobase_include_HEADERS = \\" >> headers.mk +echo "generating headers.mk" + +find mln -type f | grep -v "\.svn" | sed -e 's/$/ \\/g' >> headers.mk + +last_line=`tail -n 1 headers.mk | sed -e 's/\\\//g'` # remove '\' in last line +sed '$d' < headers.mk > headers.mk.tmp # remove last line +mv headers.mk.tmp headers.mk +echo $last_line >> headers.mk # put the cleaned last line back. + diff --git a/milena/headers.mk b/milena/headers.mk index 240f896..146e616 100644 --- a/milena/headers.mk +++ b/milena/headers.mk @@ -1,3 +1,5 @@ +## Generated by ./generate_dist_headers, do not modify ## + nobase_include_HEADERS = \ mln/histo/all.hh \ mln/histo/data.hh \ -- 1.5.6.5
16Â years, 1Â month
1
0
0
0
3057: Quick cleanup in io.
by Guillaume Lazzara
* milena/tests/io/off/load_bin.cc, * milena/tests/io/off/load_float.cc, * milena/mln/io/fits/load.hh, * milena/mln/io/off/save.hh, * milena/mln/io/pfm/load.hh: update doc. * milena/mln/io/pfm/save.hh: avoid a warning and update doc. * milena/tests/io/off/load_float.cc: Fix test. --- milena/ChangeLog | 14 +++++++++++++ milena/mln/io/fits/load.hh | 35 +++++++++++++++------------------ milena/mln/io/off/save.hh | 2 +- milena/mln/io/pfm/load.hh | 35 +++++++++++++++------------------ milena/mln/io/pfm/save.hh | 31 ++++++++++++----------------- milena/tests/io/off/load_bin.cc | 3 +- milena/tests/io/off/load_float.cc | 6 +++- milena/tests/io/off/load_save_bin.cc | 3 +- 8 files changed, 68 insertions(+), 61 deletions(-) diff --git a/milena/ChangeLog b/milena/ChangeLog index e167114..495e558 100644 --- a/milena/ChangeLog +++ b/milena/ChangeLog @@ -1,3 +1,17 @@ +2008-12-16 Guillaume Lazzara <z(a)lrde.epita.fr> + + Quick cleanup in io. + + * milena/tests/io/off/load_bin.cc, + * milena/tests/io/off/load_float.cc, + * milena/mln/io/fits/load.hh, + * milena/mln/io/off/save.hh, + * milena/mln/io/pfm/load.hh: update doc. + + * milena/mln/io/pfm/save.hh: avoid a warning and update doc. + + * milena/tests/io/off/load_float.cc: Fix test. + 2008-12-16 Alexandre Abraham <abraham(a)lrde.epita.fr> Add functors and HSL color space. diff --git a/milena/mln/io/fits/load.hh b/milena/mln/io/fits/load.hh index c09536c..dbe533b 100644 --- a/milena/mln/io/fits/load.hh +++ b/milena/mln/io/fits/load.hh @@ -29,13 +29,10 @@ #ifndef MLN_IO_FITS_LOAD_HH # define MLN_IO_FITS_LOAD_HH -/*! - * \file mln/io/fits/load.hh - * - * \brief Define a function which loads an image of kind fits with - * given path. - * - */ +/// \file mln/io/fits/load.hh +/// +/// Define a function which loads an image of kind fits with +/// given path. # include <iostream> # include <fstream> @@ -57,21 +54,21 @@ namespace mln namespace fits { - /*! Load a fits image in a Milena image. - * - * \param[out] ima A reference to the image2d<float> which will receive - * data. - * \param[in] filename The source. - */ + /// Load a fits image in a Milena image. + /// + /// \param[out] ima A reference to the image2d<float> which will receive + /// data. + /// \param[in] filename The source. + /// void load(image2d<float>& ima, const std::string& filename); - /*! Load a fits image in a image2d<float>. - * - * \param[in] filename The image source. - * - * \return An image2d<float> which contains loaded data. - */ + /// Load a fits image in a image2d<float>. + /// + /// \param[in] filename The image source. + /// + /// \return An image2d<float> which contains loaded data. + /// image2d<float> load(const std::string& filename); # ifndef MLN_INCLUDE_ONLY diff --git a/milena/mln/io/off/save.hh b/milena/mln/io/off/save.hh index 40f2e5a..7bb4292 100644 --- a/milena/mln/io/off/save.hh +++ b/milena/mln/io/off/save.hh @@ -29,7 +29,7 @@ # define MLN_IO_OFF_SAVE_HH /// \file mln/io/off/save.hh -/// \brief Input saving function for OFF files. +/// Input saving function for OFF files. /// /// \see
http://shape.cs.princeton.edu/benchmark/documentation/off_format.html
/// \see
https://people.scs.fsu.edu/~burkardt/html/off_format.html
diff --git a/milena/mln/io/pfm/load.hh b/milena/mln/io/pfm/load.hh index 5ea3a23..ebf2f97 100644 --- a/milena/mln/io/pfm/load.hh +++ b/milena/mln/io/pfm/load.hh @@ -29,13 +29,10 @@ #ifndef MLN_IO_PFM_LOAD_HH # define MLN_IO_PFM_LOAD_HH -/*! - * \file mln/io/pfm/load.hh - * - * \brief Define a function which loads an image of kind pfm with - * given path. - * - */ +/// \file mln/io/pfm/load.hh +/// +/// Define a function which loads an image of kind pfm with +/// given path. # include <iostream> # include <fstream> @@ -53,21 +50,21 @@ namespace mln namespace pfm { - /*! Load a pfm image in a Milena image. - * - * \param[out] ima A reference to the image2d<float> which will receive - * data. - * \param[in] filename The source. - */ + /// Load a pfm image in a Milena image. + /// + /// \param[out] ima A reference to the image2d<float> which will receive + /// data. + /// \param[in] filename The source. + /// void load(image2d<float>& ima, const std::string& filename); - /*! Load a pfm image in a image2d<float>. - * - * \param[in] filename The image source. - * - * \return An image2d<float> which contains loaded data. - */ + /// Load a pfm image in a image2d<float>. + /// + /// \param[in] filename The image source. + /// + /// \return An image2d<float> which contains loaded data. + /// image2d<float> load(const std::string& filename); # ifndef MLN_INCLUDE_ONLY diff --git a/milena/mln/io/pfm/save.hh b/milena/mln/io/pfm/save.hh index 1743e20..f9db876 100644 --- a/milena/mln/io/pfm/save.hh +++ b/milena/mln/io/pfm/save.hh @@ -29,13 +29,10 @@ #ifndef MLN_IO_PFM_SAVE_HH # define MLN_IO_PFM_SAVE_HH -/*! - * \file mln/io/pfm/save.hh - * - * \brief Define a function which saves an image of kind pfm into - * given path. - * - */ +/// \file mln/io/pfm/save.hh +/// +/// Define a function which saves an image of kind pfm into +/// given path. # include <iostream> # include <fstream> @@ -55,11 +52,11 @@ namespace mln namespace pfm { - /*! Save a Milena image as a pfm image. - * - * \param[in] ima The image to save. - * \param[in,out] filename the destination. - */ + /// Save a Milena image as a pfm image. + /// + /// \param[in] ima The image to save. + /// \param[in,out] filename the destination. + /// template <typename I> void save(const Image<I>& ima, const std::string& filename); @@ -68,11 +65,9 @@ namespace mln namespace impl { - // FIXME: Argument FILENAME is not used; remove? template <typename I> inline - void save_header_(const I& ima, const std::string& filename, - std::ofstream& file) + void save_header_(const I& ima, std::ofstream& file) { file << geom::nrows(ima) << ' ' << geom::nrows(ima) << std::endl << "float" << std::endl; @@ -83,11 +78,11 @@ namespace mln void save_(const Image<I>& ima_, const std::string& filename) { const I& ima = exact(ima_); + std::ofstream file(filename.c_str()); - save_header_(ima, filename, file); + save_header_(ima, file); - unsigned int - ncols = geom::ncols(ima); + unsigned int ncols = geom::ncols(ima); const mln_deduce(I, site, coord) min_row = geom::min_row(ima), diff --git a/milena/tests/io/off/load_bin.cc b/milena/tests/io/off/load_bin.cc index 4474f6e..5cac72c 100644 --- a/milena/tests/io/off/load_bin.cc +++ b/milena/tests/io/off/load_bin.cc @@ -26,7 +26,8 @@ // Public License. /// \file tests/io/off/load_bin.cc -/// \brief Test mln::io::off::load with an mln::bin_2complex_image3df. +/// +/// Test mln::io::off::load with an mln::bin_2complex_image3df. #include <algorithm> #include <iterator> diff --git a/milena/tests/io/off/load_float.cc b/milena/tests/io/off/load_float.cc index 7cbe625..06199e9 100644 --- a/milena/tests/io/off/load_float.cc +++ b/milena/tests/io/off/load_float.cc @@ -26,7 +26,8 @@ // Public License. /// \file tests/io/off/load_float.cc -/// \brief Test mln::io::off::load with an mln::float_2complex_image3df. +/// +/// Test mln::io::off::load with an mln::float_2complex_image3df. #include <algorithm> #include <iterator> @@ -36,6 +37,7 @@ #include "tests/data.hh" +// FIXME: write a test! int main() { @@ -43,7 +45,7 @@ int main() typedef float_2complex_image3df ima_t; ima_t ima; - io::off::load(ima, MLN_MESH_DIR "/cone-curv.off"); + io::off::load(ima, MLN_MESH_DIR "/cone-max-curv.off"); std::cout << ima.domain().cplx() << std::endl; diff --git a/milena/tests/io/off/load_save_bin.cc b/milena/tests/io/off/load_save_bin.cc index 2dbbdcb..2af3f9d 100644 --- a/milena/tests/io/off/load_save_bin.cc +++ b/milena/tests/io/off/load_save_bin.cc @@ -26,7 +26,8 @@ // Public License. /// \file tests/io/off/load_save_bin.cc -/// \brief Test mln::io::off::load with and mln::io::off::save with an +/// +/// Test mln::io::off::load with and mln::io::off::save with an /// mln::bin_2complex_image3df. #include <algorithm> -- 1.5.6.5
16Â years, 1Â month
1
0
0
0
3054: Fix tests.
by Guillaume Lazzara
* milena/headers.mk: update includes part of the distribution. * milena/mln/core/image/fun_image.hh * milena/mln/fun/v2w_w2v/norm.hh * milena/mln/io/off/load.hh: cleanup comments. * milena/mln/topo/adj_higher_face_iter.hh * milena/mln/topo/adj_lower_face_iter.hh * milena/mln/topo/adj_m_face_iter.hh * milena/mln/value/graylevel.hh * milena/mln/value/graylevel_f.hh * milena/mln/value/internal/gray_.hh * milena/mln/value/internal/gray_f.hh: fix includes/forward declarations. * milena/tests/unit_test/Makefile.am, * milena/tests/unit_test/mln_core_image_fun_image.cc, * milena/tests/unit_test/mln_fun_internal_ch_function_value_impl.cc, * milena/tests/unit_test/mln_fun_meta_hue.cc, * milena/tests/unit_test/mln_fun_meta_inty.cc, * milena/tests/unit_test/mln_fun_meta_red.cc, * milena/tests/unit_test/mln_fun_meta_sat.cc, * milena/tests/unit_test/mln_fun_meta_to_enc.cc, * milena/tests/unit_test/mln_fun_v2v_ch_function_value.cc, * milena/tests/unit_test/mln_fun_v2w2v_cos.cc, * milena/tests/unit_test/mln_fun_v2w_w2v_norm.cc, * milena/tests/unit_test/mln_fun_vv2b_eq.cc, * milena/tests/unit_test/mln_fun_vv2b_ge.cc, * milena/tests/unit_test/mln_fun_vv2b_gt.cc, * milena/tests/unit_test/mln_fun_vv2b_implies.cc, * milena/tests/unit_test/mln_fun_vv2b_le.cc, * milena/tests/unit_test/mln_fun_vv2b_lt.cc, * milena/tests/unit_test/mln_trait_ch_function_value.cc: add new unit tests. --- milena/ChangeLog | 39 +++++++++++ milena/headers.mk | 17 +++++ milena/mln/core/image/fun_image.hh | 16 ++--- milena/mln/fun/v2w_w2v/norm.hh | 47 ++++++------- milena/mln/io/off/load.hh | 24 ++++---- milena/mln/topo/adj_higher_face_iter.hh | 6 +- milena/mln/topo/adj_lower_face_iter.hh | 6 +- milena/mln/topo/adj_m_face_iter.hh | 12 ++-- milena/mln/value/graylevel.hh | 14 ++-- milena/mln/value/graylevel_f.hh | 18 +++--- milena/mln/value/internal/gray_.hh | 70 +++++++++++--------- milena/mln/value/internal/gray_f.hh | 31 +++++++-- milena/tests/unit_test/Makefile.am | 34 ++++++++++ milena/tests/unit_test/mln_core_image_fun_image.cc | 11 +++ .../mln_fun_internal_ch_function_value_impl.cc | 11 +++ milena/tests/unit_test/mln_fun_meta_hue.cc | 11 +++ milena/tests/unit_test/mln_fun_meta_inty.cc | 11 +++ milena/tests/unit_test/mln_fun_meta_red.cc | 11 +++ milena/tests/unit_test/mln_fun_meta_sat.cc | 11 +++ milena/tests/unit_test/mln_fun_meta_to_enc.cc | 11 +++ .../unit_test/mln_fun_v2v_ch_function_value.cc | 11 +++ milena/tests/unit_test/mln_fun_v2w2v_cos.cc | 11 +++ milena/tests/unit_test/mln_fun_v2w_w2v_norm.cc | 11 +++ milena/tests/unit_test/mln_fun_vv2b_eq.cc | 11 +++ milena/tests/unit_test/mln_fun_vv2b_ge.cc | 11 +++ milena/tests/unit_test/mln_fun_vv2b_gt.cc | 11 +++ milena/tests/unit_test/mln_fun_vv2b_implies.cc | 11 +++ milena/tests/unit_test/mln_fun_vv2b_le.cc | 11 +++ milena/tests/unit_test/mln_fun_vv2b_lt.cc | 11 +++ .../tests/unit_test/mln_trait_ch_function_value.cc | 11 +++ 30 files changed, 410 insertions(+), 111 deletions(-) create mode 100644 milena/tests/unit_test/mln_core_image_fun_image.cc create mode 100644 milena/tests/unit_test/mln_fun_internal_ch_function_value_impl.cc create mode 100644 milena/tests/unit_test/mln_fun_meta_hue.cc create mode 100644 milena/tests/unit_test/mln_fun_meta_inty.cc create mode 100644 milena/tests/unit_test/mln_fun_meta_red.cc create mode 100644 milena/tests/unit_test/mln_fun_meta_sat.cc create mode 100644 milena/tests/unit_test/mln_fun_meta_to_enc.cc create mode 100644 milena/tests/unit_test/mln_fun_v2v_ch_function_value.cc create mode 100644 milena/tests/unit_test/mln_fun_v2w2v_cos.cc create mode 100644 milena/tests/unit_test/mln_fun_v2w_w2v_norm.cc create mode 100644 milena/tests/unit_test/mln_fun_vv2b_eq.cc create mode 100644 milena/tests/unit_test/mln_fun_vv2b_ge.cc create mode 100644 milena/tests/unit_test/mln_fun_vv2b_gt.cc create mode 100644 milena/tests/unit_test/mln_fun_vv2b_implies.cc create mode 100644 milena/tests/unit_test/mln_fun_vv2b_le.cc create mode 100644 milena/tests/unit_test/mln_fun_vv2b_lt.cc create mode 100644 milena/tests/unit_test/mln_trait_ch_function_value.cc diff --git a/milena/ChangeLog b/milena/ChangeLog index a4bb060..31fada1 100644 --- a/milena/ChangeLog +++ b/milena/ChangeLog @@ -1,5 +1,44 @@ 2008-12-16 Guillaume Lazzara <z(a)lrde.epita.fr> + Fix tests. + + * milena/headers.mk: update includes part of the distribution. + + * milena/mln/core/image/fun_image.hh + * milena/mln/fun/v2w_w2v/norm.hh + * milena/mln/io/off/load.hh: cleanup comments. + + * milena/mln/topo/adj_higher_face_iter.hh + * milena/mln/topo/adj_lower_face_iter.hh + * milena/mln/topo/adj_m_face_iter.hh + * milena/mln/value/graylevel.hh + * milena/mln/value/graylevel_f.hh + * milena/mln/value/internal/gray_.hh + * milena/mln/value/internal/gray_f.hh: fix includes/forward + declarations. + + * milena/tests/unit_test/Makefile.am, + * milena/tests/unit_test/mln_core_image_fun_image.cc, + * milena/tests/unit_test/mln_fun_internal_ch_function_value_impl.cc, + * milena/tests/unit_test/mln_fun_meta_hue.cc, + * milena/tests/unit_test/mln_fun_meta_inty.cc, + * milena/tests/unit_test/mln_fun_meta_red.cc, + * milena/tests/unit_test/mln_fun_meta_sat.cc, + * milena/tests/unit_test/mln_fun_meta_to_enc.cc, + * milena/tests/unit_test/mln_fun_v2v_ch_function_value.cc, + * milena/tests/unit_test/mln_fun_v2w2v_cos.cc, + * milena/tests/unit_test/mln_fun_v2w_w2v_norm.cc, + * milena/tests/unit_test/mln_fun_vv2b_eq.cc, + * milena/tests/unit_test/mln_fun_vv2b_ge.cc, + * milena/tests/unit_test/mln_fun_vv2b_gt.cc, + * milena/tests/unit_test/mln_fun_vv2b_implies.cc, + * milena/tests/unit_test/mln_fun_vv2b_le.cc, + * milena/tests/unit_test/mln_fun_vv2b_lt.cc, + * milena/tests/unit_test/mln_trait_ch_function_value.cc: add new + unit tests. + +2008-12-16 Guillaume Lazzara <z(a)lrde.epita.fr> + Cleanup morpho. * milena/mln/morpho/closing.hh, diff --git a/milena/headers.mk b/milena/headers.mk index e528542..240f896 100644 --- a/milena/headers.mk +++ b/milena/headers.mk @@ -176,7 +176,9 @@ mln/fun/vv2v/min.hh \ mln/fun/vv2v/essential.hh \ mln/fun/internal/array_base.hh \ mln/fun/internal/x2x_linear_impl.hh \ +mln/fun/internal/ch_function_value_impl.hh \ mln/fun/internal/selector.hh \ +mln/fun/v2w_w2v/norm.hh \ mln/fun/p2v/ternary.hh \ mln/fun/p2v/iota.hh \ mln/fun/p2v/elifs.hh \ @@ -196,10 +198,18 @@ mln/fun/v2v/all.hh \ mln/fun/v2v/dec.hh \ mln/fun/v2v/abs.hh \ mln/fun/v2v/cast.hh \ +mln/fun/v2v/ch_function_value.hh \ mln/fun/v2v/rgb_to_hsi.hh \ mln/fun/v2v/enc.hh \ mln/fun/v2v/convert.hh \ mln/fun/v2v/essential.hh \ +mln/fun/v2w2v/cos.hh \ +mln/fun/vv2b/implies.hh \ +mln/fun/vv2b/le.hh \ +mln/fun/vv2b/gt.hh \ +mln/fun/vv2b/ge.hh \ +mln/fun/vv2b/lt.hh \ +mln/fun/vv2b/eq.hh \ mln/fun/cast.hh \ mln/fun/i2v/all.hh \ mln/fun/i2v/array.hh \ @@ -213,6 +223,11 @@ mln/fun/x2x/all.hh \ mln/fun/x2x/translation.hh \ mln/fun/x2x/rotation.hh \ mln/fun/x2x/essential.hh \ +mln/fun/meta/red.hh \ +mln/fun/meta/hue.hh \ +mln/fun/meta/inty.hh \ +mln/fun/meta/sat.hh \ +mln/fun/meta/to_enc.hh \ mln/fun/x2v/linear.hh \ mln/fun/x2v/bilinear.hh \ mln/fun/x2v/all.hh \ @@ -415,6 +430,7 @@ mln/trait/value/essential.hh \ mln/trait/images.hh \ mln/trait/window/props.hh \ mln/trait/window/print.hh \ +mln/trait/ch_function_value.hh \ mln/trait/ch_value.hh \ mln/trait/solve.hh \ mln/trait/solve_unary.hh \ @@ -854,6 +870,7 @@ mln/core/image/lazy_image.hh \ mln/core/image/t_image.hh \ mln/core/image/hexa_piter.hh \ mln/core/image/value_enc_image.hh \ +mln/core/image/fun_image.hh \ mln/core/image/sub_image_if.hh \ mln/core/image/all.hh \ mln/core/image/mono_rle_image.hh \ diff --git a/milena/mln/core/image/fun_image.hh b/milena/mln/core/image/fun_image.hh index 505b012..f338d08 100644 --- a/milena/mln/core/image/fun_image.hh +++ b/milena/mln/core/image/fun_image.hh @@ -1,4 +1,5 @@ // Copyright (C) 2007, 2008 EPITA Research and Development Laboratory +// (LRDE) // // This file is part of the Olena Library. This library is free // software; you can redistribute it and/or modify it under the terms @@ -28,12 +29,10 @@ #ifndef MLN_CORE_IMAGE_FUN_IMAGE_HH # define MLN_CORE_IMAGE_FUN_IMAGE_HH -/*! \file mln/core/image/fun_image.hh - * - * \brief Definition of an image morpher that make the user see the - * image through a function - * - */ +/// \file mln/core/image/fun_image.hh +/// +/// Definition of an image morpher that make the user see the +/// image through a function # include <mln/core/internal/image_value_morpher.hh> # include <mln/trait/images.hh> @@ -45,7 +44,7 @@ namespace mln { - // Fwd decl. + // Forward declaration. template <typename F, typename I> class fun_image; namespace internal @@ -93,8 +92,7 @@ namespace mln - /*! \brief Class of image morpher which takes allow to view an image throught a morpher - */ + /// Class of image morpher which takes allow to view an image throught a morpher template <typename F, typename I> struct fun_image : public internal::image_value_morpher< I, mln_result(F), fun_image<F,I> > diff --git a/milena/mln/fun/v2w_w2v/norm.hh b/milena/mln/fun/v2w_w2v/norm.hh index 51a2914..4dbb7cb 100644 --- a/milena/mln/fun/v2w_w2v/norm.hh +++ b/milena/mln/fun/v2w_w2v/norm.hh @@ -1,4 +1,5 @@ -// Copyright (C) 2007 EPITA Research and Development Laboratory +// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory +// (LRDE) // // This file is part of the Olena Library. This library is free // software; you can redistribute it and/or modify it under the terms @@ -28,12 +29,11 @@ #ifndef MLN_FUN_V2W_W2V_NORM_HH # define MLN_FUN_V2W_W2V_NORM_HH -/*! \file mln/fun/v2w_w2v/norm.hh - * - * \brief Norm functors. - * - * \see mln/norm/. - */ +/// \file mln/fun/v2w_w2v/norm.hh +/// +/// \brief Norm functors. +/// +/// \see mln/norm/. # include <mln/core/concept/function.hh> # include <mln/trait/value_.hh> @@ -50,12 +50,11 @@ namespace mln namespace v2w_w2v { - /*! \brief L1-norm. - * - * \c V is the type of input values; \c R is the result type. - * - * \see mln::norm::l1. - */ + /// L1-norm. + /// + /// \c V is the type of input values; \c R is the result type. + /// + /// \see mln::norm::l1. template <typename V, typename R> struct l1_norm : public Function_v2w_w2v< l1_norm<V, R> > { @@ -64,12 +63,11 @@ namespace mln V f_1(const V& v, const R& r) const; }; - /*! \brief L2-norm. - * - * \c V is the type of input values; \c R is the result type. - * - * \see mln::norm::l2. - */ + /// L2-norm. + /// + /// \c V is the type of input values; \c R is the result type. + /// + /// \see mln::norm::l2. template <typename V, typename R> struct l2_norm : public Function_v2w_w2v< l2_norm<V, R> > { @@ -78,12 +76,11 @@ namespace mln V f_1(const V& v, const R& r) const; }; - /*! \brief L-infty norm. - * - * \c V is the type of input values; \c R is the result type. - * - * \see mln::norm::linfty. - */ + /// L-infty norm. + /// + /// \c V is the type of input values; \c R is the result type. + /// + /// \see mln::norm::linfty. template <typename V, typename R> struct linfty_norm : public Function_v2w_w2v< linfty_norm<V, R> > { diff --git a/milena/mln/io/off/load.hh b/milena/mln/io/off/load.hh index 5bfebf3..03fc3f3 100644 --- a/milena/mln/io/off/load.hh +++ b/milena/mln/io/off/load.hh @@ -29,7 +29,7 @@ # define MLN_IO_OFF_LOAD_HH /// \file mln/io/off/load.hh -/// \brief Input loading function for OFF files. +/// Input loading function for OFF files. /// /// \see
http://shape.cs.princeton.edu/benchmark/documentation/off_format.html
/// \see
https://people.scs.fsu.edu/~burkardt/html/off_format.html
@@ -54,7 +54,7 @@ namespace mln namespace off { - /** \brief Load a (binary) OFF image into a complex image. + /** Load a (binary) OFF image into a complex image. \param[out] ima A reference to the image to construct. \param[in] filename The name of the file to load. @@ -63,7 +63,7 @@ namespace mln existence of faces. */ void load(bin_2complex_image3df& ima, const std::string& filename); - /** \brief Load a floating-point OFF image into a complex image. + /** Load a floating-point OFF image into a complex image. \param[out] ima A reference to the image to construct. \param[in] filename The name of the file to load. @@ -88,7 +88,7 @@ namespace mln /// Type of the domain. typedef mln_pset(I) domain; - /// \brief Constructor, with static checks. + /// Constructor, with static checks. off_loader(); /// Load an image from \a filename into \a ima. @@ -103,15 +103,15 @@ namespace mln struct bin_off_loader : public off_loader< bin_2complex_image3df, bin_off_loader > { - /// \brief Read face data. + /// Read face data. /// /// Dummy, does nothings (but required by the super class). void read_face_data(std::istream& istr); - /// \brief Assign values to image. + /// Assign values to image. void assign(values& vs, const domain& s); - /// \brief Pre-allocate data. + /// Pre-allocate data. /// /// Dummy, does nothings (but required by the super class). void reserve(unsigned nvertices, unsigned nedges, unsigned nfaces); @@ -121,16 +121,16 @@ namespace mln struct float_off_loader : public off_loader< float_2complex_image3df, float_off_loader > { - /// \brief Read face data. + /// Read face data. void read_face_data(std::istream& istr); - /// \brief Pre-allocate data. + /// Pre-allocate data. void reserve(unsigned nvertices, unsigned nedges, unsigned nfaces); - /// \brief Assign values to image. + /// Assign values to image. void assign(values& vs, const domain& s); - /// \brief 2-face floating-point values. + /// 2-face floating-point values. std::vector<float> face_value; }; @@ -416,7 +416,7 @@ namespace mln in the following comment. */ - /** \brief Reading values. + /** Reading values. From
https://people.scs.fsu.edu/~burkardt/html/off_format.html
: diff --git a/milena/mln/topo/adj_higher_face_iter.hh b/milena/mln/topo/adj_higher_face_iter.hh index fcd9d0f..120b234 100644 --- a/milena/mln/topo/adj_higher_face_iter.hh +++ b/milena/mln/topo/adj_higher_face_iter.hh @@ -55,11 +55,11 @@ namespace mln template <typename C, typename F, typename E> class backward_complex_relative_iterator_base; - template <unsigned D> - struct algebraic_face; - } // end of mln::topo::internal + template <unsigned D> + struct algebraic_face; + /*------------------------------------. | topo::adj_higher_face_fwd_iter<D>. | `------------------------------------*/ diff --git a/milena/mln/topo/adj_lower_face_iter.hh b/milena/mln/topo/adj_lower_face_iter.hh index 22c965a..293da90 100644 --- a/milena/mln/topo/adj_lower_face_iter.hh +++ b/milena/mln/topo/adj_lower_face_iter.hh @@ -55,11 +55,11 @@ namespace mln template <typename C, typename F, typename E> class backward_complex_relative_iterator_base; - template <unsigned D> - struct algebraic_face; - } // end of namespace mln::topo::internal + template <unsigned D> + struct algebraic_face; + /*-----------------------------------. | topo::adj_lower_face_fwd_iter<D>. | diff --git a/milena/mln/topo/adj_m_face_iter.hh b/milena/mln/topo/adj_m_face_iter.hh index e314dfb..0cd69fa 100644 --- a/milena/mln/topo/adj_m_face_iter.hh +++ b/milena/mln/topo/adj_m_face_iter.hh @@ -30,7 +30,7 @@ /// \file mln/topo/adj_m_face_iter.hh -/// \brief Definition of forward and backward iterators on all the +/// Definition of forward and backward iterators on all the /// m-faces transitively adjacent to a (reference) n-face in a /// complex. @@ -59,7 +59,7 @@ namespace mln | topo::adj_m_face_fwd_iter<D>. | `-------------------------------*/ - /** \brief Forward iterator on all the m-faces transitively + /** Forward iterator on all the m-faces transitively adjacent to a (reference) n-face in a complex. \tparam D The dimension of the complex this iterator belongs to. @@ -94,7 +94,7 @@ namespace mln adj_m_face_fwd_iter(const Fref& f_ref, unsigned m); /// \} - /// \brief Compute the set of faces adjacent to the reference face. + /// Compute the set of faces adjacent to the reference face. /// /// The computation is delegated to /// mln::topo::internal::adj_m_face_iterator. @@ -106,7 +106,7 @@ namespace mln | topo::adj_m_face_bkd_iter<D>. | `-------------------------------*/ - /** \brief Backward iterator on all the m-faces transitively + /** Backward iterator on all the m-faces transitively adjacent to a (reference) n-face in a complex. \tparam D The dimension of the complex this iterator belongs to. @@ -141,7 +141,7 @@ namespace mln adj_m_face_bkd_iter(const Fref& f_ref, unsigned m); /// \} - /// \brief Compute the set of faces adjacent to the reference face. + /// Compute the set of faces adjacent to the reference face. /// /// The computation is delegated to /// mln::topo::internal::adj_m_face_iterator. @@ -289,7 +289,7 @@ namespace mln if (center.n() == m_) return; - + typedef std::vector < topo::algebraic_face<D> > faces_t; typedef std::set < topo::algebraic_face<D> > faces_set_t; diff --git a/milena/mln/value/graylevel.hh b/milena/mln/value/graylevel.hh index 9cd6071..3d89097 100644 --- a/milena/mln/value/graylevel.hh +++ b/milena/mln/value/graylevel.hh @@ -1,4 +1,5 @@ -// Copyright (C) 2006, 2007 EPITA Research and Development Laboratory +// Copyright (C) 2006, 2007, 2008 EPITA Research and Development +// Laboratory (LRDE) // // This file is part of the Olena Library. This library is free // software; you can redistribute it and/or modify it under the terms @@ -28,10 +29,9 @@ #ifndef MLN_VALUE_GRAYLEVEL_HH # define MLN_VALUE_GRAYLEVEL_HH -/*! \file mln/value/graylevel.hh - * - * \brief Definition of the mln::value::graylevel class. - */ +/// \file mln/value/graylevel.hh +/// +/// Definition of the mln::value::graylevel class. # include <iostream> @@ -53,7 +53,7 @@ namespace mln namespace literal { - /// \{ Fwd decls. + /// \{ Forward declarations. struct black_t; struct medium_gray_t; struct white_t; @@ -62,7 +62,7 @@ namespace mln namespace value { - /// \{ Fwd decls. + /// \{ Forward declarations. namespace internal { template <unsigned n> class gray_; diff --git a/milena/mln/value/graylevel_f.hh b/milena/mln/value/graylevel_f.hh index 0b36ba0..6bf30f9 100644 --- a/milena/mln/value/graylevel_f.hh +++ b/milena/mln/value/graylevel_f.hh @@ -1,4 +1,5 @@ -// Copyright (C) 2006, 2007 EPITA Research and Development Laboratory +// Copyright (C) 2006, 2007, 2008 EPITA Research and Development +// Laboratory (LRDE) // // This file is part of the Olena Library. This library is free // software; you can redistribute it and/or modify it under the terms @@ -28,10 +29,9 @@ #ifndef MLN_VALUE_GRAYLEVEL_F_HH # define MLN_VALUE_GRAYLEVEL_F_HH -/*! \file mln/value/graylevel_f.hh - * - * \brief Definition of the mln::value::graylevel_f class. - */ +/// \file mln/value/graylevel_f.hh +/// +/// Definition of the mln::value::graylevel_f class. # include <iostream> @@ -51,7 +51,7 @@ namespace mln namespace literal { - /// \{ Fwd decls. + /// \{ Forward declarations. struct black_t; struct medium_gray_t; struct white_t; @@ -59,7 +59,7 @@ namespace mln } namespace value { - /// \{ Fwd decls. + /// \{ Forward declarations. namespace internal {class gray_f; } struct graylevel_f; template <unsigned n> struct graylevel; @@ -467,7 +467,7 @@ namespace mln } // end of namespace mln -#include <mln/value/internal/gray_f.hh> -#include <mln/value/internal/gray_.hh> +//# include <mln/value/internal/gray_f.hh> +///# include <mln/value/internal/gray_.hh> #endif // ! MLN_VALUE_GRAYLEVEL_F_HH diff --git a/milena/mln/value/internal/gray_.hh b/milena/mln/value/internal/gray_.hh index 81ed72b..8faf99d 100644 --- a/milena/mln/value/internal/gray_.hh +++ b/milena/mln/value/internal/gray_.hh @@ -29,11 +29,9 @@ #ifndef MLN_VALUE_INTERNAL_GRAY__HH # define MLN_VALUE_INTERNAL_GRAY__HH -/*! \file mln/value/internal/gray_.hh - * - * \brief FIXME. - * - */ +/// \file mln/value/internal/gray_.hh +/// +/// FIXME. # include <iostream> # include <cmath> @@ -42,14 +40,16 @@ # include <mln/metal/math/pow.hh> # include <mln/value/concept/integer.hh> +# include <mln/value/internal/value_like.hh> +# include <mln/value/graylevel_f.hh> namespace mln { namespace literal { - /// \{ Fwd decls. + /// \{ Forward declarations. struct black_t; struct white_t; /// \} @@ -57,13 +57,15 @@ namespace mln namespace value { - /// \{ Fwd decls. + /// \{ Forward declarations. + template <unsigned n> + struct graylevel; template <unsigned N> class graylevel; class graylevel_f; namespace internal { template <unsigned n> class gray_; - class gray_f; + struct gray_f; } /// \} } @@ -176,42 +178,49 @@ namespace mln operator graylevel<m>() const; /// Conversion to graylevel_f. - operator graylevel_f() const; + operator graylevel_f() const; }; // Operators. - template <unsigned n> - std::ostream& operator<<(std::ostream& ostr, const gray_<n>& g); + template <unsigned n> + std::ostream& operator<<(std::ostream& ostr, const gray_<n>& g); - template <unsigned n, unsigned m> - bool operator==(const gray_<n>& lhs, const gray_<m>& rhs); - template <unsigned n, unsigned m> - bool operator<(const gray_<n>& lhs, const gray_<m>& rhs); + template <unsigned n, unsigned m> + bool operator==(const gray_<n>& lhs, const gray_<m>& rhs); + template <unsigned n, unsigned m> + bool operator<(const gray_<n>& lhs, const gray_<m>& rhs); - template <unsigned n, unsigned m> - mln_trait_op_plus(gray_<n>, gray_<m>) - operator+(const gray_<n>& lhs, const gray_<m>& rhs); + template <unsigned n, unsigned m> + mln_trait_op_plus(gray_<n>, gray_<m>) + operator+(const gray_<n>& lhs, const gray_<m>& rhs); - template <unsigned n, unsigned m> - mln_trait_op_minus(gray_<n>, gray_<m>) - operator-(const gray_<n>& lhs, const gray_<m>& rhs); + template <unsigned n, unsigned m> + mln_trait_op_minus(gray_<n>, gray_<m>) + operator-(const gray_<n>& lhs, const gray_<m>& rhs); - template <unsigned n> - gray_<n> operator*(int s, const gray_<n>& rhs); - template <unsigned n> - gray_<n> operator*(const gray_<n>& lhs, int s); - template <unsigned n> - gray_<n> operator/(const gray_<n>& lhs, int s); + template <unsigned n> + gray_<n> operator*(int s, const gray_<n>& rhs); + template <unsigned n> + gray_<n> operator*(const gray_<n>& lhs, int s); + template <unsigned n> + gray_<n> operator/(const gray_<n>& lhs, int s); + + } // end of namespace mln::value::internal + + } // end of namespace mln::value - } // end of namespace mln::value::internal +} // end of namespace mln -} // end of namespace mln::value +# include <mln/value/internal/gray_f.hh> +namespace mln +{ + # ifndef MLN_INCLUDE_ONLY namespace value @@ -583,7 +592,7 @@ namespace mln // Op / Builtin. - /// \{ Fwd decls. + /// \{ Forward declarations. namespace internal { class gray_f; @@ -718,5 +727,4 @@ namespace trait } // end of namespace mln - #endif // ! MLN_INTERNAL_VALUE_GRAY__HH diff --git a/milena/mln/value/internal/gray_f.hh b/milena/mln/value/internal/gray_f.hh index b7ab9e2..2ff9551 100644 --- a/milena/mln/value/internal/gray_f.hh +++ b/milena/mln/value/internal/gray_f.hh @@ -29,10 +29,10 @@ #ifndef MLN_VALUE_INTERNAL_GRAY_F_HH # define MLN_VALUE_INTERNAL_GRAY_F_HH -/*! \file mln/value/internal/gray_f.hh - * - * \brief Definition of the mln::value::gray_f class. - */ +/// \file mln/value/internal/gray_f.hh +/// +/// Definition of the mln::value::gray_f class. + # include <iostream> @@ -46,13 +46,14 @@ # include <mln/value/float01_f.hh> # include <mln/trait/value_.hh> +# include <mln/value/graylevel_f.hh> namespace mln { namespace literal { - /// \{ Fwd decls. + /// \{ Forward declarations. struct black_t; struct medium_gray_t; struct white_t; @@ -60,7 +61,7 @@ namespace mln } namespace value { - /// \{ Fwd decls. + /// \{ Forward declarations. namespace internal { template <unsigned n> class gray_; @@ -198,6 +199,24 @@ namespace mln /// Op<<. std::ostream& operator<<(std::ostream& ostr, const gray_f& g); + } // end of namespace mln::value::internal + + } // end of namespace mln::value + +} // end of namespace mln + + +# include <mln/value/internal/gray_.hh> + + +namespace mln +{ + + namespace value + { + + namespace internal + { # ifndef MLN_INCLUDE_ONLY diff --git a/milena/tests/unit_test/Makefile.am b/milena/tests/unit_test/Makefile.am index 0ab70a9..a740cc1 100644 --- a/milena/tests/unit_test/Makefile.am +++ b/milena/tests/unit_test/Makefile.am @@ -179,7 +179,9 @@ mln_fun_vv2v_min \ mln_fun_vv2v_essential \ mln_fun_internal_array_base \ mln_fun_internal_x2x_linear_impl \ +mln_fun_internal_ch_function_value_impl \ mln_fun_internal_selector \ +mln_fun_v2w_w2v_norm \ mln_fun_p2v_ternary \ mln_fun_p2v_iota \ mln_fun_p2v_elifs \ @@ -199,10 +201,18 @@ mln_fun_v2v_all \ mln_fun_v2v_dec \ mln_fun_v2v_abs \ mln_fun_v2v_cast \ +mln_fun_v2v_ch_function_value \ mln_fun_v2v_rgb_to_hsi \ mln_fun_v2v_enc \ mln_fun_v2v_convert \ mln_fun_v2v_essential \ +mln_fun_v2w2v_cos \ +mln_fun_vv2b_implies \ +mln_fun_vv2b_le \ +mln_fun_vv2b_gt \ +mln_fun_vv2b_ge \ +mln_fun_vv2b_lt \ +mln_fun_vv2b_eq \ mln_fun_cast \ mln_fun_i2v_all \ mln_fun_i2v_array \ @@ -216,6 +226,11 @@ mln_fun_x2x_all \ mln_fun_x2x_translation \ mln_fun_x2x_rotation \ mln_fun_x2x_essential \ +mln_fun_meta_red \ +mln_fun_meta_hue \ +mln_fun_meta_inty \ +mln_fun_meta_sat \ +mln_fun_meta_to_enc \ mln_fun_x2v_linear \ mln_fun_x2v_bilinear \ mln_fun_x2v_all \ @@ -411,6 +426,7 @@ mln_trait_value_essential \ mln_trait_images \ mln_trait_window_props \ mln_trait_window_print \ +mln_trait_ch_function_value \ mln_trait_ch_value \ mln_trait_solve \ mln_trait_solve_unary \ @@ -828,6 +844,7 @@ mln_core_image_lazy_image \ mln_core_image_t_image \ mln_core_image_hexa_piter \ mln_core_image_value_enc_image \ +mln_core_image_fun_image \ mln_core_image_sub_image_if \ mln_core_image_all \ mln_core_image_mono_rle_image \ @@ -1154,7 +1171,9 @@ mln_fun_vv2v_min_SOURCES = mln_fun_vv2v_min.cc mln_fun_vv2v_essential_SOURCES = mln_fun_vv2v_essential.cc mln_fun_internal_array_base_SOURCES = mln_fun_internal_array_base.cc mln_fun_internal_x2x_linear_impl_SOURCES = mln_fun_internal_x2x_linear_impl.cc +mln_fun_internal_ch_function_value_impl_SOURCES = mln_fun_internal_ch_function_value_impl.cc mln_fun_internal_selector_SOURCES = mln_fun_internal_selector.cc +mln_fun_v2w_w2v_norm_SOURCES = mln_fun_v2w_w2v_norm.cc mln_fun_p2v_ternary_SOURCES = mln_fun_p2v_ternary.cc mln_fun_p2v_iota_SOURCES = mln_fun_p2v_iota.cc mln_fun_p2v_elifs_SOURCES = mln_fun_p2v_elifs.cc @@ -1174,10 +1193,18 @@ mln_fun_v2v_all_SOURCES = mln_fun_v2v_all.cc mln_fun_v2v_dec_SOURCES = mln_fun_v2v_dec.cc mln_fun_v2v_abs_SOURCES = mln_fun_v2v_abs.cc mln_fun_v2v_cast_SOURCES = mln_fun_v2v_cast.cc +mln_fun_v2v_ch_function_value_SOURCES = mln_fun_v2v_ch_function_value.cc mln_fun_v2v_rgb_to_hsi_SOURCES = mln_fun_v2v_rgb_to_hsi.cc mln_fun_v2v_enc_SOURCES = mln_fun_v2v_enc.cc mln_fun_v2v_convert_SOURCES = mln_fun_v2v_convert.cc mln_fun_v2v_essential_SOURCES = mln_fun_v2v_essential.cc +mln_fun_v2w2v_cos_SOURCES = mln_fun_v2w2v_cos.cc +mln_fun_vv2b_implies_SOURCES = mln_fun_vv2b_implies.cc +mln_fun_vv2b_le_SOURCES = mln_fun_vv2b_le.cc +mln_fun_vv2b_gt_SOURCES = mln_fun_vv2b_gt.cc +mln_fun_vv2b_ge_SOURCES = mln_fun_vv2b_ge.cc +mln_fun_vv2b_lt_SOURCES = mln_fun_vv2b_lt.cc +mln_fun_vv2b_eq_SOURCES = mln_fun_vv2b_eq.cc mln_fun_cast_SOURCES = mln_fun_cast.cc mln_fun_i2v_all_SOURCES = mln_fun_i2v_all.cc mln_fun_i2v_array_SOURCES = mln_fun_i2v_array.cc @@ -1191,6 +1218,11 @@ mln_fun_x2x_all_SOURCES = mln_fun_x2x_all.cc mln_fun_x2x_translation_SOURCES = mln_fun_x2x_translation.cc mln_fun_x2x_rotation_SOURCES = mln_fun_x2x_rotation.cc mln_fun_x2x_essential_SOURCES = mln_fun_x2x_essential.cc +mln_fun_meta_red_SOURCES = mln_fun_meta_red.cc +mln_fun_meta_hue_SOURCES = mln_fun_meta_hue.cc +mln_fun_meta_inty_SOURCES = mln_fun_meta_inty.cc +mln_fun_meta_sat_SOURCES = mln_fun_meta_sat.cc +mln_fun_meta_to_enc_SOURCES = mln_fun_meta_to_enc.cc mln_fun_x2v_linear_SOURCES = mln_fun_x2v_linear.cc mln_fun_x2v_bilinear_SOURCES = mln_fun_x2v_bilinear.cc mln_fun_x2v_all_SOURCES = mln_fun_x2v_all.cc @@ -1386,6 +1418,7 @@ mln_trait_value_essential_SOURCES = mln_trait_value_essential.cc mln_trait_images_SOURCES = mln_trait_images.cc mln_trait_window_props_SOURCES = mln_trait_window_props.cc mln_trait_window_print_SOURCES = mln_trait_window_print.cc +mln_trait_ch_function_value_SOURCES = mln_trait_ch_function_value.cc mln_trait_ch_value_SOURCES = mln_trait_ch_value.cc mln_trait_solve_SOURCES = mln_trait_solve.cc mln_trait_solve_unary_SOURCES = mln_trait_solve_unary.cc @@ -1803,6 +1836,7 @@ mln_core_image_lazy_image_SOURCES = mln_core_image_lazy_image.cc mln_core_image_t_image_SOURCES = mln_core_image_t_image.cc mln_core_image_hexa_piter_SOURCES = mln_core_image_hexa_piter.cc mln_core_image_value_enc_image_SOURCES = mln_core_image_value_enc_image.cc +mln_core_image_fun_image_SOURCES = mln_core_image_fun_image.cc mln_core_image_sub_image_if_SOURCES = mln_core_image_sub_image_if.cc mln_core_image_all_SOURCES = mln_core_image_all.cc mln_core_image_mono_rle_image_SOURCES = mln_core_image_mono_rle_image.cc diff --git a/milena/tests/unit_test/mln_core_image_fun_image.cc b/milena/tests/unit_test/mln_core_image_fun_image.cc new file mode 100644 index 0000000..36bde5f --- /dev/null +++ b/milena/tests/unit_test/mln_core_image_fun_image.cc @@ -0,0 +1,11 @@ +// Unit test for mln/core/image/fun_image.hh. +// Generated by ./build_unit_test.sh, do not modify. + +// Include the file twice, so we detect missing inclusion guards. +#include <mln/core/image/fun_image.hh> +#include <mln/core/image/fun_image.hh> + +int main() +{ + // Nothing. +} diff --git a/milena/tests/unit_test/mln_fun_internal_ch_function_value_impl.cc b/milena/tests/unit_test/mln_fun_internal_ch_function_value_impl.cc new file mode 100644 index 0000000..63166aa --- /dev/null +++ b/milena/tests/unit_test/mln_fun_internal_ch_function_value_impl.cc @@ -0,0 +1,11 @@ +// Unit test for mln/fun/internal/ch_function_value_impl.hh. +// Generated by ./build_unit_test.sh, do not modify. + +// Include the file twice, so we detect missing inclusion guards. +#include <mln/fun/internal/ch_function_value_impl.hh> +#include <mln/fun/internal/ch_function_value_impl.hh> + +int main() +{ + // Nothing. +} diff --git a/milena/tests/unit_test/mln_fun_meta_hue.cc b/milena/tests/unit_test/mln_fun_meta_hue.cc new file mode 100644 index 0000000..e65142d --- /dev/null +++ b/milena/tests/unit_test/mln_fun_meta_hue.cc @@ -0,0 +1,11 @@ +// Unit test for mln/fun/meta/hue.hh. +// Generated by ./build_unit_test.sh, do not modify. + +// Include the file twice, so we detect missing inclusion guards. +#include <mln/fun/meta/hue.hh> +#include <mln/fun/meta/hue.hh> + +int main() +{ + // Nothing. +} diff --git a/milena/tests/unit_test/mln_fun_meta_inty.cc b/milena/tests/unit_test/mln_fun_meta_inty.cc new file mode 100644 index 0000000..6b31236 --- /dev/null +++ b/milena/tests/unit_test/mln_fun_meta_inty.cc @@ -0,0 +1,11 @@ +// Unit test for mln/fun/meta/inty.hh. +// Generated by ./build_unit_test.sh, do not modify. + +// Include the file twice, so we detect missing inclusion guards. +#include <mln/fun/meta/inty.hh> +#include <mln/fun/meta/inty.hh> + +int main() +{ + // Nothing. +} diff --git a/milena/tests/unit_test/mln_fun_meta_red.cc b/milena/tests/unit_test/mln_fun_meta_red.cc new file mode 100644 index 0000000..343f7ed --- /dev/null +++ b/milena/tests/unit_test/mln_fun_meta_red.cc @@ -0,0 +1,11 @@ +// Unit test for mln/fun/meta/red.hh. +// Generated by ./build_unit_test.sh, do not modify. + +// Include the file twice, so we detect missing inclusion guards. +#include <mln/fun/meta/red.hh> +#include <mln/fun/meta/red.hh> + +int main() +{ + // Nothing. +} diff --git a/milena/tests/unit_test/mln_fun_meta_sat.cc b/milena/tests/unit_test/mln_fun_meta_sat.cc new file mode 100644 index 0000000..ee3e7b1 --- /dev/null +++ b/milena/tests/unit_test/mln_fun_meta_sat.cc @@ -0,0 +1,11 @@ +// Unit test for mln/fun/meta/sat.hh. +// Generated by ./build_unit_test.sh, do not modify. + +// Include the file twice, so we detect missing inclusion guards. +#include <mln/fun/meta/sat.hh> +#include <mln/fun/meta/sat.hh> + +int main() +{ + // Nothing. +} diff --git a/milena/tests/unit_test/mln_fun_meta_to_enc.cc b/milena/tests/unit_test/mln_fun_meta_to_enc.cc new file mode 100644 index 0000000..01a94ca --- /dev/null +++ b/milena/tests/unit_test/mln_fun_meta_to_enc.cc @@ -0,0 +1,11 @@ +// Unit test for mln/fun/meta/to_enc.hh. +// Generated by ./build_unit_test.sh, do not modify. + +// Include the file twice, so we detect missing inclusion guards. +#include <mln/fun/meta/to_enc.hh> +#include <mln/fun/meta/to_enc.hh> + +int main() +{ + // Nothing. +} diff --git a/milena/tests/unit_test/mln_fun_v2v_ch_function_value.cc b/milena/tests/unit_test/mln_fun_v2v_ch_function_value.cc new file mode 100644 index 0000000..6f37975 --- /dev/null +++ b/milena/tests/unit_test/mln_fun_v2v_ch_function_value.cc @@ -0,0 +1,11 @@ +// Unit test for mln/fun/v2v/ch_function_value.hh. +// Generated by ./build_unit_test.sh, do not modify. + +// Include the file twice, so we detect missing inclusion guards. +#include <mln/fun/v2v/ch_function_value.hh> +#include <mln/fun/v2v/ch_function_value.hh> + +int main() +{ + // Nothing. +} diff --git a/milena/tests/unit_test/mln_fun_v2w2v_cos.cc b/milena/tests/unit_test/mln_fun_v2w2v_cos.cc new file mode 100644 index 0000000..860a918 --- /dev/null +++ b/milena/tests/unit_test/mln_fun_v2w2v_cos.cc @@ -0,0 +1,11 @@ +// Unit test for mln/fun/v2w2v/cos.hh. +// Generated by ./build_unit_test.sh, do not modify. + +// Include the file twice, so we detect missing inclusion guards. +#include <mln/fun/v2w2v/cos.hh> +#include <mln/fun/v2w2v/cos.hh> + +int main() +{ + // Nothing. +} diff --git a/milena/tests/unit_test/mln_fun_v2w_w2v_norm.cc b/milena/tests/unit_test/mln_fun_v2w_w2v_norm.cc new file mode 100644 index 0000000..4d6a930 --- /dev/null +++ b/milena/tests/unit_test/mln_fun_v2w_w2v_norm.cc @@ -0,0 +1,11 @@ +// Unit test for mln/fun/v2w_w2v/norm.hh. +// Generated by ./build_unit_test.sh, do not modify. + +// Include the file twice, so we detect missing inclusion guards. +#include <mln/fun/v2w_w2v/norm.hh> +#include <mln/fun/v2w_w2v/norm.hh> + +int main() +{ + // Nothing. +} diff --git a/milena/tests/unit_test/mln_fun_vv2b_eq.cc b/milena/tests/unit_test/mln_fun_vv2b_eq.cc new file mode 100644 index 0000000..66efcd7 --- /dev/null +++ b/milena/tests/unit_test/mln_fun_vv2b_eq.cc @@ -0,0 +1,11 @@ +// Unit test for mln/fun/vv2b/eq.hh. +// Generated by ./build_unit_test.sh, do not modify. + +// Include the file twice, so we detect missing inclusion guards. +#include <mln/fun/vv2b/eq.hh> +#include <mln/fun/vv2b/eq.hh> + +int main() +{ + // Nothing. +} diff --git a/milena/tests/unit_test/mln_fun_vv2b_ge.cc b/milena/tests/unit_test/mln_fun_vv2b_ge.cc new file mode 100644 index 0000000..531f5c7 --- /dev/null +++ b/milena/tests/unit_test/mln_fun_vv2b_ge.cc @@ -0,0 +1,11 @@ +// Unit test for mln/fun/vv2b/ge.hh. +// Generated by ./build_unit_test.sh, do not modify. + +// Include the file twice, so we detect missing inclusion guards. +#include <mln/fun/vv2b/ge.hh> +#include <mln/fun/vv2b/ge.hh> + +int main() +{ + // Nothing. +} diff --git a/milena/tests/unit_test/mln_fun_vv2b_gt.cc b/milena/tests/unit_test/mln_fun_vv2b_gt.cc new file mode 100644 index 0000000..94f9677 --- /dev/null +++ b/milena/tests/unit_test/mln_fun_vv2b_gt.cc @@ -0,0 +1,11 @@ +// Unit test for mln/fun/vv2b/gt.hh. +// Generated by ./build_unit_test.sh, do not modify. + +// Include the file twice, so we detect missing inclusion guards. +#include <mln/fun/vv2b/gt.hh> +#include <mln/fun/vv2b/gt.hh> + +int main() +{ + // Nothing. +} diff --git a/milena/tests/unit_test/mln_fun_vv2b_implies.cc b/milena/tests/unit_test/mln_fun_vv2b_implies.cc new file mode 100644 index 0000000..91457d0 --- /dev/null +++ b/milena/tests/unit_test/mln_fun_vv2b_implies.cc @@ -0,0 +1,11 @@ +// Unit test for mln/fun/vv2b/implies.hh. +// Generated by ./build_unit_test.sh, do not modify. + +// Include the file twice, so we detect missing inclusion guards. +#include <mln/fun/vv2b/implies.hh> +#include <mln/fun/vv2b/implies.hh> + +int main() +{ + // Nothing. +} diff --git a/milena/tests/unit_test/mln_fun_vv2b_le.cc b/milena/tests/unit_test/mln_fun_vv2b_le.cc new file mode 100644 index 0000000..9e13aa3 --- /dev/null +++ b/milena/tests/unit_test/mln_fun_vv2b_le.cc @@ -0,0 +1,11 @@ +// Unit test for mln/fun/vv2b/le.hh. +// Generated by ./build_unit_test.sh, do not modify. + +// Include the file twice, so we detect missing inclusion guards. +#include <mln/fun/vv2b/le.hh> +#include <mln/fun/vv2b/le.hh> + +int main() +{ + // Nothing. +} diff --git a/milena/tests/unit_test/mln_fun_vv2b_lt.cc b/milena/tests/unit_test/mln_fun_vv2b_lt.cc new file mode 100644 index 0000000..46d437d --- /dev/null +++ b/milena/tests/unit_test/mln_fun_vv2b_lt.cc @@ -0,0 +1,11 @@ +// Unit test for mln/fun/vv2b/lt.hh. +// Generated by ./build_unit_test.sh, do not modify. + +// Include the file twice, so we detect missing inclusion guards. +#include <mln/fun/vv2b/lt.hh> +#include <mln/fun/vv2b/lt.hh> + +int main() +{ + // Nothing. +} diff --git a/milena/tests/unit_test/mln_trait_ch_function_value.cc b/milena/tests/unit_test/mln_trait_ch_function_value.cc new file mode 100644 index 0000000..f6cb360 --- /dev/null +++ b/milena/tests/unit_test/mln_trait_ch_function_value.cc @@ -0,0 +1,11 @@ +// Unit test for mln/trait/ch_function_value.hh. +// Generated by ./build_unit_test.sh, do not modify. + +// Include the file twice, so we detect missing inclusion guards. +#include <mln/trait/ch_function_value.hh> +#include <mln/trait/ch_function_value.hh> + +int main() +{ + // Nothing. +} -- 1.5.6.5
16Â years, 1Â month
1
0
0
0
3053: Cleanup morpho.
by Guillaume Lazzara
* milena/mln/morpho/closing.hh, * milena/mln/morpho/closing_area_on_vertices.hh, * milena/mln/morpho/opening.hh, * milena/mln/morpho/opening_area.hh, * milena/mln/morpho/opening_area_on_vertices.hh, * milena/mln/morpho/opening_attribute.hh, * milena/mln/morpho/opening_height.hh, * milena/mln/morpho/opening_volume.hh: return an image instead of taking the output by argument. * milena/tests/morpho/opening_area.cc, * milena/tests/morpho/opening_height.cc, * milena/tests/morpho/opening_volume.cc: update tests. --- milena/ChangeLog | 18 +++++++++++++ milena/mln/morpho/closing.hh | 18 +++++++------- milena/mln/morpho/closing_area_on_vertices.hh | 30 ++++++++++++++-------- milena/mln/morpho/opening.hh | 17 ++++++------- milena/mln/morpho/opening_area.hh | 33 +++++++++++++++---------- milena/mln/morpho/opening_area_on_vertices.hh | 27 +++++++++++++------- milena/mln/morpho/opening_attribute.hh | 28 ++++++++++++++------- milena/mln/morpho/opening_height.hh | 28 +++++++++++++------- milena/mln/morpho/opening_volume.hh | 28 +++++++++++++------- milena/tests/morpho/opening_area.cc | 9 +++---- milena/tests/morpho/opening_height.cc | 5 ++- milena/tests/morpho/opening_volume.cc | 5 ++- 12 files changed, 156 insertions(+), 90 deletions(-) diff --git a/milena/ChangeLog b/milena/ChangeLog index 114753f..a4bb060 100644 --- a/milena/ChangeLog +++ b/milena/ChangeLog @@ -1,3 +1,21 @@ +2008-12-16 Guillaume Lazzara <z(a)lrde.epita.fr> + + Cleanup morpho. + + * milena/mln/morpho/closing.hh, + * milena/mln/morpho/closing_area_on_vertices.hh, + * milena/mln/morpho/opening.hh, + * milena/mln/morpho/opening_area.hh, + * milena/mln/morpho/opening_area_on_vertices.hh, + * milena/mln/morpho/opening_attribute.hh, + * milena/mln/morpho/opening_height.hh, + * milena/mln/morpho/opening_volume.hh: return an image instead of + taking the output by argument. + + * milena/tests/morpho/opening_area.cc, + * milena/tests/morpho/opening_height.cc, + * milena/tests/morpho/opening_volume.cc: update tests. + 2008-12-15 Alexandre Abraham <abraham(a)lrde.epita.fr> Add missing concept for bijective functions. diff --git a/milena/mln/morpho/closing.hh b/milena/mln/morpho/closing.hh index 932186c..e275760 100644 --- a/milena/mln/morpho/closing.hh +++ b/milena/mln/morpho/closing.hh @@ -1,4 +1,5 @@ -// Copyright (C) 2007 EPITA Research and Development Laboratory +// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory +// (LRDE) // // This file is part of the Olena Library. This library is free // software; you can redistribute it and/or modify it under the terms @@ -28,10 +29,9 @@ #ifndef MLN_MORPHO_CLOSING_HH # define MLN_MORPHO_CLOSING_HH -/*! \file mln/morpho/closing.hh - * - * \brief Morphological closing. - */ +/// \file mln/morpho/closing.hh +/// +/// Morphological closing. # include <mln/morpho/includes.hh> @@ -42,10 +42,10 @@ namespace mln namespace morpho { - /*! Morphological closing. - * - * This operator is e_{-B} o d_B. - */ + /// Morphological closing. + /// + /// This operator is e_{-B} o d_B. + /// template <typename I, typename W> mln_concrete(I) closing(const Image<I>& input, const Window<W>& win); diff --git a/milena/mln/morpho/closing_area_on_vertices.hh b/milena/mln/morpho/closing_area_on_vertices.hh index 7af8e6e..cfaf955 100644 --- a/milena/mln/morpho/closing_area_on_vertices.hh +++ b/milena/mln/morpho/closing_area_on_vertices.hh @@ -47,25 +47,33 @@ namespace mln /// Morphological area closing on a mln::line_graph_image computing /// the area in terms of adjacent vertices. - template <typename P2V, typename G, typename V2P, typename N, typename O> - void closing_area_on_vertices(const pw::image<P2V, p_edges<G, V2P> >& input, - const Neighborhood<N>& nbh, - unsigned lambda, Image<O>& output); + template <typename P2V, typename G, typename V2P, typename N> + pw::image<P2V, p_edges<G, V2P> > + closing_area_on_vertices(const pw::image<P2V, p_edges<G, V2P> >& input, + const Neighborhood<N>& nbh, + unsigned lambda); # ifndef MLN_INCLUDE_ONLY - template <typename P2V, typename G, typename V2P, typename N, typename O> + template <typename P2V, typename G, typename V2P, typename N> inline - void closing_area_on_vertices(const pw::image<P2V, p_edges<G, V2P> >& input, - const Neighborhood<N>& nbh, - unsigned lambda, Image<O>& output) + pw::image<P2V, p_edges<G, V2P> > + closing_area_on_vertices(const pw::image<P2V, p_edges<G, V2P> >& input, + const Neighborhood<N>& nbh, + unsigned lambda) { - mln_precondition(exact(output).domain() == exact(input).domain()); + trace::entering("morpho::closing_area_on_vertices"); + mln_precondition(exact(input).has_data()); + typedef p_edges<G, V2P> pe_t; typedef accu::count_adjacent_vertices<P2V, pe_t> attribute_t; - // FIXME: Change sig of closing_attribute! - closing_attribute<attribute_t>(input, nbh, lambda, output); + + pw::image<P2V, p_edges<G, V2P> > output; + output = closing_attribute<attribute_t>(input, nbh, lambda); + + trace::exiting("morpho::closing_area_on_vertices"); + return output; } # endif // ! MLN_INCLUDE_ONLY diff --git a/milena/mln/morpho/opening.hh b/milena/mln/morpho/opening.hh index d3204ff..7691f4a 100644 --- a/milena/mln/morpho/opening.hh +++ b/milena/mln/morpho/opening.hh @@ -1,4 +1,5 @@ -// Copyright (C) 2007 EPITA Research and Development Laboratory +// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory +// (LRDE) // // This file is part of the Olena Library. This library is free // software; you can redistribute it and/or modify it under the terms @@ -28,10 +29,9 @@ #ifndef MLN_MORPHO_OPENING_HH # define MLN_MORPHO_OPENING_HH -/*! \file mln/morpho/opening.hh - * - * \brief Morphological opening. - */ +/// \file mln/morpho/opening.hh +/// +/// Morphological opening. # include <mln/morpho/includes.hh> @@ -42,10 +42,9 @@ namespace mln namespace morpho { - /*! Morphological opening. - * - * This operator is d_{-B} o e_B. - */ + /// Morphological opening. + /// + /// This operator is d_{-B} o e_B. template <typename I, typename W> mln_concrete(I) opening(const Image<I>& input, const Window<W>& win); diff --git a/milena/mln/morpho/opening_area.hh b/milena/mln/morpho/opening_area.hh index d400b22..211af4c 100644 --- a/milena/mln/morpho/opening_area.hh +++ b/milena/mln/morpho/opening_area.hh @@ -29,10 +29,9 @@ #ifndef MLN_MORPHO_OPENING_AREA_HH # define MLN_MORPHO_OPENING_AREA_HH -/*! \file mln/morpho/opening_area.hh - * - * \brief Morphological area opening. - */ +/// \file mln/morpho/opening_area.hh +/// +/// Morphological area opening. # include <mln/morpho/opening_attribute.hh> # include <mln/accu/count.hh> @@ -45,22 +44,30 @@ namespace mln { /// Morphological area opening. - template <typename I, typename N, typename O> - void opening_area(const Image<I>& input, const Neighborhood<N>& nbh, - unsigned lambda, Image<O>& output); + template <typename I, typename N> + mln_concrete(I) + opening_area(const Image<I>& input, const Neighborhood<N>& nbh, + unsigned lambda); # ifndef MLN_INCLUDE_ONLY - template <typename I, typename N, typename O> + template <typename I, typename N> inline - void opening_area(const Image<I>& input, const Neighborhood<N>& nbh, - unsigned lambda, Image<O>& output) + mln_concrete(I) + opening_area(const Image<I>& input, const Neighborhood<N>& nbh, + unsigned lambda) { - mln_precondition(exact(output).domain() == exact(input).domain()); + trace::entering("morpho::opening_area"); typedef util::pix<I> pix_t; - // FIXME: Change sig of opening_attribute! - opening_attribute< accu::count<pix_t> >(input, nbh, lambda, output); + + mln_precondition(exact(input).has_data()); + + mln_concrete(I) output; + output= opening_attribute< accu::count<pix_t> >(input, nbh, lambda); + + trace::exiting("morpho::opening_area"); + return output; } # endif // ! MLN_INCLUDE_ONLY diff --git a/milena/mln/morpho/opening_area_on_vertices.hh b/milena/mln/morpho/opening_area_on_vertices.hh index b8e420e..5b080e7 100644 --- a/milena/mln/morpho/opening_area_on_vertices.hh +++ b/milena/mln/morpho/opening_area_on_vertices.hh @@ -48,25 +48,32 @@ namespace mln /// Morphological area opening on a mln::line_graph_image computing /// the area in terms of adjacent vertices. - template <typename P2V, typename G, typename V2P, typename N, typename O> - void opening_area_on_vertices(const pw::image<P2V, p_edges<G, V2P> >& input, - const Neighborhood<N>& nbh, - unsigned lambda, Image<O>& output); + template <typename P2V, typename G, typename V2P, typename N> + pw::image<P2V, p_edges<G, V2P> > + opening_area_on_vertices(const pw::image<P2V, p_edges<G, V2P> >& input, + const Neighborhood<N>& nbh); # ifndef MLN_INCLUDE_ONLY - template <typename P2V, typename G, typename V2P, typename N, typename O> - inline + template <typename P2V, typename G, typename V2P, typename N> + pw::image<P2V, p_edges<G, V2P> > void opening_area_on_vertices(const pw::image<P2V, p_edges<G, V2P> >& input, const Neighborhood<N>& nbh, - unsigned lambda, Image<O>& output) + unsigned lambda) { - mln_precondition(exact(output).domain() == exact(input).domain()); + trace::entering("morpho::opening_area_on_vertices"); + + mln_precondition(exact(input).has_data()); + typedef p_edges<G, V2P> pe_t; typedef accu::count_adjacent_vertices<P2V, pe_t> attribute_t; - // FIXME: Change sig of opening_attribute! - opening_attribute<attribute_t>(input, nbh, lambda, output); + + pw::image<P2V, p_edges<G, V2P> > output; + output = opening_attribute<attribute_t>(input, nbh, lambda); + + trace::exiting("morpho::opening_area_on_vertices"); + return output; } # endif // ! MLN_INCLUDE_ONLY diff --git a/milena/mln/morpho/opening_attribute.hh b/milena/mln/morpho/opening_attribute.hh index 7d9daa5..97dc514 100644 --- a/milena/mln/morpho/opening_attribute.hh +++ b/milena/mln/morpho/opening_attribute.hh @@ -30,7 +30,8 @@ # define MLN_MORPHO_OPENING_ATTRIBUTE_HH /// \file mln/morpho/opening_attribute.hh -/// \brief Morphological attribute opening. +/// +/// Morphological attribute opening. # include <mln/morpho/includes.hh> # include <mln/canvas/morpho/algebraic_union_find.hh> @@ -46,9 +47,10 @@ namespace mln /// Morphological attribute opening. template <typename A, - typename I, typename N, typename O> - void opening_attribute(const Image<I>& input, const Neighborhood<N>& nbh, - mln_result(A) lambda, Image<O>& output); + typename I, typename N> + mln_concrete(I) + opening_attribute(const Image<I>& input, const Neighborhood<N>& nbh, + mln_result(A) lambda); # ifndef MLN_INCLUDE_ONLY @@ -100,18 +102,26 @@ namespace mln } // end of namespace mln::morpho::impl - template <typename A, - typename I, typename N, typename O> + template <typename A, typename I, typename N> inline - void opening_attribute(const Image<I>& input, - const Neighborhood<N>& nbh, mln_result(A) lambda, - Image<O>& output) + mln_concrete(I) + opening_attribute(const Image<I>& input, + const Neighborhood<N>& nbh, mln_result(A) lambda) { + trace::entering("morpho::opening_attribute"); + + mln_precondition(exact(input).has_data()); + + mln_concrete(I) output; + initialize(output, input); + typedef impl::opening_attribute_t<I, A> F; F f(input, lambda); canvas::morpho::algebraic_union_find(input, nbh, f, output); mln_postcondition(output <= input); + trace::exiting("morpho::opening_attribute"); + return output; } diff --git a/milena/mln/morpho/opening_height.hh b/milena/mln/morpho/opening_height.hh index 726547e..36ace8f 100644 --- a/milena/mln/morpho/opening_height.hh +++ b/milena/mln/morpho/opening_height.hh @@ -30,7 +30,8 @@ # define MLN_MORPHO_OPENING_HEIGHT_HH /// \file mln/morpho/opening_height.hh -/// \brief Morphological height opening. +/// +/// Morphological height opening. # include <mln/morpho/opening_attribute.hh> # include <mln/accu/height.hh> @@ -43,21 +44,28 @@ namespace mln { /// Morphological height opening. - template <typename I, typename N, typename O> - void opening_height(const Image<I>& input, const Neighborhood<N>& nbh, - unsigned lambda, Image<O>& output); + template <typename I, typename N> + mln_concrete(I) + opening_height(const Image<I>& input, const Neighborhood<N>& nbh, + unsigned lambda); # ifndef MLN_INCLUDE_ONLY - template <typename I, typename N, typename O> + template <typename I, typename N> inline - void opening_height(const Image<I>& input, const Neighborhood<N>& nbh, - unsigned lambda, Image<O>& output) + mln_concrete(I) + opening_height(const Image<I>& input, const Neighborhood<N>& nbh, + unsigned lambda) { - mln_precondition(exact(output).domain() == exact(input).domain()); - // FIXME: Change sig of opening_attribute! - opening_attribute< accu::height<I> >(input, nbh, lambda, output); + trace::entering("morpho::opening_height"); + mln_precondition(exact(input).has_data()); + + mln_concrete(I) output; + output = opening_attribute< accu::height<I> >(input, nbh, lambda); + + trace::exiting("morpho::opening_height"); + return output; } # endif // ! MLN_INCLUDE_ONLY diff --git a/milena/mln/morpho/opening_volume.hh b/milena/mln/morpho/opening_volume.hh index e6ad080..127ae2c 100644 --- a/milena/mln/morpho/opening_volume.hh +++ b/milena/mln/morpho/opening_volume.hh @@ -30,7 +30,8 @@ # define MLN_MORPHO_OPENING_VOLUME_HH /// \file mln/morpho/opening_volume.hh -/// \brief Morphological volume opening. +/// +/// Morphological volume opening. # include <mln/morpho/opening_attribute.hh> # include <mln/accu/volume.hh> @@ -43,21 +44,28 @@ namespace mln { /// Morphological volume opening. - template <typename I, typename N, typename O> - void opening_volume(const Image<I>& input, const Neighborhood<N>& nbh, - unsigned lambda, Image<O>& output); + template <typename I, typename N> + mln_concrete(I) + opening_volume(const Image<I>& input, const Neighborhood<N>& nbh, + unsigned lambda); # ifndef MLN_INCLUDE_ONLY - template <typename I, typename N, typename O> + template <typename I, typename N> inline - void opening_volume(const Image<I>& input, const Neighborhood<N>& nbh, - unsigned lambda, Image<O>& output) + mln_concrete(I) + opening_volume(const Image<I>& input, const Neighborhood<N>& nbh, + unsigned lambda) { - mln_precondition(exact(output).domain() == exact(input).domain()); - // FIXME: Change sig of opening_attribute! - opening_attribute< accu::volume<I> >(input, nbh, lambda, output); + trace::entering("morpho::opening_volume"); + mln_precondition(exact(input).has_data()); + + mln_concrete(I) output; + output = opening_attribute< accu::volume<I> >(input, nbh, lambda); + + trace::exiting("morpho::opening_volume"); + return output; } # endif // ! MLN_INCLUDE_ONLY diff --git a/milena/tests/morpho/opening_area.cc b/milena/tests/morpho/opening_area.cc index 13a3955..9ae0e56 100644 --- a/milena/tests/morpho/opening_area.cc +++ b/milena/tests/morpho/opening_area.cc @@ -25,10 +25,9 @@ // reasons why the executable file might be covered by the GNU General // Public License. -/*! \file tests/morpho/opening_area.cc - * - * \brief Test on mln::morpho::opening_area. - */ +/// \file tests/morpho/opening_area.cc +/// +/// Test on mln::morpho::opening_area. #include <mln/core/image/image2d.hh> #include <mln/value/int_u8.hh> @@ -52,6 +51,6 @@ int main() io::pgm::load(lena, MLN_IMG_DIR "/lena.pgm"); image2d<int_u8> out(lena.domain()); - morpho::opening_area(lena, c4(), 510, out); + out = morpho::opening_area(lena, c4(), 510); io::pgm::save(out, "out.pgm"); } diff --git a/milena/tests/morpho/opening_height.cc b/milena/tests/morpho/opening_height.cc index c834fea..8080425 100644 --- a/milena/tests/morpho/opening_height.cc +++ b/milena/tests/morpho/opening_height.cc @@ -26,7 +26,8 @@ // Public License. /// \file tests/morpho/opening_height.cc -/// \brief Test on mln::morpho::opening_height. +/// +/// Test on mln::morpho::opening_height. #include <mln/core/image/image2d.hh> #include <mln/value/int_u8.hh> @@ -48,6 +49,6 @@ int main() io::pgm::load(lena, MLN_IMG_DIR "/lena.pgm"); image2d<int_u8> out(lena.domain()); - morpho::opening_height(lena, c4(), 20, out); + out = morpho::opening_height(lena, c4(), 20); io::pgm::save(out, "out.pgm"); } diff --git a/milena/tests/morpho/opening_volume.cc b/milena/tests/morpho/opening_volume.cc index 75d03e0..0ccae72 100644 --- a/milena/tests/morpho/opening_volume.cc +++ b/milena/tests/morpho/opening_volume.cc @@ -26,7 +26,8 @@ // Public License. /// \file tests/morpho/opening_volume.cc -/// \brief Test on mln::morpho::opening_volume. +/// +/// Test on mln::morpho::opening_volume. #include <mln/core/image/image2d.hh> #include <mln/value/int_u8.hh> @@ -48,6 +49,6 @@ int main() io::pgm::load(lena, MLN_IMG_DIR "/lena.pgm"); image2d<int_u8> out(lena.domain()); - morpho::opening_volume(lena, c4(), 10000, out); + out = morpho::opening_volume(lena, c4(), 10000); io::pgm::save(out, "out.pgm"); } -- 1.5.6.5
16Â years, 1Â month
1
0
0
0
3052: Augment the reference code to depict object labeling err.
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 the reference code to depict object labeling err. * geraud/tufa_2008/steps.2.cc: Augment. (label): Wrong object labeling image. As a conclusion, labeling cannot come from the max label propagated by the parent relationship. steps.2.cc | 88 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 81 insertions(+), 7 deletions(-) Index: geraud/tufa_2008/steps.2.cc --- geraud/tufa_2008/steps.2.cc (revision 3051) +++ geraud/tufa_2008/steps.2.cc (working copy) @@ -76,8 +76,14 @@ template <typename I, typename A, typename N> - void run_run(const I& f, const A& a, const N& nbh) + mln_ch_value(I, util::set<unsigned>) + compute_labels(const I& f, const A& a, const N& nbh, + unsigned n_objects, + bool echo = false) { + if (echo) + debug::println("f =", f); + typedef p_array<mln_psite(I)> S; S s = level::sort_psites_increasing(a); // s maps increasing attributes. @@ -87,7 +93,6 @@ mln_ch_value(I, util::set<unsigned>) labels; unsigned nbassins, current_n; - // Initialization. { mln_piter(A) p(f.domain()); @@ -104,6 +109,15 @@ // labels mln_ch_value(I, unsigned) regmin = labeling::regional_minima(a, nbh, nbassins); + if (n_objects >= nbassins) + { + std::cerr << "The number of expected objects is higher than the number of regional minima!" << std::endl; + std::abort(); + } + + if (echo) + debug::println("regmin(f) =", regmin); + initialize(labels, f); for_all(p) if (regmin(p) != 0) // p in a reg min of the attribute image @@ -141,6 +155,27 @@ { labels(p).insert(labels(r)); --current_n; + if (current_n == n_objects && echo) + { + // Filtering. + mln_concrete(I) g; + initialize(g, f); + mln_bkd_piter(S) p(s); + for_all(p) + if (par(p) == p) + g(p) = f(p); + else + g(p) = g(par(p)); + debug::println("g =", g); + + // Testing. + unsigned n_result; + mln_ch_value(I, unsigned) g_regmin; + g_regmin = labeling::regional_minima(g, nbh, n_result); + debug::println("regmin(g) =", g_regmin); + + mln_invariant(n_result == n_objects); + } } } } @@ -148,27 +183,48 @@ } } - std::cout << std::endl; - std::cout << "end = " << current_n << std::endl; + mln_invariant(current_n == 1); // All labels are merged into a single set. + + return labels; } } // mln +void usage(char* argv[]) +{ + std::cerr << "usage: " << argv[0] << " input.pgm n echo" << std::endl; + std::cerr << "n: number of expected objects (n > 0)" << std::endl; + std::cerr << "echo: 0 (silent) or 1 (verbose)" << std::endl; + std::cerr << "merge using sets of labels from regional minima and save the highest label image" << std::endl; + std::abort(); +} -int main(int, char* argv[]) +int main(int argc, char* argv[]) { using namespace mln; using value::int_u8; - int_u8 n; + if (argc != 4) + usage(argv); typedef image2d<int_u8> I; I f; + // input image io::pgm::load(f, argv[1]); + // n + int n = std::atoi(argv[2]); + if (n <= 0) + usage(argv); + + // echo + int echo = std::atoi(argv[3]); + if (echo != 0 && echo != 1) + usage(argv); + typedef p_array<point2d> S; S s = level::sort_psites_decreasing(f); @@ -179,6 +235,24 @@ accu::count< util::pix<I> > attr; image2d<unsigned> a = morpho::tree::compute_attribute_image(attr, t); - run_run(f, a, c4()); + + + image2d< util::set<unsigned> > labels = compute_labels(f, a, c4(), n, echo); + if (echo) + debug::println("labels =", labels); + + { + image2d<unsigned> lab(f.domain()); + mln_piter_(I) p(f.domain()); + for_all(p) + { + mln_assertion(! labels(p).is_empty()); + lab(p) = labels(p).last_element(); + } + if (echo) + debug::println("max of labels (clearly NOT the objects image!) =", lab); + + // We can observe that we do NOT get objects this way... + } }
16Â years, 1Â month
1
0
0
0
← Newer
1
...
641
642
643
644
645
646
647
...
963
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
Results per page:
10
25
50
100
200