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
December 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
12 participants
201 discussions
Start a n
N
ew thread
3065: Replace some remaining .at by opt::at.
by Nicolas Ballas
https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog from Nicolas Ballas <ballas(a)lrde.epita.fr> Replace some remaining .at by opt::at. * sandbox/aroumougame/skeleton/sedt.hh, * sandbox/dalila/demat.hh, * sandbox/abraham/mln/transform/fft.hh, * sandbox/ballas/color/min_tree_volume_filter.cc, * sandbox/ballas/color/reference.cc, * sandbox/ballas/color/min_tree_area_filter.cc, * sandbox/ballas/color/min_tree_height_filter.cc, * sandbox/ballas/color/min_tree_color.cc, * sandbox/ballas/color/reference2.cc, * sandbox/ballas/color/src/graph.hh, * sandbox/ballas/color/min_tree_color_v2.cc, * sandbox/geraud/wst_edge.cc, * sandbox/geraud/fllt.svg.6.cc, * sandbox/geraud/fllt/fllt.svg.2.cc, * sandbox/geraud/fllt/fllt.svg.3.cc, * sandbox/geraud/fllt/fllt.svg.4.cc, * sandbox/geraud/fllt/fllt.svg.5.cc, * sandbox/geraud/fllt/fllt.svg.6.cc: Update. abraham/mln/transform/fft.hh | 2 +- aroumougame/skeleton/sedt.hh | 6 +++--- ballas/color/min_tree_area_filter.cc | 4 ++-- ballas/color/min_tree_color.cc | 6 ++++-- ballas/color/min_tree_color_v2.cc | 6 ++++-- ballas/color/min_tree_height_filter.cc | 6 ++++-- ballas/color/min_tree_volume_filter.cc | 4 ++-- ballas/color/reference.cc | 4 ++-- ballas/color/reference2.cc | 4 ++-- ballas/color/src/graph.hh | 3 ++- dalila/demat.hh | 22 ++++++++++++---------- geraud/fllt.svg.6.cc | 3 ++- geraud/fllt/fllt.svg.2.cc | 3 ++- geraud/fllt/fllt.svg.3.cc | 3 ++- geraud/fllt/fllt.svg.4.cc | 3 ++- geraud/fllt/fllt.svg.5.cc | 3 ++- geraud/fllt/fllt.svg.6.cc | 2 +- geraud/wst_edge.cc | 5 +++-- 18 files changed, 52 insertions(+), 37 deletions(-) Index: sandbox/aroumougame/skeleton/sedt.hh --- sandbox/aroumougame/skeleton/sedt.hh (revision 3064) +++ sandbox/aroumougame/skeleton/sedt.hh (working copy) @@ -92,7 +92,7 @@ } else { - v=1+(j*j-s[q]*s[q]+g.at(j,i)*g.at(j,i)-g.at(s[q],i)*opt::at(g, s[q],i))/(2*(j-s[q])); + v=1+(j*j-s[q]*s[q]+opt::at(g,j,i)*opt::at(g,j,i)-opt::at(g,s[q],i)*opt::at(g, s[q],i))/(2*(j-s[q])); if(v<h) { q++; @@ -104,7 +104,7 @@ for(int j= h-1; j>=0; j--) { - dt.at(j,i)= opt::at(g, s[q],i)*opt::at(g, s[q],i)+(j-s[q])*(j-s[q]); + opt::at(dt,j,i)= opt::at(g, s[q],i)*opt::at(g, s[q],i)+(j-s[q])*(j-s[q]); if(j==t[q]) q--; } @@ -184,7 +184,7 @@ { for( int j=0; j<L; j++) { - dt.at(i,j) = opt::at(DTg, i,j); + opt::at(dt,i,j) = opt::at(DTg, i,j); } } return dt; Index: sandbox/dalila/demat.hh --- sandbox/dalila/demat.hh (revision 3064) +++ sandbox/dalila/demat.hh (working copy) @@ -45,6 +45,8 @@ # include <mln/core/site_set/p_vaccess.hh> # include <mln/core/site_set/p_set.hh> +# include <mln/opt/at.hh> + # include <mln/accu/bbox.hh> # include <mln/accu/count.hh> @@ -199,16 +201,16 @@ for (unsigned i = 1; i < tboxes.first.nelements(); ++i) { - ++vend.at(tboxes.first[i].pmin().row()); - ++vend.at(tboxes.first[i].pmax().row()); - ++vcol.at(tboxes.first[i].center().col()); + opt::at(++vend, tboxes.first[i].pmin().row()); + opt::at(++vend, tboxes.first[i].pmax().row()); + opt::at(++vcol, tboxes.first[i].center().col()); } for (unsigned i = 1; i < tboxes.second.nelements(); ++i) { - ++hend.at(tboxes.second[i].pmin().col()); - ++hend.at(tboxes.second[i].pmax().col()); - ++hrow.at(tboxes.second[i].center().row()); + opt::at(++hend, tboxes.second[i].pmin().col()); + opt::at(++hend, tboxes.second[i].pmax().col()); + opt::at(++hrow, tboxes.second[i].center().row()); } #ifndef NOUT @@ -217,17 +219,17 @@ for (unsigned i = 1; i < in.ncols(); ++i) { - if (hend.at(i) > 0) + if (opt::at(hend, i) > 0) draw_col(tmp, i, literal::orange); - if (vcol.at(i) > 0) + if (opt::at(vcol, i) > 0) draw_col(tmp, i, literal::orange); } for (unsigned i = 1; i < in.nrows(); ++i) { - if (hrow.at(i) > 0) + if (opt::at(hrow, i) > 0) draw_row(tmp, i, literal::magenta); - if (vend.at(i) > 0) + if (opt::at(vend, i) > 0) draw_row(tmp, i, literal::magenta); } Index: sandbox/abraham/mln/transform/fft.hh --- sandbox/abraham/mln/transform/fft.hh (revision 3064) +++ sandbox/abraham/mln/transform/fft.hh (working copy) @@ -442,7 +442,7 @@ } for (unsigned row = 0; row < this->trans_im.nrows(); ++row) for (unsigned col = this->trans_im.ncols() - 1; col > this->trans_im.ncols() / 2; --col) - this->trans_im.at(row, col) = opt::at(this->trans_im, this->trans_im.nrows() - row - 1, + at(this->trans_im, row, col) = opt::at(this->trans_im, this->trans_im.nrows() - row - 1, this->trans_im.ncols() - col - 1); return this->trans_im; } Index: sandbox/ballas/color/min_tree_volume_filter.cc --- sandbox/ballas/color/min_tree_volume_filter.cc (revision 3064) +++ sandbox/ballas/color/min_tree_volume_filter.cc (working copy) @@ -387,7 +387,7 @@ 2 * input.ncols() - 1); for (unsigned row = 0; row < input.nrows(); ++row) for (unsigned col = 0; col < input.ncols(); ++col) - output.at(2 * row, 2 * col) = mln::opt::at(input, row, col); + mln::opt::at(output, 2 * row, 2 * col) = mln::opt::at(input, row, col); return output; } @@ -400,7 +400,7 @@ (input.ncols() + 1) / 2); for (unsigned row = 0; row < input.nrows(); row += 2) for (unsigned col = 0; col < input.ncols(); col += 2) - output.at(row / 2, col / 2) = mln::opt::at(input, row, col); + mln::opt::at(output, row / 2, col / 2) = mln::opt::at(input, row, col); return output; } Index: sandbox/ballas/color/reference.cc --- sandbox/ballas/color/reference.cc (revision 3064) +++ sandbox/ballas/color/reference.cc (working copy) @@ -351,7 +351,7 @@ 2 * input.ncols() - 1); for (int row = 0; row < input.nrows(); ++row) for (int col = 0; col < input.ncols(); ++col) - output.at(2 * row, 2 * col) = mln::opt::at(input, row, col); + mln::opt::at(output, 2 * row, 2 * col) = mln::opt::at(input, row, col); return output; } @@ -417,7 +417,7 @@ (input.ncols() + 1) / 2); for (int row = 0; row < input.nrows(); row += 2) for (int col = 0; col < input.ncols(); col += 2) - output.at(row / 2, col / 2) = mln::opt::at(input, row, col); + mln::opt::at(output, row / 2, col / 2) = mln::opt::at(input, row, col); return output; } Index: sandbox/ballas/color/min_tree_area_filter.cc --- sandbox/ballas/color/min_tree_area_filter.cc (revision 3064) +++ sandbox/ballas/color/min_tree_area_filter.cc (working copy) @@ -364,7 +364,7 @@ 2 * input.ncols() - 1); for (unsigned row = 0; row < input.nrows(); ++row) for (unsigned col = 0; col < input.ncols(); ++col) - output.at(2 * row, 2 * col) = mln::opt::at(input, row, col); + mln::opt::at(output, 2 * row, 2 * col) = mln::opt::at(input, row, col); return output; } @@ -377,7 +377,7 @@ (input.ncols() + 1) / 2); for (unsigned row = 0; row < input.nrows(); row += 2) for (unsigned col = 0; col < input.ncols(); col += 2) - output.at(row / 2, col / 2) = mln::opt::at(input, row, col); + mln::opt::at(output, row / 2, col / 2) = mln::opt::at(input, row, col); return output; } Index: sandbox/ballas/color/min_tree_height_filter.cc --- sandbox/ballas/color/min_tree_height_filter.cc (revision 3064) +++ sandbox/ballas/color/min_tree_height_filter.cc (working copy) @@ -387,7 +387,8 @@ 2 * input.ncols() - 1); for (unsigned row = 0; row < input.nrows(); ++row) for (unsigned col = 0; col < input.ncols(); ++col) - output.at(2 * row, 2 * col) = mln::opt::at(input, row, col); + mln::opt::at(output, 2 * row, 2 * col) = + mln::opt::at(input, row, col); return output; } @@ -400,7 +401,8 @@ (input.ncols() + 1) / 2); for (unsigned row = 0; row < input.nrows(); row += 2) for (unsigned col = 0; col < input.ncols(); col += 2) - output.at(row / 2, col / 2) = mln::opt::at(input, row, col); + mln::opt::at(output, row / 2, col / 2) = + mln::opt::at(input, row, col); return output; } Index: sandbox/ballas/color/min_tree_color.cc --- sandbox/ballas/color/min_tree_color.cc (revision 3064) +++ sandbox/ballas/color/min_tree_color.cc (working copy) @@ -381,7 +381,8 @@ 2 * input.ncols() - 1); for (unsigned row = 0; row < input.nrows(); ++row) for (unsigned col = 0; col < input.ncols(); ++col) - output.at(2 * row, 2 * col) = mln::opt::at(input, row, col); + mln::opt::at(output, 2 * row, 2 * col) = + mln::opt::at(input, row, col); return output; } @@ -394,7 +395,8 @@ (input.ncols() + 1) / 2); for (unsigned row = 0; row < input.nrows(); row += 2) for (unsigned col = 0; col < input.ncols(); col += 2) - output.at(row / 2, col / 2) = mln::opt::at(input, row, col); + mln::opt::at(output, row / 2, col / 2) = + mln::opt::at(input, row, col); return output; } Index: sandbox/ballas/color/reference2.cc --- sandbox/ballas/color/reference2.cc (revision 3064) +++ sandbox/ballas/color/reference2.cc (working copy) @@ -295,7 +295,7 @@ 2 * input.ncols() - 1); for (int row = 0; row < input.nrows(); ++row) for (int col = 0; col < input.ncols(); ++col) - output.at(2 * row, 2 * col) = mln::opt::at(input, row, col); + mln::opt::at(output, 2 * row, 2 * col) = mln::opt::at(input, row, col); return output; } @@ -308,7 +308,7 @@ (input.ncols() + 1) / 2); for (int row = 0; row < input.nrows(); row += 2) for (int col = 0; col < input.ncols(); col += 2) - output.at(row / 2, col / 2) = mln::opt::at(input, row, col); + mln::opt::at(output, row / 2, col / 2) = mln::opt::at(input, row, col); return output; } Index: sandbox/ballas/color/src/graph.hh --- sandbox/ballas/color/src/graph.hh (revision 3064) +++ sandbox/ballas/color/src/graph.hh (working copy) @@ -10,6 +10,7 @@ # include <mln/value/rgb8.hh> # include <mln/level/fill.hh> +# include <mln/opt/at.hh> # include <mln/core/image/image2d.hh> @@ -54,7 +55,7 @@ mln_piter(I) p(ima.domain()); for_all(p) - graph.at(p.row() * 2, p.col() * 2) = ima(p); + mln::opt::at(graph, p.row() * 2, p.col() * 2) = ima(p); } Index: sandbox/ballas/color/min_tree_color_v2.cc --- sandbox/ballas/color/min_tree_color_v2.cc (revision 3064) +++ sandbox/ballas/color/min_tree_color_v2.cc (working copy) @@ -370,7 +370,8 @@ 2 * input.ncols() - 1); for (unsigned row = 0; row < input.nrows(); ++row) for (unsigned col = 0; col < input.ncols(); ++col) - output.at(2 * row, 2 * col) = mln::opt::at(input, row, col); + mln::opt::at(output, 2 * row, 2 * col) = + mln::opt::at(input, row, col); return output; } @@ -383,7 +384,8 @@ (input.ncols() + 1) / 2); for (unsigned row = 0; row < input.nrows(); row += 2) for (unsigned col = 0; col < input.ncols(); col += 2) - output.at(row / 2, col / 2) = mln::opt::at(input, row, col); + mln::opt::at(output, row / 2, col / 2) = + mln::opt::at(input, row, col); return output; } Index: sandbox/geraud/wst_edge.cc --- sandbox/geraud/wst_edge.cc (revision 3064) +++ sandbox/geraud/wst_edge.cc (working copy) @@ -242,7 +242,7 @@ 2 * input.ncols() - 1); for (int row = 0; row < input.nrows(); ++row) for (int col = 0; col < input.ncols(); ++col) - output.at(2 * row, 2 * col) = mln::opt::at(input, row, col); + mln::opt::at(output, 2 * row, 2 * col) = mln::opt::at(input, row, col); return output; } @@ -255,7 +255,8 @@ (input.ncols() + 1) / 2); for (int row = 0; row < input.nrows(); row += 2) for (int col = 0; col < input.ncols(); col += 2) - output.at(row / 2, col / 2) = mln::opt::at(input, row, col); + mln::opt::at(output, row / 2, col / 2) = + mln::opt::at(input, row, col); return output; } Index: sandbox/geraud/fllt.svg.6.cc --- sandbox/geraud/fllt.svg.6.cc (revision 3064) +++ sandbox/geraud/fllt.svg.6.cc (working copy) @@ -179,7 +179,8 @@ image2d<T> output(nrows_, ncols_); for (int row = 0; row < nrows_; ++row) for (int col = 0; col < ncols_; ++col) - output.at(row, col) = mln::opt::at(input, row / coef, col / coef); + mln::opt::at(output, row, col) = + mln::opt::at(input, row / coef, col / coef); return output; } Index: sandbox/geraud/fllt/fllt.svg.2.cc --- sandbox/geraud/fllt/fllt.svg.2.cc (revision 3064) +++ sandbox/geraud/fllt/fllt.svg.2.cc (working copy) @@ -102,7 +102,8 @@ image2d<T> output(nrows_, ncols_); for (int row = 0; row < nrows_; ++row) for (int col = 0; col < ncols_; ++col) - output.at(row, col) = mln::opt::at(input, row / coef, col / coef); + opt::at(output, row, col) = + mln::opt::at(input, row / coef, col / coef); return output; } Index: sandbox/geraud/fllt/fllt.svg.3.cc --- sandbox/geraud/fllt/fllt.svg.3.cc (revision 3064) +++ sandbox/geraud/fllt/fllt.svg.3.cc (working copy) @@ -103,7 +103,8 @@ image2d<T> output(nrows_, ncols_); for (int row = 0; row < nrows_; ++row) for (int col = 0; col < ncols_; ++col) - output.at(row, col) = mln::opt::at(input, row / coef, col / coef); + mln::opt::at(output, row, col) = + mln::opt::at(input, row / coef, col / coef); return output; } Index: sandbox/geraud/fllt/fllt.svg.4.cc --- sandbox/geraud/fllt/fllt.svg.4.cc (revision 3064) +++ sandbox/geraud/fllt/fllt.svg.4.cc (working copy) @@ -105,7 +105,8 @@ image2d<T> output(nrows_, ncols_); for (int row = 0; row < nrows_; ++row) for (int col = 0; col < ncols_; ++col) - output.at(row, col) = mln::opt::at(input, row / coef, col / coef); + mln::opt::at(output, row, col) = + mln::opt::at(input, row / coef, col / coef); return output; } Index: sandbox/geraud/fllt/fllt.svg.5.cc --- sandbox/geraud/fllt/fllt.svg.5.cc (revision 3064) +++ sandbox/geraud/fllt/fllt.svg.5.cc (working copy) @@ -105,7 +105,8 @@ image2d<T> output(nrows_, ncols_); for (int row = 0; row < nrows_; ++row) for (int col = 0; col < ncols_; ++col) - output.at(row, col) = mln::opt::at(input, row / coef, col / coef); + opt::at(output, row, col) = + mln::opt::at(input, row / coef, col / coef); return output; } Index: sandbox/geraud/fllt/fllt.svg.6.cc --- sandbox/geraud/fllt/fllt.svg.6.cc (revision 3064) +++ sandbox/geraud/fllt/fllt.svg.6.cc (working copy) @@ -177,7 +177,7 @@ image2d<T> output(nrows_, ncols_); for (int row = 0; row < nrows_; ++row) for (int col = 0; col < ncols_; ++col) - output.at(row, col) = input.at(row / coef, col / coef); + opt::at(output, row, col) = opt::at(input, row / coef, col / coef); return output; }
16 years
1
0
0
0
3064: Add milena/tests/opt/Makefile in configure.ac.
by Nicolas Ballas
https://svn.lrde.epita.fr/svn/oln/trunk
Index: ChangeLog from Nicolas Ballas <ballas(a)lrde.epita.fr> Add milena/tests/opt/Makefile in configure.ac. * configure.ac: Update. configure.ac | 1 + 1 file changed, 1 insertion(+) Index: configure.ac --- configure.ac (revision 3063) +++ configure.ac (working copy) @@ -217,6 +217,7 @@ milena/tests/morpho/elementary/Makefile milena/tests/morpho/tree/Makefile milena/tests/norm/Makefile + milena/tests/opt/Makefile milena/tests/pw/Makefile milena/tests/set/Makefile milena/tests/subsampling/Makefile
16 years
1
0
0
0
3063: Replace calls of the method .at by the function opt::at.
by Nicolas Ballas
https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog from Nicolas Ballas <ballas(a)lrde.epita.fr> Replace calls of the method .at by the function opt::at. * mln/debug/println.spe.hh, * mln/core/pixter2d.hh, * mln/core/pixter3d.hh, * mln/level/was.median.hh, * mln/make/image.hh, * sandbox/duhamel/chamfer.cc, * sandbox/scribo/demat.hh, * sandbox/aroumougame/skeleton/miscellenous.hh, * sandbox/aroumougame/skeleton/sedt.hh, * sandbox/jardonnet/n_cmpt/fused_filter.cc, * sandbox/jardonnet/n_cmpt/ref_filter.cc, * sandbox/garrigues/ocr/skeleton.old.hh, * sandbox/garrigues/ocr/enlarge.hh, * sandbox/abraham/tests/transform/fft_.cc, * sandbox/abraham/mln/transform/fft.hh, * sandbox/inim/classif/src/proj.hh, * sandbox/inim/binarization/proof-of-concept/src/gradient.cc, * sandbox/inim/binarization/binarization.hh, * sandbox/nature/nature.cc, * sandbox/nature/co_occurence.hh, * sandbox/nature/proj.hh, * sandbox/ballas/color/min_tree_volume_filter.cc, * sandbox/ballas/color/reference.cc, * sandbox/ballas/color/min_tree_area_filter.cc, * sandbox/ballas/color/min_tree_height_filter.cc, * sandbox/ballas/color/min_tree_color.cc, * sandbox/ballas/color/reference2.cc, * sandbox/ballas/color/min_tree_color_v2.cc, * sandbox/ballas/color/laplacien.cc, * sandbox/geraud/wst_edge.cc, * sandbox/geraud/fllt.svg.6.cc, * sandbox/geraud/browsing/fwd.cc, * sandbox/geraud/fllt/fllt.hh, * sandbox/geraud/fllt/fllt.svg.7.hh, * sandbox/geraud/fllt/fllt.svg.2.cc, * sandbox/geraud/fllt/fllt.svg.3.cc, * sandbox/geraud/fllt/fllt.svg.4.cc, * sandbox/geraud/fllt/fllt.svg.5.cc, * sandbox/geraud/fllt/fllt_test.hh, * sandbox/geraud/fllt.svg.7.hh, * sandbox/geraud/dmap.cc, * sandbox/geraud/tufa_2008/steps.0.cc, * sandbox/geraud/tufa_2008/steps.1.cc, * sandbox/geraud/tufa_2008/steps.2.cc, * sandbox/geraud/tufa_2008/steps.3.cc, * sandbox/geraud/tufa_2008/steps.2b.cc, * sandbox/geraud/tufa_2008/compute_a.cc, * sandbox/geraud/tufa_2008/fz_count.cc, * sandbox/geraud/tufa_2008/regmin_count.cc, * tests/debug/println_with_border.cc, * tests/debug/println.cc, * tests/histo/compute.cc, * tests/core/other/pixel.cc, * tests/level/convert.cc, * tests/level/memset_.cc, * tests/transform/distance_geodesic.cc, * tests/transform/distance_front.cc, * tests/make/dual_neighb.cc, * tests/morpho/artificial_line_graph_image_wst.cc, * tests/canvas/chamfer.cc, * doc/tutorial/samples/ima2d-3.cc, * doc/tutorial/examples/image_plain.cc, * doc/benchmark/image2d.cc, * doc/examples/labeling_algo.cc: Replace .at by opt::add. * tests/opt/Makefile.am: New Makefile.am for opt test dir. * tests/Makefile.am: Add opt subdir. doc/benchmark/image2d.cc | 5 doc/examples/labeling_algo.cc | 4 doc/tutorial/examples/image_plain.cc | 9 - doc/tutorial/samples/ima2d-3.cc | 8 - mln/core/pixter2d.hh | 5 mln/core/pixter3d.hh | 9 - mln/debug/println.spe.hh | 5 mln/level/was.median.hh | 12 + mln/make/image.hh | 5 sandbox/abraham/mln/transform/fft.hh | 27 ++-- sandbox/abraham/tests/transform/fft_.cc | 5 sandbox/aroumougame/skeleton/miscellenous.hh | 7 - sandbox/aroumougame/skeleton/sedt.hh | 81 ++++++------ sandbox/ballas/color/laplacien.cc | 3 sandbox/ballas/color/min_tree_area_filter.cc | 16 +- sandbox/ballas/color/min_tree_color.cc | 15 +- sandbox/ballas/color/min_tree_color_v2.cc | 15 +- sandbox/ballas/color/min_tree_height_filter.cc | 15 +- sandbox/ballas/color/min_tree_volume_filter.cc | 15 +- sandbox/ballas/color/reference.cc | 31 ++-- sandbox/ballas/color/reference2.cc | 18 +- sandbox/duhamel/chamfer.cc | 8 - sandbox/garrigues/ocr/enlarge.hh | 85 ++++++------- sandbox/garrigues/ocr/skeleton.old.hh | 7 - sandbox/geraud/browsing/fwd.cc | 37 ++--- sandbox/geraud/dmap.cc | 3 sandbox/geraud/fllt.svg.6.cc | 4 sandbox/geraud/fllt.svg.7.hh | 3 sandbox/geraud/fllt/fllt.hh | 3 sandbox/geraud/fllt/fllt.svg.2.cc | 4 sandbox/geraud/fllt/fllt.svg.3.cc | 4 sandbox/geraud/fllt/fllt.svg.4.cc | 4 sandbox/geraud/fllt/fllt.svg.5.cc | 4 sandbox/geraud/fllt/fllt.svg.7.hh | 4 sandbox/geraud/fllt/fllt_test.hh | 4 sandbox/geraud/tufa_2008/compute_a.cc | 5 sandbox/geraud/tufa_2008/fz_count.cc | 5 sandbox/geraud/tufa_2008/regmin_count.cc | 6 sandbox/geraud/tufa_2008/steps.0.cc | 5 sandbox/geraud/tufa_2008/steps.1.cc | 5 sandbox/geraud/tufa_2008/steps.2.cc | 5 sandbox/geraud/tufa_2008/steps.2b.cc | 5 sandbox/geraud/tufa_2008/steps.3.cc | 6 sandbox/geraud/wst_edge.cc | 18 +- sandbox/inim/binarization/binarization.hh | 7 - sandbox/inim/binarization/proof-of-concept/src/gradient.cc | 3 sandbox/inim/classif/src/proj.hh | 7 - sandbox/jardonnet/n_cmpt/fused_filter.cc | 6 sandbox/jardonnet/n_cmpt/ref_filter.cc | 6 sandbox/nature/co_occurence.hh | 3 sandbox/nature/nature.cc | 14 +- sandbox/nature/proj.hh | 3 sandbox/scribo/demat.hh | 11 - tests/Makefile.am | 1 tests/canvas/chamfer.cc | 8 - tests/core/other/pixel.cc | 5 tests/debug/println.cc | 3 tests/debug/println_with_border.cc | 29 ++-- tests/histo/compute.cc | 4 tests/level/convert.cc | 9 - tests/level/memset_.cc | 5 tests/make/dual_neighb.cc | 5 tests/morpho/artificial_line_graph_image_wst.cc | 4 tests/opt/Makefile.am | 10 + tests/transform/distance_front.cc | 3 tests/transform/distance_geodesic.cc | 3 66 files changed, 395 insertions(+), 298 deletions(-) Index: mln/debug/println.spe.hh --- mln/debug/println.spe.hh (revision 3062) +++ mln/debug/println.spe.hh (working copy) @@ -46,6 +46,7 @@ # include <mln/debug/put_word.hh> # include <mln/level/fill.hh> # include <mln/accu/max.hh> +# include <mln/opt/at.hh> //FIXME: do not include all these headers # include <mln/core/alias/box2d.hh> @@ -86,7 +87,7 @@ for (int row = b.min_row(); row <= b.max_row(); ++row) { for (int col = b.min_col(); col <= b.max_col(); ++col) - std::cout << input.at(row, col) << ' '; + std::cout << opt::at(input, row, col) << ' '; std::cout << std::endl; } std::cout << std::endl; @@ -122,7 +123,7 @@ for (unsigned row = 0; row < b.nrows(); ++row) { for (unsigned col = 0; col < b.ncols() * len; ++col) - std::cout << output.at(row, col); + std::cout << opt::at(output, row, col); std::cout << std::endl; } std::cout << std::endl; Index: mln/core/pixter2d.hh --- mln/core/pixter2d.hh (revision 3062) +++ mln/core/pixter2d.hh (working copy) @@ -35,6 +35,7 @@ # include <mln/core/internal/pixel_iterator_base.hh> # include <mln/core/alias/point2d.hh> # include <mln/geom/size2d.hh> +# include <mln/opt/at.hh> namespace mln { @@ -117,7 +118,7 @@ : super_(image), border_x2_(2 * image.border()), row_offset_(image.bbox().ncols() + border_x2_), - eor_(& image.at(geom::min_row(image), geom::max_col(image)) + 1) + eor_(& opt::at(image, geom::min_row(image), geom::max_col(image)) + 1) { mln_precondition(image.has_data()); } @@ -146,7 +147,7 @@ : super_(image), border_x2_(2 * image.border()), row_offset_(image.bbox().ncols() + border_x2_), - bor_(& image.at(geom::max_row(image), geom::min_col(image)) - 1) + bor_(& opt::at(image, geom::max_row(image), geom::min_col(image)) - 1) { mln_precondition(image.has_data()); } Index: mln/core/pixter3d.hh --- mln/core/pixter3d.hh (revision 3062) +++ mln/core/pixter3d.hh (working copy) @@ -35,6 +35,7 @@ # include <mln/core/internal/pixel_iterator_base.hh> # include <mln/core/alias/point3d.hh> # include <mln/geom/size3d.hh> +# include <mln/opt/at.hh> namespace mln { @@ -133,14 +134,14 @@ : super_(image), border_x2_(2 * image.border()), row_offset_(image.bbox().ncols() + border_x2_), - eor_(& image.at(geom::min_sli(image), + eor_(& opt::at(image, geom::min_sli(image), geom::min_row(image), geom::max_col(image)) + 1), next_sli_offset_(row_offset_ * border_x2_ + border_x2_), next_srow_offset_(next_sli_offset_ + image.bbox().ncols()), sli_offset_((image.bbox().ncols() + border_x2_) * (image.bbox().nrows() + border_x2_)), - eos_(& image.at(geom::min_sli(image), + eos_(& opt::at(image, geom::min_sli(image), geom::max_row(image), geom::max_col(image)) + 1) { @@ -177,14 +178,14 @@ : super_(image), border_x2_(2 * image.border()), row_offset_(image.bbox().ncols() + border_x2_), - bor_(& image.at(geom::max_sli(image), + bor_(& opt::at(image, geom::max_sli(image), geom::max_row(image), geom::min_col(image)) - 1), next_sli_offset_(row_offset_ * border_x2_ + border_x2_), next_srow_offset_(next_sli_offset_ + image.bbox().ncols()), sli_offset_((image.bbox().ncols() + border_x2_) * (image.bbox().nrows() + border_x2_)), - bos_(& image.at(geom::max_sli(image), + bos_(& opt::at(image, geom::max_sli(image), geom::min_row(image), geom::min_col(image)) - 1) { Index: mln/level/was.median.hh --- mln/level/was.median.hh (revision 3062) +++ mln/level/was.median.hh (working copy) @@ -47,6 +47,8 @@ # include <mln/level/median.hh> # include <mln/win/hline2d.hh> +# include <mln/opt/at.hh> + namespace mln { @@ -167,12 +169,12 @@ // initialization (before first point of the row) med.init(); for (ct = min_col; ct < min_col + half; ++ct) - med.take(input.at(row, ct)); + med.take(opt::at(input, row, ct)); // left columns (just take new points) for (col = min_col; col <= min_col + half; ++col, ++ct) { - med.take(input.at(row, ct)); + med.take(opt::at(input, row, ct)); output(p) = med; } @@ -180,15 +182,15 @@ cu = min_col; for (; col <= max_col - half; ++cu, ++col, ++ct) { - med.take(input.at(row, ct)); - med.untake(input.at(row, cu)); + med.take(opt::at(input, row, ct)); + med.untake(opt::at(input, row, cu)); output(p) = med; } // right columns (now just untake old points) for (; col <= max_col; ++cu, ++col) { - med.untake(input.at(row, cu)); + med.untake(opt::at(input, row, cu)); output(p) = med; } } Index: mln/make/image.hh --- mln/make/image.hh (revision 3062) +++ mln/make/image.hh (working copy) @@ -36,6 +36,7 @@ # include <mln/core/image/image1d.hh> # include <mln/core/image/image2d.hh> # include <mln/core/image/image3d.hh> +# include <mln/opt/at.hh> @@ -97,7 +98,7 @@ mln::image2d<V> tmp(R, C); for (unsigned row = 0; row < R; ++row) for (unsigned col = 0; col < C; ++col) - tmp.at(row, col) = values[row][col]; + opt::at(tmp, row, col) = values[row][col]; return tmp; } @@ -110,7 +111,7 @@ for (unsigned sli = 0; sli < S; ++sli) for (unsigned row = 0; row < R; ++row) for (unsigned col = 0; col < C; ++col) - tmp.at(sli, row, col) = values[sli][row][col]; + opt::at(tmp, sli, row, col) = values[sli][row][col]; return tmp; } Index: sandbox/duhamel/chamfer.cc --- sandbox/duhamel/chamfer.cc (revision 3062) +++ sandbox/duhamel/chamfer.cc (working copy) @@ -9,6 +9,8 @@ # include <mln/core/alias/w_window2d_float.hh> # include <mln/core/image_if_interval.hh> +# include <mln/opt/at.hh> + # include "win_chamfer.hh" # include "chamfer.hh" @@ -21,7 +23,7 @@ { level::fill(ima, false); - ima.at(4,4) = true; + opt::at(ima, 4,4) = true; const w_window2d_int& w_win = win_chamfer::mk_chamfer_3x3_int<2, 0> (); image2d_b<unsigned> out = geom::chamfer(ima, w_win, max); debug::println(out | value::interval(0, 8)); @@ -29,7 +31,7 @@ { level::fill(ima, false); - ima.at(4,4) = true; + opt::at(ima, 4,4) = true; const w_window2d_int& w_win = win_chamfer::mk_chamfer_3x3_int<2, 3> (); image2d_b<unsigned> out = geom::chamfer(ima, w_win, max); debug::println(out | value::interval(0, 8)); @@ -37,7 +39,7 @@ { level::fill(ima, false); - ima.at(4,4) = true; + opt::at(ima, 4,4) = true; const w_window2d_int& w_win = win_chamfer::mk_chamfer_5x5_int<4, 6, 9> (); image2d_b<unsigned> out = geom::chamfer(ima, w_win, max); image2d_b<unsigned>::fwd_piter p(out.domain()); Index: sandbox/scribo/demat.hh --- sandbox/scribo/demat.hh (revision 3062) +++ sandbox/scribo/demat.hh (working copy) @@ -50,6 +50,7 @@ # include <mln/make/graph.hh> # include <mln/util/graph.hh> # include <mln/util/line_graph.hh> +# include <mln/opt/at.hh> # include <mln/canvas/browsing/depth_first_search.hh> @@ -337,7 +338,7 @@ level::fill(l, -1); for_all_elements(i, aligned_lines) - l.at(aligned_lines[i]) = i; + opt::at(l, aligned_lines[i]) = i; for (unsigned i = 0; i < settings.max_dist_lines; ++i) l = morpho::elementary::dilation(l, c2()); @@ -345,10 +346,10 @@ for_all_components(i, boxes) { std::pair<point2d, point2d> cp = central_sites(boxes[i], dim); - if (l.at(cp.first[dim]) != -1) - boxes[i].pmin()[dim] = aligned_lines[l.at(cp.first[dim])]; - if (l.at(cp.second[dim]) != -1) - boxes[i].pmax()[dim] = aligned_lines[l.at(cp.second[dim])]; + if (opt::at(l, cp.first[dim]) != -1) + boxes[i].pmin()[dim] = aligned_lines[opt::at(l, cp.first[dim])]; + if (opt::at(l, cp.second[dim]) != -1) + boxes[i].pmax()[dim] = aligned_lines[opt::at(l, cp.second[dim])]; } } Index: sandbox/aroumougame/skeleton/miscellenous.hh --- sandbox/aroumougame/skeleton/miscellenous.hh (revision 3062) +++ sandbox/aroumougame/skeleton/miscellenous.hh (working copy) @@ -1,6 +1,7 @@ #include <mln/core/site_set/p_set.hh> #include <mln/core/image/image2d.hh> #include <mln/value/int_u.hh> +#include <mln/opt/at.hh> #include <vector> using namespace mln; @@ -78,10 +79,10 @@ for(int i=0; i<w; i++) for(int j=0; j<h; j++) { - if(pic.at(j,i)) - out.at(j,i) = 1; + if(opt::at(pic, j,i)) + opt::at(out, j,i) = 1; else - out.at(j,i) = 0; + opt::at(out, j,i) = 0; } return out; } Index: sandbox/aroumougame/skeleton/sedt.hh --- sandbox/aroumougame/skeleton/sedt.hh (revision 3062) +++ sandbox/aroumougame/skeleton/sedt.hh (working copy) @@ -15,6 +15,7 @@ #include <mln/geom/max_col.hh> #include <mln/geom/max_ind.hh> #include <mln/debug/println.hh> +#include <mln/opt/at.hh> using namespace mln; @@ -31,31 +32,31 @@ for(int j=0; j<h; j++) { - if(!pic.at(j,0)) + if(!opt::at(pic, j,0)) { - g.at(j,0)=0; + opt::at(g, j,0)=0; } else { - g.at(j,0)=1023; + opt::at(g, j,0)=1023; } for(int i=1; i<w; i++) { - if(!pic.at(j,i)) + if(!opt::at(pic, j,i)) { - g.at(j,i)=0; + opt::at(g, j,i)=0; } else { - g.at(j,i)=g.at(j,i-1)+1; + opt::at(g, j,i)=opt::at(g, j,i-1)+1; } } for(int i=w-2; i>=0; i--) { - if(g.at(j,i+1)<g.at(j,i)) - g.at(j,i)=1+g.at(j,i+1); + if(opt::at(g, j,i+1)<opt::at(g, j,i)) + opt::at(g, j,i)=1+opt::at(g, j,i+1); } } @@ -76,13 +77,13 @@ for(int j=1; j<h; j++) { - tmp1 = g.at(s[q],i)*g.at(s[q],i)+(t[q]-s[q])*(t[q]-s[q]); - tmp2 = g.at(j,i)*g.at(j,i)+(t[q]-j)*(t[q]-j); + tmp1 = opt::at(g, s[q],i)*opt::at(g, s[q],i)+(t[q]-s[q])*(t[q]-s[q]); + tmp2 = opt::at(g, j,i)*opt::at(g, j,i)+(t[q]-j)*(t[q]-j); while((q>=0)&&( tmp1>tmp2 )) { q--; - tmp1 = g.at(s[q],i)*g.at(s[q],i)+(t[q]-s[q])*(t[q]-s[q]); - tmp2 = g.at(j,i)*g.at(j,i)+(t[q]-j)*(t[q]-j); + tmp1 = opt::at(g, s[q],i)*opt::at(g, s[q],i)+(t[q]-s[q])*(t[q]-s[q]); + tmp2 = opt::at(g, j,i)*opt::at(g, j,i)+(t[q]-j)*(t[q]-j); } if(q<0) { @@ -91,7 +92,7 @@ } else { - v=1+(j*j-s[q]*s[q]+g.at(j,i)*g.at(j,i)-g.at(s[q],i)*g.at(s[q],i))/(2*(j-s[q])); + v=1+(j*j-s[q]*s[q]+g.at(j,i)*g.at(j,i)-g.at(s[q],i)*opt::at(g, s[q],i))/(2*(j-s[q])); if(v<h) { q++; @@ -103,7 +104,7 @@ for(int j= h-1; j>=0; j--) { - dt.at(j,i)= g.at(s[q],i)*g.at(s[q],i)+(j-s[q])*(j-s[q]); + dt.at(j,i)= opt::at(g, s[q],i)*opt::at(g, s[q],i)+(j-s[q])*(j-s[q]); if(j==t[q]) q--; } @@ -125,7 +126,7 @@ image2d<int> DTg(L, L); /* compute bound xM[ and verify that xM < L */ - for (xM = 0; xM < L; xM++) if (CTg.at(0,xM) > R) break; + for (xM = 0; xM < L; xM++) if (opt::at(CTg, 0,xM) > R) break; if (xM >= L) printf ("WARNING xM is not < L\n"); /* First scan: x++, y-- */ @@ -134,11 +135,11 @@ k = 0; propag = 0; for (y = x; y >= 0; y--) { - if (CTg.at(y,x) > R) /* outside the ball : background */ + if (opt::at(CTg, y,x) > R) /* outside the ball : background */ propag = 1; else if (propag) /* inside the ball, mark to dist. k*k from bg */ - { k++; DTg.at(y,x) = k*k; } - else DTg.at(y,x) = -1; /* inside the ball, no distance propagated */ + { k++; opt::at(DTg, y,x) = k*k; } + else opt::at(DTg, y,x) = -1; /* inside the ball, no distance propagated */ } } @@ -150,11 +151,11 @@ /* Compute stacks indices Si[Sn]=x and values Sv[Sn]=DTg[x,y] */ for (x = y; x <= xM; x++) { - dp = DTg.at(y,x); + dp = opt::at(DTg, y,x); if (dp < 0) continue; /* Non propagated value */ /* To speedup algorithm, stop at the second consecutive 0 */ - if (dp == 0 && x > y && DTg.at(y,x-1)==0) break; + if (dp == 0 && x > y && opt::at(DTg, y,x-1)==0) break; while (Sn >= 2 && D_Intersec (Si[Sn-1], Sv[Sn-1], x, dp) < Sr[Sn-1]) Sn--; /* pop */ @@ -170,11 +171,11 @@ /* Compute new DTg values using stacks */ for (x = xM; x >= y; x--) { - if (DTg.at(y,x)==0) continue; + if (opt::at(DTg, y,x)==0) continue; while (Sn >= 2 && x < Sr[Sn-1]) Sn--; /* pop */ - DTg.at(y,x) = (x-Si[Sn-1])*(x-Si[Sn-1]) + Sv[Sn-1]; + opt::at(DTg, y,x) = (x-Si[Sn-1])*(x-Si[Sn-1]) + Sv[Sn-1]; } } @@ -183,7 +184,7 @@ { for( int j=0; j<L; j++) { - dt.at(i,j) = DTg.at(i,j); + dt.at(i,j) = opt::at(DTg, i,j); } } return dt; @@ -197,7 +198,7 @@ { for(int j=0; j <= i; j++) { - CTg.at(j,i) = i*i + j*j; + opt::at(CTg, j,i) = i*i + j*j; } } @@ -230,9 +231,9 @@ for (y = 0; y <= x; y++) { - r1 = CTg.at(y,x) +1; + r1 = opt::at(CTg, y,x) +1; - r2 = CTg.at(y+Mlut[ind][1], x+Mlut[ind][0]) +1; + r2 = opt::at(CTg, y+Mlut[ind][1], x+Mlut[ind][0]) +1; if (r1 <= Rmax && r2 > Lut[ind][r1]) Lut[ind][r1] = r2; } @@ -252,7 +253,7 @@ { int xx, yy, val; - val = DTg.at(y, x); + val = opt::at(DTg, y, x); for (uint i = 0; i < Mlut.size(); i++) { @@ -261,7 +262,7 @@ if (0 <= yy && yy <= xx) { - if ( DTg.at(yy, xx) >= Lut[i][val] ) + if ( opt::at(DTg, yy, xx) >= Lut[i][val] ) return false; } } @@ -288,7 +289,7 @@ { for(int y=0; y<=x; y++) { - if(DTg.at(y,x) > 0 && isMAg(x, y, Mgl, DTg, Lut)) + if(opt::at(DTg, y,x) > 0 && isMAg(x, y, Mgl, DTg, Lut)) { std::vector<int> tmp(3); tmp[0] = x; @@ -314,7 +315,7 @@ { int Vx, Vy, val, h, w; - val = DTg.at(y, x); + val = opt::at(DTg, y, x); h = geom::nrows(DTg); w = geom::ncols(DTg); @@ -325,42 +326,42 @@ if((0 <= y-Vy) && (0 <= x-Vx)) { - if ( DTg.at(y-Vy, x-Vx) >= Lut[i][val] ) + if ( opt::at(DTg, y-Vy, x-Vx) >= Lut[i][val] ) return false; } if((y+Vy < h) && (x+Vx < w)) { - if ( DTg.at(y+Vy, x+Vx) >= Lut[i][val] ) + if ( opt::at(DTg, y+Vy, x+Vx) >= Lut[i][val] ) return false; } if((0 <= y-Vy) && (x+Vx < w)) { - if ( DTg.at(y-Vy, x+Vx) >= Lut[i][val] ) + if ( opt::at(DTg, y-Vy, x+Vx) >= Lut[i][val] ) return false; } if((y+Vy < h) && (0 <= x-Vx)) { - if ( DTg.at(y+Vy, x-Vx) >= Lut[i][val] ) + if ( opt::at(DTg, y+Vy, x-Vx) >= Lut[i][val] ) return false; } if((0 <= x-Vy) && (0 <= y-Vx)) { - if ( DTg.at(y-Vx, x-Vy) >= Lut[i][val] ) + if ( opt::at(DTg, y-Vx, x-Vy) >= Lut[i][val] ) return false; } if((x+Vy < w) && (y+Vx < h)) { - if ( DTg.at(y+Vx, x+Vy) >= Lut[i][val] ) + if ( opt::at(DTg, y+Vx, x+Vy) >= Lut[i][val] ) return false; } if((0 <= x-Vy) && (y+Vx < h)) { - if ( DTg.at(y+Vx, x-Vy) >= Lut[i][val] ) + if ( opt::at(DTg, y+Vx, x-Vy) >= Lut[i][val] ) return false; } if((x+Vy < w) && (0 <= y-Vx)) { - if ( DTg.at(y-Vx, x+Vy) >= Lut[i][val] ) + if ( opt::at(DTg, y-Vx, x+Vy) >= Lut[i][val] ) return false; } @@ -378,11 +379,11 @@ { for(int j=0; j<h; j++) { - if(pic.at(j,i)) + if(opt::at(pic, j,i)) { if(!isMA(i, j, Mgl, dt, Lut)) { - pic.at(j,i) = false; + opt::at(pic, j,i) = false; } } } Index: sandbox/jardonnet/n_cmpt/fused_filter.cc --- sandbox/jardonnet/n_cmpt/fused_filter.cc (revision 3062) +++ sandbox/jardonnet/n_cmpt/fused_filter.cc (working copy) @@ -21,6 +21,8 @@ #include <mln/pw/all.hh> #include <mln/core/image/image_if.hh> +#include <mln/opt/at.hh> + namespace mln { @@ -31,10 +33,10 @@ for (int r = 0; r < nr; ++r) { for (int c = 0; c < nc; ++c) - if (par.at(r,c) == point2d(r,c)) + if (mln::opt::at(par, r,c) == point2d(r,c)) std::cout << "( ) "; else - std::cout << par.at(r,c) << ' '; + std::cout << mln::opt::at(par, r,c) << ' '; std::cout << std::endl; } } Index: sandbox/jardonnet/n_cmpt/ref_filter.cc --- sandbox/jardonnet/n_cmpt/ref_filter.cc (revision 3062) +++ sandbox/jardonnet/n_cmpt/ref_filter.cc (working copy) @@ -16,6 +16,8 @@ #include <mln/morpho/closing_area.hh> #include <mln/level/fill.hh> +#include <mln/opt/at.hh> + namespace mln { @@ -27,10 +29,10 @@ for (int r = 0; r < nr; ++r) { for (int c = 0; c < nc; ++c) - if (par.at(r,c) == point2d(r,c)) + if (opt::at(par, r,c) == point2d(r,c)) std::cout << "( ) "; else - std::cout << par.at(r,c) << ' '; + std::cout << opt::at(par, r,c) << ' '; std::cout << std::endl; } } Index: sandbox/garrigues/ocr/skeleton.old.hh --- sandbox/garrigues/ocr/skeleton.old.hh (revision 3062) +++ sandbox/garrigues/ocr/skeleton.old.hh (working copy) @@ -33,6 +33,7 @@ #include <mln/core/site_set/p_set.hh> #include <mln/math/sqrt.hh> +#include <mln/opt/at.hh> namespace mln { @@ -486,10 +487,10 @@ for(int i=0; i<w; i++) for(int j=0; j<h; j++) { - if(pic.at(j,i)) - out.at(j,i) = 1; + if(opt::at(pic, j,i)) + opt::at(out, j,i) = 1; else - out.at(j,i) = 0; + opt::at(out, j,i) = 0; } return out; } Index: sandbox/garrigues/ocr/enlarge.hh --- sandbox/garrigues/ocr/enlarge.hh (revision 3062) +++ sandbox/garrigues/ocr/enlarge.hh (working copy) @@ -9,6 +9,7 @@ # include <mln/pw/image.hh> # include <mln/pw/cst.hh> # include <mln/pw/value.hh> +# include <mln/opt/at.hh> # include <mln/core/routine/clone.hh> @@ -38,29 +39,29 @@ // row 0 - output.at(0, 0) = do_threshold(input.at(0, 0)); + opt::at(output, 0, 0) = do_threshold(opt::at(input, 0, 0)); for (int col = 2; col < output.ncols(); col += 2) { - value = val(input.at(0, col / 2)); - value += val(input.at(0, col / 2 - 1)); - output.at(0, col) = do_threshold(value / 2); + value = val(opt::at(input, 0, col / 2)); + value += val(opt::at(input, 0, col / 2 - 1)); + opt::at(output, 0, col) = do_threshold(value / 2); } for (int col = 1; col < output.ncols(); col += 2) - output.at(0, col) = do_threshold(input.at(0, col / 2)); + opt::at(output, 0, col) = do_threshold(opt::at(input, 0, col / 2)); // col 0 for (int row = 2; row < output.nrows(); row += 2) { - value = val(input.at(row / 2, 0)); - value += val(input.at(row / 2 - 1, 0)); - output.at(row, 0) = do_threshold(value / 2); + value = val(opt::at(input, row / 2, 0)); + value += val(opt::at(input, row / 2 - 1, 0)); + opt::at(output, row, 0) = do_threshold(value / 2); } for (int row = 1; row < output.nrows(); row += 2) - output.at(row, 0) = do_threshold(input.at(row / 2, 0)); + opt::at(output, row, 0) = do_threshold(opt::at(input, row / 2, 0)); // others @@ -68,17 +69,17 @@ { for (int col = 2; col < output.ncols(); col += 2) { - value = val(input.at(row / 2, col / 2)); - value += val(input.at(row / 2 - 1, col / 2)); - value += val(input.at(row / 2, col / 2 - 1)); - value += val(input.at(row / 2 - 1, col / 2 - 1)); - output.at(row, col) = do_threshold(value / 4); + value = val(opt::at(input, row / 2, col / 2)); + value += val(opt::at(input, row / 2 - 1, col / 2)); + value += val(opt::at(input, row / 2, col / 2 - 1)); + value += val(opt::at(input, row / 2 - 1, col / 2 - 1)); + opt::at(output, row, col) = do_threshold(value / 4); } for (int col = 1; col < output.ncols(); col += 2) { - value = val(input.at(row / 2, col / 2)); - value += val(input.at(row / 2 - 1, col / 2)); - output.at(row, col) = do_threshold(value / 2); + value = val(opt::at(input, row / 2, col / 2)); + value += val(opt::at(input, row / 2 - 1, col / 2)); + opt::at(output, row, col) = do_threshold(value / 2); } } @@ -86,12 +87,12 @@ { for (int col = 2; col < output.ncols(); col += 2) { - value = val(input.at(row / 2, col / 2)); - value += val(input.at(row / 2, col / 2 - 1)); - output.at(row, col) = do_threshold(value / 2); + value = val(opt::at(input, row / 2, col / 2)); + value += val(opt::at(input, row / 2, col / 2 - 1)); + opt::at(output, row, col) = do_threshold(value / 2); } for (int col = 1; col < output.ncols(); col += 2) - output.at(row, col) = do_threshold(input.at(row / 2, col / 2)); + opt::at(output, row, col) = do_threshold(opt::at(input, row / 2, col / 2)); } return output; @@ -114,29 +115,29 @@ // row 0 - output.at(0, 0) = (input.at(0, 0)); + opt::at(output, 0, 0) = (opt::at(input, 0, 0)); for (int col = 2; col < output.ncols(); col += 2) { - value = (input.at(0, col / 2)); - value += (input.at(0, col / 2 - 1)); - output.at(0, col) = (value / 2); + value = (opt::at(input, 0, col / 2)); + value += (opt::at(input, 0, col / 2 - 1)); + opt::at(output, 0, col) = (value / 2); } for (int col = 1; col < output.ncols(); col += 2) - output.at(0, col) = (input.at(0, col / 2)); + opt::at(output, 0, col) = (opt::at(input, 0, col / 2)); // col 0 for (int row = 2; row < output.nrows(); row += 2) { - value = (input.at(row / 2, 0)); - value += (input.at(row / 2 - 1, 0)); - output.at(row, 0) = (value / 2); + value = (opt::at(input, row / 2, 0)); + value += (opt::at(input, row / 2 - 1, 0)); + opt::at(output, row, 0) = (value / 2); } for (int row = 1; row < output.nrows(); row += 2) - output.at(row, 0) = (input.at(row / 2, 0)); + opt::at(output, row, 0) = (opt::at(input, row / 2, 0)); // others @@ -144,17 +145,17 @@ { for (int col = 2; col < output.ncols(); col += 2) { - value = (input.at(row / 2, col / 2)); - value += (input.at(row / 2 - 1, col / 2)); - value += (input.at(row / 2, col / 2 - 1)); - value += (input.at(row / 2 - 1, col / 2 - 1)); - output.at(row, col) = ((unsigned(value)+2) / 4); + value = (opt::at(input, row / 2, col / 2)); + value += (opt::at(input, row / 2 - 1, col / 2)); + value += (opt::at(input, row / 2, col / 2 - 1)); + value += (opt::at(input, row / 2 - 1, col / 2 - 1)); + opt::at(output, row, col) = ((unsigned(value)+2) / 4); } for (int col = 1; col < output.ncols(); col += 2) { - value = (input.at(row / 2, col / 2)); - value += (input.at(row / 2 - 1, col / 2)); - output.at(row, col) = (value / 2); + value = (opt::at(input, row / 2, col / 2)); + value += (opt::at(input, row / 2 - 1, col / 2)); + opt::at(output, row, col) = (value / 2); } } @@ -162,12 +163,12 @@ { for (int col = 2; col < output.ncols(); col += 2) { - value = (input.at(row / 2, col / 2)); - value += (input.at(row / 2, col / 2 - 1)); - output.at(row, col) = (value / 2); + value = (opt::at(input, row / 2, col / 2)); + value += (opt::at(input, row / 2, col / 2 - 1)); + opt::at(output, row, col) = (value / 2); } for (int col = 1; col < output.ncols(); col += 2) - output.at(row, col) = (input.at(row / 2, col / 2)); + opt::at(output, row, col) = (opt::at(input, row / 2, col / 2)); } return output; Index: sandbox/abraham/tests/transform/fft_.cc --- sandbox/abraham/tests/transform/fft_.cc (revision 3062) +++ sandbox/abraham/tests/transform/fft_.cc (working copy) @@ -30,6 +30,7 @@ #include <mln/value/int_u8.hh> #include <mln/io/pgm/load.hh> #include <mln/io/pgm/save.hh> +#include <mln/opt/at.hh> #include <mln/debug/println.hh> #define CHECK(Condition) \ @@ -77,11 +78,11 @@ for (int row = 40; row < im2.nrows() - 40; ++row) for (int col = 0; col < im2.ncols(); ++col) - im2.at(row, col) = 0; + opt::at(im2, row, col) = 0; for (int row = 0; row < im2.nrows(); ++row) for (int col = 40; col < im2.ncols() - 40; ++col) - im2.at(row, col) = 0; + opt::at(im2, row, col) = 0; out = fourier.transform_inv<int_u8>(); Index: sandbox/abraham/mln/transform/fft.hh --- sandbox/abraham/mln/transform/fft.hh (revision 3062) +++ sandbox/abraham/mln/transform/fft.hh (working copy) @@ -30,6 +30,7 @@ # include <mln/core/image/image2d.hh> # include <mln/estim/min_max.hh> +# include <mln/opt/at.hh> # include <complex> @@ -116,8 +117,8 @@ if (ordered) for (unsigned row = 0; row < new_im.nrows(); ++row) for (unsigned col = 0; col < new_im.ncols(); ++col) - new_im.at(row, col) = - std::norm(trans_im.at((row + trans_im.nrows() / 2) % trans_im.nrows(), + opt::at(new_im, row, col) = + std::norm(opt::at(trans_im, (row + trans_im.nrows() / 2) % trans_im.nrows(), (col + trans_im.ncols() / 2) % trans_im.ncols())); else { @@ -174,14 +175,14 @@ for (unsigned row = 0; row < new_im.nrows(); ++row) for (unsigned col = 0; col < new_im.ncols(); ++col) { - if (std::norm(trans_im.at((row + trans_im.nrows() / 2) % trans_im.nrows(), + if (std::norm(opt::at(trans_im, (row + trans_im.nrows() / 2) % trans_im.nrows(), (col + trans_im.ncols() / 2) % trans_im.ncols())) >= max * clip) - new_im.at(row, col) = mln_max(R); + opt::at(new_im, row, col) = mln_max(R); else - new_im.at(row, col) = + opt::at(new_im, row, col) = (double) mln_max(R) * - std::norm(trans_im.at((row + trans_im.nrows() / 2) % trans_im.nrows(), + std::norm(opt::at(trans_im, (row + trans_im.nrows() / 2) % trans_im.nrows(), (col + trans_im.ncols() / 2) % trans_im.ncols())) / (max * clip); } @@ -282,8 +283,8 @@ if (ordered) for (unsigned row = 0; row < new_im.nrows(); ++row) for (unsigned col = 0; col < new_im.ncols(); ++col) - new_im.at(row, col) = - log(a + b * std::norm(trans_im.at((row + trans_im.nrows() / 2) % trans_im.nrows(), + opt::at(new_im, row, col) = + log(a + b * std::norm(opt::at(trans_im, (row + trans_im.nrows() / 2) % trans_im.nrows(), (col + trans_im.ncols() / 2) % trans_im.ncols()))) / log (a + b * max) * mln_max(R); else @@ -413,7 +414,7 @@ for (unsigned row = 0; row < original_im.nrows(); ++row) for (unsigned col = 0; col < original_im.ncols(); ++col) - this->in[row * original_im.ncols() + col] = original_im.at(row, col); + this->in[row * original_im.ncols() + col] = opt::at(original_im, row, col); this->p = fftw_plan_dft_r2c_2d (original_im.nrows(), original_im.ncols(), this->in, reinterpret_cast<fftw_complex*>(this->out), FFTW_ESTIMATE); @@ -436,12 +437,12 @@ for (unsigned col = 0; col <= this->trans_im.ncols() / 2; ++col) { this->out[i] = std::complex<T> (this->out[i].real() / denom, this->out[i].imag() / denom); - this->trans_im.at(row, col) = this->out[i]; + opt::at(this->trans_im, row, col) = this->out[i]; ++i; } for (unsigned row = 0; row < this->trans_im.nrows(); ++row) for (unsigned col = this->trans_im.ncols() - 1; col > this->trans_im.ncols() / 2; --col) - this->trans_im.at(row, col) = this->trans_im.at(this->trans_im.nrows() - row - 1, + this->trans_im.at(row, col) = opt::at(this->trans_im, this->trans_im.nrows() - row - 1, this->trans_im.ncols() - col - 1); return this->trans_im; } @@ -459,7 +460,7 @@ for (unsigned row = 0; row < this->trans_im.nrows(); ++row) for (unsigned col = 0; col <= this->trans_im.ncols() / 2; ++col) this->out[row * (this->trans_im.ncols() / 2 + 1) + col] = - this->trans_im.at(row, col).real(); + opt::at(this->trans_im, row, col).real(); fftw_execute(this->p_inv); @@ -468,7 +469,7 @@ for (unsigned row = 0; row < this->trans_im.nrows(); ++row) for (unsigned col = 0; col < this->trans_im.ncols(); ++col) { - new_im.at(row, col) = (this->in[i] >= mln_min(R) ? + opt::at(new_im, row, col) = (this->in[i] >= mln_min(R) ? (this->in[i] <= mln_max(R) ? (R)this->in [i] : mln_min(R)) : Index: sandbox/inim/classif/src/proj.hh --- sandbox/inim/classif/src/proj.hh (revision 3062) +++ sandbox/inim/classif/src/proj.hh (working copy) @@ -35,7 +35,8 @@ #include <mln/accu/maj_h.hh> #include <mln/literal/white.hh> #include <mln/literal/colors.hh> -#include <mln/make/vec.hh> +#include <mln/make/vec.hh +#include <mln/opt/at.hh> namespace mln { @@ -48,7 +49,7 @@ mln_piter(image3d<T>) p(input.domain()); for_all(p) // 3d if (input(p) != literal::zero) - acc.at(p.sli(), p.row()).take(input(p)); + opt::at(acc, p.sli(), p.row()).take(input(p)); image2d<mln_result(A)> output(acc.domain()); level::paste(acc, output); @@ -91,7 +92,7 @@ mln_piter(image3d<T>) p(input.domain()); for_all(p) // 3d if (histo(p) != literal::zero) - acc.at(p.sli(), p.row()).take(input(p)); + opt::at(acc, p.sli(), p.row()).take(input(p)); image2d<mln_result(A)> output(acc.domain()); level::paste(acc, output); Index: sandbox/inim/binarization/proof-of-concept/src/gradient.cc --- sandbox/inim/binarization/proof-of-concept/src/gradient.cc (revision 3062) +++ sandbox/inim/binarization/proof-of-concept/src/gradient.cc (working copy) @@ -25,6 +25,7 @@ #include <mln/morpho/closing_area.hh> #include <mln/morpho/gradient.hh> #include <mln/level/fill.hh> +#include <mln/opt/at.hh> // DEBUG #include <mln/debug/all.hh> @@ -81,7 +82,7 @@ level::fill(hist, 0); image2d<value::int_u8>::fwd_piter p (in.domain ()); for_all (p) - hist.at(in(p)) += (unsigned) strength_of<2> (grad (p)); + opt::at(hist, in(p)) += (unsigned) strength_of<2> (grad (p)); // Histo print_histo (hist, file_hist + "_1.histo"); Index: sandbox/inim/binarization/binarization.hh --- sandbox/inim/binarization/binarization.hh (revision 3062) +++ sandbox/inim/binarization/binarization.hh (working copy) @@ -7,6 +7,7 @@ #include <mln/morpho/meyer_wst.hh> #include <mln/border/resize.hh> #include <mln/accu/maj_h.hh> +#include <mln/opt/at.hh> #include "snake2d.hh" namespace mln @@ -41,10 +42,10 @@ initialize(cla, input); typename I::fwd_piter q (input.domain()); for_all (q) - if (wst.at(input(q)) == 0) - cla(q) = wst.at(input(q) + 1); + if (opt::at(wst, input(q)) == 0) + cla(q) = opt::at(wst, input(q) + 1); else - cla(q) = wst.at(input(q)); + cla(q) = opt::at(wst, input(q)); border::resize(cla, 0); I maj = snake2d(accu::meta::maj_h(), cla, win); typename I::fwd_piter r (cla.domain()); Index: sandbox/nature/nature.cc --- sandbox/nature/nature.cc (revision 3062) +++ sandbox/nature/nature.cc (working copy) @@ -61,6 +61,8 @@ #include <mln/transform/fft.hh> +#include <mln/opt/at.hh> + #include "co_occurence.hh" #include <math.h> @@ -174,14 +176,14 @@ // If there is a plain background, there will be a massive peak in the diagonal of the matrix unsigned max = 0; for (unsigned i = 0; i < mco.nrows(); i++) - if (mco.at(i, i) > max) - max = mco.at(i, i); + if (opt::at(mco, i, i) > max) + max = opt::at(mco, i, i); for (unsigned i = 0; i < mco.nrows() - 1; i++) { - if (mco.at(i + 1, i) > max) - max = mco.at(i + 1, i); - if (mco.at(i, i + 1) > max) - max = mco.at(i, i + 1); + if (opt::at(mco, i + 1, i) > max) + max = opt::at(mco, i + 1, i); + if (opt::at(mco, i, i + 1) > max) + max = opt::at(mco, i, i + 1); } max = max * 100 / input.nelements(); Index: sandbox/nature/co_occurence.hh --- sandbox/nature/co_occurence.hh (revision 3062) +++ sandbox/nature/co_occurence.hh (working copy) @@ -37,6 +37,7 @@ # include <mln/core/dpoint.hh> # include <mln/core/image/image2d.hh> # include <mln/level/fill.hh> +# include <mln/opt/at.hh> namespace mln @@ -64,7 +65,7 @@ mln_piter(I) p(ima.domain()); for_all(p) if (ima.domain().has(p + dp)) - mco.at(ima(p), ima(p + dp))++; + opt::at(mco, ima(p), ima(p + dp))++; return mco; } Index: sandbox/nature/proj.hh --- sandbox/nature/proj.hh (revision 3062) +++ sandbox/nature/proj.hh (working copy) @@ -35,6 +35,7 @@ #include <mln/core/image/image2d.hh> #include <mln/core/image/image1d.hh> #include <mln/level/fill.hh> +#include <mln/opt/at.hh> namespace mln { @@ -47,7 +48,7 @@ mln_piter(image2d<T>) p(input.domain()); for_all(p) // 2d - out.at(p.row()) += input(p); + opt::at(out, p.row()) += input(p); mln_piter(image1d<T>) p2(out.domain()); unsigned count = geom::ncols(input); Index: sandbox/ballas/color/min_tree_volume_filter.cc --- sandbox/ballas/color/min_tree_volume_filter.cc (revision 3062) +++ sandbox/ballas/color/min_tree_volume_filter.cc (working copy) @@ -33,6 +33,7 @@ # include <mln/extension/fill.hh> # include <mln/morpho/closing_area.hh> +# include <mln/opt/at.hh> # include <mln/debug/println.hh> @@ -297,14 +298,14 @@ unsigned row = (p.row() / 2 + 1) * (zoom + 1) - 1; unsigned col = (p.col() / 2) * (zoom + 1); for (unsigned i = 0; i < zoom; ++i) - output.at(row, col + i) = ima(p); + opt::at(output, row, col + i) = ima(p); } else // vertical edge { unsigned row = (p.row() / 2) * (zoom + 1); unsigned col = (p.col() / 2 + 1) * (zoom + 1) - 1; for (unsigned i = 0; i < zoom; ++i) - output.at(row + i, col) = ima(p); + opt::at(output, row + i, col) = ima(p); } return output; } @@ -326,7 +327,7 @@ unsigned col = (q.col() / 2) * (zoom + 1); for (unsigned i = 0; i < zoom; ++i) for (unsigned j = 0; j < zoom; ++j) - output.at(row + i, col + j) = ima(q); + opt::at(output, row + i, col + j) = ima(q); } mln_VAR( edge, ima | is_edge ); @@ -337,14 +338,14 @@ unsigned row = (p.row() / 2 + 1) * (zoom + 1) - 1; unsigned col = (p.col() / 2) * (zoom + 1); for (unsigned i = 0; i < zoom; ++i) - output.at(row, col + i) = ima(p); + opt::at(output, row, col + i) = ima(p); } else // vertical edge { unsigned row = (p.row() / 2) * (zoom + 1); unsigned col = (p.col() / 2 + 1) * (zoom + 1) - 1; for (unsigned i = 0; i < zoom; ++i) - output.at(row + i, col) = ima(p); + opt::at(output, row + i, col) = ima(p); } return output; } @@ -386,7 +387,7 @@ 2 * input.ncols() - 1); for (unsigned row = 0; row < input.nrows(); ++row) for (unsigned col = 0; col < input.ncols(); ++col) - output.at(2 * row, 2 * col) = input.at(row, col); + output.at(2 * row, 2 * col) = mln::opt::at(input, row, col); return output; } @@ -399,7 +400,7 @@ (input.ncols() + 1) / 2); for (unsigned row = 0; row < input.nrows(); row += 2) for (unsigned col = 0; col < input.ncols(); col += 2) - output.at(row / 2, col / 2) = input.at(row, col); + output.at(row / 2, col / 2) = mln::opt::at(input, row, col); return output; } Index: sandbox/ballas/color/reference.cc --- sandbox/ballas/color/reference.cc (revision 3062) +++ sandbox/ballas/color/reference.cc (working copy) @@ -40,6 +40,7 @@ # include <mln/morpho/closing_volume.hh> # include <mln/make/w_window2d.hh> +# include <mln/opt/at.hh> # include <mln/debug/println.hh> @@ -163,13 +164,13 @@ const int ncols = ima.ncols(); for (int r = -1; r <= nrows; ++r) { - ima.at(r, -1) = v; - ima.at(r, ncols) = v; + opt::at(ima, r, -1) = v; + opt::at(ima, r, ncols) = v; } for (int c = -1; c <= ncols; ++c) { - ima.at(-1, c) = v; - ima.at(nrows, c) = v; + opt::at(ima, -1, c) = v; + opt::at(ima, nrows, c) = v; } } @@ -287,14 +288,14 @@ unsigned row = (p.row() / 2 + 1) * (zoom + 1) - 1; unsigned col = (p.col() / 2) * (zoom + 1); for (unsigned i = 0; i < zoom; ++i) - output.at(row, col + i) = ima(p); + opt::at(output, row, col + i) = ima(p); } else // vertical edge { unsigned row = (p.row() / 2) * (zoom + 1); unsigned col = (p.col() / 2 + 1) * (zoom + 1) - 1; for (unsigned i = 0; i < zoom; ++i) - output.at(row + i, col) = ima(p); + opt::at(output, row + i, col) = ima(p); } return output; } @@ -315,7 +316,7 @@ unsigned col = (q.col() / 2) * (zoom + 1); for (unsigned i = 0; i < zoom; ++i) for (unsigned j = 0; j < zoom; ++j) - output.at(row + i, col + j) = ima(q); + opt::at(output, row + i, col + j) = ima(q); } mln_VAR( edge, ima | is_edge ); @@ -326,14 +327,14 @@ unsigned row = (p.row() / 2 + 1) * (zoom + 1) - 1; unsigned col = (p.col() / 2) * (zoom + 1); for (unsigned i = 0; i < zoom; ++i) - output.at(row, col + i) = ima(p); + opt::at(output, row, col + i) = ima(p); } else // vertical edge { unsigned row = (p.row() / 2) * (zoom + 1); unsigned col = (p.col() / 2 + 1) * (zoom + 1) - 1; for (unsigned i = 0; i < zoom; ++i) - output.at(row + i, col) = ima(p); + opt::at(output, row + i, col) = ima(p); } return output; } @@ -350,7 +351,7 @@ 2 * input.ncols() - 1); for (int row = 0; row < input.nrows(); ++row) for (int col = 0; col < input.ncols(); ++col) - output.at(2 * row, 2 * col) = input.at(row, col); + output.at(2 * row, 2 * col) = mln::opt::at(input, row, col); return output; } @@ -416,7 +417,7 @@ (input.ncols() + 1) / 2); for (int row = 0; row < input.nrows(); row += 2) for (int col = 0; col < input.ncols(); col += 2) - output.at(row / 2, col / 2) = input.at(row, col); + output.at(row / 2, col / 2) = mln::opt::at(input, row, col); return output; } @@ -491,15 +492,15 @@ { if (is_row_odd(p)) { - mln_value(image2d<float>) t = ima.at(p.row() - 1, p.col()); - mln_value(image2d<float>) b = ima.at(p.row() + 1, p.col()); + mln_value(image2d<float>) t = opt::at(ima, p.row() - 1, p.col()); + mln_value(image2d<float>) b = opt::at(ima, p.row() + 1, p.col()); if ((t > 0 && b < 0) || (t < 0 && b > 0)) output(p) = value::rgb8(255,0,0); } else { - mln_value(image2d<float>) r = ima.at(p.row(), p.col() - 1); - mln_value(image2d<float>) d = ima.at(p.row(), p.col() + 1); + mln_value(image2d<float>) r = opt::at(ima, p.row(), p.col() - 1); + mln_value(image2d<float>) d = opt::at(ima, p.row(), p.col() + 1); if ((r > 0 && d < 0) || (r < 0 && d > 0)) output(p) = value::rgb8(255,0,0); } Index: sandbox/ballas/color/min_tree_area_filter.cc --- sandbox/ballas/color/min_tree_area_filter.cc (revision 3062) +++ sandbox/ballas/color/min_tree_area_filter.cc (working copy) @@ -36,6 +36,8 @@ # include <mln/morpho/meyer_wst.hh> # include <mln/morpho/closing_area.hh> +# include <mln/opt/at.hh> + # include <mln/debug/println.hh> # if 0 @@ -273,14 +275,14 @@ unsigned row = (p.row() / 2 + 1) * (zoom + 1) - 1; unsigned col = (p.col() / 2) * (zoom + 1); for (unsigned i = 0; i < zoom; ++i) - output.at(row, col + i) = ima(p); + opt::at(output, row, col + i) = ima(p); } else // vertical edge { unsigned row = (p.row() / 2) * (zoom + 1); unsigned col = (p.col() / 2 + 1) * (zoom + 1) - 1; for (unsigned i = 0; i < zoom; ++i) - output.at(row + i, col) = ima(p); + opt::at(output, row + i, col) = ima(p); } return output; } @@ -301,7 +303,7 @@ unsigned col = (q.col() / 2) * (zoom + 1); for (unsigned i = 0; i < zoom; ++i) for (unsigned j = 0; j < zoom; ++j) - output.at(row + i, col + j) = ima(q); + opt::at(output, row + i, col + j) = ima(q); } mln_VAR( edge, ima | is_edge ); @@ -312,14 +314,14 @@ unsigned row = (p.row() / 2 + 1) * (zoom + 1) - 1; unsigned col = (p.col() / 2) * (zoom + 1); for (unsigned i = 0; i < zoom; ++i) - output.at(row, col + i) = ima(p); + opt::at(output, row, col + i) = ima(p); } else // vertical edge { unsigned row = (p.row() / 2) * (zoom + 1); unsigned col = (p.col() / 2 + 1) * (zoom + 1) - 1; for (unsigned i = 0; i < zoom; ++i) - output.at(row + i, col) = ima(p); + opt::at(output, row + i, col) = ima(p); } return output; } @@ -362,7 +364,7 @@ 2 * input.ncols() - 1); for (unsigned row = 0; row < input.nrows(); ++row) for (unsigned col = 0; col < input.ncols(); ++col) - output.at(2 * row, 2 * col) = input.at(row, col); + output.at(2 * row, 2 * col) = mln::opt::at(input, row, col); return output; } @@ -375,7 +377,7 @@ (input.ncols() + 1) / 2); for (unsigned row = 0; row < input.nrows(); row += 2) for (unsigned col = 0; col < input.ncols(); col += 2) - output.at(row / 2, col / 2) = input.at(row, col); + output.at(row / 2, col / 2) = mln::opt::at(input, row, col); return output; } Index: sandbox/ballas/color/min_tree_height_filter.cc --- sandbox/ballas/color/min_tree_height_filter.cc (revision 3062) +++ sandbox/ballas/color/min_tree_height_filter.cc (working copy) @@ -31,6 +31,7 @@ # include <mln/level/fill.hh> # include <mln/level/transform.hh> # include <mln/extension/fill.hh> +# include <mln/opt/at.hh> # include <mln/morpho/closing_area.hh> @@ -297,14 +298,14 @@ unsigned row = (p.row() / 2 + 1) * (zoom + 1) - 1; unsigned col = (p.col() / 2) * (zoom + 1); for (unsigned i = 0; i < zoom; ++i) - output.at(row, col + i) = ima(p); + opt::at(output, row, col + i) = ima(p); } else // vertical edge { unsigned row = (p.row() / 2) * (zoom + 1); unsigned col = (p.col() / 2 + 1) * (zoom + 1) - 1; for (unsigned i = 0; i < zoom; ++i) - output.at(row + i, col) = ima(p); + opt::at(output, row + i, col) = ima(p); } return output; } @@ -326,7 +327,7 @@ unsigned col = (q.col() / 2) * (zoom + 1); for (unsigned i = 0; i < zoom; ++i) for (unsigned j = 0; j < zoom; ++j) - output.at(row + i, col + j) = ima(q); + opt::at(output, row + i, col + j) = ima(q); } mln_VAR( edge, ima | is_edge ); @@ -337,14 +338,14 @@ unsigned row = (p.row() / 2 + 1) * (zoom + 1) - 1; unsigned col = (p.col() / 2) * (zoom + 1); for (unsigned i = 0; i < zoom; ++i) - output.at(row, col + i) = ima(p); + opt::at(output, row, col + i) = ima(p); } else // vertical edge { unsigned row = (p.row() / 2) * (zoom + 1); unsigned col = (p.col() / 2 + 1) * (zoom + 1) - 1; for (unsigned i = 0; i < zoom; ++i) - output.at(row + i, col) = ima(p); + opt::at(output, row + i, col) = ima(p); } return output; } @@ -386,7 +387,7 @@ 2 * input.ncols() - 1); for (unsigned row = 0; row < input.nrows(); ++row) for (unsigned col = 0; col < input.ncols(); ++col) - output.at(2 * row, 2 * col) = input.at(row, col); + output.at(2 * row, 2 * col) = mln::opt::at(input, row, col); return output; } @@ -399,7 +400,7 @@ (input.ncols() + 1) / 2); for (unsigned row = 0; row < input.nrows(); row += 2) for (unsigned col = 0; col < input.ncols(); col += 2) - output.at(row / 2, col / 2) = input.at(row, col); + output.at(row / 2, col / 2) = mln::opt::at(input, row, col); return output; } Index: sandbox/ballas/color/min_tree_color.cc --- sandbox/ballas/color/min_tree_color.cc (revision 3062) +++ sandbox/ballas/color/min_tree_color.cc (working copy) @@ -34,6 +34,7 @@ # include <mln/extension/fill.hh> # include <mln/morpho/closing_area.hh> +# include <mln/opt/at.hh> # include <mln/debug/println.hh> @@ -292,14 +293,14 @@ unsigned row = (p.row() / 2 + 1) * (zoom + 1) - 1; unsigned col = (p.col() / 2) * (zoom + 1); for (unsigned i = 0; i < zoom; ++i) - output.at(row, col + i) = ima(p); + opt::at(output, row, col + i) = ima(p); } else // vertical edge { unsigned row = (p.row() / 2) * (zoom + 1); unsigned col = (p.col() / 2 + 1) * (zoom + 1) - 1; for (unsigned i = 0; i < zoom; ++i) - output.at(row + i, col) = ima(p); + opt::at(output, row + i, col) = ima(p); } return output; } @@ -320,7 +321,7 @@ unsigned col = (q.col() / 2) * (zoom + 1); for (unsigned i = 0; i < zoom; ++i) for (unsigned j = 0; j < zoom; ++j) - output.at(row + i, col + j) = ima(q); + opt::at(output, row + i, col + j) = ima(q); } mln_VAR( edge, ima | is_edge ); @@ -331,14 +332,14 @@ unsigned row = (p.row() / 2 + 1) * (zoom + 1) - 1; unsigned col = (p.col() / 2) * (zoom + 1); for (unsigned i = 0; i < zoom; ++i) - output.at(row, col + i) = ima(p); + opt::at(output, row, col + i) = ima(p); } else // vertical edge { unsigned row = (p.row() / 2) * (zoom + 1); unsigned col = (p.col() / 2 + 1) * (zoom + 1) - 1; for (unsigned i = 0; i < zoom; ++i) - output.at(row + i, col) = ima(p); + opt::at(output, row + i, col) = ima(p); } return output; } @@ -380,7 +381,7 @@ 2 * input.ncols() - 1); for (unsigned row = 0; row < input.nrows(); ++row) for (unsigned col = 0; col < input.ncols(); ++col) - output.at(2 * row, 2 * col) = input.at(row, col); + output.at(2 * row, 2 * col) = mln::opt::at(input, row, col); return output; } @@ -393,7 +394,7 @@ (input.ncols() + 1) / 2); for (unsigned row = 0; row < input.nrows(); row += 2) for (unsigned col = 0; col < input.ncols(); col += 2) - output.at(row / 2, col / 2) = input.at(row, col); + output.at(row / 2, col / 2) = mln::opt::at(input, row, col); return output; } Index: sandbox/ballas/color/reference2.cc --- sandbox/ballas/color/reference2.cc (revision 3062) +++ sandbox/ballas/color/reference2.cc (working copy) @@ -39,6 +39,8 @@ # include <mln/linear/convolve.hh> # include <mln/make/w_window2d.hh> +# include <mln/opt/at.hh> + # include <mln/debug/println.hh> namespace mln @@ -145,13 +147,13 @@ const int ncols = ima.ncols(); for (int r = -1; r <= nrows; ++r) { - ima.at(r, -1) = v; - ima.at(r, ncols) = v; + opt::at(ima, r, -1) = v; + opt::at(ima, r, ncols) = v; } for (int c = -1; c <= ncols; ++c) { - ima.at(-1, c) = v; - ima.at(nrows, c) = v; + opt::at(ima, -1, c) = v; + opt::at(ima, nrows, c) = v; } } @@ -269,14 +271,14 @@ unsigned row = (p.row() / 2 + 1) * (zoom + 1) - 1; unsigned col = (p.col() / 2) * (zoom + 1); for (unsigned i = 0; i < zoom; ++i) - output.at(row, col + i) = ima(p); + opt::at(output, row, col + i) = ima(p); } else // vertical edge { unsigned row = (p.row() / 2) * (zoom + 1); unsigned col = (p.col() / 2 + 1) * (zoom + 1) - 1; for (unsigned i = 0; i < zoom; ++i) - output.at(row + i, col) = ima(p); + opt::at(output, row + i, col) = ima(p); } return output; } @@ -293,7 +295,7 @@ 2 * input.ncols() - 1); for (int row = 0; row < input.nrows(); ++row) for (int col = 0; col < input.ncols(); ++col) - output.at(2 * row, 2 * col) = input.at(row, col); + output.at(2 * row, 2 * col) = mln::opt::at(input, row, col); return output; } @@ -306,7 +308,7 @@ (input.ncols() + 1) / 2); for (int row = 0; row < input.nrows(); row += 2) for (int col = 0; col < input.ncols(); col += 2) - output.at(row / 2, col / 2) = input.at(row, col); + output.at(row / 2, col / 2) = mln::opt::at(input, row, col); return output; } Index: sandbox/ballas/color/min_tree_color_v2.cc --- sandbox/ballas/color/min_tree_color_v2.cc (revision 3062) +++ sandbox/ballas/color/min_tree_color_v2.cc (working copy) @@ -33,6 +33,7 @@ # include <mln/extension/fill.hh> # include <mln/morpho/closing_area.hh> +# include <mln/opt/at.hh> # include <mln/debug/println.hh> @@ -281,14 +282,14 @@ unsigned row = (p.row() / 2 + 1) * (zoom + 1) - 1; unsigned col = (p.col() / 2) * (zoom + 1); for (unsigned i = 0; i < zoom; ++i) - output.at(row, col + i) = ima(p); + opt::at(output, row, col + i) = ima(p); } else // vertical edge { unsigned row = (p.row() / 2) * (zoom + 1); unsigned col = (p.col() / 2 + 1) * (zoom + 1) - 1; for (unsigned i = 0; i < zoom; ++i) - output.at(row + i, col) = ima(p); + opt::at(output, row + i, col) = ima(p); } return output; } @@ -309,7 +310,7 @@ unsigned col = (q.col() / 2) * (zoom + 1); for (unsigned i = 0; i < zoom; ++i) for (unsigned j = 0; j < zoom; ++j) - output.at(row + i, col + j) = ima(q); + opt::at(output, row + i, col + j) = ima(q); } mln_VAR( edge, ima | is_edge ); @@ -320,14 +321,14 @@ unsigned row = (p.row() / 2 + 1) * (zoom + 1) - 1; unsigned col = (p.col() / 2) * (zoom + 1); for (unsigned i = 0; i < zoom; ++i) - output.at(row, col + i) = ima(p); + opt::at(output, row, col + i) = ima(p); } else // vertical edge { unsigned row = (p.row() / 2) * (zoom + 1); unsigned col = (p.col() / 2 + 1) * (zoom + 1) - 1; for (unsigned i = 0; i < zoom; ++i) - output.at(row + i, col) = ima(p); + opt::at(output, row + i, col) = ima(p); } return output; } @@ -369,7 +370,7 @@ 2 * input.ncols() - 1); for (unsigned row = 0; row < input.nrows(); ++row) for (unsigned col = 0; col < input.ncols(); ++col) - output.at(2 * row, 2 * col) = input.at(row, col); + output.at(2 * row, 2 * col) = mln::opt::at(input, row, col); return output; } @@ -382,7 +383,7 @@ (input.ncols() + 1) / 2); for (unsigned row = 0; row < input.nrows(); row += 2) for (unsigned col = 0; col < input.ncols(); col += 2) - output.at(row / 2, col / 2) = input.at(row, col); + output.at(row / 2, col / 2) = mln::opt::at(input, row, col); return output; } Index: sandbox/ballas/color/laplacien.cc --- sandbox/ballas/color/laplacien.cc (revision 3062) +++ sandbox/ballas/color/laplacien.cc (working copy) @@ -13,6 +13,7 @@ #include <mln/core/var.hh> #include <mln/debug/println.hh> +#include <mln/opt/at.hh> #include "src/io.hh" #include "src/graph.hh" @@ -92,7 +93,7 @@ // if (laplacian(p) == 0u) // { // std::cout << "I'm here" << std::endl; -// graph.at(p.row() * 2, p.col() * 2) = value::rgb<8>(255, 0, 0); +// opt::at(graph, p.row() * 2, p.col() * 2) = value::rgb<8>(255, 0, 0); // } } Index: sandbox/geraud/wst_edge.cc --- sandbox/geraud/wst_edge.cc (revision 3062) +++ sandbox/geraud/wst_edge.cc (working copy) @@ -35,6 +35,8 @@ # include <mln/morpho/meyer_wst.hh> # include <mln/morpho/closing_volume.hh> +# include <mln/opt/at.hh> + # include <mln/debug/println.hh> @@ -88,13 +90,13 @@ const int ncols = ima.ncols(); for (int r = -1; r <= nrows; ++r) { - ima.at(r, -1) = v; - ima.at(r, ncols) = v; + opt::at(ima, r, -1) = v; + opt::at(ima, r, ncols) = v; } for (int c = -1; c <= ncols; ++c) { - ima.at(-1, c) = v; - ima.at(nrows, c) = v; + opt::at(ima, -1, c) = v; + opt::at(ima, nrows, c) = v; } } @@ -216,14 +218,14 @@ unsigned row = (p.row() / 2 + 1) * (zoom + 1) - 1; unsigned col = (p.col() / 2) * (zoom + 1); for (unsigned i = 0; i < zoom; ++i) - output.at(row, col + i) = ima(p); + opt::at(output, row, col + i) = ima(p); } else // vertical edge { unsigned row = (p.row() / 2) * (zoom + 1); unsigned col = (p.col() / 2 + 1) * (zoom + 1) - 1; for (unsigned i = 0; i < zoom; ++i) - output.at(row + i, col) = ima(p); + opt::at(output, row + i, col) = ima(p); } return output; } @@ -240,7 +242,7 @@ 2 * input.ncols() - 1); for (int row = 0; row < input.nrows(); ++row) for (int col = 0; col < input.ncols(); ++col) - output.at(2 * row, 2 * col) = input.at(row, col); + output.at(2 * row, 2 * col) = mln::opt::at(input, row, col); return output; } @@ -253,7 +255,7 @@ (input.ncols() + 1) / 2); for (int row = 0; row < input.nrows(); row += 2) for (int col = 0; col < input.ncols(); col += 2) - output.at(row / 2, col / 2) = input.at(row, col); + output.at(row / 2, col / 2) = mln::opt::at(input, row, col); return output; } Index: sandbox/geraud/fllt.svg.6.cc --- sandbox/geraud/fllt.svg.6.cc (revision 3062) +++ sandbox/geraud/fllt.svg.6.cc (working copy) @@ -60,6 +60,8 @@ #include <mln/util/branch_iter_ind.hh> #include <mln/util/branch_iter.hh> +#include <mln/opt/at.hh> + #include <sstream> @@ -177,7 +179,7 @@ image2d<T> output(nrows_, ncols_); for (int row = 0; row < nrows_; ++row) for (int col = 0; col < ncols_; ++col) - output.at(row, col) = input.at(row / coef, col / coef); + output.at(row, col) = mln::opt::at(input, row / coef, col / coef); return output; } Index: sandbox/geraud/browsing/fwd.cc --- sandbox/geraud/browsing/fwd.cc (revision 3062) +++ sandbox/geraud/browsing/fwd.cc (working copy) @@ -3,6 +3,7 @@ # include <mln/value/int_u8.hh> # include <mln/accu/min_h.hh> # include <mln/accu/max_h.hh> +# include <mln/opt/at.hh> # include <mln/debug/println.hh> # include <mln/debug/iota.hh> @@ -104,10 +105,10 @@ // << std::endl; // for (unsigned c = 0; c <= half; ++c) - // std::cout << " take " << ima.at(row, c) << " "; + // std::cout << " take " << opt::at(ima, row, c) << " "; // std::cout << std::endl; - // std::cout << " --> OK at " << ima.at(row, col) << std::endl; + // std::cout << " --> OK at " << opt::at(ima, row, col) << std::endl; // // ok (row, col) at line start @@ -122,8 +123,8 @@ // { // ++col; // ++col_plus; - // std::cout << " take " << ima.at(row, col_plus) << " "; - // std::cout << " --> OK at " << ima.at(row, col) << std::endl; + // std::cout << " take " << opt::at(ima, row, col_plus) << " "; + // std::cout << " --> OK at " << opt::at(ima, row, col) << std::endl; // } // std::cout << std::endl @@ -138,9 +139,9 @@ // ++col; // ++col_plus; // ++col_minus; - // std::cout << " take " << ima.at(row, col_plus) << " "; - // std::cout << " untake " << ima.at(row, col_minus) << " "; - // std::cout << " --> OK at " << ima.at(row, col) << std::endl; + // std::cout << " take " << opt::at(ima, row, col_plus) << " "; + // std::cout << " untake " << opt::at(ima, row, col_minus) << " "; + // std::cout << " --> OK at " << opt::at(ima, row, col) << std::endl; // // ok (row, col) at line middle // } // std::cout << std::endl; @@ -155,8 +156,8 @@ // { // ++col; // ++col_minus; - // std::cout << " untake " << ima.at(row, col_minus) << " "; - // std::cout << " --> OK at " << ima.at(row, col) << std::endl; + // std::cout << " untake " << opt::at(ima, row, col_minus) << " "; + // std::cout << " --> OK at " << opt::at(ima, row, col) << std::endl; // } // std::cout << std::endl; @@ -185,10 +186,10 @@ unsigned col = col_start; for (unsigned c = 0; c <= half && c < len; ++c) - std::cout << " take " << ima.at(row, col + c) << " "; + std::cout << " take " << opt::at(ima, row, col + c) << " "; std::cout << std::endl; - std::cout << " --> OK at " << ima.at(row, col) << std::endl; + std::cout << " --> OK at " << opt::at(ima, row, col) << std::endl; // ok (row, col) at line start if (col == col_last) @@ -206,8 +207,8 @@ ++col; ++col_plus; if (col_plus <= col_last) - std::cout << " take " << ima.at(row, col_plus) << " "; - std::cout << " --> OK at " << ima.at(row, col) << std::endl; + std::cout << " take " << opt::at(ima, row, col_plus) << " "; + std::cout << " --> OK at " << opt::at(ima, row, col) << std::endl; } if (col == col_last) @@ -227,10 +228,10 @@ ++col_plus; ++col_minus; mln_invariant(col_plus >= col_start && col_plus <= col_last); - std::cout << " take " << ima.at(row, col_plus) << " "; + std::cout << " take " << opt::at(ima, row, col_plus) << " "; mln_invariant(col_minus >= col_start && col_minus <= col_last); - std::cout << " untake " << ima.at(row, col_minus) << " "; - std::cout << " --> OK at " << ima.at(row, col) << std::endl; + std::cout << " untake " << opt::at(ima, row, col_minus) << " "; + std::cout << " --> OK at " << opt::at(ima, row, col) << std::endl; // ok (row, col) at line middle } std::cout << std::endl; @@ -248,8 +249,8 @@ ++col; ++col_minus; mln_invariant(col_minus >= col_start && col_minus <= col_last); - std::cout << " untake " << ima.at(row, col_minus) << " "; - std::cout << " --> OK at " << ima.at(row, col) << std::endl; + std::cout << " untake " << opt::at(ima, row, col_minus) << " "; + std::cout << " --> OK at " << opt::at(ima, row, col) << std::endl; } std::cout << std::endl; Index: sandbox/geraud/fllt/fllt.hh --- sandbox/geraud/fllt/fllt.hh (revision 3062) +++ sandbox/geraud/fllt/fllt.hh (working copy) @@ -36,6 +36,7 @@ #include <mln/core/image/sub_image.hh> #include <mln/core/site_set/p_queue_fast.hh> #include <mln/core/image/cast_image.hh> +#include <mln/opt/at.hh> #include <mln/value/int_u8.hh> #include <mln/value/rgb8.hh> @@ -186,7 +187,7 @@ image2d<T> output(nrows_, ncols_); for (int row = 0; row < nrows_; ++row) for (int col = 0; col < ncols_; ++col) - output.at(row, col) = input.at(row / coef, col / coef); + opt::at(output, row, col) = opt::at(input, row / coef, col / coef); return output; } Index: sandbox/geraud/fllt/fllt.svg.7.hh --- sandbox/geraud/fllt/fllt.svg.7.hh (revision 3062) +++ sandbox/geraud/fllt/fllt.svg.7.hh (working copy) @@ -40,6 +40,8 @@ #include <mln/core/site_set/p_queue_fast.hh> #include <mln/core/image/cast_image.hh> +#include <mln/opt/at.hh> + #include <mln/value/int_u8.hh> #include <mln/value/rgb8.hh> @@ -178,7 +180,7 @@ image2d<T> output(nrows_, ncols_); for (int row = 0; row < nrows_; ++row) for (int col = 0; col < ncols_; ++col) - output.at(row, col) = input.at(row / coef, col / coef); + opt::at(output, row, col) = opt::at(input, row / coef, col / coef); return output; } Index: sandbox/geraud/fllt/fllt.svg.2.cc --- sandbox/geraud/fllt/fllt.svg.2.cc (revision 3062) +++ sandbox/geraud/fllt/fllt.svg.2.cc (working copy) @@ -48,6 +48,8 @@ #include <mln/literal/white.hh> #include <mln/literal/colors.hh> +#include <mln/opt/at.hh> + #include <sstream> @@ -100,7 +102,7 @@ image2d<T> output(nrows_, ncols_); for (int row = 0; row < nrows_; ++row) for (int col = 0; col < ncols_; ++col) - output.at(row, col) = input.at(row / coef, col / coef); + output.at(row, col) = mln::opt::at(input, row / coef, col / coef); return output; } Index: sandbox/geraud/fllt/fllt.svg.3.cc --- sandbox/geraud/fllt/fllt.svg.3.cc (revision 3062) +++ sandbox/geraud/fllt/fllt.svg.3.cc (working copy) @@ -49,6 +49,8 @@ #include <mln/literal/white.hh> #include <mln/literal/colors.hh> +#include <mln/opt/at.hh> + #include <sstream> @@ -101,7 +103,7 @@ image2d<T> output(nrows_, ncols_); for (int row = 0; row < nrows_; ++row) for (int col = 0; col < ncols_; ++col) - output.at(row, col) = input.at(row / coef, col / coef); + output.at(row, col) = mln::opt::at(input, row / coef, col / coef); return output; } Index: sandbox/geraud/fllt/fllt.svg.4.cc --- sandbox/geraud/fllt/fllt.svg.4.cc (revision 3062) +++ sandbox/geraud/fllt/fllt.svg.4.cc (working copy) @@ -51,6 +51,8 @@ #include <mln/literal/white.hh> #include <mln/literal/colors.hh> +#include <mln/opt/at.hh> + #include <sstream> @@ -103,7 +105,7 @@ image2d<T> output(nrows_, ncols_); for (int row = 0; row < nrows_; ++row) for (int col = 0; col < ncols_; ++col) - output.at(row, col) = input.at(row / coef, col / coef); + output.at(row, col) = mln::opt::at(input, row / coef, col / coef); return output; } Index: sandbox/geraud/fllt/fllt.svg.5.cc --- sandbox/geraud/fllt/fllt.svg.5.cc (revision 3062) +++ sandbox/geraud/fllt/fllt.svg.5.cc (working copy) @@ -51,6 +51,8 @@ #include <mln/literal/white.hh> #include <mln/literal/colors.hh> +#include <mln/opt/at.hh> + #include <sstream> @@ -103,7 +105,7 @@ image2d<T> output(nrows_, ncols_); for (int row = 0; row < nrows_; ++row) for (int col = 0; col < ncols_; ++col) - output.at(row, col) = input.at(row / coef, col / coef); + output.at(row, col) = mln::opt::at(input, row / coef, col / coef); return output; } Index: sandbox/geraud/fllt/fllt_test.hh --- sandbox/geraud/fllt/fllt_test.hh (revision 3062) +++ sandbox/geraud/fllt/fllt_test.hh (working copy) @@ -36,6 +36,8 @@ #include <mln/core/site_set/p_queue_fast.hh> #include <mln/core/image/cast_image.hh> +#include <mln/opt/at.hh> + #include <mln/value/int_u8.hh> #include <mln/value/rgb8.hh> @@ -181,7 +183,7 @@ image2d<T> output(nrows_, ncols_); for (int row = 0; row < nrows_; ++row) for (int col = 0; col < ncols_; ++col) - output.at(row, col) = input.at(row / coef, col / coef); + opt::at(output, row, col) = opt::at(input, row / coef, col / coef); return output; } Index: sandbox/geraud/fllt.svg.7.hh --- sandbox/geraud/fllt.svg.7.hh (revision 3062) +++ sandbox/geraud/fllt.svg.7.hh (working copy) @@ -63,6 +63,7 @@ #include <mln/util/tree.hh> #include <mln/util/branch_iter_ind.hh> #include <mln/util/branch_iter.hh> +#include <mln/opt/at.hh> #include <sstream> @@ -178,7 +179,7 @@ image2d<T> output(nrows_, ncols_); for (int row = 0; row < nrows_; ++row) for (int col = 0; col < ncols_; ++col) - output.at(row, col) = input.at(row / coef, col / coef); + opt::at(output, row, col) = opt::at(input, row / coef, col / coef); return output; } Index: sandbox/geraud/dmap.cc --- sandbox/geraud/dmap.cc (revision 3062) +++ sandbox/geraud/dmap.cc (working copy) @@ -8,6 +8,7 @@ #include <mln/accu/max.hh> #include <mln/io/pbm/load.hh> #include <mln/io/pgm/save.hh> +#include <mln/opt/at.hh> namespace mln @@ -107,7 +108,7 @@ const unsigned n = 9; image2d<bool> ima(n, n); level::fill(ima, false); - ima.at(n / 2, n / 2) = true; + opt::at(ima, n / 2, n / 2) = true; // int ws[] = { 3, 2, 3, // 2, 0, 2, Index: sandbox/geraud/tufa_2008/steps.0.cc --- sandbox/geraud/tufa_2008/steps.0.cc (revision 3062) +++ sandbox/geraud/tufa_2008/steps.0.cc (working copy) @@ -42,6 +42,7 @@ #include <mln/morpho/tree/compute_attribute_image.hh> #include <mln/morpho/closing_area.hh> #include <mln/level/fill.hh> +#include <mln/opt/at.hh> namespace mln @@ -54,10 +55,10 @@ for (int r = 0; r < nr; ++r) { for (int c = 0; c < nc; ++c) - if (par.at(r,c) == point2d(r,c)) + if (opt::at(par, r,c) == point2d(r,c)) std::cout << "( ) "; else - std::cout << par.at(r,c) << ' '; + std::cout << opt::at(par, r,c) << ' '; std::cout << std::endl; } } Index: sandbox/geraud/tufa_2008/steps.1.cc --- sandbox/geraud/tufa_2008/steps.1.cc (revision 3062) +++ sandbox/geraud/tufa_2008/steps.1.cc (working copy) @@ -44,6 +44,7 @@ #include <mln/morpho/tree/compute_attribute_image.hh> #include <mln/morpho/closing_area.hh> #include <mln/level/fill.hh> +#include <mln/opt/at.hh> namespace mln @@ -56,10 +57,10 @@ for (int r = 0; r < nr; ++r) { for (int c = 0; c < nc; ++c) - if (par.at(r,c) == point2d(r,c)) + if (opt::at(par, r,c) == point2d(r,c)) std::cout << "( ) "; else - std::cout << par.at(r,c) << ' '; + std::cout << opt::at(par, r,c) << ' '; std::cout << std::endl; } } Index: sandbox/geraud/tufa_2008/steps.2.cc --- sandbox/geraud/tufa_2008/steps.2.cc (revision 3062) +++ sandbox/geraud/tufa_2008/steps.2.cc (working copy) @@ -44,6 +44,7 @@ #include <mln/morpho/tree/compute_attribute_image.hh> #include <mln/morpho/closing_area.hh> #include <mln/level/fill.hh> +#include <mln/opt/at.hh> namespace mln @@ -56,10 +57,10 @@ for (int r = 0; r < nr; ++r) { for (int c = 0; c < nc; ++c) - if (par.at(r,c) == point2d(r,c)) + if (opt::at(par, r,c) == point2d(r,c)) std::cout << "( ) "; else - std::cout << par.at(r,c) << ' '; + std::cout << opt::at(par, r,c) << ' '; std::cout << std::endl; } } Index: sandbox/geraud/tufa_2008/steps.3.cc --- sandbox/geraud/tufa_2008/steps.3.cc (revision 3062) +++ sandbox/geraud/tufa_2008/steps.3.cc (working copy) @@ -45,6 +45,8 @@ #include <mln/morpho/closing_area.hh> #include <mln/level/fill.hh> +#include <mln/opt/at.hh> + namespace mln { @@ -56,10 +58,10 @@ for (int r = 0; r < nr; ++r) { for (int c = 0; c < nc; ++c) - if (par.at(r,c) == point2d(r,c)) + if (opt::at(par, r,c) == point2d(r,c)) std::cout << "( ) "; else - std::cout << par.at(r,c) << ' '; + std::cout << opt::at(par, r,c) << ' '; std::cout << std::endl; } } Index: sandbox/geraud/tufa_2008/steps.2b.cc --- sandbox/geraud/tufa_2008/steps.2b.cc (revision 3062) +++ sandbox/geraud/tufa_2008/steps.2b.cc (working copy) @@ -44,6 +44,7 @@ #include <mln/morpho/tree/compute_attribute_image.hh> #include <mln/morpho/closing_area.hh> #include <mln/level/fill.hh> +#include <mln/opt/at.hh> namespace mln @@ -56,10 +57,10 @@ for (int r = 0; r < nr; ++r) { for (int c = 0; c < nc; ++c) - if (par.at(r,c) == point2d(r,c)) + if (opt::at(par, r,c) == point2d(r,c)) std::cout << "( ) "; else - std::cout << par.at(r,c) << ' '; + std::cout << opt::at(par, r,c) << ' '; std::cout << std::endl; } } Index: sandbox/geraud/tufa_2008/compute_a.cc --- sandbox/geraud/tufa_2008/compute_a.cc (revision 3062) +++ sandbox/geraud/tufa_2008/compute_a.cc (working copy) @@ -46,6 +46,7 @@ #include <mln/labeling/regional_minima.hh> #include <mln/accu/count.hh> +#include <mln/opt/at.hh> @@ -59,10 +60,10 @@ for (int r = 0; r < nr; ++r) { for (int c = 0; c < nc; ++c) - if (par.at(r,c) == point2d(r,c)) + if (opt::at(par, r,c) == point2d(r,c)) std::cout << "( ) "; else - std::cout << par.at(r,c) << ' '; + std::cout << opt::at(par, r,c) << ' '; std::cout << std::endl; } } Index: sandbox/geraud/tufa_2008/fz_count.cc --- sandbox/geraud/tufa_2008/fz_count.cc (revision 3062) +++ sandbox/geraud/tufa_2008/fz_count.cc (working copy) @@ -39,6 +39,7 @@ #include <mln/labeling/regional_minima.hh> #include <mln/labeling/flat_zones.hh> #include <mln/level/fill.hh> +#include <mln/opt/at.hh> namespace mln @@ -51,10 +52,10 @@ for (int r = 0; r < nr; ++r) { for (int c = 0; c < nc; ++c) - if (par.at(r,c) == point2d(r,c)) + if (opt::at(par, r,c) == point2d(r,c)) std::cout << "( ) "; else - std::cout << par.at(r,c) << ' '; + std::cout << opt::at(par, r,c) << ' '; std::cout << std::endl; } } Index: sandbox/geraud/tufa_2008/regmin_count.cc --- sandbox/geraud/tufa_2008/regmin_count.cc (revision 3062) +++ sandbox/geraud/tufa_2008/regmin_count.cc (working copy) @@ -40,6 +40,8 @@ #include <mln/labeling/flat_zones.hh> #include <mln/level/fill.hh> +#include <mln/opt/at.hh> + namespace mln { @@ -51,10 +53,10 @@ for (int r = 0; r < nr; ++r) { for (int c = 0; c < nc; ++c) - if (par.at(r,c) == point2d(r,c)) + if (opt::at(par, r,c) == point2d(r,c)) std::cout << "( ) "; else - std::cout << par.at(r,c) << ' '; + std::cout << opt::at(par, r,c) << ' '; std::cout << std::endl; } } Index: tests/debug/println_with_border.cc --- tests/debug/println_with_border.cc (revision 3062) +++ tests/debug/println_with_border.cc (working copy) @@ -35,6 +35,7 @@ #include <mln/level/fill.hh> #include <mln/debug/println.hh> #include <mln/debug/println_with_border.hh> +#include <mln/opt/at.hh> using namespace mln; @@ -46,17 +47,17 @@ { image2d<bool> msk(3, 3); - msk.at(0, 0) = true; - msk.at(1, 0) = true; - msk.at(2, 0) = true; - - msk.at(0, 1) = true; - msk.at(1, 1) = false; - msk.at(2, 1) = true; - - msk.at(0, 2) = true; - msk.at(1, 2) = true; - msk.at(2, 2) = true; + opt::at(msk, 0, 0) = true; + opt::at(msk, 1, 0) = true; + opt::at(msk, 2, 0) = true; + + opt::at(msk, 0, 1) = true; + opt::at(msk, 1, 1) = false; + opt::at(msk, 2, 1) = true; + + opt::at(msk, 0, 2) = true; + opt::at(msk, 1, 2) = true; + opt::at(msk, 2, 2) = true; debug::println(msk); debug::println_with_border(msk); @@ -64,9 +65,9 @@ { image1d<bool> msk(3); - msk.at(0) = false; - msk.at(1) = true; - msk.at(2) = false; + opt::at(msk, 0) = false; + opt::at(msk, 1) = true; + opt::at(msk, 2) = false; debug::println(msk); debug::println_with_border(msk); Index: tests/debug/println.cc --- tests/debug/println.cc (revision 3062) +++ tests/debug/println.cc (working copy) @@ -33,6 +33,7 @@ #include <mln/core/image/image2d.hh> #include <mln/level/fill.hh> #include <mln/debug/println.hh> +#include <mln/opt/at.hh> using namespace mln; @@ -41,6 +42,6 @@ int main() { image2d<bool> msk(3, 3); - msk.at(1, 1) = true; + opt::at(msk, 1, 1) = true; debug::println(msk); } Index: tests/histo/compute.cc --- tests/histo/compute.cc (revision 3062) +++ tests/histo/compute.cc (working copy) @@ -42,6 +42,8 @@ #include <mln/accu/histo.hh> #include <mln/histo/compute.hh> +#include <mln/opt/at.hh> + int main() { @@ -66,7 +68,7 @@ { image2d<int_u8> ima(3, 3); debug::iota(ima); - ima.at(0,0) = 2; + opt::at(ima, 0,0) = 2; histo::data<int_u8> h = histo::compute(ima); std::ostringstream oss; Index: tests/core/other/pixel.cc --- tests/core/other/pixel.cc (revision 3062) +++ tests/core/other/pixel.cc (working copy) @@ -33,6 +33,7 @@ #include <mln/core/image/image2d.hh> #include <mln/core/pixel.hh> #include <mln/metal/equal.hh> +#include <mln/opt/at.hh> int main() @@ -47,12 +48,12 @@ { pixel<I> pxl(ima, point2d(1, 1)); pxl.val() = 51; - mln_assertion(ima.at(1, 1) == 51); + mln_assertion(opt::at(ima, 1, 1) == 51); } { pixel<const I> pxl(ima, point2d(1, 1)); - ima.at(1, 1) = 51; + opt::at(ima, 1, 1) = 51; mln_assertion(unsigned(pxl) == 4); mln_assertion(pxl.val() == 51); Index: tests/opt/Makefile.am --- tests/opt/Makefile.am (revision 0) +++ tests/opt/Makefile.am (revision 0) @@ -0,0 +1,10 @@ +## Process this file through Automake to create Makefile.in -*- Makefile -*- + +include $(top_srcdir)/milena/tests/tests.mk + +check_PROGRAMS = \ + at + +at_SOURCES = at.cc + +TESTS = $(check_PROGRAMS) Index: tests/level/convert.cc --- tests/level/convert.cc (revision 3062) +++ tests/level/convert.cc (working copy) @@ -35,6 +35,7 @@ #include <mln/value/rgb8.hh> #include <mln/literal/grays.hh> +#include <mln/opt/at.hh> int main() @@ -47,10 +48,10 @@ // bool -> rgb8 { image2d<bool> ima(1, 2); - ima.at(0, 0) = false; - ima.at(0, 1) = true; + opt::at(ima, 0, 0) = false; + opt::at(ima, 0, 1) = true; image2d<rgb8> out = level::convert(rgb8(), ima); - mln_assertion(out.at(0, 0) == literal::black); - mln_assertion(out.at(0, 1) == literal::white); + mln_assertion(opt::at(out, 0, 0) == literal::black); + mln_assertion(opt::at(out, 0, 1) == literal::white); } } Index: tests/level/memset_.cc --- tests/level/memset_.cc (revision 3062) +++ tests/level/memset_.cc (working copy) @@ -34,6 +34,7 @@ #include <mln/geom/ncols.hh> #include <mln/level/fill.hh> #include <mln/level/memset_.hh> +#include <mln/opt/at.hh> int main() @@ -48,6 +49,6 @@ geom::ncols(ima) + 2 * ima.border() + 1); // ^ // | - mln_assertion(ima.at(1,0) == X); // <----------------+ - mln_assertion(ima.at(1,1) != X); + mln_assertion(opt::at(ima, 1,0) == X); // <----------------+ + mln_assertion(opt::at(ima, 1,1) != X); } Index: tests/transform/distance_geodesic.cc --- tests/transform/distance_geodesic.cc (revision 3062) +++ tests/transform/distance_geodesic.cc (working copy) @@ -34,6 +34,7 @@ #include <mln/value/int_u8.hh> #include <mln/level/fill.hh> #include <mln/debug/println.hh> +#include <mln/opt/at.hh> #include <mln/transform/distance_geodesic.hh> @@ -45,7 +46,7 @@ image2d<bool> input(9, 9); level::fill(input, false); - input.at(4, 4) = true; + opt::at(input, 4, 4) = true; image2d<int_u8> output = transform::distance_geodesic(input, c4(), int_u8(4)); debug::println(output); Index: tests/transform/distance_front.cc --- tests/transform/distance_front.cc (revision 3062) +++ tests/transform/distance_front.cc (working copy) @@ -35,6 +35,7 @@ #include <mln/value/int_u8.hh> #include <mln/level/fill.hh> #include <mln/debug/println.hh> +#include <mln/opt/at.hh> #include <mln/transform/distance_front.hh> @@ -46,7 +47,7 @@ image2d<bool> input(9, 9); level::fill(input, false); - input.at(4, 4) = true; + opt::at(input, 4, 4) = true; int ws[] = { 0, 9, 0, 9, 0, 9, 6, 4, 6, 9, Index: tests/make/dual_neighb.cc --- tests/make/dual_neighb.cc (revision 3062) +++ tests/make/dual_neighb.cc (working copy) @@ -32,6 +32,7 @@ #include <mln/make/dual_neighb.hh> #include <mln/core/alias/neighb2d.hh> #include <mln/core/image/image2d.hh> +#include <mln/opt/at.hh> @@ -53,8 +54,8 @@ using namespace mln; image2d<bool> ima(1, 2, 1); - ima.at(0, 0) = true; - ima.at(0, 1) = false; + opt::at(ima, 0, 0) = true; + opt::at(ima, 0, 1) = false; mln_assertion( count(ima, make::dual_neighb(ima, c4(), c8())) == c4().size() + c8().size() ); Index: tests/morpho/artificial_line_graph_image_wst.cc --- tests/morpho/artificial_line_graph_image_wst.cc (revision 3062) +++ tests/morpho/artificial_line_graph_image_wst.cc (working copy) @@ -76,6 +76,8 @@ #include <mln/math/max.hh> #include <mln/math/abs.hh> +#include <mln/opt/at.hh> + #include "tests/data.hh" @@ -100,7 +102,7 @@ image2d<input_val_t> input (nrows, ncols); for (unsigned r = 0; r < nrows; ++r) for (unsigned c = 0; c < ncols; ++c) - input.at(r,c) = + opt::at(input, r,c) = ((r / square_length) % 2 == (c / square_length) % 2) ? mln_min(input_val_t) : mln_max(input_val_t); Index: tests/Makefile.am --- tests/Makefile.am (revision 3062) +++ tests/Makefile.am (working copy) @@ -30,6 +30,7 @@ metal \ morpho \ norm \ + opt \ pw \ set \ subsampling \ Index: tests/canvas/chamfer.cc --- tests/canvas/chamfer.cc (revision 3062) +++ tests/canvas/chamfer.cc (working copy) @@ -43,6 +43,8 @@ #include <mln/geom/chamfer.hh> #include <mln/level/compare.hh> +#include <mln/opt/at.hh> + int main() { @@ -53,7 +55,7 @@ { level::fill(ima, false); - ima.at(4,4) = true; + opt::at(ima, 4,4) = true; const w_window2d_int& w_win = make::mk_chamfer_3x3_int<2, 0> (); image2d<unsigned> out = geom::chamfer(ima, w_win, max); unsigned r[9][9] = @@ -75,7 +77,7 @@ { level::fill(ima, false); - ima.at(4,4) = true; + opt::at(ima, 4,4) = true; const w_window2d_int& w_win = make::mk_chamfer_3x3_int<2, 3> (); image2d<unsigned> out = geom::chamfer(ima, w_win, max); @@ -98,7 +100,7 @@ { level::fill(ima, false); - ima.at(4,4) = true; + opt::at(ima, 4,4) = true; const w_window2d_int& w_win = make::mk_chamfer_5x5_int<4, 6, 9> (); image2d<unsigned> out = geom::chamfer(ima, w_win, max); image2d<unsigned>::fwd_piter p(out.domain()); Index: doc/tutorial/samples/ima2d-3.cc --- doc/tutorial/samples/ima2d-3.cc (revision 3062) +++ doc/tutorial/samples/ima2d-3.cc (working copy) @@ -1,5 +1,7 @@ #include <mln/core/image/image2d.hh> #include <mln/core/alias/box2d.hh> +#include <mln/opt/at.hh> + int main() { using namespace mln; @@ -13,8 +15,8 @@ // Associate '9' as value for the site/point2d (1,2). // The value is returned by reference and can be changed. - ima.at(1,2) = 9; - std::cout << "ima.at(1,2) = " << ima.at(1,2) + opt::at(ima, 1,2) = 9; + std::cout << "ima.at(1,2) = " << opt::at(ima, 1,2) << std::endl; std::cout << "ima(p) = " << ima(p) << std::endl; @@ -25,7 +27,7 @@ // The value is returned by reference // and can be changed as well. ima(p) = 2; - std::cout << "ima.at(1,2) = " << ima.at(1,2) + std::cout << "ima.at(1,2) = " << opt::at(ima, 1,2) << std::endl; std::cout << "ima(p) = " << ima(p) << std::endl; // \} Index: doc/tutorial/examples/image_plain.cc --- doc/tutorial/examples/image_plain.cc (revision 3062) +++ doc/tutorial/examples/image_plain.cc (working copy) @@ -3,6 +3,7 @@ # include <mln/debug/println.hh> # include <mln/debug/iota.hh> # include <mln/level/fill_with_value.hh> +# include <mln/opt/at.hh> template <typename I> @@ -10,14 +11,14 @@ { using namespace mln; const unsigned - nr = ima.at(0,0).domain().nrows(), - nc = ima.at(0,0).domain().ncols(); + nr = opt::at(ima, 0,0).domain().nrows(), + nc = opt::at(ima, 0,0).domain().ncols(); for (unsigned row = 0; row < ima.nrows(); ++row) for (unsigned r = 0; r < nr; ++r) { for (unsigned col = 0; col < ima.ncols(); ++col) for (unsigned c = 0; c < nc; ++c) - std::cout << ima.at(row, col)(point2d(r,c)) << ' '; + std::cout << opt::at(ima, row, col)(point2d(r,c)) << ' '; std::cout << std::endl; } } @@ -36,6 +37,6 @@ image2d<I_> mos(2, 2); level::fill_with_value(mos, ima); - level::fill_with_value(mos.at(1,1), 0); + level::fill_with_value(opt::at(mos, 1,1), 0); picture(mos); } Index: doc/benchmark/image2d.cc --- doc/benchmark/image2d.cc (revision 3062) +++ doc/benchmark/image2d.cc (working copy) @@ -2,6 +2,7 @@ # include <mln/util/timer.hh> # include <mln/core/pixter2d.hh> +# include <mln/opt/at.hh> int size; @@ -45,7 +46,7 @@ t.start(); for (int row = 0; row < size; ++row) for (int col = 0; col < size; ++col) - ima.at(row, col) = 0; + mln::opt::at(ima, row, col) = 0; return t.read(); } @@ -80,7 +81,7 @@ mln::def::coord & row = p.row(), & col = p.col(); for (row = 0; row < size; ++row) for (col = 0; col < size; ++col) - ima.at(row, col) = 0; + mln::opt::at(ima, row, col) = 0; return t.read(); } Index: doc/examples/labeling_algo.cc --- doc/examples/labeling_algo.cc (revision 3062) +++ doc/examples/labeling_algo.cc (working copy) @@ -43,6 +43,8 @@ # include <mln/draw/mesh.hh> # include <mln/geom/seeds2tiling.hh> # include <mln/make/voronoi.hh> +# include <mln/make/voronoi.hh> +# include <mln/opt/at.hh> int main() { @@ -59,7 +61,7 @@ image2d<int> input(in.domain()); level::fill(input, lab); - lab.at(0,0) = 0; + opt::at(lab, 0,0) = 0; image2d<unsigned> inte = geom::seeds2tiling(lab, c4 ()); border::fill(inte, 0);
16 years
1
0
0
0
3062: Handle data mutability in pw::image.
by Thierry Geraud
https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog from Thierry Geraud <thierry.geraud(a)lrde.epita.fr> Handle data mutability in pw::image. * mln/trait/images.hh: Upgrade doc style. * mln/core/site_set/p_array.hh (operator int, operator unsigned): New in p_indexed_psite. * mln/core/concept/function.hh (is_mutable): New. * mln/fun/l2l/relabel.hh: Likewise. * mln/fun/i2v/array.hh: Likewise. * mln/fun/internal/array_base.hh: Likewise. * mln/pw/image.hh (value_io, pw_io): Allow mutability. * tests/pw/image.cc: Add a test on a mutable image. mln/core/concept/function.hh | 1 + mln/core/site_set/p_array.hh | 18 ++++++++++++++++++ mln/fun/i2v/array.hh | 4 ++++ mln/fun/internal/array_base.hh | 1 + mln/fun/l2l/relabel.hh | 3 +-- mln/pw/image.hh | 26 ++++++++++++++++++-------- mln/trait/images.hh | 18 +++++++++--------- tests/pw/image.cc | 19 ++++++++++++++++++- 8 files changed, 70 insertions(+), 20 deletions(-) Index: mln/trait/images.hh --- mln/trait/images.hh (revision 3061) +++ mln/trait/images.hh (working copy) @@ -1,4 +1,5 @@ // Copyright (C) 2007, 2008 EPITA Research and Development Laboratory +// (LRDE) // // This file is part of the Olena Library. This library is free // software; you can redistribute it and/or modify it under the terms @@ -28,14 +29,13 @@ #ifndef MLN_TRAIT_IMAGES_HH # define MLN_TRAIT_IMAGES_HH -/*! \file mln/trait/images.hh - * - * \brief Some base trait types for images. - * - * \todo Split this file into many. - * - * \todo the 'nature' prop is not set yet in image types. - */ +/// \file mln/trait/images.hh +/// +/// Some base trait types for images. +/// +/// \todo Split this file into many. +/// +/// \todo the 'nature' prop is not set yet in image types. # include <iostream> # include <string> @@ -113,7 +113,7 @@ template <typename T> struct image1d; template <typename T> struct image2d; template <typename T> struct image3d; - namespace pw { template <typename F, typename S> struct image; } + namespace pw { template <typename F, typename S> class image; } template <typename P, typename T> class rle_image; template <typename P, typename T> class sparse_image; Index: mln/core/site_set/p_array.hh --- mln/core/site_set/p_array.hh (revision 3061) +++ mln/core/site_set/p_array.hh (working copy) @@ -1,4 +1,5 @@ // Copyright (C) 2007, 2008 EPITA Research and Development Laboratory +// (LRDE) // // This file is part of the Olena Library. This library is free // software; you can redistribute it and/or modify it under the terms @@ -206,6 +207,8 @@ bool is_valid() const; operator util::index() const; + operator int() const; // To interoperate, e.g., with fun::i2v expecting an int. + operator unsigned() const; // To avoid ambiguity when an unsigned is expected. void update_() const; @@ -586,6 +589,21 @@ return i_; } + template <typename S> + inline + p_indexed_psite<S>::operator int() const + { + return i_; + } + + template <typename S> + inline + p_indexed_psite<S>::operator unsigned() const + { + mln_precondition(i_ >= 0); + return i_; + } + // p_indexed_fwd_piter<S>. Index: mln/core/concept/function.hh --- mln/core/concept/function.hh (revision 3061) +++ mln/core/concept/function.hh (working copy) @@ -100,6 +100,7 @@ struct Function_v2v : public Function<E> { typedef Function_v2v<void> category; + typedef metal::false_ is_mutable; // Meaning: no mutable result by default. protected: Function_v2v(); Function_v2v(const Function_v2v&); Index: mln/pw/image.hh --- mln/pw/image.hh (revision 3061) +++ mln/pw/image.hh (working copy) @@ -44,7 +44,7 @@ { // Fwd decl. - namespace pw { template <typename F, typename S> struct image; } + namespace pw { template <typename F, typename S> class image; } @@ -93,10 +93,14 @@ typedef trait::image::value_storage::disrupted value_storage; typedef trait::image::value_browsing::site_wise_only value_browsing; typedef trait::image::value_alignement::irrelevant value_alignement; - typedef trait::image::value_io::read_only value_io; + typedef mlc_if(typename F::is_mutable, + trait::image::value_io::read_write, + trait::image::value_io::read_only) value_io; // site / domain - typedef trait::image::pw_io::read pw_io; + typedef mlc_if(typename F::is_mutable, + trait::image::pw_io::read_write, + trait::image::pw_io::read) pw_io; typedef /* FIXME: depends on S */ undef localization; typedef /* FIXME: depends on S */ undef dimension; @@ -115,9 +119,11 @@ /// FIXME /// template <typename F, typename S> - struct image : + class image : public internal::image_primary<mln_result(F), S, image<F,S> > { + public: + /// Skeleton. typedef image< tag::function_<F>, tag::pset_<S> > skeleton; @@ -129,7 +135,7 @@ typedef mln_result(F) rvalue; /// Return type of read-write access. - typedef rvalue lvalue; + typedef mlc_if(typename F::is_mutable, mln_result(F)&, mln_result(F)) lvalue; /// Constructor without argument. image(); @@ -149,12 +155,15 @@ /// Read-only access of pixel value at point site \p p. mln_result(F) operator()(const mln_psite(S)& p) const; - /// Read-write access is present but return a temporary value. - mln_result(F) operator()(const mln_psite(S)&); + /// Read-write access returns either a temporary value (copy) or + /// a reference in the case of a mutable function (container). + lvalue operator()(const mln_psite(S)&); }; } // end of namespace mln::pw + + template <typename F, typename S> void init_(tag::function_t, Function_v2v<F>& target, const mln::pw::image<F,S>& model); @@ -163,6 +172,7 @@ void init_(tag::image_t, mln::pw::image<F,S>& target, const J& model); + # ifndef MLN_INCLUDE_ONLY // init_ @@ -264,7 +274,7 @@ template <typename F, typename S> inline - mln_result(F) + typename image<F,S>::lvalue image<F,S>::operator()(const mln_psite(S)& p) { mln_precondition(this->data_->pset_.has(p)); Index: mln/fun/l2l/relabel.hh --- mln/fun/l2l/relabel.hh (revision 3061) +++ mln/fun/l2l/relabel.hh (working copy) @@ -106,8 +106,7 @@ /// Always prefer using from_to instead of this constructor. relabel(const std::vector<L>& from); - /// \} - + typedef metal::true_ is_mutable; }; } // end of namespace mln::fun::l2l Index: mln/fun/i2v/array.hh --- mln/fun/i2v/array.hh (revision 3061) +++ mln/fun/i2v/array.hh (working copy) @@ -31,6 +31,9 @@ /// \file mln/fun/i2v/array.hh /// /// Function mapping an Id i to a value v. +/// +/// \todo Change design so that there is no multiple inheritance: +/// array<T> : internal::array_base<T, E==array<T> > : Function_i2v<E> # include <vector> # include <algorithm> @@ -107,6 +110,7 @@ /// \} + typedef metal::true_ is_mutable; }; } // end of namespace mln::fun::i2v Index: mln/fun/internal/array_base.hh --- mln/fun/internal/array_base.hh (revision 3061) +++ mln/fun/internal/array_base.hh (working copy) @@ -53,6 +53,7 @@ public: typedef T result; + typedef metal::true_ is_mutable; void resize(unsigned n); void resize(unsigned n, const T& val); Index: tests/pw/image.cc --- tests/pw/image.cc (revision 3061) +++ tests/pw/image.cc (working copy) @@ -31,7 +31,9 @@ /// Tests on mln::pw::image. #include <mln/fun/p2b/chess.hh> +#include <mln/fun/i2v/array.hh> #include <mln/core/alias/box2d.hh> +#include <mln/core/site_set/p_array.hh> #include <mln/pw/image.hh> #include <mln/core/var.hh> @@ -41,8 +43,10 @@ using namespace mln; mln_VAR(ima, fun::p2b::chess() | make::box2d(8, 8)); - mln_piter_(ima_t) p(ima.domain()); + // trait::image::print(ima); + unsigned i = 0; + mln_piter_(ima_t) p(ima.domain()); for_all(p) { if (p.row() % 2) @@ -52,4 +56,17 @@ ++i; } mln_assertion(i == 64); + + // A mutable pw::image. + { + p_array<int> arr; // Sites are ints (why not?) + arr.insert(51); // Site 51. + mln_VAR(ima, fun::i2v::array<int>(1) | arr); // An array psite converts to int so that works :-) + // trait::image::print(ima); + + p_array<int>::psite p(ima.domain(), 0); // index 0 means the 1st element of arr + ima(p) = 7; + mln_assertion(ima(p) == 7); + } + }
16 years
1
0
0
0
3061: Spot differences between step2 and n_cmpt5.
by Ugo Jardonnet
https://svn.lrde.epita.fr/svn/oln/trunk/milena/sandbox
Index: ChangeLog from Ugo Jardonnet <ugo.jardonnet(a)lrde.epita.fr> Spot differences between step2 and n_cmpt5. * jardonnet/n_cmpt/prob.pgm: Test case. * jardonnet/n_cmpt/fused_filter.cc: Version using boolean image. * jardonnet/n_cmpt/ref_filter.cc: Version using set. * jardonnet/n_cmpt/n_cmpt5.hh: Minor change. * jardonnet/n_cmpt/fused: Log. * jardonnet/n_cmpt/ref: Log. * jardonnet/n_cmpt/Makefile: Add related rules. * jardonnet/n_cmpt/diff_ref_fused_on_small: diff. igr/Makefile | 2 igr/src/igr.cc | 8 - n_cmpt/Makefile | 26 ++-- n_cmpt/diff_ref_fused_on_small | 13 ++ n_cmpt/fused | 26 ++++ n_cmpt/fused_filter.cc | 252 +++++++++++++++++++++++++++++++++++++++++ n_cmpt/n_cmpt5.hh | 14 +- n_cmpt/prob.pgm | 5 n_cmpt/ref | 22 +++ n_cmpt/ref_filter.cc | 224 ++++++++++++++++++++++++++++++++++++ test/big_chess.cc | 21 ++- 11 files changed, 586 insertions(+), 27 deletions(-) Index: jardonnet/test/big_chess.cc --- jardonnet/test/big_chess.cc (revision 3060) +++ jardonnet/test/big_chess.cc (working copy) @@ -8,9 +8,12 @@ #include <mln/core/image/image2d.hh> #include <mln/value/int_u8.hh> +#include <mln/value/rgb8.hh> #include <mln/io/pgm/load.hh> #include <mln/level/paste.hh> -#include <mln/io/pgm/save.hh> + +#include <mln/io/ppm/load.hh> +#include <mln/io/ppm/save.hh> #include <mln/fun/p2b/big_chess.hh> @@ -19,9 +22,9 @@ bool usage(int argc, char ** argv) { - if (argc != 3) + if (argc != 4) { - std::cout << argv[0] << " ima1.pgm ima2.pgm" << std::endl; + std::cout << argv[0] << " ima1.pgm ima2.pgm div" << std::endl; return false; } return true; @@ -52,14 +55,16 @@ if (not usage(argc,argv)) return 1; - typedef image2d<int_u8> I; + typedef image2d<rgb8> I; I ima1; I ima2; - io::pgm::load(ima1, argv[1]); - io::pgm::load(ima2, argv[2]); + io::ppm::load(ima1, argv[1]); + io::ppm::load(ima2, argv[2]); + + int div = atoi(argv[3]); - fun::p2b::big_chess<box2d> fun(ima1.domain(), 4); + fun::p2b::big_chess<box2d> fun(ima1.domain(), div); image_if< I, fun::p2b::big_chess<box2d> > visio = ima1 | fun; @@ -67,5 +72,5 @@ level::paste(visio, ima2); - io::pgm::save(ima2, "out.ppm"); + io::ppm::save(ima2, "out.ppm"); } Index: jardonnet/n_cmpt/prob.pgm --- jardonnet/n_cmpt/prob.pgm (revision 0) +++ jardonnet/n_cmpt/prob.pgm (revision 0) @@ -0,0 +1,5 @@ +P5 +# CREATOR: GIMP PNM Filter Version 1.1 +24 22 +255 +��������`fijjqy~���������������~^chhhpy}���������������^cighpx|��������������~\chghox|�������������}[bgfgowz}~�����������|Ybgfgowz|}~����������~X`ggipx{}~������������}T\bdhovy{|~�����ex���|QYacfkruy{|wyz��zUy���zP[ccekqtxyxou{�`Vz���yR[bdekquy{xnrwx{jXYy���xS\bdekrvyyoousvYZZx���yR[cceksv{soqsv~�Z[Zx���zRYadekru�jmpsz��ZZWv���{PW_bejm~�gnqv���[][u���yNVacdil��emrz}~`b`w���|QZcefln��dksy{~{ccbz���~S[cedim�fhnvy{�cbcz���RZbccfp��nipv{��a`ay����S[bbcds��}imv���`_`{����T\bacas���mp����aad~����QZaab_u���z{��� \ No newline at end of file Index: jardonnet/n_cmpt/fused_filter.cc --- jardonnet/n_cmpt/fused_filter.cc (revision 0) +++ jardonnet/n_cmpt/fused_filter.cc (revision 0) @@ -0,0 +1,252 @@ +#include <mln/core/image/image2d.hh> +#include <mln/value/int_u8.hh> +#include <mln/io/pgm/load.hh> +#include <mln/debug/println.hh> + +#include <mln/core/site_set/p_array.hh> +#include <mln/level/sort_psites.hh> +#include <mln/core/alias/neighb2d.hh> +#include <mln/morpho/tree/data.hh> + +#include <mln/accu/count.hh> +#include <mln/util/set.hh> + +#include <mln/labeling/regional_minima.hh> +#include <mln/morpho/tree/compute_attribute_image.hh> +#include <mln/morpho/closing_area.hh> +#include <mln/level/fill.hh> + +#include <mln/debug/iota.hh> + +#include <mln/pw/all.hh> +#include <mln/core/image/image_if.hh> + +namespace mln +{ + + template <typename I> + void println_par(const I& par) + { + int nr = par.nrows(), nc = par.ncols(); + for (int r = 0; r < nr; ++r) + { + for (int c = 0; c < nc; ++c) + if (par.at(r,c) == point2d(r,c)) + std::cout << "( ) "; + else + std::cout << par.at(r,c) << ' '; + std::cout << std::endl; + } + } + + template <typename P> + inline + mln_value(P) find_root__(P& par, const mln_value(P)& x) + { + if (par(x) == x) + return x; + else + return par(x) = find_root__(par, par(x)); + } + + + template <typename I, typename A, typename N> + mln_ch_value(I, util::set<unsigned>) + compute_labels(const I& f, const A& a, const N& nbh, + unsigned n_objects, + bool echo = false) + { + if (echo) + debug::println("f =", f); + + typedef p_array<mln_psite(I)> S; + S s = level::sort_psites_increasing(a); + // s maps increasing attributes. + + mln_ch_value(I, mln_site(I)) par; + mln_ch_value(I, bool) deja_vu; + mln_ch_value(I, util::set<unsigned>) labels; + unsigned nbassins, current_n; + + // init fused image + mln_ch_value(I, bool) fused; + initialize(fused, a); + mln::level::fill(fused, false); + + // iota + mln_ch_value(I,value::int_u<16>) iota(a.domain()); + debug::iota(iota); + + // labels + mln_ch_value(I, unsigned) regmin = labeling::regional_minima(a, nbh, + nbassins); + + { + // Initialization. + mln_piter(A) p(f.domain()); + + // parent + initialize(par, f); + for_all(p) + par(p) = p; + + // deja_vu + initialize(deja_vu, f); + level::fill(deja_vu, false); + + + if (n_objects >= nbassins) + { + std::cerr << "The number of expected objects is higher than the number of regional minima!" << std::endl; + std::abort(); + } + + if (echo) + debug::println("regmin(f) =", regmin); + + initialize(labels, f); + for_all(p) + if (regmin(p) != 0) // p in a reg min of the attribute image + { + labels(p).insert(regmin(p)); + fused(p) = true; + } + } + + current_n = nbassins; + + // First pass. + mln_site(I) r; + mln_fwd_piter(S) p(s); + mln_niter(N) n(nbh, p); + for_all(p) + { + std::cout << p << std::endl; + for_all(n) + { + if (a.domain().has(n) && deja_vu(n)) + { + std::cout << " " << n << std::endl; + r = find_root__(par, n); + if (r != p) + { + par(r) = p; // Union. + + + /////TMP + if (labels(r).is_empty()) + // No-op. + ; + else + if (labels(p).is_empty()) + labels(p) = labels(r); + else + if (labels(p) == labels(r)) + { + // No-op. + // Should only happen if p and r are minima + } + else + labels(p).insert(labels(r)); + + ///// + + if (p == point2d(1,0) && r == point2d(2,0)) + { + std::cerr << "fused(r) " << fused(r) << std::endl; + std::cerr << "regmin(p) == 0 " << (regmin(p) == 0) << std::endl; + std::cerr << "fused(p) " << fused(p) << std::endl; + std::cerr << "current_n > n_objects " << (current_n > n_objects) << std::endl; + } + + // min_v != 0 <=> volume(p) == 1 ? + if (fused(r) && + regmin(p) == 0 &&// p is not a minima + fused(p) &&// p already belong to a cmpt (fused for an another n) + current_n > n_objects) // union is still allowed + { + std::cerr << p << " <- " << r + << labels(p) << labels(r) << std::endl; + + current_n--; + std::cout << "dec" << std::endl; + } + + //mln_invariant(fused(r) || a(r) == a(p)); + // DOESNT WORK + + // Union made if + if (current_n >= n_objects || // union is still allowed or + not fused(r) || // r not fused or + not fused(p) || // p not fused or + regmin(p) != 0) // p is a minima + { + //par(r) = p; + fused(p) = fused(r); + //iota(p) = iota(r); + +// std::cout << "volume " << a(p) << " - " << current_n << std::endl; +// debug::println(iota | pw::value(fused) == pw::cst(true)); +// std::cout << "---------------------" << std::endl; + } + } + } + } + deja_vu(p) = true; + } + return labels; + } + + +} // end of namespace mln + + +void usage(char* argv[]) +{ + std::cerr << "usage: " << argv[0] << " input.pgm n echo" << std::endl; + std::cerr << "n: number of expected objects (n > 0)" << std::endl; + std::cerr << "echo: 0 (silent) or 1 (verbose)" << std::endl; + std::cerr << "merge using sets of labels from regional minima and save the highest label image" << std::endl; + std::abort(); +} + + +int main(int argc, char* argv[]) +{ + using namespace mln; + using value::int_u8; + + if (argc != 4) + usage(argv); + + typedef image2d<int_u8> I; + I f; + // input image + io::pgm::load(f, argv[1]); + + // n + int n = std::atoi(argv[2]); + if (n <= 0) + usage(argv); + + // echo + int echo = std::atoi(argv[3]); + if (echo != 0 && echo != 1) + usage(argv); + + typedef p_array<point2d> S; + S s = level::sort_psites_decreasing(f); + + // Children go towards lower levels so leafs are regional minima. + // We get a min-tree so that we can perform morphological closings. + + morpho::tree::data<I,S> t(f, s, c4()); + accu::count< util::pix<I> > attr; + + image2d<unsigned> a = morpho::tree::compute_attribute_image(attr, t); + + + image2d< util::set<unsigned> > labels = compute_labels(f, a, c4(), n, echo); + if (echo) + debug::println("labels =", labels); +} Index: jardonnet/n_cmpt/n_cmpt5.hh --- jardonnet/n_cmpt/n_cmpt5.hh (revision 3060) +++ jardonnet/n_cmpt/n_cmpt5.hh (working copy) @@ -39,6 +39,10 @@ # include <mln/morpho/tree/data.hh> # include <mln/morpho/tree/compute_attribute_image.hh> +# include <mln/pw/all.hh> + +# include <mln/core/image/image_if.hh> + namespace mln { @@ -133,6 +137,9 @@ } } + mln_ch_value(I,value::int_u<16>) iota(ima.domain()); + debug::iota(iota); + // UNION FIND ON VOLUME mln_fwd_piter(S) p(sp); mln_niter(N) n(nbh, p); @@ -175,6 +182,7 @@ } mln_invariant(fused(r) || volume(r) == volume(p)); + //Note at the end of level every fake component have been processed. // Union made if if (cmpts >= lambda || // union is still allowed or @@ -194,6 +202,7 @@ if (fused(r)) fused(p) = true; + iota(p) = iota(r); // If I try to fuse with something never fused I am on a plateau. // not fused(r) => ( volume(r) == volume(p) ) @@ -208,6 +217,8 @@ std::cerr << "volume " << volume(p) << " - " << cmpts << std::endl; //debug::println(fused); + + debug::println(iota | pw::value(fused) == pw::cst(true)); } } } @@ -215,9 +226,6 @@ deja_vu(p) = true; } - mln_ch_value(I,value::int_u<16>) iota(ima.domain()); - debug::iota(iota); - std::cout << std::endl; std::cout << "cmpts : " << cmpts << std::endl; Index: jardonnet/n_cmpt/ref_filter.cc --- jardonnet/n_cmpt/ref_filter.cc (revision 0) +++ jardonnet/n_cmpt/ref_filter.cc (revision 0) @@ -0,0 +1,224 @@ +#include <mln/core/image/image2d.hh> +#include <mln/value/int_u8.hh> +#include <mln/io/pgm/load.hh> +#include <mln/debug/println.hh> + +#include <mln/core/site_set/p_array.hh> +#include <mln/level/sort_psites.hh> +#include <mln/core/alias/neighb2d.hh> +#include <mln/morpho/tree/data.hh> + +#include <mln/accu/count.hh> +#include <mln/util/set.hh> + +#include <mln/labeling/regional_minima.hh> +#include <mln/morpho/tree/compute_attribute_image.hh> +#include <mln/morpho/closing_area.hh> +#include <mln/level/fill.hh> + + +namespace mln +{ + + template <typename I> + void println_par(const I& par) + { + int nr = par.nrows(), nc = par.ncols(); + for (int r = 0; r < nr; ++r) + { + for (int c = 0; c < nc; ++c) + if (par.at(r,c) == point2d(r,c)) + std::cout << "( ) "; + else + std::cout << par.at(r,c) << ' '; + std::cout << std::endl; + } + } + + template <typename P> + inline + mln_value(P) find_root__(P& par, const mln_value(P)& x) + { + if (par(x) == x) + return x; + else + return par(x) = find_root__(par, par(x)); + } + + + template <typename I, typename A, typename N> + mln_ch_value(I, util::set<unsigned>) + compute_labels(const I& f, const A& a, const N& nbh, + unsigned n_objects, + bool echo = false) + { + if (echo) + debug::println("f =", f); + + typedef p_array<mln_psite(I)> S; + S s = level::sort_psites_increasing(a); + // s maps increasing attributes. + + mln_ch_value(I, mln_site(I)) par; + mln_ch_value(I, bool) deja_vu; + mln_ch_value(I, util::set<unsigned>) labels; + unsigned nbassins, current_n; + + // Initialization. + { + mln_piter(A) p(f.domain()); + + // parent + initialize(par, f); + for_all(p) + par(p) = p; + + // deja_vu + initialize(deja_vu, f); + level::fill(deja_vu, false); + + // labels + mln_ch_value(I, unsigned) regmin = labeling::regional_minima(a, nbh, + nbassins); + if (n_objects >= nbassins) + { + std::cerr << "The number of expected objects is higher than the number of regional minima!" << std::endl; + std::abort(); + } + + if (echo) + debug::println("regmin(f) =", regmin); + + initialize(labels, f); + for_all(p) + if (regmin(p) != 0) // p in a reg min of the attribute image + labels(p).insert(regmin(p)); + } + + debug::println(labels); + + current_n = nbassins; + + // First pass. + { + mln_site(I) r; + mln_fwd_piter(S) p(s); + mln_niter(N) n(nbh, p); + for_all(p) + { + std::cout << p << std::endl; + for_all(n) + if (a.domain().has(n) && deja_vu(n)) + { + std::cout << " " << n << std::endl; + r = find_root__(par, n); + if (r != p) + { + par(r) = p; // Union. + + if (labels(r).is_empty()) + // No-op. + ; + else + if (labels(p).is_empty()) + labels(p) = labels(r); + else + if (labels(p) == labels(r)) + { + // No-op. + // Should only happen if p and r are minima + } + else + { + labels(p).insert(labels(r)); + --current_n; + + if (current_n >= n_objects) + std::cerr << p << " <- " << r + << labels(p) << labels(r) << std::endl; + + if (current_n == n_objects && echo) + { + // Filtering. +// mln_concrete(I) g; +// initialize(g, f); +// mln_bkd_piter(S) p(s); +// for_all(p) +// if (par(p) == p) +// g(p) = f(p); +// else +// g(p) = g(par(p)); +// debug::println("g =", g); + + // Testing. +// unsigned n_result; +// mln_ch_value(I, unsigned) g_regmin; +// g_regmin = labeling::regional_minima(g, nbh, n_result); +// debug::println("regmin(g) =", g_regmin); + +// mln_invariant(n_result == n_objects); + } + } + } + } + deja_vu(p) = true; + } + } + + mln_invariant(current_n == 1); // All labels are merged into a single set. + + return labels; + } + + +} // mln + + +void usage(char* argv[]) +{ + std::cerr << "usage: " << argv[0] << " input.pgm n echo" << std::endl; + std::cerr << "n: number of expected objects (n > 0)" << std::endl; + std::cerr << "echo: 0 (silent) or 1 (verbose)" << std::endl; + std::cerr << "merge using sets of labels from regional minima and save the highest label image" << std::endl; + std::abort(); +} + + +int main(int argc, char* argv[]) +{ + using namespace mln; + using value::int_u8; + + if (argc != 4) + usage(argv); + + typedef image2d<int_u8> I; + I f; + // input image + io::pgm::load(f, argv[1]); + + // n + int n = std::atoi(argv[2]); + if (n <= 0) + usage(argv); + + // echo + int echo = std::atoi(argv[3]); + if (echo != 0 && echo != 1) + usage(argv); + + typedef p_array<point2d> S; + S s = level::sort_psites_decreasing(f); + + // Children go towards lower levels so leafs are regional minima. + // We get a min-tree so that we can perform morphological closings. + + morpho::tree::data<I,S> t(f, s, c4()); + accu::count< util::pix<I> > attr; + + image2d<unsigned> a = morpho::tree::compute_attribute_image(attr, t); + + image2d< util::set<unsigned> > labels = compute_labels(f, a, c4(), n, echo); + if (echo) + debug::println("labels =", labels); +} Index: jardonnet/n_cmpt/fused --- jardonnet/n_cmpt/fused (revision 0) +++ jardonnet/n_cmpt/fused (revision 0) @@ -0,0 +1,26 @@ +(11, 2) <- (11, 1){18, 22}{18} +fused(r) 1 +regmin(p) == 0 1 +fused(p) 0 +current_n > n_objects 1 +(11, 8) <- (13, 8){14, 21}{14} +(12, 1) <- (12, 0){16, 18, 22}{16} +(13, 2) <- (14, 2){15, 16, 18, 22}{15} +(17, 8) <- (18, 8){11, 14, 21}{11} +(20, 8) <- (21, 8){7, 11, 14, 21}{7} +(10, 20) <- (14, 19){13, 19, 20}{13, 19} +(17, 1) <- (18, 1){9, 15, 16, 18, 22}{9} +(11, 20) <- (11, 21){13, 17, 19, 20}{17} +(21, 12) <- (20, 13){6, 7, 11, 14, 21}{6} +(4, 10) <- (3, 11){2, 6, 7, 11, 14, 21}{2} +(11, 17) <- (8, 21){2, 6, 7, 11, 13, 14, 17, 19, 20, 21}{13, 17, 19, 20} +(16, 22) <- (16, 23){2, 6, 7, 11, 12, 13, 14, 17, 19, 20, 21}{12} +(4, 20) <- (6, 20){1, 2, 6, 7, 11, 12, 13, 14, 17, 19, 20, 21}{1} +(4, 23) <- (5, 23){1, 2, 6, 7, 11, 12, 13, 14, 17, 19, 20, 21, 23}{23} +(21, 20) <- (21, 21){1, 2, 5, 6, 7, 11, 12, 13, 14, 17, 19, 20, 21, 23}{5} +(0, 17) <- (0, 18){1, 2, 5, 6, 7, 11, 12, 13, 14, 17, 19, 20, 21, 23, 25}{25} +(20, 21) <- (13, 22){1, 2, 5, 6, 7, 8, 11, 12, 13, 14, 17, 19, 20, 21, 23, 25}{1, 2, 5, 6, 7, 11, 12, 13, 14, 17, 19, 20, 21, 23, 25} +(21, 22) <- (21, 23){1, 2, 4, 5, 6, 7, 8, 11, 12, 13, 14, 17, 19, 20, 21, 23, 25}{4} +(19, 22) <- (19, 23){1, 2, 4, 5, 6, 7, 8, 10, 11, 12, 13, 14, 17, 19, 20, 21, 23, 25}{10} +(5, 5) <- (18, 4){1, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 25}{9, 15, 16, 18, 22} +(5, 2) <- (7, 1){1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25}{1, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 25} Index: jardonnet/n_cmpt/ref --- jardonnet/n_cmpt/ref (revision 0) +++ jardonnet/n_cmpt/ref (revision 0) @@ -0,0 +1,22 @@ +(11, 2) <- (11, 1){18, 22}{18} +(1, 0) <- (2, 0){3, 24}{24} +(11, 8) <- (13, 8){14, 21}{14} +(12, 1) <- (12, 0){16, 18, 22}{16} +(13, 2) <- (14, 2){15, 16, 18, 22}{15} +(17, 8) <- (18, 8){11, 14, 21}{11} +(20, 8) <- (21, 8){7, 11, 14, 21}{7} +(12, 18) <- (18, 17){13, 19}{13} +(10, 20) <- (14, 19){13, 19, 20}{13, 19} +(17, 1) <- (18, 1){9, 15, 16, 18, 22}{9} +(11, 20) <- (11, 21){13, 17, 19, 20}{17} +(21, 12) <- (20, 13){6, 7, 11, 14, 21}{6} +(4, 10) <- (3, 11){2, 6, 7, 11, 14, 21}{2} +(11, 17) <- (8, 21){2, 6, 7, 11, 13, 14, 17, 19, 20, 21}{13, 17, 19, 20} +(16, 22) <- (16, 23){2, 6, 7, 11, 12, 13, 14, 17, 19, 20, 21}{12} +(4, 20) <- (6, 20){1, 2, 6, 7, 11, 12, 13, 14, 17, 19, 20, 21}{1} +(4, 23) <- (5, 23){1, 2, 6, 7, 11, 12, 13, 14, 17, 19, 20, 21, 23}{23} +(21, 20) <- (21, 21){1, 2, 5, 6, 7, 11, 12, 13, 14, 17, 19, 20, 21, 23}{5} +(0, 17) <- (0, 18){1, 2, 5, 6, 7, 11, 12, 13, 14, 17, 19, 20, 21, 23, 25}{25} +(20, 21) <- (13, 22){1, 2, 5, 6, 7, 8, 11, 12, 13, 14, 17, 19, 20, 21, 23, 25}{1, 2, 5, 6, 7, 11, 12, 13, 14, 17, 19, 20, 21, 23, 25} +(21, 22) <- (21, 23){1, 2, 4, 5, 6, 7, 8, 11, 12, 13, 14, 17, 19, 20, 21, 23, 25}{4} +(19, 22) <- (19, 23){1, 2, 4, 5, 6, 7, 8, 10, 11, 12, 13, 14, 17, 19, 20, 21, 23, 25}{10} Index: jardonnet/n_cmpt/Makefile --- jardonnet/n_cmpt/Makefile (revision 3060) +++ jardonnet/n_cmpt/Makefile (working copy) @@ -1,21 +1,31 @@ -n_cmpt: n_cmpt.hh n_cmpt.cc - g++ -I../../.. -Wall -W -Wextra n_cmpt.cc -DNDEBUG -O1 -o n_cmpt +n_cmpt6: n_cmpt6.hh n_cmpt6.cc + g++ -I../../.. -Wall -W -Wextra n_cmpt6.cc -DNDEBUG -O1 -o n_cmpt6 -n_cmpt2: n_cmpt2.hh n_cmpt2.cc - g++ -I../../.. -Wall -W -Wextra n_cmpt2.cc -DNDEBUG -O1 -o n_cmpt2 +n_cmpt5: n_cmpt5.hh n_cmpt5.cc + g++ -I../../.. -Wall -W -Wextra n_cmpt5.cc -DNDEBUG -O1 -o n_cmpt5 + +n_cmpt4: n_cmpt4.hh n_cmpt4.cc + g++ -I../../.. -Wall -W -Wextra n_cmpt4.cc -DNDEBUG -O1 -o n_cmpt4 n_cmpt3: n_cmpt3.hh n_cmpt3.cc g++ -I../../.. -Wall -W -Wextra n_cmpt3.cc -DNDEBUG -O1 -o n_cmpt3 -n_cmpt4: n_cmpt4.hh n_cmpt4.cc - g++ -I../../.. -Wall -W -Wextra n_cmpt4.cc -DNDEBUG -O1 -o n_cmpt4 +n_cmpt2: n_cmpt2.hh n_cmpt2.cc + g++ -I../../.. -Wall -W -Wextra n_cmpt2.cc -DNDEBUG -O1 -o n_cmpt2 + +n_cmpt: n_cmpt.hh n_cmpt.cc + g++ -I../../.. -Wall -W -Wextra n_cmpt.cc -DNDEBUG -O1 -o n_cmtp -n_cmpt5: n_cmpt5.hh n_cmpt5.cc - g++ -I../../.. -Wall -W -Wextra n_cmpt5.cc -DNDEBUG -O1 -o n_cmpt5 nwst: nwst.hh nwst.cc g++ -I../../.. -Wall -W -Wextra nwst.cc -DNDEBUG -O1 -o nwst +ref_filter: ref_filter.cc + g++ -I../../.. -Wall -W -Wextra ref_filter.cc -DNDEBUG -O1 -o ref_filter + +ref_seg: ref_seg.cc + g++ -I../../.. -Wall -W -Wextra ref_seg.cc -DNDEBUG -O1 -o ref_seg + debug: n_cmpt.hh n_cmpt.cc g++ -I../../.. -Wall -W -Wextra n_cmpt.cc -g -g3 -o n_cmpt Index: jardonnet/n_cmpt/diff_ref_fused_on_small --- jardonnet/n_cmpt/diff_ref_fused_on_small (revision 0) +++ jardonnet/n_cmpt/diff_ref_fused_on_small (revision 0) @@ -0,0 +1,13 @@ +60d59 +< (1, 0) <- (2, 0) +92d90 +< (12, 18) <- (18, 17) +174d171 +< (62, 51) <- (56, 57) +198d194 +< (57, 46) <- (60, 52) +200d195 +< (49, 47) <- (47, 54) +252a248,249 +> (18, 46) <- (18, 47) +> (46, 61) <- (41, 63) Index: jardonnet/igr/src/igr.cc --- jardonnet/igr/src/igr.cc (revision 3060) +++ jardonnet/igr/src/igr.cc (working copy) @@ -24,11 +24,6 @@ #include <mln/value/hsi.hh> -#include <mln/core/image/thru.hh> - -//FIXME: Alexandre' sandbox -#include <mln/fun/meta/inty.hh> - using namespace mln; using namespace value; @@ -67,7 +62,7 @@ mln_piter_(image2d<rgb8>) p(g_ima.domain()); for_all(p) { - g_ima(p) = hsi(p).inty() * 255; + g_ima(p) = hsi(p).inty(); } io::pgm::save(g_ima, "g_ima.ppm"); @@ -88,7 +83,6 @@ /////////////////// image2d<int_u8> o_ima = morpho::closing_volume(mg_ima, c4(), lambda); - io::pgm::save(o_ima, "o_ima.ppm"); Index: jardonnet/igr/Makefile --- jardonnet/igr/Makefile (revision 3060) +++ jardonnet/igr/Makefile (working copy) @@ -6,7 +6,7 @@ CXXC?=g++ -LFLAGS=-I../../abraham/ -I../../../ +LFLAGS= -I../../../ CFLAGS=-W -Wall -Wextra -O1 -DNDEBUG PROJ=igr-reco
16 years
1
0
0
0
3060: Add an opt::at function.
by Nicolas Ballas
https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog from Nicolas Ballas <ballas(a)lrde.epita.fr> Add an opt::at function. * mln/core/image/cast_image.hh: Fix properties. * mln/opt: New directory. * mln/opt/at.hh: New function opt::at. * mln/level/paste.spe.hh: Fix a bug. * tests/opt, * tests/opt/at.cc: New tests. mln/core/image/cast_image.hh | 1 mln/level/paste.spe.hh | 2 mln/opt/at.hh | 337 +++++++++++++++++++++++++++++++++++++++++++ tests/opt/at.cc | 157 ++++++++++++++++++++ 4 files changed, 496 insertions(+), 1 deletion(-) Index: mln/core/image/cast_image.hh --- mln/core/image/cast_image.hh (revision 3059) +++ mln/core/image/cast_image.hh (working copy) @@ -99,6 +99,7 @@ trait::image::quant::high, trait::image::quant::low) quant; + typedef trait::image::category::value_morpher category; typedef trait::image::value_io::read_only value_io; typedef trait::image::pw_io::read pw_io; typedef trait::image::value_access::indirect value_access; Index: mln/opt/at.hh --- mln/opt/at.hh (revision 0) +++ mln/opt/at.hh (revision 0) @@ -0,0 +1,337 @@ +// Copyright (C) 2008 EPITA Research and Development Laboratory +// (LRDE) +// +// This file is part of the Olena Library. This library is free +// software; you can redistribute it and/or modify it under the terms +// of the GNU General Public License version 2 as published by the +// Free Software Foundation. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this library; see the file COPYING. If not, write to +// the Free Software Foundation, 51 Franklin Street, Fifth Floor, +// Boston, MA 02111-1307, USA. +// +// As a special exception, you may use this file as part of a free +// software library without restriction. Specifically, if other files +// instantiate templates or use macros or inline functions from this +// file, or you compile this file and link it with other files to +// produce an executable, this file does not by itself cause the +// resulting executable to be covered by the GNU General Public +// License. This exception does not however invalidate any other +// reasons why the executable file might be covered by the GNU General +// Public License. + +#ifndef MLN_OPT_AT_HH +# define MLN_OPT_AT_HH + +/// \file mln/opt/at.hh +/// +/// FIXME + +# include <mln/core/concept/image.hh> +# include <mln/trait/images.hh> +# include <mln/trace/all.hh> + +# include <mln/core/alias/point1d.hh> +# include <mln/core/alias/point2d.hh> +# include <mln/core/alias/point3d.hh> + +namespace mln +{ + + namespace opt + { + + /// One dimension + template <typename I> + mln_rvalue(I) at(const Image<I>& ima, int ind); + + template <typename I> + mln_lvalue(I) at(Image<I>& ima, int ind); + + + /// Two dimensions + template <typename I> + mln_rvalue(I) at(const Image<I>& ima, int row, int col); + + template <typename I> + mln_lvalue(I) at(Image<I>& ima, int row, int col); + + /// Three dimensions + template <typename I> + mln_rvalue(I) at(const Image<I>& ima, int sli, int row, int col); + + template <typename I> + mln_lvalue(I) at(Image<I>& ima, int sli, int row, int col); + + +# ifndef MLN_INCLUDE_ONLY + + + /// One dimension + namespace impl + { + + template <typename I> + inline + mln_rvalue(I) at_1d_impl(trait::image::category::domain_morpher, + const Image<I>& ima, int ind) + { + point1d p(ind); + return exact(ima)(p); + } + + template <typename I> + inline + mln_rvalue(I) at_1d_impl(trait::image::category::morpher, + const Image<I>& ima, int ind) + { + // FIXME: what about morpher that modify the image value? + // (through a function for instance) + return at(*exact(ima).delegatee_(), ind); + } + + template <typename I> + inline + mln_rvalue(I) at_1d_impl(trait::image::category::primary, + const Image<I>& ima, int ind) + { + return exact(ima).at(ind); + } + + + template <typename I> + inline + mln_lvalue(I) at_1d_impl(trait::image::category::domain_morpher, + Image<I>& ima, int ind) + { + mlc_is(mln_trait_image_pw_io(I), + trait::image::pw_io::read_write)::check(); + + point1d p(ind); + return exact(ima)(p); + } + + template <typename I> + inline + mln_lvalue(I) at_1d_impl(trait::image::category::morpher, + Image<I>& ima, int ind) + { + // FIXME: what about morpher that modify the image value? + // (through a function for instance) + return at(*exact(ima).delegatee_(), ind); + } + + template <typename I> + inline + mln_lvalue(I) at_1d_impl(trait::image::category::primary, + Image<I>& ima, int ind) + { + return exact(ima).at(ind); + } + + } // end of namespace mln::opt::impl + + template <typename I> + inline + mln_rvalue(I) at(const Image<I>& ima, int ind) + { + mlc_is(mln_trait_image_dimension(I), + trait::image::dimension::one_d)::check(); + + return impl::at_1d_impl(mln_trait_image_category(I)(), ima, ind); + } + + template <typename I> + mln_lvalue(I) at(Image<I>& ima, int ind) + { + mlc_is(mln_trait_image_dimension(I), + trait::image::dimension::one_d)::check(); + + return impl::at_1d_impl(mln_trait_image_category(I)(), ima, ind); + } + + + + /// Two dimensions + namespace impl + { + + template <typename I> + inline + mln_rvalue(I) at_2d_impl(trait::image::category::domain_morpher, + const Image<I>& ima, int row, int col) + { + point2d p(row, col); + return exact(ima)(p); + } + + template <typename I> + inline + mln_rvalue(I) at_2d_impl(trait::image::category::morpher, + const Image<I>& ima, int row, int col) + { + // FIXME: what about morpher that modify the image value? + // (through a function for instance) + return at(*exact(ima).delegatee_(), row, col); + } + + template <typename I> + inline + mln_rvalue(I) at_2d_impl(trait::image::category::primary, + const Image<I>& ima, int row, int col) + { + return exact(ima).at(row, col); + } + + + template <typename I> + inline + mln_lvalue(I) at_2d_impl(trait::image::category::domain_morpher, + Image<I>& ima, int row, int col) + { + mlc_is(mln_trait_image_pw_io(I), + trait::image::pw_io::read_write)::check(); + + point2d p(row, col); + return exact(ima)(p); + } + + template <typename I> + inline + mln_lvalue(I) at_2d_impl(trait::image::category::morpher, + Image<I>& ima, int row, int col) + { + // FIXME: what about morpher that modify the image value? + // (through a function for instance) + return at(*exact(ima).delegatee_(), row, col); + } + + template <typename I> + inline + mln_lvalue(I) at_2d_impl(trait::image::category::primary, + Image<I>& ima, int row, int col) + { + return exact(ima).at(row, col); + } + + } // end of namespace mln::opt::impl + + template <typename I> + inline + mln_rvalue(I) at(const Image<I>& ima, int row, int col) + { + mlc_is(mln_trait_image_dimension(I), + trait::image::dimension::two_d)::check(); + + return impl::at_2d_impl(mln_trait_image_category(I)(), ima, row, col); + } + + template <typename I> + mln_lvalue(I) at(Image<I>& ima, int row, int col) + { + mlc_is(mln_trait_image_dimension(I), + trait::image::dimension::two_d)::check(); + + return impl::at_2d_impl(mln_trait_image_category(I)(), ima, row, col); + } + + + /// Three dimensions + namespace impl + { + + template <typename I> + inline + mln_rvalue(I) at_3d_impl(trait::image::category::domain_morpher, + const Image<I>& ima, int sli, int row, int col) + { + point3d p(sli, row, col); + return exact(ima)(p); + } + + template <typename I> + inline + mln_rvalue(I) at_3d_impl(trait::image::category::morpher, + const Image<I>& ima, int sli, int row, int col) + { + // FIXME: what about morpher that modify the image value? + // (through a function for instance) + return at(*exact(ima).delegatee_(), sli, row, col); + } + + template <typename I> + inline + mln_rvalue(I) at_3d_impl(trait::image::category::primary, + const Image<I>& ima, int sli, int row, int col) + { + return exact(ima).at(sli, row, col); + } + + + template <typename I> + inline + mln_lvalue(I) at_3d_impl(trait::image::category::domain_morpher, + Image<I>& ima, int sli, int row, int col) + { + mlc_is(mln_trait_image_pw_io(I), + trait::image::pw_io::read_write)::check(); + + point3d p(sli, row, col); + return exact(ima)(p); + } + + template <typename I> + inline + mln_lvalue(I) at_3d_impl(trait::image::category::morpher, + Image<I>& ima, int sli, int row, int col) + { + // FIXME: what about morpher that modify the image value? + // (through a function for instance) + return at(*exact(ima).delegatee_(), sli, row, col); + } + + template <typename I> + inline + mln_lvalue(I) at_3d_impl(trait::image::category::primary, + Image<I>& ima, int sli, int row, int col) + { + return exact(ima).at(sli, row, col); + } + + } // end of namespace mln::opt::impl + + template <typename I> + inline + mln_rvalue(I) at(const Image<I>& ima, int sli, int row, int col) + { + mlc_is(mln_trait_image_dimension(I), + trait::image::dimension::three_d)::check(); + + return impl::at_3d_impl(mln_trait_image_category(I)(), + ima, sli, row, col); + } + + template <typename I> + mln_lvalue(I) at(Image<I>& ima, int sli, int row, int col) + { + mlc_is(mln_trait_image_dimension(I), + trait::image::dimension::three_d)::check(); + + return impl::at_3d_impl(mln_trait_image_category(I)(), + ima, sli, row, col); + } + +# endif // ! MLN_INCLUDE_ONLY + + } // end of namespace mln::opt + +} // end of namespace mln + + +#endif // ! MLN_OPT_AT_HH Index: mln/level/paste.spe.hh --- mln/level/paste.spe.hh (revision 3059) +++ mln/level/paste.spe.hh (working copy) @@ -143,7 +143,7 @@ const I& input = exact(input_); - level::fill_with_value(output_, input.val()); + level::fill_with_value((output_ | input.domain()).rw(), input.val()); trace::exiting("level::impl::paste_singleton"); } Index: tests/opt/at.cc --- tests/opt/at.cc (revision 0) +++ tests/opt/at.cc (revision 0) @@ -0,0 +1,157 @@ +// Copyright (C) 2008 EPITA Research and Development Laboratory +// (LRDE) +// +// This file is part of the Olena Library. This library is free +// software; you can redistribute it and/or modify it under the terms +// of the GNU General Public License version 2 as published by the +// Free Software Foundation. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this library; see the file COPYING. If not, write to +// the Free Software Foundation, 51 Franklin Street, Fifth Floor, +// Boston, MA 02111-1307, USA. +// +// As a special exception, you may use this file as part of a free +// software library without restriction. Specifically, if other files +// instantiate templates or use macros or inline functions from this +// file, or you compile this file and link it with other files to +// produce an executable, this file does not by itself cause the +// resulting executable to be covered by the GNU General Public +// License. This exception does not however invalidate any other +// reasons why the executable file might be covered by the GNU General +// Public License. + +/// \file tests/opt/at.cc +/// +/// Tests on mln::opt::at. + +#include <mln/core/image/image1d.hh> +#include <mln/core/image/sub_image.hh> +#include <mln/core/image/cast_image.hh> + +/*#include <mln/core/image/image2d.hh> +#include <mln/core/image/image3d.hh> +#include <mln/pw/image.hh> +#include <mln/core/image/flat_image.hh> +#include <mln/core/image/image_if.hh> +#include <mln/core/image/extension_val.hh>*/ + +#include <mln/level/fill.hh> +#include <mln/level/paste.hh> +#include <mln/level/compare.hh> + +#include <mln/opt/at.hh> + +#include <mln/debug/iota.hh> +#include <mln/debug/println.hh> +#include <mln/trace/all.hh> + + +int main() +{ + using namespace mln; + const unsigned size = 50; + + /// One dimensions tests... + { + image1d<short> ima(size); + debug::iota(ima); + const image1d<short> cima = ima; + + point1d p(5); + mln_assertion(cima(p) == opt::at(cima, 5)); + + opt::at(ima, 5) = 12; + mln_assertion(cima(p) == 12); + } + { + typedef image1d<short> I; + typedef sub_image< image1d<short>, box1d > II; + + I ima(size); + II sub_ima(ima, make::box1d(4, 10)); + const II csub_ima(ima, make::box1d(4, 10)); + point1d p(5); + + level::fill(ima, 51); + mln_assertion(csub_ima(p) == opt::at(csub_ima, 5)); + opt::at(sub_ima, 5) = 12; + mln_assertion(sub_ima(p) == 12); + } + { + typedef image1d<unsigned short> I; + typedef cast_image_<int, I> II; + + I in(size, size); + II cast(in); + const II ccast(in); + point1d p(5); + + level::fill(in, 51); + mln_assertion(ccast(p) == opt::at(ccast, 5)); + // FIXME + //opt::at(cast, 5) = 12; + //mln_assertion(cast(p) == 12); + } + + /// Two dimensions tests... + { + image2d<short> ima(size, size); + debug::iota(ima); + const image2d<short> cima = ima; + + point2d p(5, 5); + mln_assertion(cima(p) == opt::at(cima, 5, 5)); + + opt::at(ima, 5, 5) = 12; + mln_assertion(cima(p) == 12); + } + { + typedef image2d<short> I; + typedef sub_image< image2d<short>, box2d > II; + + I ima(size, size); + II sub_ima(ima, make::box2d(4,4, 10, 10)); + const II csub_ima(ima, make::box2d(4, 4, 10, 10)); + point2d p(5, 5); + + level::fill(ima, 51); + mln_assertion(csub_ima(p) == opt::at(csub_ima, 5, 5)); + opt::at(sub_ima, 5, 5) = 12; + mln_assertion(sub_ima(p) == 12); + } + { + typedef image2d<unsigned short> I; + typedef cast_image_<int, I> II; + + I in(size, size); + II cast(in); + const II ccast(in); + point2d p(5,5); + + level::fill(in, 51); + mln_assertion(ccast(p) == opt::at(ccast, 5, 5)); + // FIXME + //opt::at(cast, 5) = 12; + //mln_assertion(cast(p) == 12); + } + + + /// Three dimensions tests... + { + image3d<short> ima(size, size, size); + debug::iota(ima); + const image3d<short> cima = ima; + + point3d p(5, 5, 5); + mln_assertion(cima(p) == opt::at(cima, 5, 5, 5)); + + opt::at(ima, 5, 5, 5) = 12; + mln_assertion(cima(p) == 12); + } +}
16 years
1
0
0
0
Re: [Olena-patches] 3059: Make use of milena/generate_dist_headers.sh.
by Alexandre Duret-Lutz
>>> "z" == Guillaume Lazzara <z(a)lrde.epita.fr> writes: z> * bootstrap: update here. Je ne l'ai pas vu dans la tarball ? -- Alexandre Duret-Lutz
16 years
1
0
0
0
3059: Make use of milena/generate_dist_headers.sh.
by Guillaume Lazzara
* bootstrap: update here. --- ChangeLog | 6 ++++++ bootstrap | 20 ++------------------ 2 files changed, 8 insertions(+), 18 deletions(-) diff --git a/ChangeLog b/ChangeLog index 64a4638..e34918b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2008-12-16 Guillaume Lazzara <z(a)lrde.epita.fr> + + Make use of milena/generate_dist_headers.sh. + + * bootstrap: update here. + 2008-12-09 Guillaume Lazzara <z(a)lrde.epita.fr> Update call to build_unit_test.sh diff --git a/bootstrap b/bootstrap index f0ebe78..c0ee7e8 100755 --- a/bootstrap +++ b/bootstrap @@ -108,22 +108,6 @@ run () ) } -# Generate milena/headers.mk -# ------------------------------ -# List all the headers in order to make them part of distribution. -dist_headers () -{ - cd "milena" - echo "nobase_include_HEADERS = \\" > headers.mk - echo "generating headers.mk" - find mln -type f | sed -e 's/$/ \\/g' >> headers.mk - - last_line=`tail -n 1 headers.mk | sed -e 's/\\\//g'` # remove '\' in last line - sed '$d' < headers.mk > headers.mk.tmp # remove last line - mv headers.mk.tmp headers.mk - echo $last_line >> headers.mk # put the cleaned last line back. - cd - -} # Failures do matter. set -e @@ -135,8 +119,8 @@ require automake 1.9.4 # Generate unit test files. run milena/tests/unit_test ./build_unit_test.sh $PWD/milena/mln -# Generate headers distribution config file. -dist_headers +# Generate milena/dist_headers.mk +run milena ./generate_dist_headers.sh # Tell what's going on. set -x -- 1.5.6.5
16 years
1
0
0
0
3058: Generate the distributed header list thanks to a specific script.
by Guillaume Lazzara
* generate_dist_headers.sh: generate the list of distributed headers. * Makefile.am: include generate_dist_headers.sh in the distribution tarball. * headers.mk: Add comment saying that it is generated. * doc/tutorial/samples/fill-subdomain-shorter.cc: fix a warning. --- milena/ChangeLog | 13 +++++++++++++ milena/Makefile.am | 2 ++ .../doc/tutorial/samples/fill-subdomain-shorter.cc | 2 +- milena/generate_dist_headers.sh | 18 ++++++++++++++++++ milena/headers.mk | 2 ++ 5 files changed, 36 insertions(+), 1 deletions(-) create mode 100755 milena/generate_dist_headers.sh diff --git a/milena/ChangeLog b/milena/ChangeLog index 495e558..1255d74 100644 --- a/milena/ChangeLog +++ b/milena/ChangeLog @@ -1,5 +1,18 @@ 2008-12-16 Guillaume Lazzara <z(a)lrde.epita.fr> + Generate the distributed header list thanks to a specific script. + + * generate_dist_headers.sh: generate the list of distributed headers. + + * Makefile.am: include generate_dist_headers.sh in the distribution + tarball. + + * headers.mk: Add comment saying that it is generated. + + * doc/tutorial/samples/fill-subdomain-shorter.cc: fix a warning. + +2008-12-16 Guillaume Lazzara <z(a)lrde.epita.fr> + Quick cleanup in io. * milena/tests/io/off/load_bin.cc, diff --git a/milena/Makefile.am b/milena/Makefile.am index 64d0365..485c4bd 100644 --- a/milena/Makefile.am +++ b/milena/Makefile.am @@ -35,3 +35,5 @@ img/small.pbm \ img/lena.ppm \ img/small.pgm +EXTRA_DIST += \ +generate_dist_headers.sh diff --git a/milena/doc/tutorial/samples/fill-subdomain-shorter.cc b/milena/doc/tutorial/samples/fill-subdomain-shorter.cc index da3ce7b..7526682 100644 --- a/milena/doc/tutorial/samples/fill-subdomain-shorter.cc +++ b/milena/doc/tutorial/samples/fill-subdomain-shorter.cc @@ -28,6 +28,6 @@ int main() initialize(ima2, ima); level::fill(ima2, literal::black); - level::fill((ima2 | pw::value(lab) == pw::cst(2u)).rw(), literal::red); + level::fill((ima2 | (pw::value(lab) == pw::cst(2u))).rw(), literal::red); // \} } diff --git a/milena/generate_dist_headers.sh b/milena/generate_dist_headers.sh new file mode 100755 index 0000000..bb5bb30 --- /dev/null +++ b/milena/generate_dist_headers.sh @@ -0,0 +1,18 @@ +#/bin/sh +# +# Generate milena/headers.mk +# ------------------------------ +# List all the headers in order to make them part of distribution. + +echo "## Generated by ./generate_dist_headers, do not modify ##" > headers.mk +echo "" >> headers.mk +echo "nobase_include_HEADERS = \\" >> headers.mk +echo "generating headers.mk" + +find mln -type f | grep -v "\.svn" | sed -e 's/$/ \\/g' >> headers.mk + +last_line=`tail -n 1 headers.mk | sed -e 's/\\\//g'` # remove '\' in last line +sed '$d' < headers.mk > headers.mk.tmp # remove last line +mv headers.mk.tmp headers.mk +echo $last_line >> headers.mk # put the cleaned last line back. + diff --git a/milena/headers.mk b/milena/headers.mk index 240f896..146e616 100644 --- a/milena/headers.mk +++ b/milena/headers.mk @@ -1,3 +1,5 @@ +## Generated by ./generate_dist_headers, do not modify ## + nobase_include_HEADERS = \ mln/histo/all.hh \ mln/histo/data.hh \ -- 1.5.6.5
16 years
1
0
0
0
3057: Quick cleanup in io.
by Guillaume Lazzara
* milena/tests/io/off/load_bin.cc, * milena/tests/io/off/load_float.cc, * milena/mln/io/fits/load.hh, * milena/mln/io/off/save.hh, * milena/mln/io/pfm/load.hh: update doc. * milena/mln/io/pfm/save.hh: avoid a warning and update doc. * milena/tests/io/off/load_float.cc: Fix test. --- milena/ChangeLog | 14 +++++++++++++ milena/mln/io/fits/load.hh | 35 +++++++++++++++------------------ milena/mln/io/off/save.hh | 2 +- milena/mln/io/pfm/load.hh | 35 +++++++++++++++------------------ milena/mln/io/pfm/save.hh | 31 ++++++++++++----------------- milena/tests/io/off/load_bin.cc | 3 +- milena/tests/io/off/load_float.cc | 6 +++- milena/tests/io/off/load_save_bin.cc | 3 +- 8 files changed, 68 insertions(+), 61 deletions(-) diff --git a/milena/ChangeLog b/milena/ChangeLog index e167114..495e558 100644 --- a/milena/ChangeLog +++ b/milena/ChangeLog @@ -1,3 +1,17 @@ +2008-12-16 Guillaume Lazzara <z(a)lrde.epita.fr> + + Quick cleanup in io. + + * milena/tests/io/off/load_bin.cc, + * milena/tests/io/off/load_float.cc, + * milena/mln/io/fits/load.hh, + * milena/mln/io/off/save.hh, + * milena/mln/io/pfm/load.hh: update doc. + + * milena/mln/io/pfm/save.hh: avoid a warning and update doc. + + * milena/tests/io/off/load_float.cc: Fix test. + 2008-12-16 Alexandre Abraham <abraham(a)lrde.epita.fr> Add functors and HSL color space. diff --git a/milena/mln/io/fits/load.hh b/milena/mln/io/fits/load.hh index c09536c..dbe533b 100644 --- a/milena/mln/io/fits/load.hh +++ b/milena/mln/io/fits/load.hh @@ -29,13 +29,10 @@ #ifndef MLN_IO_FITS_LOAD_HH # define MLN_IO_FITS_LOAD_HH -/*! - * \file mln/io/fits/load.hh - * - * \brief Define a function which loads an image of kind fits with - * given path. - * - */ +/// \file mln/io/fits/load.hh +/// +/// Define a function which loads an image of kind fits with +/// given path. # include <iostream> # include <fstream> @@ -57,21 +54,21 @@ namespace mln namespace fits { - /*! Load a fits image in a Milena image. - * - * \param[out] ima A reference to the image2d<float> which will receive - * data. - * \param[in] filename The source. - */ + /// Load a fits image in a Milena image. + /// + /// \param[out] ima A reference to the image2d<float> which will receive + /// data. + /// \param[in] filename The source. + /// void load(image2d<float>& ima, const std::string& filename); - /*! Load a fits image in a image2d<float>. - * - * \param[in] filename The image source. - * - * \return An image2d<float> which contains loaded data. - */ + /// Load a fits image in a image2d<float>. + /// + /// \param[in] filename The image source. + /// + /// \return An image2d<float> which contains loaded data. + /// image2d<float> load(const std::string& filename); # ifndef MLN_INCLUDE_ONLY diff --git a/milena/mln/io/off/save.hh b/milena/mln/io/off/save.hh index 40f2e5a..7bb4292 100644 --- a/milena/mln/io/off/save.hh +++ b/milena/mln/io/off/save.hh @@ -29,7 +29,7 @@ # define MLN_IO_OFF_SAVE_HH /// \file mln/io/off/save.hh -/// \brief Input saving function for OFF files. +/// Input saving function for OFF files. /// /// \see
http://shape.cs.princeton.edu/benchmark/documentation/off_format.html
/// \see
https://people.scs.fsu.edu/~burkardt/html/off_format.html
diff --git a/milena/mln/io/pfm/load.hh b/milena/mln/io/pfm/load.hh index 5ea3a23..ebf2f97 100644 --- a/milena/mln/io/pfm/load.hh +++ b/milena/mln/io/pfm/load.hh @@ -29,13 +29,10 @@ #ifndef MLN_IO_PFM_LOAD_HH # define MLN_IO_PFM_LOAD_HH -/*! - * \file mln/io/pfm/load.hh - * - * \brief Define a function which loads an image of kind pfm with - * given path. - * - */ +/// \file mln/io/pfm/load.hh +/// +/// Define a function which loads an image of kind pfm with +/// given path. # include <iostream> # include <fstream> @@ -53,21 +50,21 @@ namespace mln namespace pfm { - /*! Load a pfm image in a Milena image. - * - * \param[out] ima A reference to the image2d<float> which will receive - * data. - * \param[in] filename The source. - */ + /// Load a pfm image in a Milena image. + /// + /// \param[out] ima A reference to the image2d<float> which will receive + /// data. + /// \param[in] filename The source. + /// void load(image2d<float>& ima, const std::string& filename); - /*! Load a pfm image in a image2d<float>. - * - * \param[in] filename The image source. - * - * \return An image2d<float> which contains loaded data. - */ + /// Load a pfm image in a image2d<float>. + /// + /// \param[in] filename The image source. + /// + /// \return An image2d<float> which contains loaded data. + /// image2d<float> load(const std::string& filename); # ifndef MLN_INCLUDE_ONLY diff --git a/milena/mln/io/pfm/save.hh b/milena/mln/io/pfm/save.hh index 1743e20..f9db876 100644 --- a/milena/mln/io/pfm/save.hh +++ b/milena/mln/io/pfm/save.hh @@ -29,13 +29,10 @@ #ifndef MLN_IO_PFM_SAVE_HH # define MLN_IO_PFM_SAVE_HH -/*! - * \file mln/io/pfm/save.hh - * - * \brief Define a function which saves an image of kind pfm into - * given path. - * - */ +/// \file mln/io/pfm/save.hh +/// +/// Define a function which saves an image of kind pfm into +/// given path. # include <iostream> # include <fstream> @@ -55,11 +52,11 @@ namespace mln namespace pfm { - /*! Save a Milena image as a pfm image. - * - * \param[in] ima The image to save. - * \param[in,out] filename the destination. - */ + /// Save a Milena image as a pfm image. + /// + /// \param[in] ima The image to save. + /// \param[in,out] filename the destination. + /// template <typename I> void save(const Image<I>& ima, const std::string& filename); @@ -68,11 +65,9 @@ namespace mln namespace impl { - // FIXME: Argument FILENAME is not used; remove? template <typename I> inline - void save_header_(const I& ima, const std::string& filename, - std::ofstream& file) + void save_header_(const I& ima, std::ofstream& file) { file << geom::nrows(ima) << ' ' << geom::nrows(ima) << std::endl << "float" << std::endl; @@ -83,11 +78,11 @@ namespace mln void save_(const Image<I>& ima_, const std::string& filename) { const I& ima = exact(ima_); + std::ofstream file(filename.c_str()); - save_header_(ima, filename, file); + save_header_(ima, file); - unsigned int - ncols = geom::ncols(ima); + unsigned int ncols = geom::ncols(ima); const mln_deduce(I, site, coord) min_row = geom::min_row(ima), diff --git a/milena/tests/io/off/load_bin.cc b/milena/tests/io/off/load_bin.cc index 4474f6e..5cac72c 100644 --- a/milena/tests/io/off/load_bin.cc +++ b/milena/tests/io/off/load_bin.cc @@ -26,7 +26,8 @@ // Public License. /// \file tests/io/off/load_bin.cc -/// \brief Test mln::io::off::load with an mln::bin_2complex_image3df. +/// +/// Test mln::io::off::load with an mln::bin_2complex_image3df. #include <algorithm> #include <iterator> diff --git a/milena/tests/io/off/load_float.cc b/milena/tests/io/off/load_float.cc index 7cbe625..06199e9 100644 --- a/milena/tests/io/off/load_float.cc +++ b/milena/tests/io/off/load_float.cc @@ -26,7 +26,8 @@ // Public License. /// \file tests/io/off/load_float.cc -/// \brief Test mln::io::off::load with an mln::float_2complex_image3df. +/// +/// Test mln::io::off::load with an mln::float_2complex_image3df. #include <algorithm> #include <iterator> @@ -36,6 +37,7 @@ #include "tests/data.hh" +// FIXME: write a test! int main() { @@ -43,7 +45,7 @@ int main() typedef float_2complex_image3df ima_t; ima_t ima; - io::off::load(ima, MLN_MESH_DIR "/cone-curv.off"); + io::off::load(ima, MLN_MESH_DIR "/cone-max-curv.off"); std::cout << ima.domain().cplx() << std::endl; diff --git a/milena/tests/io/off/load_save_bin.cc b/milena/tests/io/off/load_save_bin.cc index 2dbbdcb..2af3f9d 100644 --- a/milena/tests/io/off/load_save_bin.cc +++ b/milena/tests/io/off/load_save_bin.cc @@ -26,7 +26,8 @@ // Public License. /// \file tests/io/off/load_save_bin.cc -/// \brief Test mln::io::off::load with and mln::io::off::save with an +/// +/// Test mln::io::off::load with and mln::io::off::save with an /// mln::bin_2complex_image3df. #include <algorithm> -- 1.5.6.5
16 years
1
0
0
0
← Newer
1
...
9
10
11
12
13
14
15
...
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