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
March 2009
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
olena-patches@lrde.epita.fr
9 participants
202 discussions
Start a n
N
ew thread
3515: configure.ac: configure approx/ and closing/approx in milena/tests/morpho/.
by Guillaume Lazzara
--- ChangeLog | 5 +++++ configure.ac | 2 ++ 2 files changed, 7 insertions(+), 0 deletions(-) diff --git a/ChangeLog b/ChangeLog index e27b4aa..0449d8a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2009-03-10 Guillaume Lazzara <lazzara(a)lrde.epita.fr> + + configure.ac: configure approx/ and closing/approx in + milena/tests/morpho/. + 2009-03-10 Guillaume Lazzara <z(a)lrde.epita.fr> * configure.ac: configure tests/morpho/opening/approx. diff --git a/configure.ac b/configure.ac index d8a30b5..52b5b19 100644 --- a/configure.ac +++ b/configure.ac @@ -243,10 +243,12 @@ AC_CONFIG_FILES([ milena/tests/metal/math/Makefile milena/tests/morpho/Makefile milena/tests/morpho/attribute/Makefile + milena/tests/morpho/approx/Makefile milena/tests/morpho/elementary/Makefile milena/tests/morpho/tree/Makefile milena/tests/morpho/watershed/Makefile milena/tests/morpho/closing/Makefile + milena/tests/morpho/closing/approx/Makefile milena/tests/morpho/opening/Makefile milena/tests/morpho/opening/approx/Makefile milena/tests/norm/Makefile -- 1.5.6.5
15 years, 9 months
1
0
0
0
r3514: Pipo type
by Etienne FOLIO
URL:
https://svn.lrde.epita.fr/svn/oln/trunk/milena/sandbox
ChangeLog: 2009-03-11 Etienne FOLIO <folio(a)lrde.epita.fr> Pipo type. * folio/test/value/pipo.cc: New tests for the pipo type. * folio/test/value: New directory for testing value-related algorithms. * folio/value/pipo.hh: New pipo type. * folio/value: New directory for value-related algorithms. --- test/value/pipo.cc | 21 ++++++++++++ value/pipo.hh | 88 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 109 insertions(+) Index: trunk/milena/sandbox/folio/test/value/pipo.cc =================================================================== --- trunk/milena/sandbox/folio/test/value/pipo.cc (revision 0) +++ trunk/milena/sandbox/folio/test/value/pipo.cc (revision 3514) @@ -0,0 +1,21 @@ +/*! + * \file test_pipo.cc + * \author etiennefolio <ornthalas(a)gmail.com> + */ + +#include "../../value/pipo.hh" + +int main() +{ + using namespace mln; + + value::pipo p; + std::cout << p << std::endl; + + p.c0 = -1; + p.c1 = 0.42f; + p.c2 = 42; + std::cout << p << std::endl; + + return 0; +} Index: trunk/milena/sandbox/folio/value/pipo.hh =================================================================== --- trunk/milena/sandbox/folio/value/pipo.hh (revision 0) +++ trunk/milena/sandbox/folio/value/pipo.hh (revision 3514) @@ -0,0 +1,88 @@ +/*! + * \file pipo.hh + * \author etiennefolio <ornthalas(a)gmail.com> + */ + +#ifndef PIPO_HH_ +# define PIPO_HH_ + +#include <mln/value/int_s.hh> +#include <mln/value/int_u.hh> +#include <mln/value/float01.hh> + +namespace mln +{ + namespace value + { + class pipo + { + public: + + int_s<3> c0; + float01_<8> c1; + int_u<7> c2; + + pipo(); + pipo(int_s<3> _c0, + float01_<8> _c1, + int_u<7> _c2); + + pipo& operator=(const pipo& rhs); + + }; + +# ifndef MLN_INCLUDE_ONLY + + inline + pipo::pipo() + : c0(mln_min(int_s<3>)), + c1(mln_min(float01_<8>)), + c2(mln_min(int_u<7>)) + { + } + + inline + pipo::pipo(int_s<3> _c0, + float01_<8> _c1, + int_u<7> _c2) + : c0(_c0), + c1(_c1), + c2(_c2) + { + } + + inline + pipo& + pipo::operator=(const pipo& rhs) + { + if (& rhs == this) + return *this; + this->c0 = rhs.c0; + this->c1 = rhs.c1; + this->c2 = rhs.c2; + return *this; + } + + inline + std::ostream& operator<<(std::ostream& ostr, const pipo& v) + { + return ostr << '(' << debug::format(v.c0) + << ',' << debug::format(v.c1) + << ',' << debug::format(v.c2) + << ')'; + } + +// dunno why this doesn't compile... *_*" + +// inline +// std::istream& operator>>(std::istream& istr, pipo& c) +// { +// return istr >> c.c0 >> c.c1 >> c.c2; +// } + +# endif // ! MLN_INCLUDE_ONLY + + } +} + +#endif /* !PIPO_HH_ */
15 years, 9 months
1
0
0
0
r3513: compute_histo_rgb
by Etienne FOLIO
URL:
https://svn.lrde.epita.fr/svn/oln/trunk/milena/sandbox
ChangeLog: 2009-03-11 Etienne FOLIO <folio(a)lrde.epita.fr> compute_histo_rgb. * folio/histo/compute_histo_rgb.hh: New algorithm for computing an histogram on image2d<rgb8>. * folio/histo: New directory for histogram-related algorithms. * folio/test/histo/compute_histo_rgb.cc: New tests about the algorithm above. * folio/test/histo: New directory for testing histogram-related algorithms. --- histo/compute_histo_rgb.hh | 35 ++++++++++++++++++++++++++ test/histo/compute_histo_rgb.cc | 52 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 87 insertions(+) Index: trunk/milena/sandbox/folio/test/histo/compute_histo_rgb.cc =================================================================== --- trunk/milena/sandbox/folio/test/histo/compute_histo_rgb.cc (revision 0) +++ trunk/milena/sandbox/folio/test/histo/compute_histo_rgb.cc (revision 3513) @@ -0,0 +1,52 @@ +/*! + * \file compute_histo_rgb.cc<2> + * \author etiennefolio <ornthalas(a)gmail.com> + */ + +#include <iostream> +#include <mln/debug/println.hh> +#include <mln/literal/all.hh> + +#include "../../histo/compute_histo_rgb.hh" + +int main() +{ + using namespace mln; + + // build test image + image2d<value::rgb8> ima(10, 10); + + value::rgb8 red = literal::red; + value::rgb8 green = literal::green; + value::rgb8 black = literal::black; + + for (unsigned i = 0; i < 10; ++i) + for (unsigned j = 5; j < 10; ++j) + { + point2d p(j, i); + ima(p) = black; + } + + for (unsigned i = 0; i < 10; ++i) + for (unsigned j = 0; j < 5; ++j) + { + point2d p(j, i); + ima(p) = red; + } + + point2d p(8, 2); + ima(p) = green; + + std::cout << "input :" << std::endl; + debug::println(ima); + + // let's run ! + image3d<value::int_u8> out = histo::compute_histo_rgb<value::int_u8>(ima); + + // output ? + std::cout << "out(0, 0, 0) = " << out(point3d(0, 0, 0)) << std::endl; + std::cout << "out(255, 0, 0) = " << out(point3d(255, 0, 0)) << std::endl; + std::cout << "out(0, 255, 0) = " << out(point3d(0, 255, 0)) << std::endl; + + return 0; +} Index: trunk/milena/sandbox/folio/histo/compute_histo_rgb.hh =================================================================== --- trunk/milena/sandbox/folio/histo/compute_histo_rgb.hh (revision 0) +++ trunk/milena/sandbox/folio/histo/compute_histo_rgb.hh (revision 3513) @@ -0,0 +1,35 @@ +/*! + * \file compute_histo_rgb.cc + * \author etiennefolio <ornthalas(a)gmail.com> + */ + +#include <mln/core/image/image2d.hh> +#include <mln/core/image/image3d.hh> +#include <mln/value/int_u8.hh> +#include <mln/value/rgb8.hh> + +namespace mln +{ + namespace histo + { + + template <typename C, typename T> + image3d<C> compute_histo_rgb(image2d<T> ima) + { + // out + image3d<C> out(mln_max(C), + mln_max(C), + mln_max(C)); + data::fill(out, mln_min(C)); + + // count + mln_fwd_piter(image2d<T>) p(ima.domain()); + for_all(p) + ++out(point3d(ima(p).red(), ima(p).green(), ima(p).blue())); + + // return + return out; + } + + } +}
15 years, 9 months
1
0
0
0
r3512: Create watershed images in 3D..
by Fabien Freling
URL:
https://svn.lrde.epita.fr/svn/oln/trunk/milena/sandbox
ChangeLog: 2009-03-11 Fabien Freling <fabien.freling(a)lrde.epita.fr> Create watershed images in 3D.. * fabien/bin/dump2pgm8b.cc: Fix. * fabien/igr/Makefile: Update. * fabien/igr/nbasins_check.sh: New test file. * fabien/igr/nbasins_finder.cc: New file for finding optimal parameters. * fabien/igr/watershed3d.cc: Update. --- TODO | 4 +- bin/dump2pgm8b.cc | 5 --- igr/Makefile | 5 ++- igr/nbasins_check.sh | 17 ++++++++++ igr/nbasins_finder.cc | 80 ++++++++++++++++++++++++++++++++++++++++++++++++++ igr/watershed3d.cc | 1 6 files changed, 105 insertions(+), 7 deletions(-) Index: trunk/milena/sandbox/fabien/igr/watershed3d.cc =================================================================== --- trunk/milena/sandbox/fabien/igr/watershed3d.cc (revision 3511) +++ trunk/milena/sandbox/fabien/igr/watershed3d.cc (revision 3512) @@ -277,6 +277,7 @@ // Watershed label_32 nbasins; image3d<label_32> wshed = morpho::meyer_wst(clo, c6(), nbasins); + std::cout << "nbasins = " << nbasins << std::endl; // Debug io::dump::save(level::stretch(int_u8(), clo), "wsd_02.dump"); Index: trunk/milena/sandbox/fabien/igr/nbasins_check.sh =================================================================== --- trunk/milena/sandbox/fabien/igr/nbasins_check.sh (revision 0) +++ trunk/milena/sandbox/fabien/igr/nbasins_check.sh (revision 3512) @@ -0,0 +1,17 @@ +#!/bin/zsh + +process_file () +{ + echo "Processing $2..." + + for lambda_closure in 500 1000 5000 10000 50000; do + echo " for lambda_closure = ${lambda_closure}"; + ./nbasins_finder $1 $lambda_closure + ../bin/dump2ppm result_nbasins.dump results/nbasins_${2}_${lambda_closure}.ppm + done +} + +#make nbasins +#process_file "/Users/HiSoKa/Work/IGR/souris18/irm/IM_0052.dcm" "52" +process_file "/Users/HiSoKa/Work/IGR/souris18/irm/IM_0061.dcm" "61" +process_file "/Users/HiSoKa/Work/IGR/souris18/irm/IM_0064.dcm" "64" Property changes on: trunk/milena/sandbox/fabien/igr/nbasins_check.sh ___________________________________________________________________ Name: svn:executable + * Index: trunk/milena/sandbox/fabien/igr/nbasins_finder.cc =================================================================== --- trunk/milena/sandbox/fabien/igr/nbasins_finder.cc (revision 0) +++ trunk/milena/sandbox/fabien/igr/nbasins_finder.cc (revision 3512) @@ -0,0 +1,80 @@ +#include <iostream> +#include <mln/core/image/image3d.hh> + +#include <mln/core/alias/neighb3d.hh> +#include <mln/core/alias/window3d.hh> +#include <mln/core/image/image_if.hh> + +#include <mln/io/pgm/load.hh> +#include <mln/io/dicom/load.hh> +#include <mln/io/pgm/save.hh> +#include <mln/io/dump/save.hh> + +#include <mln/value/int_u8.hh> +#include <mln/value/int_u12.hh> +#include <mln/value/label_16.hh> +#include <mln/value/label_32.hh> +#include <mln/value/rgb8.hh> + +#include <mln/labeling/regional_minima.hh> + +#include <mln/level/transform.hh> +#include <mln/level/stretch.hh> + +#include <mln/morpho/elementary/gradient.hh> +#include <mln/morpho/closing/volume.hh> +#include <mln/morpho/watershed/flooding.hh> + +#include <mln/fun/l2l/wrap.hh> + +#include <mln/debug/colorize.hh> + + + +/////////////////// +// // +// Main Function // +// // +/////////////////// + + +int main(int argc, char *argv[]) +{ + using namespace mln; + using value::int_u8; + using value::int_u12; + using value::label_16; + using value::label_32; + using value::rgb8; + + if (argc != 3) + { + std::cout << "Usage: " << argv[0] << " <ima.dcm> <closure_lambda>" + << std::endl; + return 1; + } + + unsigned closure_lambda = atoi(argv[2]); + + image3d<int_u12> dcm; + io::dicom::load(dcm, argv[1]); + + // Gradient + image3d<int_u12> grad = morpho::elementary::gradient(dcm, c6()); + + // Closure + image3d<int_u12> clo = morpho::closing::volume(grad, c6(), closure_lambda); + + // Watershed + label_32 nbasins; + image3d<label_32> wshed = morpho::watershed::flooding(clo, c6(), nbasins); + //image3d<label_32> wshed = morpho::watershed::flooding(clo, c6(), nbasins); + + // Visualization + std::cout << " nbasins = " << nbasins << std::endl; + //io::dump::save(level::transform(wshed, fun::l2l::wrap<int_u8>()), "result_nbasins.dump"); + //io::dump::save(level::stretch(int_u8(), wshed), "result_nbasins.dump"); + io::dump::save(debug::colorize(rgb8(), wshed, nbasins), "result_nbasins.dump"); + + return 0; +} Index: trunk/milena/sandbox/fabien/igr/Makefile =================================================================== --- trunk/milena/sandbox/fabien/igr/Makefile (revision 3511) +++ trunk/milena/sandbox/fabien/igr/Makefile (revision 3512) @@ -23,7 +23,10 @@ g++ -I../../../ ${DICOM_INC} ${DICOM_LIB} ${CXXFLAGS} $^ -o wsd3d wsd3dg: watershed.hh watershed3d.cc - g++ -I../../../ ${DICOM_INC} ${DICOM_LIB} -DNDEBUG -g $^ -o wsd3dg + g++ -I../../../ ${DICOM_INC} ${DICOM_LIB} -g $^ -o wsd3dg + +nbasins: nbasins_finder.cc + g++ -I../../../ ${DICOM_INC} ${DICOM_LIB} ${CXXFLAGS} $^ -o nbasins_finder clean: rm -rf *.dump *.p?m *.plot *.log *.csv Index: trunk/milena/sandbox/fabien/TODO =================================================================== --- trunk/milena/sandbox/fabien/TODO (revision 3511) +++ trunk/milena/sandbox/fabien/TODO (revision 3512) @@ -25,4 +25,6 @@ [X] US: projection of internal gradient [X] Create 3D US morpho with 2D stack [ ] Create macro for_all_slice -[ ] Batch process watershed with 2D, 3D and any combination of parameters +[X] Batch process watershed with 2D, 3D and any combination of parameters +[ ] Cut into small tools +[ ] Test 3D workflow on 2D images Index: trunk/milena/sandbox/fabien/bin/dump2pgm8b.cc =================================================================== --- trunk/milena/sandbox/fabien/bin/dump2pgm8b.cc (revision 3511) +++ trunk/milena/sandbox/fabien/bin/dump2pgm8b.cc (revision 3512) @@ -3,12 +3,9 @@ #include <mln/debug/slices_2d.hh> #include <mln/value/int_u8.hh> -#include <mln/value/int_u12.hh> #include <mln/io/dump/load.hh> #include <mln/io/pgm/save.hh> -#include <mln/literal/colors.hh> - int usage(char* argv[]) { @@ -21,7 +18,6 @@ int main(int argc, char* argv[]) { using namespace mln; - using value::rgb8; using value::int_u8; if (argc != 3) @@ -30,7 +26,6 @@ image3d<int_u8> vol; io::dump::load(vol, argv[1]); - rgb8 bg = literal::black; image2d<int_u8> ima = debug::slices_2d(vol, 1.f, 0); io::pgm::save(ima, argv[2]);
15 years, 9 months
1
0
0
0
3511: Fix missing update in labeling extrema.
by Thierry Geraud
https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog from Thierry Geraud <thierry.geraud(a)lrde.epita.fr> Fix missing update in labeling extrema. * mln/labeling/regional_minima.hh, * mln/labeling/regional_maxima.hh: Fix missing update. regional_maxima.hh | 6 +++--- regional_minima.hh | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) Index: mln/labeling/regional_minima.hh --- mln/labeling/regional_minima.hh (revision 3510) +++ mln/labeling/regional_minima.hh (working copy) @@ -1,5 +1,5 @@ -// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory -// (LRDE) +// Copyright (C) 2007, 2008, 2009 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 @@ -154,7 +154,7 @@ typedef impl::regional_minima_functor<I> F; F f(exact(input)); mln_ch_value(I, L) output = canvas::labeling_sorted(input, nbh, nlabels, - f, true); + f, false); trace::exiting("labeling::regional_minima"); return output; Index: mln/labeling/regional_maxima.hh --- mln/labeling/regional_maxima.hh (revision 3510) +++ mln/labeling/regional_maxima.hh (working copy) @@ -1,5 +1,5 @@ -// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory -// (LRDE) +// Copyright (C) 2007, 2008, 2009 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 @@ -141,7 +141,7 @@ typedef impl::regional_maxima_functor<I> F; F f(exact(input)); mln_ch_value(I, L) output = canvas::labeling_sorted(input, nbh, nlabels, - f, false); + f, true); trace::exiting("labeling::regional_maxima"); return output;
15 years, 9 months
1
0
0
0
r3510: Bug in 3D watershed
by Fabien Freling
URL:
https://svn.lrde.epita.fr/svn/oln/trunk/milena/sandbox
ChangeLog: 2009-03-11 Fabien Freling <fabien.freling(a)lrde.epita.fr> Bug in 3D watershed. * fabien/igr/Makefile: Update with debug build. * fabien/igr/check3d_wsd.sh: Update. * fabien/igr/watershed3d.cc: Update. --- Makefile | 3 +++ check3d_wsd.sh | 1 + watershed3d.cc | 43 ++++++++++++++++++++++++++----------------- 3 files changed, 30 insertions(+), 17 deletions(-) Index: trunk/milena/sandbox/fabien/igr/watershed3d.cc =================================================================== --- trunk/milena/sandbox/fabien/igr/watershed3d.cc (revision 3509) +++ trunk/milena/sandbox/fabien/igr/watershed3d.cc (revision 3510) @@ -19,6 +19,7 @@ #include <mln/value/int_u8.hh> #include <mln/value/int_u12.hh> #include <mln/value/label_16.hh> +#include <mln/value/label_32.hh> #include <mln/level/transform.hh> #include <mln/level/stretch.hh> @@ -29,14 +30,14 @@ #include <mln/make/graph.hh> -#include <mln/morpho/gradient.hh> -#include <mln/morpho/closing/area.hh> +#include <mln/morpho/elementary/dilation.hh> +#include <mln/morpho/elementary/gradient.hh> +#include <mln/morpho/closing/volume.hh> #include <mln/morpho/meyer_wst.hh> #include <mln/fun/l2l/wrap.hh> #include <mln/core/var.hh> -#include <mln/morpho/elementary/dilation.hh> #include <mln/core/routine/extend.hh> @@ -247,6 +248,7 @@ using value::int_u12; using value::rgb8; using value::label_16; + using value::label_32; if (argc < 4) { @@ -262,32 +264,39 @@ image3d<int_u12> dcm; io::dicom::load(dcm, argv[1]); + // Debug + assert(mln_max(label_32) == 4294967295); io::dump::save(level::stretch(int_u8(), dcm), "wsd_01_src.dump"); - image3d<int_u12> grad = morpho::gradient(dcm, win_c4p_3d()); - image3d<int_u12> clo = morpho::closing::area(grad, c6(), closure_lambda); + // Gradient + image3d<int_u12> grad = morpho::elementary::gradient(dcm, c6()); - label_16 nbasins; - image3d<label_16> wshed = morpho::meyer_wst(clo, c6(), nbasins); + // Closure + image3d<int_u12> clo = morpho::closing::volume(grad, c6(), closure_lambda); + // Watershed + label_32 nbasins; + image3d<label_32> wshed = morpho::meyer_wst(clo, c6(), nbasins); + + // Debug io::dump::save(level::stretch(int_u8(), clo), "wsd_02.dump"); io::dump::save(level::transform(wshed, fun::l2l::wrap<int_u8>()), "wsd_03.dump"); - mln_VAR(vol2_, morpho::elementary::dilation(extend(wshed | (pw::value(wshed) == 0u), wshed), c26())); - - data::fill((wshed | (pw::value(wshed) == 0u)).rw(), vol2_); + //mln_VAR(vol2_, morpho::elementary::dilation(extend(wshed | (pw::value(wshed) == 0u), wshed), c26())); + //data::fill((wshed | (pw::value(wshed) == 0u)).rw(), vol2_); io::dump::save(level::transform(wshed, fun::l2l::wrap<int_u8>()), "wsd_04.dump"); - /// Build graph - util::graph g = make::graph(wshed, c6(), nbasins); + /// Graph + trace::quiet = false; + util::graph g = make::region_adjacency_graph(wshed, c6(), nbasins); // Build graph images and compute distance values with a RGB image. - mln_VAR(ima_v, make_vertex_graph_image(g, dcm, wshed, nbasins)); + /*mln_VAR(ima_v, make_vertex_graph_image(g, dcm, wshed, nbasins)); mln_VAR(ima_e, make_edge_graph_image(ima_v, g)); /// Try to merge vertices. mln_piter_(ima_e_t) e(ima_e.domain()); - util::array<label_16> parent(g.v_nmax()); + util::array<label_32> parent(g.v_nmax()); for (unsigned i = 0; i < parent.nelements(); ++i) parent[i] = i; @@ -299,7 +308,7 @@ parent[find_root(parent, v1)] = find_root(parent, v2); } - fun::i2v::array<label_16> f(parent.nelements()); + fun::i2v::array<label_32> f(parent.nelements()); std::vector<unsigned> new_label(parent.nelements(), 0); unsigned nbasins2 = 0; for (unsigned i = 0; i < parent.nelements(); ++i) @@ -312,7 +321,7 @@ } mln_invariant(f(0) == 0u); --nbasins2; // nbasins2 does not count the basin with label 0. - image3d<label_16> wsd2 = level::transform(wshed, f); + image3d<label_32> wsd2 = level::transform(wshed, f); io::dump::save(level::transform(wsd2, fun::l2l::wrap<int_u8>()), "wsd_05.dump"); @@ -330,5 +339,5 @@ io::dump::save(level::transform(labeling::mean_values(dcm, wsd2, nbasins2), fun::l2l::wrap<int_u8>()), "wsd_06_mean_colors.dump"); //io::dump::save(level::stretch(int_u8(), make_debug_graph_image(dcm, ima_v2, ima_e2, box_size, 4095)), "wsd_07_graph_image2_white.dump"); //io::dump::save(level::stretch(int_u8(), make_debug_graph_image(dcm, ima_v2, ima_e2, box_size, 0)), "wsd_08_graph_image2_black.dump"); - io::dump::save(level::transform(wsd2, fun::l2l::wrap<int_u8>()), "wsd_99_result.dump"); + io::dump::save(level::transform(wsd2, fun::l2l::wrap<int_u8>()), "wsd_99_result.dump");*/ } Index: trunk/milena/sandbox/fabien/igr/check3d_wsd.sh =================================================================== --- trunk/milena/sandbox/fabien/igr/check3d_wsd.sh (revision 3509) +++ trunk/milena/sandbox/fabien/igr/check3d_wsd.sh (revision 3510) @@ -29,6 +29,7 @@ done } +make wsd3d process_file "/Users/HiSoKa/Work/IGR/souris18/irm/IM_0052.dcm" "52" process_file "/Users/HiSoKa/Work/IGR/souris18/irm/IM_0061.dcm" "61" process_file "/Users/HiSoKa/Work/IGR/souris18/irm/IM_0064.dcm" "64" Index: trunk/milena/sandbox/fabien/igr/Makefile =================================================================== --- trunk/milena/sandbox/fabien/igr/Makefile (revision 3509) +++ trunk/milena/sandbox/fabien/igr/Makefile (revision 3510) @@ -22,5 +22,8 @@ wsd3d: watershed.hh watershed3d.cc g++ -I../../../ ${DICOM_INC} ${DICOM_LIB} ${CXXFLAGS} $^ -o wsd3d +wsd3dg: watershed.hh watershed3d.cc + g++ -I../../../ ${DICOM_INC} ${DICOM_LIB} -DNDEBUG -g $^ -o wsd3dg + clean: rm -rf *.dump *.p?m *.plot *.log *.csv
15 years, 9 months
1
0
0
0
milena r3509: Fix bug in leaf propagation
by Edwin Carlinet
URL:
https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog: 2009-03-10 Edwin Carlinet <carlinet(a)lrde.epita.fr> Fix bug in leaf propagation. * mln/morpho/tree/data.hh: Fix leaves calculus. * sandbox/edwin/tree/propagate.hh: Fix bugs in propagations. * sandbox/edwin/tree/tree.cc: Test file. --- mln/morpho/tree/data.hh | 27 +++++++++++----- sandbox/edwin/tree/propagate.hh | 17 +++++----- sandbox/edwin/tree/tree.cc | 66 +++++++++++++++++++++++++++++----------- 3 files changed, 77 insertions(+), 33 deletions(-) Index: trunk/milena/mln/morpho/tree/data.hh =================================================================== --- trunk/milena/mln/morpho/tree/data.hh (revision 3508) +++ trunk/milena/mln/morpho/tree/data.hh (revision 3509) @@ -41,6 +41,7 @@ # include <mln/core/image/sub_image.hh> # include <mln/core/site_set/p_array.hh> # include <mln/core/site_set/p_set.hh> +# include <mln/data/fill.hh> namespace mln { @@ -140,11 +141,12 @@ /// \} - /// \{ Leaves-related materials. - typedef p_array<mln_psite(I)> leaves_t; + /// \{ Nodes-related materials. + + typedef p_set<mln_psite(I)> leaves_t; - const p_set<mln_psite(I)>& leaves() const + const leaves_t& leaves() const { mln_precondition(is_valid()); return leaves_; @@ -185,8 +187,8 @@ const I& f_; const S& s_; mln_ch_value(I, mln_psite(I)) parent_; + leaves_t leaves_; p_array<mln_psite(I)> nodes_; - p_set<mln_psite(I)> leaves_; unsigned nroots_; }; @@ -210,14 +212,11 @@ // Store tree nodes. nroots_ = 0; mln_bkd_piter(S) p(s_); - mln_psite(I) old; for_all(p) { if (f_(parent_(p)) != f_(p)) { nodes_.insert(p); - if (parent_(p) != old) - leaves_.insert(old); } else if (parent_(p) == p) @@ -225,7 +224,19 @@ nodes_.insert(p); ++nroots_; } - old = p; + } + + // Store leaves. + mln_ch_value(I, bool) deja_vu; + initialize(deja_vu, f); + mln::data::fill(deja_vu, false); + + mln_fwd_piter(nodes_t) n(nodes_); + for_all(n) + { + deja_vu(parent_(n)) = true; + if (!deja_vu(n)) + leaves_.insert(n); } } Index: trunk/milena/sandbox/edwin/tree/propagate.hh =================================================================== --- trunk/milena/sandbox/edwin/tree/propagate.hh (revision 3508) +++ trunk/milena/sandbox/edwin/tree/propagate.hh (revision 3509) @@ -43,8 +43,9 @@ /// non-representative points of the same node. template <typename T, typename A> void - propagate_to_node(const T& t, A& a) + propagate_representant(const T& t, Image<A>& a_) { + A a = exact(a_); mln_fwd_piter(T) p(t.domain()); for_all(p) if (! t.is_a_node(p)) @@ -54,6 +55,8 @@ } } + namespace binary { + /// Propagate a tagged node's value to its subbranches. template <typename T, typename A> void @@ -62,7 +65,6 @@ mln_bkd_piter(T::nodes_t) n(t.nodes()); for_all(n) { - mln_assertion(t.is_a_node(n)); if (a(t.parent(n))) { mln_assertion(t.is_a_node(t.parent(n))); @@ -80,7 +82,6 @@ mln_fwd_piter(T::nodes_t) n(t.nodes()); for_all(n) { - mln_assertion(t.is_a_node(n)); if (a(t.parent(n))) { mln_assertion(t.is_a_node(t.parent(n))); @@ -97,7 +98,6 @@ mln_fwd_piter(T::nodes_t) n(t.nodes()); for_all(n) { - mln_assertion(t.is_a_node(n)); if (a(n)) { mln_assertion(t.is_a_node(t.parent(n))); @@ -109,7 +109,7 @@ /// Propagate a tagged node's value to its direct parents. template <typename T, typename A> void - propagate_to_parents(const T& t, A& a) + propagate_to_parent(const T& t, A& a) { mln_bkd_piter(T::nodes_t) n(t.nodes()); for_all(n) @@ -131,16 +131,17 @@ /// n <== l and a(l) is true. /// TODO: post-condition which checks this property. + template <typename T, typename A> void propagate_leaf_to_ancestors(const T& t, A& a) { - // 1st pass: leaves' parents are set to false. + mln_fwd_piter(T::leaves_t) l(t.leaves()); for_all(l) - t.parent(l) = 0; + a(t.parent(l)) = 0; + - // 2nd pass mln_fwd_piter(T::nodes_t) n(t.nodes()); for_all(n) { Index: trunk/milena/sandbox/edwin/tree/tree.cc =================================================================== --- trunk/milena/sandbox/edwin/tree/tree.cc (revision 3508) +++ trunk/milena/sandbox/edwin/tree/tree.cc (revision 3509) @@ -77,14 +77,18 @@ { mln_VAR(a, morpho::tree::compute_attribute_image(a_, tree_)); - display_tree_attributes(tree_, a); - find_treshold(a, tree_); + //display_tree_attributes(tree_, a); + //find_treshold(a, tree_); + + mln_fwd_piter(tree_t::nodes_t) n(tree_.nodes()); + for_all(n) + assert(tree_.is_a_leaf(tree_.parent(n)) == false); img_ = duplicate((pw::cst(lambda1) < pw::value(a) && pw::value(a) < pw::cst(lambda2)) | a.domain()); - debug::println("attribut", a); + //debug::println("attribut", a); } template <typename I, typename T> @@ -151,12 +155,12 @@ // Debug. - { - std::cout << " - " << val << ":" << pset.nsites() << " {"; - for_all(p) - std::cout << p << ","; - std::cout << "}" << std::endl; - } +// { +// std::cout << " - " << val << ":" << pset.nsites() << " {"; +// for_all(p) +// std::cout << p << ","; +// std::cout << "}" << std::endl; +// } } for (unsigned i = 0; i < f_domain.size() - 1; i++) @@ -213,8 +217,9 @@ void usage(char* argv[]) { - std::cerr << "usage: " << argv[0] << " input.pgm accumulator lambda1 [lambda2]" - << std::endl; + std::cerr << "usage: " << argv[0] << " input.pgm accumulator propagation lambda1 [lambda2]" + << "\taccu:\tcard | sharpness" << std::endl + << "\tpropa:\tto_children | to_childhood | to_parent | to_ancestors | leaf_to_ancestors" << std::endl; abort(); } @@ -228,17 +233,29 @@ float lambda1; float lambda2; - I input; + if (argc < 4) usage(argv); + I input; io::pgm::load(input, argv[1]); +// int_u8 vals[] = { 0, 1, 0, 2, 0, 1, 0, +// 1, 1, 1, 2, 1, 1, 1, +// 0, 1, 0, 2, 0, 1, 0, +// 2, 2, 2, 2, 2, 2, 2, +// 1, 1, 1, 2, 0, 1, 0, +// 1, 1, 1, 2, 1, 1, 1, +// 1, 1, 1, 2, 0, 1, 0}; +// I input = make::image2d(vals); - lambda1 = atof(argv[3]); - lambda2 = (argc == 5) ? atof(argv[4]) : mln_max(float); + + + lambda1 = atof(argv[4]); + lambda2 = (argc == 6) ? atof(argv[5]) : mln_max(float); std::string s(argv[2]); + std::string propa(argv[3]); treefilter<I>* f = 0; if (s == "card") f = new treefilter<I>(input, morpho::attribute::card<I>(), lambda1, lambda2); @@ -249,11 +266,26 @@ std::cout << "s1" << std::endl; - propagate_to_childhood(f->tree(), f->img()); + if (propa == "to_childhood") + morpho::tree::propagate_to_childhood(f->tree(), f->img()); + else if (propa == "to_children") + morpho::tree::propagate_to_children(f->tree(), f->img()); + else if (propa == "to_ancestors") + morpho::tree::propagate_to_ancestors(f->tree(), f->img()); + else if (propa == "to_parent") + morpho::tree::propagate_to_parent(f->tree(), f->img()); + else if (propa == "leaf_to_ancestors") + morpho::tree::propagate_leaf_to_ancestors(f->tree(), f->img()); + else + usage(argv); + std::cout << "s2" << std::endl; - propagate_to_node(f->tree(), f->img()); + morpho::tree::propagate_to_node(f->tree(), f->img()); std::cout << "s3" << std::endl; - filtercheck(*f, accu::meta::count()); + + + + //filtercheck(*f, accu::meta::count()); io::pbm::save(f->img(), "out.pbm");
15 years, 9 months
1
0
0
0
3508: Make io::dump::* more robust and improve dump format.
by Guillaume Lazzara
* mln/io/dump/load.hh, * mln/io/dump/save.hh: - Add new information in the header. - Add more assertion on value type, dimension and file type. Important note: Old dump files are not compatible with this new format. * mln/trait/value_.hh: add a new macro mln_trait_value_name. * mln/value/builtin/floatings.hh * mln/value/builtin/integers.hh * mln/value/builtin/symbolics.hh * mln/value/int_s.hh * mln/value/int_u.hh * mln/value/label.hh * mln/value/rgb.hh: add name() member to value_<> specialization. It returns the type name as a const char*. * tests/io/dump/dump.cc: add new tests with builtin types. --- milena/ChangeLog | 25 ++++++++++++ milena/mln/io/dump/load.hh | 70 +++++++++++++++++++++++++++++--- milena/mln/io/dump/save.hh | 26 ++++++++++++- milena/mln/trait/value_.hh | 3 +- milena/mln/value/builtin/floatings.hh | 10 ++++- milena/mln/value/builtin/integers.hh | 65 ++++++++++++++++++++++++++---- milena/mln/value/builtin/symbolics.hh | 15 ++++--- milena/mln/value/int_s.hh | 9 ++++- milena/mln/value/int_u.hh | 9 ++++- milena/mln/value/label.hh | 7 +++ milena/mln/value/rgb.hh | 7 +++ milena/tests/io/dump/dump.cc | 28 +++++++++++++- 12 files changed, 246 insertions(+), 28 deletions(-) diff --git a/milena/ChangeLog b/milena/ChangeLog index 199bdd1..bd6d99c 100644 --- a/milena/ChangeLog +++ b/milena/ChangeLog @@ -1,5 +1,30 @@ 2009-03-10 Guillaume Lazzara <lazzara(a)lrde.epita.fr> + Make io::dump::* more robust and improve dump format. + + * mln/io/dump/load.hh, + * mln/io/dump/save.hh: + - Add new information in the header. + - Add more assertion on value type, dimension and file type. + + Important note: Old dump files are not compatible with this new + format. + + * mln/trait/value_.hh: add a new macro mln_trait_value_name. + + * mln/value/builtin/floatings.hh + * mln/value/builtin/integers.hh + * mln/value/builtin/symbolics.hh + * mln/value/int_s.hh + * mln/value/int_u.hh + * mln/value/label.hh + * mln/value/rgb.hh: add name() member to value_<> specialization. + It returns the type name as a const char*. + + * tests/io/dump/dump.cc: add new tests with builtin types. + +2009-03-10 Guillaume Lazzara <lazzara(a)lrde.epita.fr> + Various small fixes. * headers.mk: update dist header list. diff --git a/milena/mln/io/dump/load.hh b/milena/mln/io/dump/load.hh index bc6a051..88f60a2 100644 --- a/milena/mln/io/dump/load.hh +++ b/milena/mln/io/dump/load.hh @@ -73,20 +73,74 @@ namespace mln } - template <typename I> + template <typename I> inline - void load_header(Image<I>& ima, std::ifstream& file) + void load_header(Image<I>& ima, std::ifstream& file, + const std::string& filename) { + // Milena's file type ? + std::string file_type; + file >> file_type; + if (file_type != "milena/dump") + { + std::cerr << "io::dump::load - Error: invalid file type. '" + << filename + << "' is NOT a valid milena/dump file!" + << std::endl; + abort(); + } + + // Dimension ? unsigned dim; file >> dim; - typedef mln_site(I) P; - mln_assertion(P::dim == dim); + if (P::dim != dim) + { + std::cerr << "io::dump::load - Error: invalid image dimension. '" + << filename << "' is a " << dim << "-D image " + << "but you try to load it into a " << P::dim + << "-D image!" + << std::endl; + abort(); + } - P pmin, pmax; + // Size information - Skip it, useless. + std::string tmp; + for (unsigned i = 0; i < dim; ++i) + file >> tmp; + // Skipping endline. + char c; + file.get(c); + + // Value type name ? + // WARNING: value type name limited to 255 characters... + char value_type[255]; + file.getline(value_type, 255); + if (mln_trait_value_name(mln_value(I)) != std::string(value_type)) + { + std::cerr << "io::dump::load - Error: invalid image value type. '" + << filename << "' is an image of '" << value_type + << "' but you try to load it into an image of '" + << mln_trait_value_name(mln_value(I)) << "'!" + << std::endl; + abort(); + } + + // Empty line - may be used for a new information. + file.get(c); + + // Empty line - may be used for a new information. + file.get(c); + + // Pmin + P pmin; read_point<P>(file, pmin); + + // Pmax + P pmax; read_point<P>(file, pmax); + // Initialize the image buffer. mln_concrete(I) result(box<P>(pmin, pmax)); initialize(ima, result); mln_assertion(exact(ima).is_valid()); @@ -123,11 +177,13 @@ namespace mln std::ifstream file(filename.c_str()); if (! file) { - std::cerr << "error: cannot open file '" << filename << "'!"; + std::cerr << "io::dump::load - Error: cannot open file '" + << filename << "'!" + << std::endl; abort(); } - internal::load_header(ima, file); + internal::load_header(ima, file, filename); internal::load_data(ima, file); mln_postcondition(exact(ima).is_valid()); diff --git a/milena/mln/io/dump/save.hh b/milena/mln/io/dump/save.hh index a489a20..41d4571 100644 --- a/milena/mln/io/dump/save.hh +++ b/milena/mln/io/dump/save.hh @@ -40,6 +40,7 @@ # include <mln/core/box_runstart_piter.hh> # include <mln/core/pixel.hh> # include <mln/data/memcpy_.hh> +# include <mln/trait/value_.hh> namespace mln { @@ -68,12 +69,35 @@ namespace mln void save_header(const I& ima, std::ofstream& file) { + // Milena's file type + file << "milena/dump" << std::endl; + + // Dimension typedef mln_site(I) P; - file << P::dim; + file << P::dim << std::endl; + + // Image size. + typedef algebra::vec<P::dim, unsigned> vec_t; + vec_t size = ima.domain().pmax() - ima.domain().pmin(); + for (unsigned i = 0; i < P::dim - 1; ++i) + file << size[i] + 1 << " "; + file << size[P::dim - 1] + 1 << std::endl; + + // Value type name + // WARNING: value type name limited to 255 characters... + file << mln_trait_value_name(mln_value(I)) << std::endl; + + // Empty line - may be used for a new information. + file << std::endl; + + // Empty line - may be used for a new information. + file << std::endl; + // Pmin mln_site(I) p = ima.domain().pmin(); file.write((char*) (&p), sizeof (P)); + // Pmax p = ima.domain().pmax(); file.write((char*) (&p), sizeof (P)); } diff --git a/milena/mln/trait/value_.hh b/milena/mln/trait/value_.hh index d03403d..f607604 100644 --- a/milena/mln/trait/value_.hh +++ b/milena/mln/trait/value_.hh @@ -66,7 +66,8 @@ # define mln_sum(V) mln_trait_value_sum(V) # define mln_sum_(V) mln_trait_value_sum_(V) - +/// Give the value type name +# define mln_trait_value_name(V) mln::trait::value_< V >::name() /// FIXME: check that the -1 is correct # define mln_value_quant_from_(C) \ diff --git a/milena/mln/value/builtin/floatings.hh b/milena/mln/value/builtin/floatings.hh index 3fd0b50..c777555 100644 --- a/milena/mln/value/builtin/floatings.hh +++ b/milena/mln/value/builtin/floatings.hh @@ -1,4 +1,4 @@ -// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory +// Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory // (LRDE) // // This file is part of the Olena Library. This library is free @@ -89,6 +89,10 @@ namespace mln } typedef float sum; + + static const char* name() + { return "float"; } + }; template <> @@ -120,6 +124,10 @@ namespace mln } typedef double sum; + + static const char* name() + { return "float"; } + }; } // end of namespace mln::trait diff --git a/milena/mln/value/builtin/integers.hh b/milena/mln/value/builtin/integers.hh index cb4cced..71cfd34 100644 --- a/milena/mln/value/builtin/integers.hh +++ b/milena/mln/value/builtin/integers.hh @@ -1,4 +1,4 @@ -// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory +// Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory // (LRDE) // // This file is part of the Olena Library. This library is free @@ -90,14 +90,61 @@ namespace mln } // end of namespace mln::trait::internal - template <> struct value_< unsigned char > : internal::value_integer_< unsigned char > {}; - template <> struct value_< signed char > : internal::value_integer_< signed char > {}; - template <> struct value_< unsigned short > : internal::value_integer_< unsigned short > {}; - template <> struct value_< signed short > : internal::value_integer_< signed short > {}; - template <> struct value_< unsigned int > : internal::value_integer_< unsigned int > {}; - template <> struct value_< signed int > : internal::value_integer_< signed int > {}; - template <> struct value_< unsigned long > : internal::value_integer_< unsigned long > {}; - template <> struct value_< signed long > : internal::value_integer_< signed long > {}; + template <> struct value_< unsigned char > + : internal::value_integer_< unsigned char > + { + static const char* name() + { return "unsigned char"; } + }; + + template <> struct value_< signed char > + : internal::value_integer_< signed char > + { + static const char* name() + { return "signed char"; } + }; + + template <> struct value_< unsigned short > + : internal::value_integer_< unsigned short > + { + static const char* name() + { return "unsigned short"; } + }; + + template <> struct value_< signed short > + : internal::value_integer_< signed short > + { + static const char* name() + { return "signed short"; } + }; + + template <> struct value_< unsigned int > + : internal::value_integer_< unsigned int > + { + static const char* name() + { return "unsigned int"; } + }; + + template <> struct value_< signed int > + : internal::value_integer_< signed int > + { + static const char* name() + { return "signed int"; } + }; + + template <> struct value_< unsigned long > + : internal::value_integer_< unsigned long > + { + static const char* name() + { return "unsigned long"; } + }; + + template <> struct value_< signed long > + : internal::value_integer_< signed long > + { + static const char* name() + { return "signed long"; } + }; } // end of namespace mln::trait diff --git a/milena/mln/value/builtin/symbolics.hh b/milena/mln/value/builtin/symbolics.hh index 8724c3a..65cdb3c 100644 --- a/milena/mln/value/builtin/symbolics.hh +++ b/milena/mln/value/builtin/symbolics.hh @@ -1,4 +1,4 @@ -// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory +// Copyright (C) 2007, 2008, 2009 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 @@ -28,10 +28,10 @@ #ifndef MLN_VALUE_BUILTIN_SYMBOLICS_HH # define MLN_VALUE_BUILTIN_SYMBOLICS_HH -/*! \file mln/value/builtin/symbolics.hh - * - * \brief Some definitions about built-in symbolic types. - */ +/// \file mln/value/builtin/symbolics.hh +/// +/// Some definitions about built-in symbolic types. + # include <mln/value/concept/built_in.hh> # include <mln/value/concept/symbolic.hh> @@ -53,7 +53,7 @@ namespace mln { template <> - struct value_< bool> + struct value_<bool> { typedef value::nature::symbolic nature; typedef value::kind::binary kind; @@ -63,6 +63,9 @@ namespace mln card = 2 }; typedef value::quant::low quant; + + static const char* name() { return "bool"; } + }; } // end of namespace mln::trait diff --git a/milena/mln/value/int_s.hh b/milena/mln/value/int_s.hh index e30206c..a6d02ca 100644 --- a/milena/mln/value/int_s.hh +++ b/milena/mln/value/int_s.hh @@ -1,4 +1,4 @@ -// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory +// Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory // (LRDE) // // This file is part of the Olena Library. This library is free @@ -89,6 +89,13 @@ namespace mln static const self_ epsilon() { return 0; } typedef float sum; + + static const char* name() + { + static std::string s = std::string("int_s").append(1, n + '0'); + return s.c_str(); + } + }; } // end of namespace mln::trait diff --git a/milena/mln/value/int_u.hh b/milena/mln/value/int_u.hh index ce1993b..db3353e 100644 --- a/milena/mln/value/int_u.hh +++ b/milena/mln/value/int_u.hh @@ -1,4 +1,4 @@ -// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory +// Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory // (LRDE) // // This file is part of the Olena Library. This library is free @@ -95,6 +95,13 @@ namespace mln static const self_ epsilon() { return 0; } typedef float sum; + + static const char* name() + { + static std::string s = std::string("int_u").append(1, n + '0'); + return s.c_str(); + } + }; } // end of namespace mln::trait diff --git a/milena/mln/value/label.hh b/milena/mln/value/label.hh index 53c3d60..51dfa2d 100644 --- a/milena/mln/value/label.hh +++ b/milena/mln/value/label.hh @@ -78,6 +78,13 @@ namespace mln static const self_ min() { return 0; } static const self_ max() { return mlc_pow_int(2, n) - 1; } + + static const char* name() + { + static std::string s = std::string("label_").append(1, n + '0'); + return s.c_str(); + } + }; } // end of namespace trait diff --git a/milena/mln/value/rgb.hh b/milena/mln/value/rgb.hh index 2d13f94..11733cc 100644 --- a/milena/mln/value/rgb.hh +++ b/milena/mln/value/rgb.hh @@ -217,6 +217,13 @@ namespace mln typedef mln_value_quant_from_(card) quant; typedef algebra::vec<3, float> sum; + + static const char* name() + { + static std::string s = std::string("rgb").append(1, n + '0'); + return s.c_str(); + } + }; } // end of namespace trait diff --git a/milena/tests/io/dump/dump.cc b/milena/tests/io/dump/dump.cc index 6099bc9..7c7ba04 100644 --- a/milena/tests/io/dump/dump.cc +++ b/milena/tests/io/dump/dump.cc @@ -67,7 +67,6 @@ int main() 1, 9 }; image2d<value::int_u8> pic = make::image2d(data); io::dump::save(pic, "pic.dump"); - image2d<value::int_u8> pic2; io::dump::load(pic2, "pic.dump"); @@ -75,6 +74,33 @@ int main() mln_assertion(pic == pic2); } + /// Value: unsigned + { + unsigned data[4] = { 5, 1, + 1, 9 }; + image2d<unsigned> pic = make::image2d(data); + io::dump::save(pic, "pic.dump"); + image2d<unsigned> pic2; + io::dump::load(pic2, "pic.dump"); + + mln_assertion(pic.domain() == pic2.domain()); + mln_assertion(pic == pic2); + } + + /// Value: float + { + float data[4] = { 5, 1, + 1, 9 }; + image2d<float> pic = make::image2d(data); + io::dump::save(pic, "pic.dump"); + image2d<float> pic2; + io::dump::load(pic2, "pic.dump"); + + mln_assertion(pic.domain() == pic2.domain()); + mln_assertion(pic == pic2); + } + + /// Value: rgb8 { using value::rgb8; -- 1.5.6.5
15 years, 9 months
1
0
0
0
3507: Various small fixes.
by Guillaume Lazzara
* headers.mk: update dist header list. * mln/algebra/vec.hh: add contructor and operator= with literal::zero. * mln/canvas/distance_front.hh: avoid a warning. * mln/fun/i2v/array.hh, * mln/fun/l2l/relabel.hh, * mln/convert/from_to.hxx: add new from_to over_loads. * mln/convert/impl/all.hh, * mln/convert/impl/from_unsigned_to_value.hh: add a new from_to implementation to fix ambiguities with from_int_to_value and from_float_to_value. * mln/win/essential.hh, * mln/core/internal/image_identity.hh: update doc. * mln/core/routine/essential.hh: fix includes. * mln/fun/essential.hh: include fun/meta/essential.hh. * mln/util/soft_heap.hh: fix guards. --- milena/ChangeLog | 28 +++++ milena/headers.mk | 12 +- milena/mln/algebra/vec.hh | 26 ++++- milena/mln/canvas/distance_front.hh | 1 + milena/mln/convert/from_to.hxx | 42 +++++++ milena/mln/convert/impl/all.hh | 1 + milena/mln/convert/impl/from_unsigned_to_value.hh | 132 +++++++++++++++++++++ milena/mln/core/internal/image_identity.hh | 15 +-- milena/mln/core/routine/essential.hh | 12 +- milena/mln/fun/essential.hh | 10 +- milena/mln/fun/i2v/array.hh | 34 ++++++ milena/mln/fun/l2l/relabel.hh | 34 ++++++ milena/mln/util/soft_heap.hh | 6 +- milena/mln/win/essential.hh | 9 +- 14 files changed, 328 insertions(+), 34 deletions(-) create mode 100644 milena/mln/convert/impl/from_unsigned_to_value.hh diff --git a/milena/ChangeLog b/milena/ChangeLog index 4f0c24c..199bdd1 100644 --- a/milena/ChangeLog +++ b/milena/ChangeLog @@ -1,5 +1,33 @@ 2009-03-10 Guillaume Lazzara <lazzara(a)lrde.epita.fr> + Various small fixes. + + * headers.mk: update dist header list. + + * mln/algebra/vec.hh: add contructor and operator= with literal::zero. + + * mln/canvas/distance_front.hh: avoid a warning. + + * mln/fun/i2v/array.hh, + * mln/fun/l2l/relabel.hh, + * mln/convert/from_to.hxx: add new from_to over_loads. + + * mln/convert/impl/all.hh, + * mln/convert/impl/from_unsigned_to_value.hh: add a new from_to + implementation to fix ambiguities with from_int_to_value and + from_float_to_value. + + * mln/win/essential.hh, + * mln/core/internal/image_identity.hh: update doc. + + * mln/core/routine/essential.hh: fix includes. + + * mln/fun/essential.hh: include fun/meta/essential.hh. + + * mln/util/soft_heap.hh: fix guards. + +2009-03-10 Guillaume Lazzara <lazzara(a)lrde.epita.fr> + Add meta::first and meta::second. * mln/fun/meta/all.hh, diff --git a/milena/headers.mk b/milena/headers.mk index e37427e..9513a84 100644 --- a/milena/headers.mk +++ b/milena/headers.mk @@ -95,6 +95,7 @@ mln/util/line_graph.hh \ mln/util/ord.hh \ mln/util/tree_fast_to_image.hh \ mln/util/tree.hh \ +mln/util/couple.hh \ mln/util/index.hh \ mln/util/multi_site.hh \ mln/util/branch_iter.hh \ @@ -367,6 +368,7 @@ mln/value/label_8.hh \ mln/value/essential.hh \ mln/accu/tuple.hh \ mln/accu/min_h.hh \ +mln/accu/stat/deviation.hh \ mln/accu/max.hh \ mln/accu/lor.hh \ mln/accu/rank.hh \ @@ -602,7 +604,6 @@ mln/linear/log.hh \ mln/linear/essential.hh \ mln/morpho/thinning.hh \ mln/morpho/meyer_wst.hh \ -mln/morpho/opening.hh \ mln/morpho/includes.hh \ mln/morpho/elementary/opening.hh \ mln/morpho/elementary/gradient_internal.hh \ @@ -634,7 +635,9 @@ mln/morpho/closing/leveling.hh \ mln/morpho/closing/area_on_vertices.hh \ mln/morpho/closing/area.hh \ mln/morpho/closing/volume.hh \ +mln/morpho/closing/sum.hh \ mln/morpho/closing/height.hh \ +mln/morpho/closing/structural.hh \ mln/morpho/closing/essential.hh \ mln/morpho/laplacian.hh \ mln/morpho/all.hh \ @@ -647,6 +650,7 @@ mln/morpho/opening/area_on_vertices.hh \ mln/morpho/opening/area.hh \ mln/morpho/opening/volume.hh \ mln/morpho/opening/height.hh \ +mln/morpho/opening/structural.hh \ mln/morpho/opening/essential.hh \ mln/morpho/attribute/all.hh \ mln/morpho/attribute/volume.hh \ @@ -665,15 +669,12 @@ mln/morpho/tree/data.hh \ mln/morpho/tree/compute_attribute_image.hh \ mln/morpho/general.spe.hh \ mln/morpho/min.hh \ -mln/morpho/closing.hh \ mln/morpho/top_hat.hh \ mln/morpho/erosion.hh \ mln/morpho/leveling_filter.hh \ -mln/morpho/closing_sum.hh \ mln/morpho/Rd.hh \ mln/morpho/thick_miss.hh \ mln/morpho/algebraic_filter.hh \ -mln/morpho/closing_attribute.hh \ mln/morpho/rank_filter.hh \ mln/morpho/essential.hh \ mln/topo/n_face_iter.hh \ @@ -708,6 +709,7 @@ mln/essential/routine.hh \ mln/essential/3d.hh \ mln/essential/2d.hh \ mln/win/inter.hh \ +mln/win/sphere3d.hh \ mln/win/backdiag2d.hh \ mln/win/segment1d.hh \ mln/win/cuboid3d.hh \ @@ -718,10 +720,10 @@ mln/win/multiple_size.hh \ mln/win/cube3d.hh \ mln/win/shift.hh \ mln/win/sym.hh \ +mln/win/ball.hh \ mln/win/diff.hh \ mln/win/multiple.hh \ mln/win/diag2d.hh \ -mln/win/ball3d.hh \ mln/win/disk2d.hh \ mln/win/rectangle2d.hh \ mln/win/hline2d.hh \ diff --git a/milena/mln/algebra/vec.hh b/milena/mln/algebra/vec.hh index da2541c..9563a27 100644 --- a/milena/mln/algebra/vec.hh +++ b/milena/mln/algebra/vec.hh @@ -1,4 +1,4 @@ -// Copyright (C) 2006, 2008 EPITA Research and Development Laboratory +// Copyright (C) 2006, 2008, 2009 EPITA Research and Development Laboratory // (LRDE) // // This file is part of the Olena Library. This library is free @@ -39,6 +39,7 @@ # include <mln/core/concept/object.hh> # include <mln/literal/zero.hh> +# include <mln/literal/origin.hh> # include <mln/norm/l2.hh> # include <mln/trait/all.hh> # include <mln/trait/value_.hh> @@ -188,11 +189,16 @@ namespace mln vec(); - /// \{ Constructors/assignments with literal zero. + /// \{ Constructors/assignments with literal::zero. vec(const literal::zero_t&); vec& operator=(const literal::zero_t&); /// \} + /// \{ Constructors/assignments with literal::origin. + vec(const literal::origin_t&); + vec& operator=(const literal::origin_t&); + /// \} + vec(const vec<n, T>& rhs); template <typename U> @@ -386,6 +392,22 @@ namespace mln template <unsigned n, typename T> inline + vec<n,T>::vec(const literal::origin_t&) + { + this->set_all(0); + } + + template <unsigned n, typename T> + inline + vec<n,T>& + vec<n,T>::operator=(const literal::origin_t&) + { + this->set_all(0); + return *this; + } + + template <unsigned n, typename T> + inline vec<n,T>::vec(const vec<n,T>& rhs) : super_() { diff --git a/milena/mln/canvas/distance_front.hh b/milena/mln/canvas/distance_front.hh index f374a2b..3eb8eeb 100644 --- a/milena/mln/canvas/distance_front.hh +++ b/milena/mln/canvas/distance_front.hh @@ -88,6 +88,7 @@ namespace mln (void) nbh; (void) max; (void) functor; + (void) w_win; } diff --git a/milena/mln/convert/from_to.hxx b/milena/mln/convert/from_to.hxx index df12d5d..d4ccc22 100644 --- a/milena/mln/convert/from_to.hxx +++ b/milena/mln/convert/from_to.hxx @@ -76,6 +76,10 @@ namespace mln namespace i2v { template <typename T> class array; } + + namespace l2l { + template <typename T> class relabel; + } } namespace histo { @@ -333,17 +337,55 @@ namespace mln void from_to_(const util::array<T>& from, fun::i2v::array<T>& to); + // util::array<T> -> fun::i2v::array<U> + template <typename T, typename U> + void + from_to_(const util::array<T>& from, fun::i2v::array<U>& to); + // std::vector<T> -> fun::i2v::array<T> template <typename T> void from_to_(const std::vector<T>& from, fun::i2v::array<T>& to); + // std::vector<T> -> fun::i2v::array<U> + template <typename T, typename U> + void + from_to_(const std::vector<T>& from, fun::i2v::array<U>& to); + + // util::array<T1> -> util::array<T2> + template <typename T1, typename T2> + void + from_to_(const util::array<T1>& from, util::array<T2>& to); + + + + // util::array<T> -> fun::l2l::relabel<T> + template <typename T> + void + from_to_(const util::array<T>& from, fun::l2l::relabel<T>& to); + + // util::array<T> -> fun::l2l::relabel<U> + template <typename T, typename U> + void + from_to_(const util::array<T>& from, fun::l2l::relabel<U>& to); + + // std::vector<T> -> fun::l2l::relabel<T> + template <typename T> + void + from_to_(const std::vector<T>& from, fun::l2l::relabel<T>& to); + + // std::vector<T> -> fun::l2l::relabel<U> + template <typename T, typename U> + void + from_to_(const std::vector<T>& from, fun::l2l::relabel<U>& to); + // util::array<T1> -> util::array<T2> template <typename T1, typename T2> void from_to_(const util::array<T1>& from, util::array<T2>& to); + // Accumulator<A> -> mln_result(A) template <typename A> void diff --git a/milena/mln/convert/impl/all.hh b/milena/mln/convert/impl/all.hh index dcaaf24..28cdde1 100644 --- a/milena/mln/convert/impl/all.hh +++ b/milena/mln/convert/impl/all.hh @@ -38,6 +38,7 @@ # include <mln/convert/impl/from_image_to_site_set.hh> # include <mln/convert/impl/from_int_to_value.hh> # include <mln/convert/impl/from_site_set_to_image.hh> +# include <mln/convert/impl/from_unsigned_to_value.hh> # include <mln/convert/impl/from_value_to_value.hh> diff --git a/milena/mln/convert/impl/from_unsigned_to_value.hh b/milena/mln/convert/impl/from_unsigned_to_value.hh new file mode 100644 index 0000000..4c6bac7 --- /dev/null +++ b/milena/mln/convert/impl/from_unsigned_to_value.hh @@ -0,0 +1,132 @@ +// Copyright (C) 2009 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_CONVERT_IMPL_FROM_UNSIGNED_TO_VALUE_HH +# define MLN_CONVERT_IMPL_FROM_UNSIGNED_TO_VALUE_HH + +/// \file mln/convert/impl/from_unsigned_to_value.hh +/// +/// General conversion procedure from an unsigned to a value. +/// +/// \todo Augment code + add checks. + +# include <utility> +# include <mln/value/concept/integer.hh> +# include <mln/core/concept/value.hh> +# include <mln/math/round.hh> + + + + +namespace mln +{ + + namespace convert + { + + /// Conversion of an unsigned \p from towards a value \p to. + template <typename V> + void + from_to(const unsigned& from, Value<V>& to); + + +# ifndef MLN_INCLUDE_ONLY + + namespace impl + { + + // Case 1: + + template <typename V> + inline + void + from_unsigned_to_value(const unsigned& from, + mln::value::Integer<V>& to) + { + exact(to) = from; + } + + template <unsigned n> + inline + void + from_unsigned_to_value(const unsigned& from, + mln::value::label<n>& to) + { + exact(to) = from; + } + + // Default: no conversion defined. + + template <typename V> + inline + void + from_unsigned_to_value(const unsigned&, + Value<V>&) + { + mlc_abort(V)::check(); + } + + } // end of namespace mln::convert::impl + + + namespace internal + { + + template <typename V> + inline + void + from_unsigned_to_value_dispatch(const unsigned& from, Value<V>& to) + { + impl::from_unsigned_to_value(from, exact(to)); + } + + } // end of namespace mln::convert::unsignedernal + + + namespace over_load + { + + // Facades. + // unsigned-> Value + template <typename V> + void + from_to_(const unsigned& from, Value<V>& to) + { + internal::from_unsigned_to_value_dispatch(from, to); + } + + } // end of namespace mln::convert::over_load + + +# endif // ! MLN_INCLUDE_ONLY + + } // end of namespace mln::convert + +} // end of namespace mln + + +#endif // ! MLN_CONVERT_IMPL_FROM_UNSIGNED_TO_VALUE_HH diff --git a/milena/mln/core/internal/image_identity.hh b/milena/mln/core/internal/image_identity.hh index 3a2b20b..bddcdf7 100644 --- a/milena/mln/core/internal/image_identity.hh +++ b/milena/mln/core/internal/image_identity.hh @@ -1,4 +1,4 @@ -// Copyright (C) 2007 EPITA Research and Development Laboratory +// Copyright (C) 2007, 2009 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 @@ -28,13 +28,12 @@ #ifndef MLN_CORE_INTERNAL_IMAGE_IDENTITY_HH # define MLN_CORE_INTERNAL_IMAGE_IDENTITY_HH -/*! \file mln/core/internal/image_identity.hh - * - * \brief Definition of a base class for image morphers w.r.t. identity. - * - * \todo Move "fastest impl" elsewhere; it can be used by some other - * classes. - */ +/// \file mln/core/internal/image_identity.hh +/// +/// Definition of a base class for image morphers w.r.t. identity. +/// +/// \todo Move "fastest impl" elsewhere; it can be used by some other +/// classes. # include <mln/core/internal/image_morpher.hh> diff --git a/milena/mln/core/routine/essential.hh b/milena/mln/core/routine/essential.hh index 26568e5..dfc3d44 100644 --- a/milena/mln/core/routine/essential.hh +++ b/milena/mln/core/routine/essential.hh @@ -1,4 +1,4 @@ -// Copyright (C) 2008 EPITA Research and Development Laboratory +// Copyright (C) 2008, 2009 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 @@ -28,11 +28,11 @@ #ifndef MLN_CORE_ROUTINE_ESSENTIAL_HH_ # define MLN_CORE_ROUTINE_ESSENTIAL_HH_ -# include <mln/core/routine/duplicate.hh> -# include <mln/core/routine/exact.hh> -# include <mln/core/routine/extend.hh> -# include <mln/core/routine/initialize.hh> -# include <mln/core/routine/ops.hh> +/// \file mln/core/routine/essential.hh +/// +/// File that includes essential core routines. + +# include <mln/core/routine/all.hh> #endif // !MLN_CORE_ROUTINE_ESSENTIAL_HH_ diff --git a/milena/mln/fun/essential.hh b/milena/mln/fun/essential.hh index 9626e45..393242e 100644 --- a/milena/mln/fun/essential.hh +++ b/milena/mln/fun/essential.hh @@ -1,4 +1,4 @@ -// Copyright (C) 2008 EPITA Research and Development Laboratory +// Copyright (C) 2008, 2009 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 @@ -28,14 +28,14 @@ #ifndef MLN_FUN_ESSENTIAL_HH # define MLN_FUN_ESSENTIAL_HH -/*! \file mln/fun/essential.hh - * - * \brief File that includes essential fun-related routines. - */ +/// \file mln/fun/essential.hh +/// +/// File that includes essential fun-related routines. # include <mln/fun/c.hh> # include <mln/fun/ops.hh> # include <mln/fun/i2v/essential.hh> +# include <mln/fun/meta/essential.hh> # include <mln/fun/p2b/essential.hh> # include <mln/fun/p2v/essential.hh> # include <mln/fun/v2b/essential.hh> diff --git a/milena/mln/fun/i2v/array.hh b/milena/mln/fun/i2v/array.hh index 13b6d5e..cd00db5 100644 --- a/milena/mln/fun/i2v/array.hh +++ b/milena/mln/fun/i2v/array.hh @@ -75,11 +75,22 @@ namespace mln void from_to_(const util::array<T>& from, fun::i2v::array<T>& to); + template <typename T, typename U> + inline + void + from_to_(const util::array<T>& from, fun::i2v::array<U>& to); + template <typename T> inline void from_to_(const std::vector<T>& from, fun::i2v::array<T>& to); + template <typename T, typename U> + inline + void + from_to_(const std::vector<T>& from, fun::i2v::array<U>& to); + + } // end of namespace mln::convert::over_load } // end of namespace mln::convert @@ -157,6 +168,17 @@ namespace mln to = fun::i2v::array<T>(from); } + template <typename T, typename U> + inline + void + from_to_(const util::array<T>& from, fun::i2v::array<U>& to) + { + mlc_converts_to(T,U)::check(); + + for (unsigned i = 0; i < from.nelements(); ++i) + to.append(convert::to<U>(from[i])); + } + template <typename T> inline void @@ -165,6 +187,18 @@ namespace mln to = fun::i2v::array<T>(from); } + template <typename T, typename U> + inline + void + from_to_(const std::vector<T>& from, fun::i2v::array<U>& to) + { + mlc_converts_to(T,U)::check(); + + for (unsigned i = 0; i < from.size(); ++i) + to.append(convert::to<U>(from[i])); + } + + } // end of namespace mln::convert::over_load } // end of namespace mln::convert diff --git a/milena/mln/fun/l2l/relabel.hh b/milena/mln/fun/l2l/relabel.hh index 16da5b4..a57f3d4 100644 --- a/milena/mln/fun/l2l/relabel.hh +++ b/milena/mln/fun/l2l/relabel.hh @@ -72,12 +72,24 @@ namespace mln from_to_(const util::array<L>& from, fun::l2l::relabel<L>& to); + template <typename T, typename L> + inline + void + from_to_(const util::array<T>& from, + fun::l2l::relabel<L>& to); + template <typename L> inline void from_to_(const std::vector<L>& from, fun::l2l::relabel<L>& to); + template <typename T, typename L> + inline + void + from_to_(const std::vector<T>& from, + fun::l2l::relabel<L>& to); + } // end of namespace mln::convert::over_load } // end of namespace mln::convert @@ -155,6 +167,17 @@ namespace mln to = fun::l2l::relabel<L>(from); } + template <typename T, typename L> + inline + void + from_to_(const util::array<T>& from, fun::l2l::relabel<L>& to) + { + mlc_converts_to(T,L)::check(); + + for (unsigned i = 0; i < from.nelements(); ++i) + to.append(convert::to<L>(from[i])); + } + template <typename L> inline void @@ -163,6 +186,17 @@ namespace mln to = fun::l2l::relabel<L>(from); } + template <typename T, typename L> + inline + void + from_to_(const std::vector<T>& from, fun::l2l::relabel<L>& to) + { + mlc_converts_to(T,L)::check(); + + for (unsigned i = 0; i < from.size(); ++i) + to.append(convert::to<L>(from[i])); + } + } // end of namespace mln::convert::over_load } // end of namespace mln::convert diff --git a/milena/mln/util/soft_heap.hh b/milena/mln/util/soft_heap.hh index bff9d11..e0f8768 100644 --- a/milena/mln/util/soft_heap.hh +++ b/milena/mln/util/soft_heap.hh @@ -25,8 +25,8 @@ // reasons why the executable file might be covered by the GNU General // Public License. -#ifndef MLN_UTIL_FAST_HEAP_HH -# define MLN_UTIL_FAST_HEAP_HH +#ifndef MLN_UTIL_SOFT_HEAP_HH +# define MLN_UTIL_SOFT_HEAP_HH /// \file mln/util/soft_heap.hh /// @@ -1132,4 +1132,4 @@ namespace mln } // end of namespace mln -#endif // ! MLN_UTIL_FAST_HEAP_HH +#endif // ! MLN_UTIL_SOFT_HEAP_HH diff --git a/milena/mln/win/essential.hh b/milena/mln/win/essential.hh index e6fe809..00a4995 100644 --- a/milena/mln/win/essential.hh +++ b/milena/mln/win/essential.hh @@ -1,4 +1,4 @@ -// Copyright (C) 2008 EPITA Research and Development Laboratory +// Copyright (C) 2009 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 @@ -28,10 +28,9 @@ #ifndef MLN_WIN_ESSENTIAL_HH # define MLN_WIN_ESSENTIAL_HH -/*! \file mln/win/essential.hh - * - * \brief File that includes essential win-related routines. - */ +/// \file mln/win/essential.hh +/// +/// File that includes essential win-related routines. // Types. -- 1.5.6.5
15 years, 9 months
1
0
0
0
3506: Add meta::first and meta::second.
by Guillaume Lazzara
* mln/fun/meta/all.hh, * mln/fun/meta/essential.hh: include new headers. * mln/fun/meta/first.hh, * mln/fun/meta/second.hh: meta function to access util::couple data. --- milena/ChangeLog | 10 ++++ milena/mln/fun/meta/all.hh | 19 ++++--- milena/mln/fun/meta/{all.hh => essential.hh} | 31 ++--------- milena/mln/fun/meta/{all.hh => first.hh} | 69 ++++++++++++++++++++------ milena/mln/fun/meta/{all.hh => second.hh} | 69 ++++++++++++++++++++------ 5 files changed, 134 insertions(+), 64 deletions(-) copy milena/mln/fun/meta/{all.hh => essential.hh} (69%) copy milena/mln/fun/meta/{all.hh => first.hh} (52%) copy milena/mln/fun/meta/{all.hh => second.hh} (52%) diff --git a/milena/ChangeLog b/milena/ChangeLog index 994c509..4f0c24c 100644 --- a/milena/ChangeLog +++ b/milena/ChangeLog @@ -1,3 +1,13 @@ +2009-03-10 Guillaume Lazzara <lazzara(a)lrde.epita.fr> + + Add meta::first and meta::second. + + * mln/fun/meta/all.hh, + * mln/fun/meta/essential.hh: include new headers. + + * mln/fun/meta/first.hh, + * mln/fun/meta/second.hh: meta function to access util::couple data. + 2009-03-09 Edwin Carlinet <carlinet(a)lrde.epita.fr> Add leaves container in tree structure and test new propagations. diff --git a/milena/mln/fun/meta/all.hh b/milena/mln/fun/meta/all.hh index 23d7bc2..49bd5b5 100644 --- a/milena/mln/fun/meta/all.hh +++ b/milena/mln/fun/meta/all.hh @@ -40,15 +40,16 @@ namespace mln } // end of namespace mln -#include<mln/fun/meta/red.hh> -#include<mln/fun/meta/hue.hh> -#include<mln/fun/meta/lum.hh> -#include<mln/fun/meta/all.hh> -#include<mln/fun/meta/green.hh> -#include<mln/fun/meta/inty.hh> -#include<mln/fun/meta/blue.hh> -#include<mln/fun/meta/sat.hh> -#include<mln/fun/meta/to_enc.hh> +# include <mln/fun/meta/blue.hh> +# include <mln/fun/meta/first.hh> +# include <mln/fun/meta/green.hh> +# include <mln/fun/meta/hue.hh> +# include <mln/fun/meta/inty.hh> +# include <mln/fun/meta/lum.hh> +# include <mln/fun/meta/red.hh> +# include <mln/fun/meta/sat.hh> +# include <mln/fun/meta/second.hh> +# include <mln/fun/meta/to_enc.hh> #endif // ! MLN_FUN_META_ALL_HH diff --git a/milena/mln/fun/meta/all.hh b/milena/mln/fun/meta/essential.hh similarity index 69% copy from milena/mln/fun/meta/all.hh copy to milena/mln/fun/meta/essential.hh index 23d7bc2..821a0a9 100644 --- a/milena/mln/fun/meta/all.hh +++ b/milena/mln/fun/meta/essential.hh @@ -1,5 +1,5 @@ -// Copyright (C) 2007, 2008, 2009 EPITA Research and Development -// Laboratory (LRDE) +// Copyright (C) 2009 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 @@ -26,29 +26,10 @@ // reasons why the executable file might be covered by the GNU General // Public License. -#ifndef MLN_FUN_META_ALL_HH -# define MLN_FUN_META_ALL_HH +#ifndef MLN_FUN_META_ESSENTIAL_HH +# define MLN_FUN_META_ESSENTIAL_HH -namespace mln -{ +# include <mln/fun/meta/all.hh> - namespace meta - { - - } // end of namespace mln::meta - -} // end of namespace mln - - -#include<mln/fun/meta/red.hh> -#include<mln/fun/meta/hue.hh> -#include<mln/fun/meta/lum.hh> -#include<mln/fun/meta/all.hh> -#include<mln/fun/meta/green.hh> -#include<mln/fun/meta/inty.hh> -#include<mln/fun/meta/blue.hh> -#include<mln/fun/meta/sat.hh> -#include<mln/fun/meta/to_enc.hh> - -#endif // ! MLN_FUN_META_ALL_HH +#endif // ! MLN_FUN_META_ESSENTIAL_HH diff --git a/milena/mln/fun/meta/all.hh b/milena/mln/fun/meta/first.hh similarity index 52% copy from milena/mln/fun/meta/all.hh copy to milena/mln/fun/meta/first.hh index 23d7bc2..89d3f12 100644 --- a/milena/mln/fun/meta/all.hh +++ b/milena/mln/fun/meta/first.hh @@ -1,5 +1,5 @@ -// Copyright (C) 2007, 2008, 2009 EPITA Research and Development -// Laboratory (LRDE) +// Copyright (C) 2009 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 @@ -26,8 +26,15 @@ // reasons why the executable file might be covered by the GNU General // Public License. -#ifndef MLN_FUN_META_ALL_HH -# define MLN_FUN_META_ALL_HH +#ifndef MLN_FUN_META_FIRST_HH +# define MLN_FUN_META_FIRST_HH + +/// \file mln/fun/meta/first.hh +/// +/// Meta function to retrieve/modify the first component. + +# include <mln/core/concept/meta_fun.hh> +# include <mln/util/couple.hh> namespace mln { @@ -35,20 +42,52 @@ namespace mln namespace meta { + template <class T> + struct first : impl< first<T> > + { + typedef T value; + }; + } // end of namespace mln::meta -} // end of namespace mln + template <typename T, typename U> + struct function< meta::first< util::couple<T,U> > > + : public Function_v2w_w2v<function< meta::first < util::couple<T,U> > > > + { + typedef util::couple<T,U> value; + + typedef T result; + result read(const value& c); + + typedef result& lresult; + lresult write(value& c); + }; + + +# ifndef MLN_INCLUDE_ONLY -#include<mln/fun/meta/red.hh> -#include<mln/fun/meta/hue.hh> -#include<mln/fun/meta/lum.hh> -#include<mln/fun/meta/all.hh> -#include<mln/fun/meta/green.hh> -#include<mln/fun/meta/inty.hh> -#include<mln/fun/meta/blue.hh> -#include<mln/fun/meta/sat.hh> -#include<mln/fun/meta/to_enc.hh> -#endif // ! MLN_FUN_META_ALL_HH + template <typename T, typename U> + inline + typename function< meta::first< util::couple<T,U> > >::result + function< meta::first< util::couple<T,U> > >::read(const value& c) + { + return c.first(); + } + + template <typename T, typename U> + inline + typename function< meta::first< util::couple<T,U> > >::lresult + function< meta::first< util::couple<T,U> > >::write(value& c) + { + return c.first(); + } + + +# endif // ! MLN_INCLUDE_ONLY + + +} // end of namespace mln +#endif // MLN_FUN_META_FIRST_HH diff --git a/milena/mln/fun/meta/all.hh b/milena/mln/fun/meta/second.hh similarity index 52% copy from milena/mln/fun/meta/all.hh copy to milena/mln/fun/meta/second.hh index 23d7bc2..5f94846 100644 --- a/milena/mln/fun/meta/all.hh +++ b/milena/mln/fun/meta/second.hh @@ -1,5 +1,5 @@ -// Copyright (C) 2007, 2008, 2009 EPITA Research and Development -// Laboratory (LRDE) +// Copyright (C) 2009 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 @@ -26,8 +26,15 @@ // reasons why the executable file might be covered by the GNU General // Public License. -#ifndef MLN_FUN_META_ALL_HH -# define MLN_FUN_META_ALL_HH +#ifndef MLN_FUN_META_SECOND_HH +# define MLN_FUN_META_SECOND_HH + +/// \file mln/fun/meta/second.hh +/// +/// Meta function to retrieve/modify the second component. + +# include <mln/core/concept/meta_fun.hh> +# include <mln/util/couple.hh> namespace mln { @@ -35,20 +42,52 @@ namespace mln namespace meta { + template <class T> + struct second : impl< second<T> > + { + typedef T value; + }; + } // end of namespace mln::meta -} // end of namespace mln + template <typename T, typename U> + struct function< meta::second< util::couple<T,U> > > + : public Function_v2w_w2v<function< meta::second < util::couple<T,U> > > > + { + typedef util::couple<T,U> value; + + typedef T result; + result read(const value& c); + + typedef result& lresult; + lresult write(value& c); + }; + + +# ifndef MLN_INCLUDE_ONLY -#include<mln/fun/meta/red.hh> -#include<mln/fun/meta/hue.hh> -#include<mln/fun/meta/lum.hh> -#include<mln/fun/meta/all.hh> -#include<mln/fun/meta/green.hh> -#include<mln/fun/meta/inty.hh> -#include<mln/fun/meta/blue.hh> -#include<mln/fun/meta/sat.hh> -#include<mln/fun/meta/to_enc.hh> -#endif // ! MLN_FUN_META_ALL_HH + template <typename T, typename U> + inline + typename function< meta::second< util::couple<T,U> > >::result + function< meta::second< util::couple<T,U> > >::read(const value& c) + { + return c.second(); + } + + template <typename T, typename U> + inline + typename function< meta::second< util::couple<T,U> > >::lresult + function< meta::second< util::couple<T,U> > >::write(value& c) + { + return c.second(); + } + + +# endif // ! MLN_INCLUDE_ONLY + + +} // end of namespace mln +#endif // MLN_FUN_META_SECOND_HH -- 1.5.6.5
15 years, 9 months
1
0
0
0
← Newer
1
...
11
12
13
14
15
16
17
...
21
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
Results per page:
10
25
50
100
200