LRE
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
List overview
Download
Olena-patches
October 2008
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
olena-patches@lrde.epita.fr
14 participants
373 discussions
Start a n
N
ew thread
cleanup-2008 2689: INIM: Clean up classification.
by Ugo Jardonnet
https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena/sandbox
Index: ChangeLog from Ugo Jardonnet <ugo.jardonnet(a)lrde.epita.fr> INIM: Clean up classification. * classif/iccvg04.cc: Clean it up. iccvg04.cc | 82 ++++++++----------------------------------------------------- 1 file changed, 11 insertions(+), 71 deletions(-) Index: classif/iccvg04.cc --- classif/iccvg04.cc (revision 2688) +++ classif/iccvg04.cc (working copy) @@ -14,7 +14,6 @@ #include <mln/util/array.hh> #include <mln/labeling/compute.hh> -// FIXME: !? #include <mln/geom/all.hh> #include <mln/io/ppm/load.hh> @@ -99,86 +98,45 @@ void classify_image(const I& ima, const J& histo, const K& ws, int nbasins, int f) { - unsigned count[nbasins + 1]; memset(count, 0, (nbasins + 1) * sizeof(unsigned)); - algebra::vec<3, unsigned> sum[nbasins + 1]; + algebra::vec<3, unsigned> sum[nbasins + 1]; for (int i = 1; i < nbasins + 1; ++i) sum[i] = literal::zero; + // Compute representatives of every class mln_piter(I) p(ima.domain()); for_all(p) { point3d p3(ima(p).red() / f, ima(p).green() / f, ima(p).blue() / f); int w = ws(p3); - // Check if we are not on a border of the WS + //check if we are not on a border of the WS if (w != 0) { count[w] += histo(p3); sum[w] += histo(p3) * convert::to< algebra::vec<3, value::int_u8> >(p3); } -#if DEBUG - std::cerr << "p3 : " << p3 << " == " << convert::to<algebra::vec<3, value::int_u8> >(p3) << std::endl; -#endif // DEBUG } - for (int i = 1; i < nbasins + 1; ++i) - { - sum[i] *= f; - sum[i] /= count[i]; - //std::cout << "count[" << i << "] = " << count[i] << std::endl; -#if DEBUG - std::cout << "sum[" << i << "] = " << sum[i] << std::endl; -#endif // DEBUG - } - + sum[i] = (sum[i] * f) / count[i]; + // Make an output image where colors are replaced by their representatives. mln_piter(I) pi(ima.domain()); I out(ima.domain()); - I ws_out(ima.domain()); - for_all(pi) { - value::rgb8 coul = ima(pi); + //retrieve color class + value::rgb8 coul = ima(pi); int w = ws(point3d(coul.red() / f, coul.green() / f, coul.blue() / f)); - if (w != 0) // If w == 0 it means that the current point is part of a border of the watershed - { -#if DEBUG - std::cerr << "out(" << pi << ") = sum[" << w << "]; //" << sum[w] << std::endl; -#endif + //if w == 0, out(pi) = 0 ie is part of a border of the watershed out(pi) = convert::to<value::rgb8>(sum[w]); - //out(pi) = value::rgb8(sum[w][0], sum[w][1], sum[w][2]); - ws_out(pi) = value::rgb8(0, 0, 0); } - else - { -#if DEBUG - std::cerr << "Border : " << pi << std::endl; -#endif - ws_out(pi) = value::rgb8(255, 255, 255); - - // FIXME - // ima(pi) is a border in the histogram and therefore lacks of a mean color. - // Choosing a good value for out(pi) is not so easy. One idea could be to randomly - // choose a color from one of the surrounding classes, but it's not the best idea - // because of large « border » zones. - out(pi) = value::rgb8(255, 255, 255); - } - - //std::cerr << "(" << coul << ") -> (" << out(pi) << "); sum[" << w << "] = " << sum[w] << " -> " << convert::to<value::rgb8>(sum[w]) << std::endl; - } - - // 1- La valeur contenue dans sum n'est pas correctement écrite dans out.ppm. À vérifier ! - // 2- Le cast de sum[w] en rgb8 se passe très bizarrement. À vérifier ! - // 3- Rajoute le std::cout de count change le comportement du programme. À vérifier ! - // 4- Le WS semble faire des pâtés (beaucoup de points de classe 0) io::ppm::save(out, "out.ppm"); - io::ppm::save(ws_out, "out-ws.ppm"); } bool usage(int argc, char ** argv) @@ -196,7 +154,6 @@ { if (not usage(argc, argv)) return 1; - const int div_factor = atoi(argv[2]); const int lambda = atoi(argv[3]); @@ -205,36 +162,19 @@ //make histo image3d<unsigned> histo = fill_histo(ima,div_factor); - { - unsigned m, M; - estim::min_max(histo, m, M); - std::cout << "histo : " << m << ' ' << M << std::endl; - } //revert histo image3d<unsigned> rhisto = arith::revert(histo); - { - unsigned m, M; - estim::min_max(rhisto, m, M); - std::cout << "rhisto : " << m << ' ' << M << std::endl; - } - //compute closing_area of histo + //compute closing_volume of histo image3d<unsigned> histo_closure(histo.domain()); - morpho::closing_area(rhisto, c6(), lambda, histo_closure); - { - unsigned m, M; - estim::min_max(histo_closure, m, M); - std::cout << "histo_closure : " << m << ' ' << M << std::endl; - } + morpho::closing_volume(rhisto, c6(), lambda, histo_closure); //watershed over histo_closure unsigned nbasins = 0; image3d<unsigned> ws = morpho::meyer_wst(histo_closure, c6(), nbasins); - std::cout << "nbassins : " << nbasins << std::endl; - // Classify image ! - //classify_image(const I& ima, const J& histo, const K& ws, int nbasins, int f) + //classify image classify_image(ima, histo, ws, nbasins, div_factor); }
16 years, 2 months
1
0
0
0
cleanup-2008 2688: Fix bugs in low level routines.
by Nicolas Ballas
https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena
Index: ChangeLog from Nicolas Ballas <ballas(a)lrde.epita.fr> Fix bugs in low level routines. * tests/level/fill_with_image.cc, * tests/level/transform.cc, * tests/level/paste.cc: Add tests. * mln/core/image/cast_image.hh: Update properties. * mln/level/transform.spe.hh, * mln/level/paste.spe.hh, * mln/level/fill_with_image.spe.hh: Update dispatch, fix bugs. * mln/level/transform.hh, * mln/level/paste.hh: Rename routines. mln/core/image/cast_image.hh | 12 +++ mln/level/fill_with_image.spe.hh | 111 +++++++++++++++++++++++-------- mln/level/paste.hh | 2 mln/level/paste.spe.hh | 117 ++++++++++++++++++++++++-------- mln/level/transform.hh | 2 mln/level/transform.spe.hh | 135 ++++++++++++++++++++++++++----------- tests/level/fill_with_image.cc | 139 +++++++++++++++++++++++++++++++++++++-- tests/level/paste.cc | 122 +++++++++++++++++++++++++++++++++- tests/level/transform.cc | 62 +++++++++++++++++ 9 files changed, 592 insertions(+), 110 deletions(-) Index: tests/level/fill_with_image.cc --- tests/level/fill_with_image.cc (revision 2687) +++ tests/level/fill_with_image.cc (working copy) @@ -32,17 +32,24 @@ #include <mln/level/fill_with_value.hh> #include <mln/level/fill_with_image.hh> +#include <mln/level/compare.hh> +#include <mln/core/image/image1d.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/cast_image.hh> +#include <mln/core/image/image_if.hh> #include <mln/core/image/sub_image.hh> +#include <mln/core/image/extension_val.hh> -#include <mln/core/image/image_if.hh> -#include <mln/level/compare.hh> +#include <mln/fun/p2b/chess.hh> +#include <mln/fun/p2v/iota.hh> #include <mln/debug/iota.hh> #include <mln/debug/println.hh> -#include <mln/fun/p2b/chess.hh> +#include <mln/trace/all.hh> int main() @@ -50,6 +57,7 @@ using namespace mln; const unsigned size = 100; + // 2d tests { image2d<unsigned int> ima(size, size); image2d<unsigned int> ima2(size, size); @@ -68,7 +76,7 @@ debug::iota(ima2); level::fill_with_image(ima, ima2); - assert(ima == (ima2 | b)); + mln_assertion(ima == (ima2 | b)); } { @@ -88,4 +96,127 @@ mln_assertion(ima_if(p) == 42); } + + // tests in three dimension + { + box3d b(point3d(1,2,1), point3d(2,4,3)); + image3d<int> ima(b, 2); + debug::iota(ima); + + box3d b2(point3d(-1,-2,-1), point3d(3,6,3)); + image3d<int> ima2(b2, 2); + debug::iota(ima2); + + image3d<int> ima3(b, 2); + + level::fill_with_image(ima, ima2); // Not so fast version... + mln_assertion(ima == (ima2 | b)); + + level::fill_with_image(ima3, ima); // Fast version... + mln_assertion(ima == ima3); + } + + // image 1d test + { + image1d<unsigned short> ima(size); + image1d<unsigned short> out(size); + + debug::iota(ima); + level::fill_with_image(out, ima); + + mln_assertion(ima == out); + } + + + // pw image test + { + const pw::image<fun::p2v::iota_t, box2d> ima(fun::p2v::iota, + make::box2d(-2,-2, 15,15)); + image2d<short unsigned int> out(8, 8); + + level::fill(out, 0); + level::fill_with_image(out, ima); + } + + // flat image test + { + flat_image<short, box2d> ima(5, make::box2d(size, size)); + image2d<unsigned short> out(size, size); + + level::fill_with_value(ima, 51); + level::fill_with_image(out, ima); + + mln_assertion(ima == out); + } + + // image if test + { + typedef image2d<unsigned short> I; + typedef image_if<I, fun::p2b::chess_t> II; + + I ima(size, size); + I out(size, size); + II ima_if = ima | fun::p2b::chess; + + level::fill_with_value(ima, 42); + level::fill_with_value(out, 0); + level::fill_with_image(ima_if, ima); + + mln_piter_(II) p(ima_if.domain()); + for_all(p) + mln_assertion(ima_if(p) == ima(p)); + } + + // cast image test + { + typedef image2d<unsigned short> I; + typedef cast_image_<int, I> II; + + I in(size, size); + II cast(in); + I out(size, size); + + level::fill(in, 51); + level::fill(out, 42); + + level::fill_with_image(out, cast); + + mln_assertion(cast == out); + } + + // sub_image test + { + typedef image2d<int> I; + typedef sub_image< image2d<int>, box2d > II; + + I ima(size, size); + I out(size, size); + II sub_ima(ima, make::box2d(4,4, 10,10)); + + + level::fill(ima, 51); + level::fill(out, 0); + level::fill_with_image(sub_ima, ima); + + II::piter p(sub_ima.domain()); + for_all(p) + mln_assertion(sub_ima(p) == ima(p)); + } + + // extended image test + { + typedef image2d<int> I; + typedef extension_val< image2d<int> > II; + typedef image2d<unsigned short> III; + + I ima(size, size); + II extend_ima(ima, 5); + III out(size, size); + + level::fill(ima, 51); + level::fill_with_image(out, extend_ima); + + mln_assertion(out == extend_ima); + } + } Index: tests/level/transform.cc --- tests/level/transform.cc (revision 2687) +++ tests/level/transform.cc (working copy) @@ -1,4 +1,4 @@ -// Copyright (C) 2007 EPITA Research and Development Laboratory +// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory // // This file is part of the Olena Library. This library is free // software; you can redistribute it and/or modify it under the terms @@ -37,7 +37,11 @@ #include <mln/core/image/image3d.hh> #include <mln/pw/image.hh> #include <mln/core/image/flat_image.hh> +#include <mln/core/image/cast_image.hh> #include <mln/core/image/image_if.hh> +#include <mln/core/image/sub_image.hh> +#include <mln/core/image/extension_val.hh> + #include <mln/level/fill.hh> #include <mln/level/transform.hh> @@ -140,6 +144,7 @@ mln_assertion((unsigned short)std::sqrt(ima(p)) == out(p)); } + // image if test { typedef image2d<unsigned short> I; typedef image_if<I, fun::p2b::chess_t> II; @@ -157,4 +162,59 @@ mln_assertion((unsigned short)std::sqrt(ima_if(p)) == out(p)); } + // cast image test + { + typedef image2d<unsigned short> I; + typedef cast_image_<int, I> II; + typedef image2d<unsigned short> III; + + I in(size, size); + II cast(in); + III out(size, size); + + level::fill(in, 51); + level::fill(out, 42); + + out = level::transform(cast, mysqrt()); + + II::piter p(cast.domain()); + for_all(p) + mln_assertion((unsigned short)std::sqrt(cast(p)) == out(p)); + } + + // sub_image test + { + typedef image2d<int> I; + typedef sub_image< image2d<int>, box2d > II; + typedef image2d<unsigned short> III; + + I ima(size, size); + II sub_ima(ima, make::box2d(4,4, 10,10)); + III out(size, size); + + level::fill(ima, 51); + out = level::transform(sub_ima, mysqrt()); + + II::piter p(sub_ima.domain()); + for_all(p) + mln_assertion((unsigned short)std::sqrt(sub_ima(p)) == out(p)); + } + + // extended image test + { + typedef image2d<int> I; + typedef extension_val< image2d<int> > II; + typedef image2d<unsigned short> III; + + I ima(size, size); + II extend_ima(ima, 5); + III out(size, size); + + level::fill(ima, 51); + out = level::transform(extend_ima, mysqrt()); + + II::piter p(extend_ima.domain()); + for_all(p) + mln_assertion((unsigned short)std::sqrt(extend_ima(p)) == out(p)); + } } Index: tests/level/paste.cc --- tests/level/paste.cc (revision 2687) +++ tests/level/paste.cc (working copy) @@ -30,21 +30,32 @@ * \brief Tests on mln::level::paste. */ +#include <mln/core/image/image1d.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/cast_image.hh> +#include <mln/core/image/image_if.hh> #include <mln/core/image/sub_image.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/fun/p2b/chess.hh> +#include <mln/fun/p2v/iota.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; // tests in two dimension { @@ -59,10 +70,10 @@ image2d<int> ima3(b, 2); level::paste(ima, ima2); // Not so fast version... - assert(ima == (ima2 | b)); + mln_assertion(ima == (ima2 | b)); level::paste(ima, ima3); // Fast version... - assert(ima == ima3); + mln_assertion(ima == ima3); } // tests in three dimension @@ -78,9 +89,112 @@ image3d<int> ima3(b, 2); level::paste(ima, ima2); // Not so fast version... - assert(ima == (ima2 | b)); + mln_assertion(ima == (ima2 | b)); level::paste(ima, ima3); // Fast version... - assert(ima == ima3); + mln_assertion(ima == ima3); + } + + /// image 1d test + { + image1d<unsigned short> ima(size); + image1d<unsigned short> out(size); + + debug::iota(ima); + level::paste(ima, out); + + mln_assertion(ima == out); + } + + + /// pw image test + { + const pw::image<fun::p2v::iota_t, box2d> ima(fun::p2v::iota, + make::box2d(2,2, 5,5)); + image2d<short unsigned int> out(8, 8); + + level::fill(out, 0); + level::paste(ima, out); + } + + // flat image test + { + flat_image<short, box2d> ima(5, make::box2d(size, size)); + image2d<unsigned short> out(size, size); + + level::fill_with_value(ima, 51); + level::paste(ima, out); + + mln_assertion(ima == out); + } + + // image if test + { + typedef image2d<unsigned short> I; + typedef image_if<I, fun::p2b::chess_t> II; + + I ima(size, size); + I out(size, size); + II ima_if = ima | fun::p2b::chess; + + level::fill_with_value(ima, 0); + debug::iota(ima); + level::paste(ima_if, out); + + mln_assertion(ima_if == out); + } + + // cast image test + { + typedef image2d<unsigned short> I; + typedef cast_image_<int, I> II; + typedef image2d<unsigned short> III; + + I in(size, size); + II cast(in); + III out(size, size); + + level::fill(in, 51); + level::fill(out, 42); + + level::paste(cast, out); + + mln_assertion(cast == out); + } + + // sub_image test + { + typedef image2d<int> I; + typedef sub_image< image2d<int>, box2d > II; + typedef image2d<unsigned short> III; + + I ima(size, size); + II sub_ima(ima, make::box2d(4,4, 10,10)); + III out(size, size); + + level::fill(ima, 51); + level::paste(sub_ima, out); + + II::piter p(sub_ima.domain()); + for_all(p) + mln_assertion(sub_ima(p) == out(p)); + } + + // extended image test + { + typedef image2d<int> I; + typedef extension_val< image2d<int> > II; + typedef image2d<unsigned short> III; + + I ima(size, size); + II extend_ima(ima, 5); + III out(size, size); + + level::fill(ima, 51); + level::paste(extend_ima, out); + + II::piter p(extend_ima.domain()); + for_all(p) + mln_assertion(extend_ima(p) == out(p)); } } Index: mln/core/image/cast_image.hh --- mln/core/image/cast_image.hh (revision 2687) +++ mln/core/image/cast_image.hh (working copy) @@ -91,8 +91,20 @@ struct image_< cast_image_<T,I> > : cast_image_trait_selector<T, I, mln_trait_image_vw_io(I)> { + private: + typedef mlc_equal(mln_trait_value_quant(T), + trait::value::quant::high) is_high_quant_; + public: + typedef mlc_if(is_high_quant_, + trait::image::quant::high, + trait::image::quant::low) quant; + 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; + + /// FIXME is the following property correct? + typedef trait::image::ext_domain::none ext_domain; }; } // end of namespace mln::trait Index: mln/level/transform.spe.hh --- mln/level/transform.spe.hh (revision 2687) +++ mln/level/transform.spe.hh (working copy) @@ -175,6 +175,7 @@ for_all(pi) { po.val() = f(pi.val()); + po.next(); } trace::exiting("level::impl::transform_fast"); @@ -204,8 +205,8 @@ po.start(); for_all(pi) { - //po.val() = lut(pi.val); - po.val() = f(pi.val()); + po.val() = lut(pi.val()); + po.next(); } trace::exiting("level::impl::transform_fast_lowq"); @@ -221,7 +222,7 @@ /// Deal with image not updated template <typename I, typename F, typename O> inline - void transform_dispatch(mln::trait::undef, + void transform_dispatch_(mln::trait::undef, mln::trait::image::quant::any, const Image<I>& input, const Function_v2v<F>& f, @@ -232,7 +233,7 @@ template <typename I, typename F, typename O> inline - void transform_dispatch(mln::trait::image::vw_set::any, + void transform_dispatch_(mln::trait::image::vw_set::any, mln::trait::image::quant::any, const Image<I>& input, const Function_v2v<F>& f, @@ -243,7 +244,7 @@ template <typename I, typename F, typename O> inline - void transform_dispatch(mln::trait::image::vw_set::uni, + void transform_dispatch_(mln::trait::image::vw_set::uni, mln::trait::image::quant::any, const Image<I>& input, const Function_v2v<F>& f, @@ -255,7 +256,7 @@ template <typename I, typename F, typename O> inline - void transform_dispatch(mln::trait::image::vw_set::none, + void transform_dispatch_(mln::trait::image::vw_set::none, mln::trait::image::quant::low, const Image<I>& input, const Function_v2v<F>& f, @@ -266,7 +267,34 @@ template <typename I, typename F, typename O> inline - void transform_dispatch_oneblock(mln::trait::image::quant::any, + void transform_dispatch_(mln::trait::image::quant::any, + mln::trait::image::value_access::direct, + mln::trait::image::value_access::direct, + mln::trait::image::ext_domain::some, + mln::trait::image::ext_domain::some, + const Image<I>& input_, + const Function_v2v<F>& f, + Image<O>& output_) + { + const I& input = exact(input_); + O& output = exact(output_); + + + if (input.domain() == output.domain()) + transform_fast(input, f, output); + else + transform_dispatch_(mln_trait_image_vw_set(I)(), + mln_trait_image_quant(I)(), + input, f, output); + } + + template <typename I, typename F, typename O> + inline + void transform_dispatch_(mln::trait::image::quant::any, + mln::trait::image::value_access::direct, + mln::trait::image::value_access::direct, + mln::trait::image::ext_domain::none, + mln::trait::image::ext_domain::none, const Image<I>& input, const Function_v2v<F>& f, Image<O>& output) @@ -276,7 +304,33 @@ template <typename I, typename F, typename O> inline - void transform_dispatch_oneblock(mln::trait::image::quant::low, + void transform_dispatch_(mln::trait::image::quant::low, + mln::trait::image::value_access::direct, + mln::trait::image::value_access::direct, + mln::trait::image::ext_domain::some, + mln::trait::image::ext_domain::some, + const Image<I>& input_, + const Function_v2v<F>& f, + Image<O>& output_) + { + const I& input = exact(input_); + O& output = exact(output_); + + if (input.domain() == output.domain()) + transform_fast_lowq(input, f, output); + else + transform_dispatch_(mln_trait_image_vw_set(I)(), + mln_trait_image_quant(I)(), + input, f, output); + } + + template <typename I, typename F, typename O> + inline + void transform_dispatch_(mln::trait::image::quant::low, + mln::trait::image::value_access::direct, + mln::trait::image::value_access::direct, + mln::trait::image::ext_domain::none, + mln::trait::image::ext_domain::none, const Image<I>& input, const Function_v2v<F>& f, Image<O>& output) @@ -287,20 +341,37 @@ template <typename I, typename F, typename O> inline - void transform_dispatch(mln::trait::image::value_storage::any, + void transform_dispatch_(mln::trait::image::quant::any, + mln::trait::image::value_access::any, + mln::trait::image::value_access::any, + mln::trait::image::ext_domain::any, + mln::trait::image::ext_domain::any, + const Image<I>& input, + const Function_v2v<F>& f, + Image<O>& output) + { + transform_dispatch_(mln_trait_image_vw_set(I)(), + mln_trait_image_quant(I)(), + input, f, output); + } + + + template <typename I, typename F, typename O> + inline + void transform_dispatch_(mln::trait::image::value_storage::any, mln::trait::image::value_storage::any, const Image<I>& input, const Function_v2v<F>& f, Image<O>& output) { - transform_dispatch(mln_trait_image_vw_set(I)(), + transform_dispatch_(mln_trait_image_vw_set(I)(), mln_trait_image_quant(I)(), input, f, output); } template <typename I, typename F, typename O> inline - void transform_dispatch(mln::trait::image::value_storage::singleton, + void transform_dispatch_(mln::trait::image::value_storage::singleton, mln::trait::image::value_storage::any, const Image<I>& input, const Function_v2v<F>& f, @@ -311,7 +382,7 @@ template <typename I, typename F, typename O> inline - void transform_dispatch(mln::trait::image::value_storage::one_block, + void transform_dispatch_(mln::trait::image::value_storage::one_block, mln::trait::image::value_storage::one_block, const Image<I>& input_, const Function_v2v<F>& f_, @@ -320,40 +391,22 @@ const I& input = exact(input_); O& output = exact(output_); + /// Check basic properties - if (mlc_is(mln_trait_image_value_access(O), - trait::image::value_access::direct)::value && - mlc_is(mln_trait_image_value_access(I), - trait::image::value_access::direct)::value && - mlc_is(mln_trait_image_value_alignement(I), + if (mlc_is(mln_trait_image_value_alignement(I), trait::image::value_alignement::with_grid)::value && mlc_is(mln_trait_image_value_alignement(O), trait::image::value_alignement::with_grid)::value) { - /// Check ext_domain - if ( - ((mlc_is(mln_trait_image_ext_domain(I), - trait::image::ext_domain::fixed)::value || - mlc_is(mln_trait_image_ext_domain(I), - trait::image::ext_domain::extendable)::value) && - (mlc_is(mln_trait_image_ext_domain(O), - trait::image::ext_domain::fixed)::value || - mlc_is(mln_trait_image_ext_domain(O), - trait::image::ext_domain::extendable)::value) && - input.border() == output.border()) || - (mlc_is(mln_trait_image_ext_domain(I), - trait::image::ext_domain::none)::value && - mlc_is(mln_trait_image_ext_domain(O), - trait::image::ext_domain::none)::value)) - { - - /// Check domain - if (input.domain() == output.domain()) - transform_dispatch_oneblock(mln_trait_image_quant(I)(), + transform_dispatch_(mln_trait_image_quant(I)(), + mln_trait_image_value_access(I)(), + mln_trait_image_value_access(O)(), + mln_trait_image_ext_domain(I)(), + mln_trait_image_ext_domain(O)(), input, f_, output); } - } - transform_dispatch(mln_trait_image_vw_set(I)(), + else + transform_dispatch_(mln_trait_image_vw_set(I)(), mln_trait_image_quant(I)(), input, f_, output); } @@ -362,11 +415,11 @@ template <typename I, typename F, typename O> inline - void transform_dispatch(const Image<I>& input, + void transform_dispatch_(const Image<I>& input, const Function_v2v<F>& f, Image<O>& output) { - transform_dispatch(mln_trait_image_value_storage(I)(), + transform_dispatch_(mln_trait_image_value_storage(I)(), mln_trait_image_value_storage(O)(), input, f, output); } Index: mln/level/paste.spe.hh --- mln/level/paste.spe.hh (revision 2687) +++ mln/level/paste.spe.hh (working copy) @@ -66,11 +66,9 @@ namespace generic { template <typename I, typename J> - void paste_(const Image<I>& input, Image<J>& output); + void paste(const Image<I>& input, Image<J>& output); } - - // template <typename I, typename J> // inline // void paste_lines_(const I& data, J& destination) @@ -111,10 +109,30 @@ for_all(pi) { po.val() = pi.val(); + po.next(); } trace::entering("level::impl::paste_fast"); } + + template <typename I, typename J> + void paste_fast_singleton(const Image<I>& input_, Image<J>& output_) + { + trace::entering("level::impl::paste_fast_singleton"); + + const I& input = exact(input_); + J& output = exact(output_); + + level::internal::paste_tests(input, output); + + mln_pixter(J) po(output); + + for_all(po) + po.val() = input.val(); + + trace::entering("level::impl::paste_fast_singleton"); + } + } // end of namespace impl. @@ -122,6 +140,48 @@ namespace internal { + template <typename I, typename J> + inline + void paste_(mln::trait::image::value_access::direct, + mln::trait::image::value_access::direct, + mln::trait::image::ext_domain::some, + mln::trait::image::ext_domain::some, + const Image<I>& input_, + Image<J>& output_) + { + const I& input = exact(input_); + J& output = exact(output_); + + if (input.domain() == output.domain()) + impl::paste_fast(input, output); + else + impl::generic::paste(input, output); + } + + template <typename I, typename J> + inline + void paste_(mln::trait::image::value_access::direct, + mln::trait::image::value_access::direct, + mln::trait::image::ext_domain::none, + mln::trait::image::ext_domain::none, + const Image<I>& input, + Image<J>& output) + { + impl::paste_fast(input, output); + } + + + template <typename I, typename J> + inline + void paste_(mln::trait::image::value_access::any, + mln::trait::image::value_access::any, + mln::trait::image::ext_domain::any, + mln::trait::image::ext_domain::any, + const Image<I>& input, + Image<J>& output) + { + impl::generic::paste(input, output); + } template <typename I, typename J> inline @@ -130,51 +190,45 @@ const Image<I>& input, Image<J>& output) { - impl::generic::paste_(input, output); + impl::generic::paste(input, output); } template <typename I, typename J> inline - void paste_(trait::image::value_storage::one_block, + void paste_(trait::image::value_storage::singleton, trait::image::value_storage::one_block, + const Image<I>& input, + Image<J>& output) + { + impl::paste_fast_singleton(input, output); + } + + + template <typename I, typename J> + inline + void paste_(mln::trait::image::value_storage::one_block, + mln::trait::image::value_storage::one_block, const Image<I>& input_, Image<J>& output_) { const I& input = exact(input_); J& output = exact(output_); + /// Check basic properties - if (mlc_is(mln_trait_image_value_access(J), - trait::image::value_access::direct)::value && - mlc_is(mln_trait_image_value_access(I), - trait::image::value_access::direct)::value && - mlc_is(mln_trait_image_value_alignement(I), + if (mlc_is(mln_trait_image_value_alignement(I), trait::image::value_alignement::with_grid)::value && mlc_is(mln_trait_image_value_alignement(J), trait::image::value_alignement::with_grid)::value) { - /// Check ext_domain - if ( - ((mlc_is(mln_trait_image_ext_domain(I), - trait::image::ext_domain::fixed)::value || - mlc_is(mln_trait_image_ext_domain(I), - trait::image::ext_domain::extendable)::value) && - (mlc_is(mln_trait_image_ext_domain(J), - trait::image::ext_domain::fixed)::value || - mlc_is(mln_trait_image_ext_domain(J), - trait::image::ext_domain::extendable)::value) && - input.border() == output.border()) || - (mlc_is(mln_trait_image_ext_domain(I), - trait::image::ext_domain::none)::value && - mlc_is(mln_trait_image_ext_domain(J), - trait::image::ext_domain::none)::value)) - { - /// Check domain - if (input.domain() == output.domain()) - impl::paste_fast(input, output); - } + paste_(mln_trait_image_value_access(I)(), + mln_trait_image_value_access(J)(), + mln_trait_image_ext_domain(I)(), + mln_trait_image_ext_domain(J)(), + input, output); } - impl::generic::paste_(input, output); + else + impl::generic::paste(input, output); } @@ -182,6 +236,7 @@ inline void paste_(const Image<I>& input, Image<J>& output) { + paste_(mln_trait_image_value_storage(I)(), mln_trait_image_value_storage(J)(), input, output); Index: mln/level/fill_with_image.spe.hh --- mln/level/fill_with_image.spe.hh (revision 2687) +++ mln/level/fill_with_image.spe.hh (working copy) @@ -86,9 +86,31 @@ for_all(pi) { pi.val() = d.val(); + d.next(); } trace::entering("level::impl::fill_with_image_fast"); } + + + template <typename I, typename J> + void fill_with_image_fast_singleton(Image<I>& ima_, + const Image<J>& data_) + { + trace::entering("level::impl::fill_with_image_fast_singleton"); + + I& ima = exact(ima_); + const J& data = exact(data_); + + level::internal::fill_with_image_tests(ima, data); + + mln_pixter(I) pi(ima); + + for_all(pi) + pi.val() = data.val(); + + trace::entering("level::impl::fill_with_image_fast_singleton"); + } + } // end of namespace mln::level::impl @@ -99,6 +121,49 @@ template <typename I, typename J> inline + void fill_with_image_(mln::trait::image::value_access::direct, + mln::trait::image::value_access::direct, + mln::trait::image::ext_domain::some, + mln::trait::image::ext_domain::some, + Image<I>& ima_, + const Image<J>& data_) + { + I& ima = exact(ima_); + const J& data = exact(data_); + + if (ima.domain() == data.domain()) + impl::fill_with_image_fast(ima, data); + else + impl::generic::fill_with_image(ima, data); + } + + template <typename I, typename J> + inline + void fill_with_image_(mln::trait::image::value_access::direct, + mln::trait::image::value_access::direct, + mln::trait::image::ext_domain::none, + mln::trait::image::ext_domain::none, + Image<I>& ima, + const Image<J>& data) + { + impl::fill_with_image_fast(ima, data); + } + + + template <typename I, typename J> + inline + void fill_with_image_(mln::trait::image::value_access::any, + mln::trait::image::value_access::any, + mln::trait::image::ext_domain::any, + mln::trait::image::ext_domain::any, + Image<I>& ima, + const Image<J>& data) + { + impl::generic::fill_with_image(ima, data); + } + + template <typename I, typename J> + inline void fill_with_image_(trait::image::value_storage::any, trait::image::value_storage::any, Image<I>& ima, @@ -110,49 +175,41 @@ template <typename I, typename J> inline void fill_with_image_(trait::image::value_storage::one_block, - trait::image::value_storage::one_block, + trait::image::value_storage::singleton, + Image<I>& ima, + const Image<J>& data) + { + impl::generic::fill_with_image(ima, data); + } + + template <typename I, typename J> + inline + void fill_with_image_(mln::trait::image::value_storage::one_block, + mln::trait::image::value_storage::one_block, Image<I>& ima_, const Image<J>& data_) { I& ima = exact(ima_); const J& data = exact(data_); + /// Check basic properties - if (mlc_is(mln_trait_image_value_access(J), - trait::image::value_access::direct)::value && - mlc_is(mln_trait_image_value_access(I), - trait::image::value_access::direct)::value && - mlc_is(mln_trait_image_value_alignement(I), + if (mlc_is(mln_trait_image_value_alignement(I), trait::image::value_alignement::with_grid)::value && mlc_is(mln_trait_image_value_alignement(J), trait::image::value_alignement::with_grid)::value) { - /// Check ext_domain - if ( - ((mlc_is(mln_trait_image_ext_domain(I), - trait::image::ext_domain::fixed)::value || - mlc_is(mln_trait_image_ext_domain(I), - trait::image::ext_domain::extendable)::value) && - (mlc_is(mln_trait_image_ext_domain(J), - trait::image::ext_domain::fixed)::value || - mlc_is(mln_trait_image_ext_domain(J), - trait::image::ext_domain::extendable)::value) && - data.border() == data.border()) || - (mlc_is(mln_trait_image_ext_domain(I), - trait::image::ext_domain::none)::value && - mlc_is(mln_trait_image_ext_domain(J), - trait::image::ext_domain::none)::value)) - { - /// Check domain - if (data.domain() == data.domain()) - impl::fill_with_image_fast(ima, data); - } + fill_with_image_(mln_trait_image_value_access(I)(), + mln_trait_image_value_access(J)(), + mln_trait_image_ext_domain(I)(), + mln_trait_image_ext_domain(J)(), + ima, data); } + else impl::generic::fill_with_image(ima, data); } - template <typename I, typename J> inline void fill_with_image_(Image<I>& ima, const Image<J>& data) Index: mln/level/transform.hh --- mln/level/transform.hh (revision 2687) +++ mln/level/transform.hh (working copy) @@ -159,7 +159,7 @@ trace::entering("level::transform"); mln_precondition(exact(output).domain() >= exact(input).domain()); - transform_dispatch(exact(input), exact(f), exact(output)); + transform_dispatch_(exact(input), exact(f), exact(output)); trace::exiting("level::transform"); } Index: mln/level/paste.hh --- mln/level/paste.hh (revision 2687) +++ mln/level/paste.hh (working copy) @@ -102,7 +102,7 @@ template <typename I, typename J> inline - void paste_(const Image<I>& input_, Image<J>& output_) + void paste(const Image<I>& input_, Image<J>& output_) { trace::entering("level::impl::generic::paste");
16 years, 2 months
1
0
0
0
2688: Fix bugs in low level routines.
by Guillaume Lazzara
* tests/level/fill_with_image.cc, * tests/level/transform.cc, * tests/level/paste.cc: Add tests. * mln/core/image/cast_image.hh: Update properties. * mln/level/transform.spe.hh, * mln/level/paste.spe.hh, * mln/level/fill_with_image.spe.hh: Update dispatch, fix bugs. * mln/level/transform.hh, * mln/level/paste.hh: Rename routines. --- milena/ChangeLog | 14 ++ milena/mln/core/image/cast_image.hh | 12 ++ milena/mln/level/fill_with_image.spe.hh | 113 ++++++++++++---- milena/mln/level/paste.hh | 2 +- milena/mln/level/paste.spe.hh | 117 ++++++++++++----- milena/mln/level/transform.hh | 2 +- milena/mln/level/transform.spe.hh | 225 +++++++++++++++++++------------ milena/tests/level/fill_with_image.cc | 139 ++++++++++++++++++- milena/tests/level/paste.cc | 122 ++++++++++++++++- milena/tests/level/transform.cc | 62 +++++++++- 10 files changed, 652 insertions(+), 156 deletions(-) diff --git a/milena/ChangeLog b/milena/ChangeLog index 35f360b..2c1de6a 100644 --- a/milena/ChangeLog +++ b/milena/ChangeLog @@ -1,3 +1,17 @@ +2008-10-27 Nicolas Ballas <ballas(a)lrde.epita.fr> + + Fix bugs in low level routines. + + * tests/level/fill_with_image.cc, + * tests/level/transform.cc, + * tests/level/paste.cc: Add tests. + * mln/core/image/cast_image.hh: Update properties. + * mln/level/transform.spe.hh, + * mln/level/paste.spe.hh, + * mln/level/fill_with_image.spe.hh: Update dispatch, fix bugs. + * mln/level/transform.hh, + * mln/level/paste.hh: Rename routines. + 2008-10-24 Roland Levillain <roland(a)lrde.epita.fr> Fix mln::level::stretch w.r.t. the initialization. diff --git a/milena/mln/core/image/cast_image.hh b/milena/mln/core/image/cast_image.hh index 6de5892..d5baa8d 100644 --- a/milena/mln/core/image/cast_image.hh +++ b/milena/mln/core/image/cast_image.hh @@ -91,8 +91,20 @@ namespace mln struct image_< cast_image_<T,I> > : cast_image_trait_selector<T, I, mln_trait_image_vw_io(I)> { + private: + typedef mlc_equal(mln_trait_value_quant(T), + trait::value::quant::high) is_high_quant_; + public: + typedef mlc_if(is_high_quant_, + trait::image::quant::high, + trait::image::quant::low) quant; + 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; + + /// FIXME is the following property correct? + typedef trait::image::ext_domain::none ext_domain; }; } // end of namespace mln::trait diff --git a/milena/mln/level/fill_with_image.spe.hh b/milena/mln/level/fill_with_image.spe.hh index 846da96..6084e72 100644 --- a/milena/mln/level/fill_with_image.spe.hh +++ b/milena/mln/level/fill_with_image.spe.hh @@ -86,9 +86,31 @@ namespace mln for_all(pi) { pi.val() = d.val(); + d.next(); } trace::entering("level::impl::fill_with_image_fast"); } + + + template <typename I, typename J> + void fill_with_image_fast_singleton(Image<I>& ima_, + const Image<J>& data_) + { + trace::entering("level::impl::fill_with_image_fast_singleton"); + + I& ima = exact(ima_); + const J& data = exact(data_); + + level::internal::fill_with_image_tests(ima, data); + + mln_pixter(I) pi(ima); + + for_all(pi) + pi.val() = data.val(); + + trace::entering("level::impl::fill_with_image_fast_singleton"); + } + } // end of namespace mln::level::impl @@ -99,6 +121,49 @@ namespace mln template <typename I, typename J> inline + void fill_with_image_(mln::trait::image::value_access::direct, + mln::trait::image::value_access::direct, + mln::trait::image::ext_domain::some, + mln::trait::image::ext_domain::some, + Image<I>& ima_, + const Image<J>& data_) + { + I& ima = exact(ima_); + const J& data = exact(data_); + + if (ima.domain() == data.domain()) + impl::fill_with_image_fast(ima, data); + else + impl::generic::fill_with_image(ima, data); + } + + template <typename I, typename J> + inline + void fill_with_image_(mln::trait::image::value_access::direct, + mln::trait::image::value_access::direct, + mln::trait::image::ext_domain::none, + mln::trait::image::ext_domain::none, + Image<I>& ima, + const Image<J>& data) + { + impl::fill_with_image_fast(ima, data); + } + + + template <typename I, typename J> + inline + void fill_with_image_(mln::trait::image::value_access::any, + mln::trait::image::value_access::any, + mln::trait::image::ext_domain::any, + mln::trait::image::ext_domain::any, + Image<I>& ima, + const Image<J>& data) + { + impl::generic::fill_with_image(ima, data); + } + + template <typename I, typename J> + inline void fill_with_image_(trait::image::value_storage::any, trait::image::value_storage::any, Image<I>& ima, @@ -110,49 +175,41 @@ namespace mln template <typename I, typename J> inline void fill_with_image_(trait::image::value_storage::one_block, - trait::image::value_storage::one_block, + trait::image::value_storage::singleton, + Image<I>& ima, + const Image<J>& data) + { + impl::generic::fill_with_image(ima, data); + } + + template <typename I, typename J> + inline + void fill_with_image_(mln::trait::image::value_storage::one_block, + mln::trait::image::value_storage::one_block, Image<I>& ima_, const Image<J>& data_) { I& ima = exact(ima_); const J& data = exact(data_); + /// Check basic properties - if (mlc_is(mln_trait_image_value_access(J), - trait::image::value_access::direct)::value && - mlc_is(mln_trait_image_value_access(I), - trait::image::value_access::direct)::value && - mlc_is(mln_trait_image_value_alignement(I), + if (mlc_is(mln_trait_image_value_alignement(I), trait::image::value_alignement::with_grid)::value && mlc_is(mln_trait_image_value_alignement(J), trait::image::value_alignement::with_grid)::value) { - /// Check ext_domain - if ( - ((mlc_is(mln_trait_image_ext_domain(I), - trait::image::ext_domain::fixed)::value || - mlc_is(mln_trait_image_ext_domain(I), - trait::image::ext_domain::extendable)::value) && - (mlc_is(mln_trait_image_ext_domain(J), - trait::image::ext_domain::fixed)::value || - mlc_is(mln_trait_image_ext_domain(J), - trait::image::ext_domain::extendable)::value) && - data.border() == data.border()) || - (mlc_is(mln_trait_image_ext_domain(I), - trait::image::ext_domain::none)::value && - mlc_is(mln_trait_image_ext_domain(J), - trait::image::ext_domain::none)::value)) - { - /// Check domain - if (data.domain() == data.domain()) - impl::fill_with_image_fast(ima, data); - } + fill_with_image_(mln_trait_image_value_access(I)(), + mln_trait_image_value_access(J)(), + mln_trait_image_ext_domain(I)(), + mln_trait_image_ext_domain(J)(), + ima, data); } - impl::generic::fill_with_image(ima, data); + else + impl::generic::fill_with_image(ima, data); } - template <typename I, typename J> inline void fill_with_image_(Image<I>& ima, const Image<J>& data) diff --git a/milena/mln/level/paste.hh b/milena/mln/level/paste.hh index c3b8fcc..6bbac4a 100644 --- a/milena/mln/level/paste.hh +++ b/milena/mln/level/paste.hh @@ -102,7 +102,7 @@ namespace mln template <typename I, typename J> inline - void paste_(const Image<I>& input_, Image<J>& output_) + void paste(const Image<I>& input_, Image<J>& output_) { trace::entering("level::impl::generic::paste"); diff --git a/milena/mln/level/paste.spe.hh b/milena/mln/level/paste.spe.hh index 028ced8..e7c7390 100644 --- a/milena/mln/level/paste.spe.hh +++ b/milena/mln/level/paste.spe.hh @@ -66,11 +66,9 @@ namespace mln namespace generic { template <typename I, typename J> - void paste_(const Image<I>& input, Image<J>& output); + void paste(const Image<I>& input, Image<J>& output); } - - // template <typename I, typename J> // inline // void paste_lines_(const I& data, J& destination) @@ -111,10 +109,30 @@ namespace mln for_all(pi) { po.val() = pi.val(); + po.next(); } trace::entering("level::impl::paste_fast"); } + + template <typename I, typename J> + void paste_fast_singleton(const Image<I>& input_, Image<J>& output_) + { + trace::entering("level::impl::paste_fast_singleton"); + + const I& input = exact(input_); + J& output = exact(output_); + + level::internal::paste_tests(input, output); + + mln_pixter(J) po(output); + + for_all(po) + po.val() = input.val(); + + trace::entering("level::impl::paste_fast_singleton"); + } + } // end of namespace impl. @@ -122,6 +140,48 @@ namespace mln namespace internal { + template <typename I, typename J> + inline + void paste_(mln::trait::image::value_access::direct, + mln::trait::image::value_access::direct, + mln::trait::image::ext_domain::some, + mln::trait::image::ext_domain::some, + const Image<I>& input_, + Image<J>& output_) + { + const I& input = exact(input_); + J& output = exact(output_); + + if (input.domain() == output.domain()) + impl::paste_fast(input, output); + else + impl::generic::paste(input, output); + } + + template <typename I, typename J> + inline + void paste_(mln::trait::image::value_access::direct, + mln::trait::image::value_access::direct, + mln::trait::image::ext_domain::none, + mln::trait::image::ext_domain::none, + const Image<I>& input, + Image<J>& output) + { + impl::paste_fast(input, output); + } + + + template <typename I, typename J> + inline + void paste_(mln::trait::image::value_access::any, + mln::trait::image::value_access::any, + mln::trait::image::ext_domain::any, + mln::trait::image::ext_domain::any, + const Image<I>& input, + Image<J>& output) + { + impl::generic::paste(input, output); + } template <typename I, typename J> inline @@ -130,51 +190,45 @@ namespace mln const Image<I>& input, Image<J>& output) { - impl::generic::paste_(input, output); + impl::generic::paste(input, output); } template <typename I, typename J> inline - void paste_(trait::image::value_storage::one_block, + void paste_(trait::image::value_storage::singleton, trait::image::value_storage::one_block, + const Image<I>& input, + Image<J>& output) + { + impl::paste_fast_singleton(input, output); + } + + + template <typename I, typename J> + inline + void paste_(mln::trait::image::value_storage::one_block, + mln::trait::image::value_storage::one_block, const Image<I>& input_, Image<J>& output_) { const I& input = exact(input_); J& output = exact(output_); + /// Check basic properties - if (mlc_is(mln_trait_image_value_access(J), - trait::image::value_access::direct)::value && - mlc_is(mln_trait_image_value_access(I), - trait::image::value_access::direct)::value && - mlc_is(mln_trait_image_value_alignement(I), + if (mlc_is(mln_trait_image_value_alignement(I), trait::image::value_alignement::with_grid)::value && mlc_is(mln_trait_image_value_alignement(J), trait::image::value_alignement::with_grid)::value) { - /// Check ext_domain - if ( - ((mlc_is(mln_trait_image_ext_domain(I), - trait::image::ext_domain::fixed)::value || - mlc_is(mln_trait_image_ext_domain(I), - trait::image::ext_domain::extendable)::value) && - (mlc_is(mln_trait_image_ext_domain(J), - trait::image::ext_domain::fixed)::value || - mlc_is(mln_trait_image_ext_domain(J), - trait::image::ext_domain::extendable)::value) && - input.border() == output.border()) || - (mlc_is(mln_trait_image_ext_domain(I), - trait::image::ext_domain::none)::value && - mlc_is(mln_trait_image_ext_domain(J), - trait::image::ext_domain::none)::value)) - { - /// Check domain - if (input.domain() == output.domain()) - impl::paste_fast(input, output); - } + paste_(mln_trait_image_value_access(I)(), + mln_trait_image_value_access(J)(), + mln_trait_image_ext_domain(I)(), + mln_trait_image_ext_domain(J)(), + input, output); } - impl::generic::paste_(input, output); + else + impl::generic::paste(input, output); } @@ -182,6 +236,7 @@ namespace mln inline void paste_(const Image<I>& input, Image<J>& output) { + paste_(mln_trait_image_value_storage(I)(), mln_trait_image_value_storage(J)(), input, output); diff --git a/milena/mln/level/transform.hh b/milena/mln/level/transform.hh index adece40..255751e 100644 --- a/milena/mln/level/transform.hh +++ b/milena/mln/level/transform.hh @@ -159,7 +159,7 @@ namespace mln trace::entering("level::transform"); mln_precondition(exact(output).domain() >= exact(input).domain()); - transform_dispatch(exact(input), exact(f), exact(output)); + transform_dispatch_(exact(input), exact(f), exact(output)); trace::exiting("level::transform"); } diff --git a/milena/mln/level/transform.spe.hh b/milena/mln/level/transform.spe.hh index 0f044d2..e498997 100644 --- a/milena/mln/level/transform.spe.hh +++ b/milena/mln/level/transform.spe.hh @@ -175,6 +175,7 @@ namespace mln for_all(pi) { po.val() = f(pi.val()); + po.next(); } trace::exiting("level::impl::transform_fast"); @@ -195,8 +196,8 @@ namespace mln level::internal::transform_tests(input, f, output); - value::lut_vec<mln_vset(I), mln_result(F)> - lut(input.values_eligible(), f); + value::lut_vec<mln_vset(I), mln_result(F)> + lut(input.values_eligible(), f); mln_pixter(const I) pi(input); mln_pixter(O) po(output); @@ -204,8 +205,8 @@ namespace mln po.start(); for_all(pi) { - //po.val() = lut(pi.val); - po.val() = f(pi.val()); + po.val() = lut(pi.val()); + po.next(); } trace::exiting("level::impl::transform_fast_lowq"); @@ -221,33 +222,33 @@ namespace mln /// Deal with image not updated template <typename I, typename F, typename O> inline - void transform_dispatch(mln::trait::undef, - mln::trait::image::quant::any, - const Image<I>& input, - const Function_v2v<F>& f, - Image<O>& output) + void transform_dispatch_(mln::trait::undef, + mln::trait::image::quant::any, + const Image<I>& input, + const Function_v2v<F>& f, + Image<O>& output) { impl::generic::transform(input, f, output); } template <typename I, typename F, typename O> inline - void transform_dispatch(mln::trait::image::vw_set::any, - mln::trait::image::quant::any, - const Image<I>& input, - const Function_v2v<F>& f, - Image<O>& output) + void transform_dispatch_(mln::trait::image::vw_set::any, + mln::trait::image::quant::any, + const Image<I>& input, + const Function_v2v<F>& f, + Image<O>& output) { impl::generic::transform(input, f, output); } template <typename I, typename F, typename O> inline - void transform_dispatch(mln::trait::image::vw_set::uni, - mln::trait::image::quant::any, - const Image<I>& input, - const Function_v2v<F>& f, - Image<O>& output) + void transform_dispatch_(mln::trait::image::vw_set::uni, + mln::trait::image::quant::any, + const Image<I>& input, + const Function_v2v<F>& f, + Image<O>& output) { impl::transform_taken(input, f, output); } @@ -255,31 +256,84 @@ namespace mln template <typename I, typename F, typename O> inline - void transform_dispatch(mln::trait::image::vw_set::none, - mln::trait::image::quant::low, - const Image<I>& input, - const Function_v2v<F>& f, - Image<O>& output) + void transform_dispatch_(mln::trait::image::vw_set::none, + mln::trait::image::quant::low, + const Image<I>& input, + const Function_v2v<F>& f, + Image<O>& output) { impl::transform_lowq(input, f, output); } template <typename I, typename F, typename O> inline - void transform_dispatch_oneblock(mln::trait::image::quant::any, - const Image<I>& input, - const Function_v2v<F>& f, - Image<O>& output) + void transform_dispatch_(mln::trait::image::quant::any, + mln::trait::image::value_access::direct, + mln::trait::image::value_access::direct, + mln::trait::image::ext_domain::some, + mln::trait::image::ext_domain::some, + const Image<I>& input_, + const Function_v2v<F>& f, + Image<O>& output_) + { + const I& input = exact(input_); + O& output = exact(output_); + + + if (input.domain() == output.domain()) + transform_fast(input, f, output); + else + transform_dispatch_(mln_trait_image_vw_set(I)(), + mln_trait_image_quant(I)(), + input, f, output); + } + + template <typename I, typename F, typename O> + inline + void transform_dispatch_(mln::trait::image::quant::any, + mln::trait::image::value_access::direct, + mln::trait::image::value_access::direct, + mln::trait::image::ext_domain::none, + mln::trait::image::ext_domain::none, + const Image<I>& input, + const Function_v2v<F>& f, + Image<O>& output) { transform_fast(input, f, output); } template <typename I, typename F, typename O> inline - void transform_dispatch_oneblock(mln::trait::image::quant::low, - const Image<I>& input, - const Function_v2v<F>& f, - Image<O>& output) + void transform_dispatch_(mln::trait::image::quant::low, + mln::trait::image::value_access::direct, + mln::trait::image::value_access::direct, + mln::trait::image::ext_domain::some, + mln::trait::image::ext_domain::some, + const Image<I>& input_, + const Function_v2v<F>& f, + Image<O>& output_) + { + const I& input = exact(input_); + O& output = exact(output_); + + if (input.domain() == output.domain()) + transform_fast_lowq(input, f, output); + else + transform_dispatch_(mln_trait_image_vw_set(I)(), + mln_trait_image_quant(I)(), + input, f, output); + } + + template <typename I, typename F, typename O> + inline + void transform_dispatch_(mln::trait::image::quant::low, + mln::trait::image::value_access::direct, + mln::trait::image::value_access::direct, + mln::trait::image::ext_domain::none, + mln::trait::image::ext_domain::none, + const Image<I>& input, + const Function_v2v<F>& f, + Image<O>& output) { transform_fast_lowq(input, f, output); } @@ -287,88 +341,87 @@ namespace mln template <typename I, typename F, typename O> inline - void transform_dispatch(mln::trait::image::value_storage::any, - mln::trait::image::value_storage::any, - const Image<I>& input, - const Function_v2v<F>& f, - Image<O>& output) + void transform_dispatch_(mln::trait::image::quant::any, + mln::trait::image::value_access::any, + mln::trait::image::value_access::any, + mln::trait::image::ext_domain::any, + mln::trait::image::ext_domain::any, + const Image<I>& input, + const Function_v2v<F>& f, + Image<O>& output) { - transform_dispatch(mln_trait_image_vw_set(I)(), - mln_trait_image_quant(I)(), - input, f, output); + transform_dispatch_(mln_trait_image_vw_set(I)(), + mln_trait_image_quant(I)(), + input, f, output); } + template <typename I, typename F, typename O> inline - void transform_dispatch(mln::trait::image::value_storage::singleton, - mln::trait::image::value_storage::any, - const Image<I>& input, - const Function_v2v<F>& f, - Image<O>& output) + void transform_dispatch_(mln::trait::image::value_storage::any, + mln::trait::image::value_storage::any, + const Image<I>& input, + const Function_v2v<F>& f, + Image<O>& output) + { + transform_dispatch_(mln_trait_image_vw_set(I)(), + mln_trait_image_quant(I)(), + input, f, output); + } + + template <typename I, typename F, typename O> + inline + void transform_dispatch_(mln::trait::image::value_storage::singleton, + mln::trait::image::value_storage::any, + const Image<I>& input, + const Function_v2v<F>& f, + Image<O>& output) { transform_singleton(input, f, output); } template <typename I, typename F, typename O> inline - void transform_dispatch(mln::trait::image::value_storage::one_block, - mln::trait::image::value_storage::one_block, - const Image<I>& input_, - const Function_v2v<F>& f_, - Image<O>& output_) + void transform_dispatch_(mln::trait::image::value_storage::one_block, + mln::trait::image::value_storage::one_block, + const Image<I>& input_, + const Function_v2v<F>& f_, + Image<O>& output_) { const I& input = exact(input_); O& output = exact(output_); + /// Check basic properties - if (mlc_is(mln_trait_image_value_access(O), - trait::image::value_access::direct)::value && - mlc_is(mln_trait_image_value_access(I), - trait::image::value_access::direct)::value && - mlc_is(mln_trait_image_value_alignement(I), + if (mlc_is(mln_trait_image_value_alignement(I), trait::image::value_alignement::with_grid)::value && mlc_is(mln_trait_image_value_alignement(O), trait::image::value_alignement::with_grid)::value) { - /// Check ext_domain - if ( - ((mlc_is(mln_trait_image_ext_domain(I), - trait::image::ext_domain::fixed)::value || - mlc_is(mln_trait_image_ext_domain(I), - trait::image::ext_domain::extendable)::value) && - (mlc_is(mln_trait_image_ext_domain(O), - trait::image::ext_domain::fixed)::value || - mlc_is(mln_trait_image_ext_domain(O), - trait::image::ext_domain::extendable)::value) && - input.border() == output.border()) || - (mlc_is(mln_trait_image_ext_domain(I), - trait::image::ext_domain::none)::value && - mlc_is(mln_trait_image_ext_domain(O), - trait::image::ext_domain::none)::value)) - { - - /// Check domain - if (input.domain() == output.domain()) - transform_dispatch_oneblock(mln_trait_image_quant(I)(), - input, f_, output); - } + transform_dispatch_(mln_trait_image_quant(I)(), + mln_trait_image_value_access(I)(), + mln_trait_image_value_access(O)(), + mln_trait_image_ext_domain(I)(), + mln_trait_image_ext_domain(O)(), + input, f_, output); } - transform_dispatch(mln_trait_image_vw_set(I)(), - mln_trait_image_quant(I)(), - input, f_, output); + else + transform_dispatch_(mln_trait_image_vw_set(I)(), + mln_trait_image_quant(I)(), + input, f_, output); } template <typename I, typename F, typename O> inline - void transform_dispatch(const Image<I>& input, - const Function_v2v<F>& f, - Image<O>& output) + void transform_dispatch_(const Image<I>& input, + const Function_v2v<F>& f, + Image<O>& output) { - transform_dispatch(mln_trait_image_value_storage(I)(), - mln_trait_image_value_storage(O)(), - input, f, output); + transform_dispatch_(mln_trait_image_value_storage(I)(), + mln_trait_image_value_storage(O)(), + input, f, output); } } diff --git a/milena/tests/level/fill_with_image.cc b/milena/tests/level/fill_with_image.cc index a9bd8cf..303dad8 100644 --- a/milena/tests/level/fill_with_image.cc +++ b/milena/tests/level/fill_with_image.cc @@ -32,17 +32,24 @@ #include <mln/level/fill_with_value.hh> #include <mln/level/fill_with_image.hh> +#include <mln/level/compare.hh> +#include <mln/core/image/image1d.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/cast_image.hh> +#include <mln/core/image/image_if.hh> #include <mln/core/image/sub_image.hh> +#include <mln/core/image/extension_val.hh> -#include <mln/core/image/image_if.hh> -#include <mln/level/compare.hh> +#include <mln/fun/p2b/chess.hh> +#include <mln/fun/p2v/iota.hh> #include <mln/debug/iota.hh> #include <mln/debug/println.hh> -#include <mln/fun/p2b/chess.hh> +#include <mln/trace/all.hh> int main() @@ -50,6 +57,7 @@ int main() using namespace mln; const unsigned size = 100; + // 2d tests { image2d<unsigned int> ima(size, size); image2d<unsigned int> ima2(size, size); @@ -68,7 +76,7 @@ int main() debug::iota(ima2); level::fill_with_image(ima, ima2); - assert(ima == (ima2 | b)); + mln_assertion(ima == (ima2 | b)); } { @@ -88,4 +96,127 @@ int main() mln_assertion(ima_if(p) == 42); } + + // tests in three dimension + { + box3d b(point3d(1,2,1), point3d(2,4,3)); + image3d<int> ima(b, 2); + debug::iota(ima); + + box3d b2(point3d(-1,-2,-1), point3d(3,6,3)); + image3d<int> ima2(b2, 2); + debug::iota(ima2); + + image3d<int> ima3(b, 2); + + level::fill_with_image(ima, ima2); // Not so fast version... + mln_assertion(ima == (ima2 | b)); + + level::fill_with_image(ima3, ima); // Fast version... + mln_assertion(ima == ima3); + } + + // image 1d test + { + image1d<unsigned short> ima(size); + image1d<unsigned short> out(size); + + debug::iota(ima); + level::fill_with_image(out, ima); + + mln_assertion(ima == out); + } + + + // pw image test + { + const pw::image<fun::p2v::iota_t, box2d> ima(fun::p2v::iota, + make::box2d(-2,-2, 15,15)); + image2d<short unsigned int> out(8, 8); + + level::fill(out, 0); + level::fill_with_image(out, ima); + } + + // flat image test + { + flat_image<short, box2d> ima(5, make::box2d(size, size)); + image2d<unsigned short> out(size, size); + + level::fill_with_value(ima, 51); + level::fill_with_image(out, ima); + + mln_assertion(ima == out); + } + + // image if test + { + typedef image2d<unsigned short> I; + typedef image_if<I, fun::p2b::chess_t> II; + + I ima(size, size); + I out(size, size); + II ima_if = ima | fun::p2b::chess; + + level::fill_with_value(ima, 42); + level::fill_with_value(out, 0); + level::fill_with_image(ima_if, ima); + + mln_piter_(II) p(ima_if.domain()); + for_all(p) + mln_assertion(ima_if(p) == ima(p)); + } + + // cast image test + { + typedef image2d<unsigned short> I; + typedef cast_image_<int, I> II; + + I in(size, size); + II cast(in); + I out(size, size); + + level::fill(in, 51); + level::fill(out, 42); + + level::fill_with_image(out, cast); + + mln_assertion(cast == out); + } + + // sub_image test + { + typedef image2d<int> I; + typedef sub_image< image2d<int>, box2d > II; + + I ima(size, size); + I out(size, size); + II sub_ima(ima, make::box2d(4,4, 10,10)); + + + level::fill(ima, 51); + level::fill(out, 0); + level::fill_with_image(sub_ima, ima); + + II::piter p(sub_ima.domain()); + for_all(p) + mln_assertion(sub_ima(p) == ima(p)); + } + + // extended image test + { + typedef image2d<int> I; + typedef extension_val< image2d<int> > II; + typedef image2d<unsigned short> III; + + I ima(size, size); + II extend_ima(ima, 5); + III out(size, size); + + level::fill(ima, 51); + level::fill_with_image(out, extend_ima); + + mln_assertion(out == extend_ima); + } + } diff --git a/milena/tests/level/paste.cc b/milena/tests/level/paste.cc index cd97898..e748602 100644 --- a/milena/tests/level/paste.cc +++ b/milena/tests/level/paste.cc @@ -30,21 +30,32 @@ * \brief Tests on mln::level::paste. */ +#include <mln/core/image/image1d.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/cast_image.hh> +#include <mln/core/image/image_if.hh> #include <mln/core/image/sub_image.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/fun/p2b/chess.hh> +#include <mln/fun/p2v/iota.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; // tests in two dimension { @@ -59,10 +70,10 @@ int main() image2d<int> ima3(b, 2); level::paste(ima, ima2); // Not so fast version... - assert(ima == (ima2 | b)); + mln_assertion(ima == (ima2 | b)); level::paste(ima, ima3); // Fast version... - assert(ima == ima3); + mln_assertion(ima == ima3); } // tests in three dimension @@ -78,9 +89,112 @@ int main() image3d<int> ima3(b, 2); level::paste(ima, ima2); // Not so fast version... - assert(ima == (ima2 | b)); + mln_assertion(ima == (ima2 | b)); level::paste(ima, ima3); // Fast version... - assert(ima == ima3); + mln_assertion(ima == ima3); + } + + /// image 1d test + { + image1d<unsigned short> ima(size); + image1d<unsigned short> out(size); + + debug::iota(ima); + level::paste(ima, out); + + mln_assertion(ima == out); + } + + + /// pw image test + { + const pw::image<fun::p2v::iota_t, box2d> ima(fun::p2v::iota, + make::box2d(2,2, 5,5)); + image2d<short unsigned int> out(8, 8); + + level::fill(out, 0); + level::paste(ima, out); + } + + // flat image test + { + flat_image<short, box2d> ima(5, make::box2d(size, size)); + image2d<unsigned short> out(size, size); + + level::fill_with_value(ima, 51); + level::paste(ima, out); + + mln_assertion(ima == out); + } + + // image if test + { + typedef image2d<unsigned short> I; + typedef image_if<I, fun::p2b::chess_t> II; + + I ima(size, size); + I out(size, size); + II ima_if = ima | fun::p2b::chess; + + level::fill_with_value(ima, 0); + debug::iota(ima); + level::paste(ima_if, out); + + mln_assertion(ima_if == out); + } + + // cast image test + { + typedef image2d<unsigned short> I; + typedef cast_image_<int, I> II; + typedef image2d<unsigned short> III; + + I in(size, size); + II cast(in); + III out(size, size); + + level::fill(in, 51); + level::fill(out, 42); + + level::paste(cast, out); + + mln_assertion(cast == out); + } + + // sub_image test + { + typedef image2d<int> I; + typedef sub_image< image2d<int>, box2d > II; + typedef image2d<unsigned short> III; + + I ima(size, size); + II sub_ima(ima, make::box2d(4,4, 10,10)); + III out(size, size); + + level::fill(ima, 51); + level::paste(sub_ima, out); + + II::piter p(sub_ima.domain()); + for_all(p) + mln_assertion(sub_ima(p) == out(p)); + } + + // extended image test + { + typedef image2d<int> I; + typedef extension_val< image2d<int> > II; + typedef image2d<unsigned short> III; + + I ima(size, size); + II extend_ima(ima, 5); + III out(size, size); + + level::fill(ima, 51); + level::paste(extend_ima, out); + + II::piter p(extend_ima.domain()); + for_all(p) + mln_assertion(extend_ima(p) == out(p)); } } diff --git a/milena/tests/level/transform.cc b/milena/tests/level/transform.cc index f177446..e0b8ec9 100644 --- a/milena/tests/level/transform.cc +++ b/milena/tests/level/transform.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2007 EPITA Research and Development Laboratory +// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory // // This file is part of the Olena Library. This library is free // software; you can redistribute it and/or modify it under the terms @@ -37,7 +37,11 @@ #include <mln/core/image/image3d.hh> #include <mln/pw/image.hh> #include <mln/core/image/flat_image.hh> +#include <mln/core/image/cast_image.hh> #include <mln/core/image/image_if.hh> +#include <mln/core/image/sub_image.hh> +#include <mln/core/image/extension_val.hh> + #include <mln/level/fill.hh> #include <mln/level/transform.hh> @@ -140,6 +144,7 @@ int main() mln_assertion((unsigned short)std::sqrt(ima(p)) == out(p)); } + // image if test { typedef image2d<unsigned short> I; typedef image_if<I, fun::p2b::chess_t> II; @@ -157,4 +162,59 @@ int main() mln_assertion((unsigned short)std::sqrt(ima_if(p)) == out(p)); } + // cast image test + { + typedef image2d<unsigned short> I; + typedef cast_image_<int, I> II; + typedef image2d<unsigned short> III; + + I in(size, size); + II cast(in); + III out(size, size); + + level::fill(in, 51); + level::fill(out, 42); + + out = level::transform(cast, mysqrt()); + + II::piter p(cast.domain()); + for_all(p) + mln_assertion((unsigned short)std::sqrt(cast(p)) == out(p)); + } + + // sub_image test + { + typedef image2d<int> I; + typedef sub_image< image2d<int>, box2d > II; + typedef image2d<unsigned short> III; + + I ima(size, size); + II sub_ima(ima, make::box2d(4,4, 10,10)); + III out(size, size); + + level::fill(ima, 51); + out = level::transform(sub_ima, mysqrt()); + + II::piter p(sub_ima.domain()); + for_all(p) + mln_assertion((unsigned short)std::sqrt(sub_ima(p)) == out(p)); + } + + // extended image test + { + typedef image2d<int> I; + typedef extension_val< image2d<int> > II; + typedef image2d<unsigned short> III; + + I ima(size, size); + II extend_ima(ima, 5); + III out(size, size); + + level::fill(ima, 51); + out = level::transform(extend_ima, mysqrt()); + + II::piter p(extend_ima.domain()); + for_all(p) + mln_assertion((unsigned short)std::sqrt(extend_ima(p)) == out(p)); + } } -- 1.5.6.5
16 years, 2 months
1
0
0
0
2687: INIM: classif: Fix iccvg04.
by Guillaume Lazzara
* classif/iccvg04.cc: Cleanup. Fix wrong initialization. --- milena/sandbox/ChangeLog | 6 ++++ milena/sandbox/classif/iccvg04.cc | 54 +++++++++++++++--------------------- 2 files changed, 29 insertions(+), 31 deletions(-) diff --git a/milena/sandbox/ChangeLog b/milena/sandbox/ChangeLog index 074d329..686d969 100644 --- a/milena/sandbox/ChangeLog +++ b/milena/sandbox/ChangeLog @@ -1,3 +1,9 @@ +2008-10-25 Ugo Jardonnet <jardonnet(a)lrde.epita.fr> + + INIM: classif: Fix iccvg04. + + * classif/iccvg04.cc: Cleanup. Fix wrong initialization. + 2008-10-24 Thierry Geraud <thierry.geraud(a)lrde.epita.fr> Update morpho classif for LN. diff --git a/milena/sandbox/classif/iccvg04.cc b/milena/sandbox/classif/iccvg04.cc index b0525ef..1902e90 100644 --- a/milena/sandbox/classif/iccvg04.cc +++ b/milena/sandbox/classif/iccvg04.cc @@ -101,20 +101,11 @@ classify_image(const I& ima, const J& histo, const K& ws, int nbasins, int f) { unsigned count[nbasins + 1]; - memset(count, 0, nbasins + 1); + memset(count, 0, (nbasins + 1) * sizeof(unsigned)); algebra::vec<3, unsigned> sum[nbasins + 1]; for (int i = 1; i < nbasins + 1; ++i) - { sum[i] = literal::zero; - } - - /*mln_piter(K) p(ws.domain()); - for_all(p) - { - count[ws(p)] += histo(p); - sum[ws(p)] += histo(p) * convert::to<algebra::vec<3, value::int_u8> >(p) * f; - }*/ mln_piter(I) p(ima.domain()); for_all(p) @@ -128,7 +119,9 @@ classify_image(const I& ima, const J& histo, const K& ws, int nbasins, int f) count[w] += histo(p3); sum[w] += histo(p3) * convert::to< algebra::vec<3, value::int_u8> >(p3); } +#if DEBUG std::cerr << "p3 : " << p3 << " == " << convert::to<algebra::vec<3, value::int_u8> >(p3) << std::endl; +#endif // DEBUG } for (int i = 1; i < nbasins + 1; ++i) @@ -136,7 +129,9 @@ classify_image(const I& ima, const J& histo, const K& ws, int nbasins, int f) sum[i] *= f; sum[i] /= count[i]; //std::cout << "count[" << i << "] = " << count[i] << std::endl; +#if DEBUG std::cout << "sum[" << i << "] = " << sum[i] << std::endl; +#endif // DEBUG } @@ -152,14 +147,18 @@ classify_image(const I& ima, const J& histo, const K& ws, int nbasins, int f) if (w != 0) // If w == 0 it means that the current point is part of a border of the watershed { +#if DEBUG std::cerr << "out(" << pi << ") = sum[" << w << "]; //" << sum[w] << std::endl; +#endif out(pi) = convert::to<value::rgb8>(sum[w]); //out(pi) = value::rgb8(sum[w][0], sum[w][1], sum[w][2]); ws_out(pi) = value::rgb8(0, 0, 0); } else { +#if DEBUG std::cerr << "Border : " << pi << std::endl; +#endif ws_out(pi) = value::rgb8(255, 255, 255); // FIXME @@ -182,8 +181,22 @@ classify_image(const I& ima, const J& histo, const K& ws, int nbasins, int f) io::ppm::save(ws_out, "out-ws.ppm"); } +bool usage(int argc, char ** argv) +{ + if (argc != 4) + { + std::cout << "usage: " << argv[0] << " image div_factor lambda" << std::endl; + return false; + } + return true; +} + + int main(int argc, char **argv) { + if (not usage(argc, argv)) + return 1; + const int div_factor = atoi(argv[2]); const int lambda = atoi(argv[3]); @@ -198,20 +211,6 @@ int main(int argc, char **argv) std::cout << "histo : " << m << ' ' << M << std::endl; } -// Normalize histogram frequences -#if 0 - image3d<value::int_u8> nhisto(histo.domain()); - level::stretch(histo, nhisto); - //image3d<value::int_u8> nhisto = normalizeu8(histo); - { - value::int_u8 m, M; - estim::min_max(nhisto, m, M); - std::cout << "nhisto : " << m << ' ' << M << std::endl; - } -#endif - - //display(nhisto, "histo"); - //revert histo image3d<unsigned> rhisto = arith::revert(histo); { @@ -219,7 +218,6 @@ int main(int argc, char **argv) estim::min_max(rhisto, m, M); std::cout << "rhisto : " << m << ' ' << M << std::endl; } - //display(rhisto, "rhisto"); //compute closing_area of histo image3d<unsigned> histo_closure(histo.domain()); @@ -230,18 +228,12 @@ int main(int argc, char **argv) std::cout << "histo_closure : " << m << ' ' << M << std::endl; } - //display_proj_revert(histo_closure, "chisto.ppm"); - //watershed over histo_closure unsigned nbasins = 0; image3d<unsigned> ws = morpho::meyer_wst(histo_closure, c6(), nbasins); std::cout << "nbassins : " << nbasins << std::endl; - //display(ws, "ws"); - //display_proj_revert(ws, "whisto.ppm"); - //gplot(ws); - // Classify image ! //classify_image(const I& ima, const J& histo, const K& ws, int nbasins, int f) classify_image(ima, histo, ws, nbasins, div_factor); -- 1.5.6.5
16 years, 2 months
1
0
0
0
2687: INIM: classif: Fix iccvg04.
by Ugo Jardonnet
https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena/sandbox
Index: ChangeLog from Ugo Jardonnet <jardonnet(a)lrde.epita.fr> INIM: classif: Fix iccvg04. * classif/iccvg04.cc: Cleanup. Fix wrong initialization. iccvg04.cc | 54 +++++++++++++++++++++++------------------------------- 1 file changed, 23 insertions(+), 31 deletions(-) Index: classif/iccvg04.cc --- classif/iccvg04.cc (revision 2686) +++ classif/iccvg04.cc (working copy) @@ -101,20 +101,11 @@ { unsigned count[nbasins + 1]; - memset(count, 0, nbasins + 1); + memset(count, 0, (nbasins + 1) * sizeof(unsigned)); algebra::vec<3, unsigned> sum[nbasins + 1]; for (int i = 1; i < nbasins + 1; ++i) - { sum[i] = literal::zero; - } - - /*mln_piter(K) p(ws.domain()); - for_all(p) - { - count[ws(p)] += histo(p); - sum[ws(p)] += histo(p) * convert::to<algebra::vec<3, value::int_u8> >(p) * f; - }*/ mln_piter(I) p(ima.domain()); for_all(p) @@ -128,7 +119,9 @@ count[w] += histo(p3); sum[w] += histo(p3) * convert::to< algebra::vec<3, value::int_u8> >(p3); } +#if DEBUG std::cerr << "p3 : " << p3 << " == " << convert::to<algebra::vec<3, value::int_u8> >(p3) << std::endl; +#endif // DEBUG } for (int i = 1; i < nbasins + 1; ++i) @@ -136,7 +129,9 @@ sum[i] *= f; sum[i] /= count[i]; //std::cout << "count[" << i << "] = " << count[i] << std::endl; +#if DEBUG std::cout << "sum[" << i << "] = " << sum[i] << std::endl; +#endif // DEBUG } @@ -152,14 +147,18 @@ if (w != 0) // If w == 0 it means that the current point is part of a border of the watershed { +#if DEBUG std::cerr << "out(" << pi << ") = sum[" << w << "]; //" << sum[w] << std::endl; +#endif out(pi) = convert::to<value::rgb8>(sum[w]); //out(pi) = value::rgb8(sum[w][0], sum[w][1], sum[w][2]); ws_out(pi) = value::rgb8(0, 0, 0); } else { +#if DEBUG std::cerr << "Border : " << pi << std::endl; +#endif ws_out(pi) = value::rgb8(255, 255, 255); // FIXME @@ -182,8 +181,22 @@ io::ppm::save(ws_out, "out-ws.ppm"); } +bool usage(int argc, char ** argv) +{ + if (argc != 4) + { + std::cout << "usage: " << argv[0] << " image div_factor lambda" << std::endl; + return false; + } + return true; +} + + int main(int argc, char **argv) { + if (not usage(argc, argv)) + return 1; + const int div_factor = atoi(argv[2]); const int lambda = atoi(argv[3]); @@ -198,20 +211,6 @@ std::cout << "histo : " << m << ' ' << M << std::endl; } -// Normalize histogram frequences -#if 0 - image3d<value::int_u8> nhisto(histo.domain()); - level::stretch(histo, nhisto); - //image3d<value::int_u8> nhisto = normalizeu8(histo); - { - value::int_u8 m, M; - estim::min_max(nhisto, m, M); - std::cout << "nhisto : " << m << ' ' << M << std::endl; - } -#endif - - //display(nhisto, "histo"); - //revert histo image3d<unsigned> rhisto = arith::revert(histo); { @@ -219,7 +218,6 @@ estim::min_max(rhisto, m, M); std::cout << "rhisto : " << m << ' ' << M << std::endl; } - //display(rhisto, "rhisto"); //compute closing_area of histo image3d<unsigned> histo_closure(histo.domain()); @@ -230,18 +228,12 @@ std::cout << "histo_closure : " << m << ' ' << M << std::endl; } - //display_proj_revert(histo_closure, "chisto.ppm"); - //watershed over histo_closure unsigned nbasins = 0; image3d<unsigned> ws = morpho::meyer_wst(histo_closure, c6(), nbasins); std::cout << "nbassins : " << nbasins << std::endl; - //display(ws, "ws"); - //display_proj_revert(ws, "whisto.ppm"); - //gplot(ws); - // Classify image ! //classify_image(const I& ima, const J& histo, const K& ws, int nbasins, int f) classify_image(ima, histo, ws, nbasins, div_factor);
16 years, 2 months
1
0
0
0
2686: Fix mln::level::stretch w.r.t. the initialization.
by Guillaume Lazzara
* mln/level/stretch.hh (mln::level::impl::stretch(int_u<n>, const Image<I>&, Image<O>&)): Initialize the output image from the input. --- milena/ChangeLog | 8 ++++++++ milena/mln/level/stretch.hh | 2 ++ 2 files changed, 10 insertions(+), 0 deletions(-) diff --git a/milena/ChangeLog b/milena/ChangeLog index 47a4f3a..35f360b 100644 --- a/milena/ChangeLog +++ b/milena/ChangeLog @@ -1,5 +1,13 @@ 2008-10-24 Roland Levillain <roland(a)lrde.epita.fr> + Fix mln::level::stretch w.r.t. the initialization. + + * mln/level/stretch.hh + (mln::level::impl::stretch(int_u<n>, const Image<I>&, Image<O>&)): + Initialize the output image from the input. + +2008-10-24 Roland Levillain <roland(a)lrde.epita.fr> + First attempt at generating a GraphViz' neato output. * tests/morpho/complex_image_wst.cc: Generate a neato graph. diff --git a/milena/mln/level/stretch.hh b/milena/mln/level/stretch.hh index 81c516f..4b70e66 100644 --- a/milena/mln/level/stretch.hh +++ b/milena/mln/level/stretch.hh @@ -70,6 +70,8 @@ namespace mln { trace::entering("level::impl::stretch"); + initialize(output, input); + mln_value(I) min_, max_; estim::min_max(input, min_, max_); if (max_ != min_) -- 1.5.6.5
16 years, 2 months
1
0
0
0
2686: Fix mln::level::stretch w.r.t. the initialization.
by Roland Levillain
* mln/level/stretch.hh (mln::level::impl::stretch(int_u<n>, const Image<I>&, Image<O>&)): Initialize the output image from the input. --- milena/ChangeLog | 8 ++++++++ milena/mln/level/stretch.hh | 2 ++ 2 files changed, 10 insertions(+), 0 deletions(-) diff --git a/milena/ChangeLog b/milena/ChangeLog index 47a4f3a..35f360b 100644 --- a/milena/ChangeLog +++ b/milena/ChangeLog @@ -1,5 +1,13 @@ 2008-10-24 Roland Levillain <roland(a)lrde.epita.fr> + Fix mln::level::stretch w.r.t. the initialization. + + * mln/level/stretch.hh + (mln::level::impl::stretch(int_u<n>, const Image<I>&, Image<O>&)): + Initialize the output image from the input. + +2008-10-24 Roland Levillain <roland(a)lrde.epita.fr> + First attempt at generating a GraphViz' neato output. * tests/morpho/complex_image_wst.cc: Generate a neato graph. diff --git a/milena/mln/level/stretch.hh b/milena/mln/level/stretch.hh index 81c516f..4b70e66 100644 --- a/milena/mln/level/stretch.hh +++ b/milena/mln/level/stretch.hh @@ -70,6 +70,8 @@ namespace mln { trace::entering("level::impl::stretch"); + initialize(output, input); + mln_value(I) min_, max_; estim::min_max(input, min_, max_); if (max_ != min_) -- 1.6.0.1
16 years, 2 months
1
0
0
0
2685: First attempt at generating a GraphViz' neato output.
by Guillaume Lazzara
* tests/morpho/complex_image_wst.cc: Generate a neato graph. --- milena/ChangeLog | 6 ++ milena/tests/morpho/complex_image_wst.cc | 111 +++++++++++++++++++++++++++++- 2 files changed, 116 insertions(+), 1 deletions(-) diff --git a/milena/ChangeLog b/milena/ChangeLog index 9994d8b..47a4f3a 100644 --- a/milena/ChangeLog +++ b/milena/ChangeLog @@ -1,3 +1,9 @@ +2008-10-24 Roland Levillain <roland(a)lrde.epita.fr> + + First attempt at generating a GraphViz' neato output. + + * tests/morpho/complex_image_wst.cc: Generate a neato graph. + 2008-10-24 Nicolas Ballas <ballas(a)lrde.epita.fr> Update transform routine interface. diff --git a/milena/tests/morpho/complex_image_wst.cc b/milena/tests/morpho/complex_image_wst.cc index 88e5bc9..8060cee 100644 --- a/milena/tests/morpho/complex_image_wst.cc +++ b/milena/tests/morpho/complex_image_wst.cc @@ -29,8 +29,15 @@ /// \brief Testing Meyer's Watershed Transform on mln::complex_image. #include <iostream> +#include <fstream> +#include <sstream> +#include <iomanip> #include <mln/value/int_u8.hh> +#include <mln/value/rgb8.hh> +#include <mln/literal/black.hh> +#include <mln/literal/white.hh> + #include <mln/core/alias/point2d.hh> #include <mln/core/site_set/p_faces.hh> @@ -47,6 +54,29 @@ #include <mln/morpho/closing_area.hh> #include <mln/morpho/meyer_wst.hh> +#include <mln/core/concept/function.hh> + +// FIXME: To be put elsewhere (from milena/sandbox/geraud/wst_edge.cc). +struct colorize : mln::Function_v2v< colorize > +{ + typedef mln::value::rgb8 result; + colorize(unsigned max) + : lut(max + 1) + { + lut[0] = mln::literal::black; + for (unsigned i = 1; i <= max; ++i) + lut[i] = result(100 + std::rand() % 150, + 100 + std::rand() % 150, + 100 + std::rand() % 150); + } + result operator()(unsigned i) const + { + return lut[i]; + } + std::vector<result> lut; +}; + + int main() { @@ -203,5 +233,84 @@ int main() We definitely need a complex_image that can accept a subset of a complex as domain (or at least a p_face<N, D, P>. */ - std::cout << "nbasins = " << nbasins << std::endl; + wst_val_t actual_nbasins = nbasins - c.nfaces<0>(); + std::cout << "nbasins = " << actual_nbasins << std::endl; + + + colorize color(nbasins); + + std::ofstream g("wst.neato"); + g << "graph wst" << std::endl + << "{" << std::endl + << " graph [bgcolor = \"#000000\"]" << std::endl + << " edge [color = \"#FFFFFF\"]" << std::endl + << " node [color = \"#FFFFFF\", fontcolor = \"#FFFFFF\" ]" << std::endl; + + // Vertices. + typedef complex_higher_neighborhood<D, G> e_nbh_t; + e_nbh_t e_nbh; + mln_niter_(e_nbh_t) v_e(e_nbh, v_); + for_all(v_) + { + // Find the adjacent basin (color). + value::rgb8 basin_color = literal::white; + for_all(v_e) + if (wshed(v_e) != 0) + { + basin_color = color(wshed(v_e)); + break; + } + std::ostringstream basin_color_str; + basin_color_str << '#' + << std::hex + << std::setfill('0') + << std::setw(2) << basin_color.red() + << std::setw(2) << basin_color.green() + << std::setw(2) << basin_color.blue() + << std::dec; + + g << " v" << v_.unproxy_().face_id() + << " [pos = \"" + << std::fixed << std::setprecision(1) + << (float)v_.to_site().front()[1] << ", " + << -(float)v_.to_site().front()[0] + << "\", color = \"" << basin_color_str.str() + << "\", fillcolor = \"" << basin_color_str.str() + << "\", pin = \"true\", style=\"filled,setlinewidth(3)\"];" + << std::endl; + } + + for_all(e) + { + value::rgb8 basin_color = color(wshed(e)); + std::ostringstream basin_color_str; + basin_color_str << '#' + << std::hex + << std::setfill('0') + << std::setw(2) << basin_color.red() + << std::setw(2) << basin_color.green() + << std::setw(2) << basin_color.blue() + << std::dec; + + // Adjacent vertices. + v.start(); + topo::face<1> v1 = v.unproxy_().face(); + point2d p1 = v.to_site().front(); + v.next(); + topo::face<1> v2 = v.unproxy_().face(); + point2d p2 = v.to_site().front(); + v.next(); + mln_invariant(!v.is_valid()); + + // Edges. + g << " v" << v1.face_id() << " -- v" << v2.face_id() << " "; + if (wshed(e) == 0) + g << "[color = \"#FFFFFF\"];" << std::endl; + else + g << "[color = \"" << basin_color_str.str() + << "\", style=\"setlinewidth(3)\"];" << std::endl; + } + + g << "}" << std::endl; + g.close(); } -- 1.5.6.5
16 years, 2 months
1
0
0
0
2685: First attempt at generating a GraphViz' neato output.
by Roland Levillain
* tests/morpho/complex_image_wst.cc: Generate a neato graph. --- milena/ChangeLog | 6 ++ milena/tests/morpho/complex_image_wst.cc | 111 +++++++++++++++++++++++++++++- 2 files changed, 116 insertions(+), 1 deletions(-) diff --git a/milena/ChangeLog b/milena/ChangeLog index 9994d8b..47a4f3a 100644 --- a/milena/ChangeLog +++ b/milena/ChangeLog @@ -1,3 +1,9 @@ +2008-10-24 Roland Levillain <roland(a)lrde.epita.fr> + + First attempt at generating a GraphViz' neato output. + + * tests/morpho/complex_image_wst.cc: Generate a neato graph. + 2008-10-24 Nicolas Ballas <ballas(a)lrde.epita.fr> Update transform routine interface. diff --git a/milena/tests/morpho/complex_image_wst.cc b/milena/tests/morpho/complex_image_wst.cc index 88e5bc9..8060cee 100644 --- a/milena/tests/morpho/complex_image_wst.cc +++ b/milena/tests/morpho/complex_image_wst.cc @@ -29,8 +29,15 @@ /// \brief Testing Meyer's Watershed Transform on mln::complex_image. #include <iostream> +#include <fstream> +#include <sstream> +#include <iomanip> #include <mln/value/int_u8.hh> +#include <mln/value/rgb8.hh> +#include <mln/literal/black.hh> +#include <mln/literal/white.hh> + #include <mln/core/alias/point2d.hh> #include <mln/core/site_set/p_faces.hh> @@ -47,6 +54,29 @@ #include <mln/morpho/closing_area.hh> #include <mln/morpho/meyer_wst.hh> +#include <mln/core/concept/function.hh> + +// FIXME: To be put elsewhere (from milena/sandbox/geraud/wst_edge.cc). +struct colorize : mln::Function_v2v< colorize > +{ + typedef mln::value::rgb8 result; + colorize(unsigned max) + : lut(max + 1) + { + lut[0] = mln::literal::black; + for (unsigned i = 1; i <= max; ++i) + lut[i] = result(100 + std::rand() % 150, + 100 + std::rand() % 150, + 100 + std::rand() % 150); + } + result operator()(unsigned i) const + { + return lut[i]; + } + std::vector<result> lut; +}; + + int main() { @@ -203,5 +233,84 @@ int main() We definitely need a complex_image that can accept a subset of a complex as domain (or at least a p_face<N, D, P>. */ - std::cout << "nbasins = " << nbasins << std::endl; + wst_val_t actual_nbasins = nbasins - c.nfaces<0>(); + std::cout << "nbasins = " << actual_nbasins << std::endl; + + + colorize color(nbasins); + + std::ofstream g("wst.neato"); + g << "graph wst" << std::endl + << "{" << std::endl + << " graph [bgcolor = \"#000000\"]" << std::endl + << " edge [color = \"#FFFFFF\"]" << std::endl + << " node [color = \"#FFFFFF\", fontcolor = \"#FFFFFF\" ]" << std::endl; + + // Vertices. + typedef complex_higher_neighborhood<D, G> e_nbh_t; + e_nbh_t e_nbh; + mln_niter_(e_nbh_t) v_e(e_nbh, v_); + for_all(v_) + { + // Find the adjacent basin (color). + value::rgb8 basin_color = literal::white; + for_all(v_e) + if (wshed(v_e) != 0) + { + basin_color = color(wshed(v_e)); + break; + } + std::ostringstream basin_color_str; + basin_color_str << '#' + << std::hex + << std::setfill('0') + << std::setw(2) << basin_color.red() + << std::setw(2) << basin_color.green() + << std::setw(2) << basin_color.blue() + << std::dec; + + g << " v" << v_.unproxy_().face_id() + << " [pos = \"" + << std::fixed << std::setprecision(1) + << (float)v_.to_site().front()[1] << ", " + << -(float)v_.to_site().front()[0] + << "\", color = \"" << basin_color_str.str() + << "\", fillcolor = \"" << basin_color_str.str() + << "\", pin = \"true\", style=\"filled,setlinewidth(3)\"];" + << std::endl; + } + + for_all(e) + { + value::rgb8 basin_color = color(wshed(e)); + std::ostringstream basin_color_str; + basin_color_str << '#' + << std::hex + << std::setfill('0') + << std::setw(2) << basin_color.red() + << std::setw(2) << basin_color.green() + << std::setw(2) << basin_color.blue() + << std::dec; + + // Adjacent vertices. + v.start(); + topo::face<1> v1 = v.unproxy_().face(); + point2d p1 = v.to_site().front(); + v.next(); + topo::face<1> v2 = v.unproxy_().face(); + point2d p2 = v.to_site().front(); + v.next(); + mln_invariant(!v.is_valid()); + + // Edges. + g << " v" << v1.face_id() << " -- v" << v2.face_id() << " "; + if (wshed(e) == 0) + g << "[color = \"#FFFFFF\"];" << std::endl; + else + g << "[color = \"" << basin_color_str.str() + << "\", style=\"setlinewidth(3)\"];" << std::endl; + } + + g << "}" << std::endl; + g.close(); } -- 1.5.6.5
16 years, 2 months
1
0
0
0
cleanup-2008 2684: Update morpho classif for LN.
by Thierry Geraud
https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena/sandbox
Index: ChangeLog from Thierry Geraud <thierry.geraud(a)lrde.epita.fr> Update morpho classif for LN. * geraud/laurent/classif.cc: Update. classif.cc | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) Index: geraud/laurent/classif.cc --- geraud/laurent/classif.cc (revision 2683) +++ geraud/laurent/classif.cc (working copy) @@ -58,6 +58,8 @@ #include <mln/norm/l2.hh> #include <mln/morpho/closing_area.hh> +#include <mln/morpho/closing_volume.hh> +#include <mln/morpho/closing_height.hh> #include <mln/morpho/meyer_wst.hh> @@ -116,9 +118,17 @@ } +void usage(char* argv[]) +{ + std::cerr << argv[0] << " lambda" << std::endl; + abort(); +} -int main() +int main(int argc, char* argv[]) { + if (argc != 2) + usage(argv); + using namespace mln; using mln::value::int_u8; @@ -156,7 +166,20 @@ unsigned nlabels; image2d<unsigned> label = labeling::blobs(seeds, c4(), nlabels); + + std::cout << "n seeds = " << nlabels << std::endl; + { + image2d<int_u8> lab(label.domain()); + level::paste(label, lab); + io::pgm::save(lab, "label.pgm"); + } + image2d<unsigned> iz = influence_zones(label, c4()); + { + image2d<int_u8> IZ(iz.domain()); + level::paste(iz, IZ); + io::pgm::save(IZ, "iz.pgm"); + } // debug::println( (pw::value(iz) - pw::cst(1)) | iz.domain() ); @@ -217,6 +240,8 @@ } } + std::cout << "v size = " << v.size() << std::endl; + // 1-faces (edges). std::vector<edge> e; { @@ -226,6 +251,8 @@ e.push_back( c.add_face(-v[l-1] + v[ll-1]) ); } + std::cout << "e size = " << e.size() << std::endl; + } @@ -284,7 +311,7 @@ v.next(); mln_invariant(!v.is_valid()); - dist_ima(e) = norm::l2_distance(p1.to_vec(), p2.to_vec()); + dist_ima(e) = norm::l2_distance(p1.to_vec(), p2.to_vec()) / 2; dist_max.take(dist_ima(e)); draw::line(canvas, p1, p2, dist_ima(e)); @@ -332,7 +359,7 @@ // Currently, does nothing (lambda = 1). dist_ima_t closed_dist_ima (dist_ima.domain()); - morpho::closing_area(dist_ima, nbh, 1, closed_dist_ima); + morpho::closing_height(dist_ima, nbh, atoi(argv[1]), closed_dist_ima); /*------. | WST. |
16 years, 2 months
1
0
0
0
← Newer
1
...
9
10
11
12
13
14
15
...
38
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
Results per page:
10
25
50
100
200