olena: olena-2.0-580-gca15e47 Swap arguments in data::convert.

* mln/data/convert.hh: Here. * apps/morphers/iz.cc, * demos/inter_pixel/inter_pixel.cc, * doc/examples/trash/graph.cc, * doc/mln/convert.dox, * mln/debug/superpose.hh, * mln/morpho/watershed/superpose.hh, * mln/world/binary_2d/subsample.hh, * tests/data/compute_in_window.cc, * tests/data/convert.cc: Update calls to data::convert. --- milena/ChangeLog | 16 ++++++++++++++ milena/apps/morphers/iz.cc | 4 +- milena/demos/inter_pixel/inter_pixel.cc | 2 +- milena/doc/examples/trash/graph.cc | 9 ++++--- milena/doc/mln/convert.dox | 12 +++++----- milena/mln/data/convert.hh | 33 +++++++++++++++++++++-------- milena/mln/debug/superpose.hh | 6 ++-- milena/mln/morpho/watershed/superpose.hh | 5 ++- milena/mln/world/binary_2d/subsample.hh | 2 +- milena/tests/data/compute_in_window.cc | 7 +++-- milena/tests/data/convert.cc | 29 +++++++++++++++++++++++-- 11 files changed, 91 insertions(+), 34 deletions(-) diff --git a/milena/ChangeLog b/milena/ChangeLog index 796405c..951de6f 100644 --- a/milena/ChangeLog +++ b/milena/ChangeLog @@ -1,5 +1,21 @@ 2013-04-29 Guillaume Lazzara <z@lrde.epita.fr> + Swap arguments in data::convert. + + * mln/data/convert.hh: Here. + + * apps/morphers/iz.cc, + * demos/inter_pixel/inter_pixel.cc, + * doc/examples/trash/graph.cc, + * doc/mln/convert.dox, + * mln/debug/superpose.hh, + * mln/morpho/watershed/superpose.hh, + * mln/world/binary_2d/subsample.hh, + * tests/data/compute_in_window.cc, + * tests/data/convert.cc: Update calls to data::convert. + +2013-04-29 Guillaume Lazzara <z@lrde.epita.fr> + * doc/mln/io/io.dox: List the required dependencies for each I/O type. diff --git a/milena/apps/morphers/iz.cc b/milena/apps/morphers/iz.cc index 4216dc5..ae0d6d3 100644 --- a/milena/apps/morphers/iz.cc +++ b/milena/apps/morphers/iz.cc @@ -107,7 +107,7 @@ int main(int argc, char* argv[]) c4(), make::w_window2d(ww), mln_max(int_u8)); dmap = morpho::closing::area(dmap, c4(), 500); - + io::pgm::save(dmap, "tmp_dmap.pgm"); @@ -119,7 +119,7 @@ int main(int argc, char* argv[]) io::ppm::save(labeling::colorize(value::rgb8(), ws), "tmp_ws.ppm"); { - image2d<value::rgb8> ws_ = data::convert(value::rgb8(), input); + image2d<value::rgb8> ws_ = data::convert(input, value::rgb8()); data::fill((ws_ | (pw::value(ws) == pw::cst(0))).rw(), literal::red); io::ppm::save(ws_, "tmp_ws_superpose.ppm"); diff --git a/milena/demos/inter_pixel/inter_pixel.cc b/milena/demos/inter_pixel/inter_pixel.cc index 61ba33f..32012db 100644 --- a/milena/demos/inter_pixel/inter_pixel.cc +++ b/milena/demos/inter_pixel/inter_pixel.cc @@ -78,7 +78,7 @@ int main(int argc, char* argv[]) io::pgm::save(world::inter_pixel::display_edge(edges.unmorph_(), 0, 3), "edge_dist.pgm"); // Color on edge image. - image2d<rgb8> edge_color = data::convert(rgb8(), edges.unmorph_()); + image2d<rgb8> edge_color = data::convert(edges.unmorph_(), rgb8()); mln_piter_(image2d<int_u8>) p(input.domain()); for_all(p) convert::from_to(input(p), opt::at(edge_color, p.row() * 2, p.col() * 2)); diff --git a/milena/doc/examples/trash/graph.cc b/milena/doc/examples/trash/graph.cc index 294a215..4271e6d 100644 --- a/milena/doc/examples/trash/graph.cc +++ b/milena/doc/examples/trash/graph.cc @@ -1,4 +1,5 @@ -// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE) +// Copyright (C) 2008, 2013 EPITA Research and Development Laboratory +// (LRDE) // // This file is part of Olena. // @@ -98,7 +99,7 @@ int main(int argc, char *argv[]) p_vertices<G, fv2p_t> pv(g, fv2p); #ifndef NOUT - image2d<rgb8> gima = data::convert(rgb8(), ima); + image2d<rgb8> gima = data::convert(ima, rgb8()); debug::draw_graph(gima, pv, pw::cst(literal::cyan), @@ -121,7 +122,7 @@ int main(int argc, char *argv[]) pvlg_t pvlg(lg, convert::to<i2e_t>(lines)); #ifndef NOUT - image2d<rgb8> lgima = data::convert(rgb8(), ima); + image2d<rgb8> lgima = data::convert(ima, rgb8()); debug::draw_graph(lgima, pvlg, pw::cst(literal::cyan), @@ -152,7 +153,7 @@ int main(int argc, char *argv[]) #ifndef NOUT - image2d<rgb8> lgima2 = data::convert(rgb8(), ima); + image2d<rgb8> lgima2 = data::convert(ima, rgb8()); debug::draw_graph(lgima2, pvlg, pw::cst(literal::cyan), ecolor); io::ppm::save(lgima2, "05-line-graph-cleanup.ppm"); #endif diff --git a/milena/doc/mln/convert.dox b/milena/doc/mln/convert.dox index a2f30a1..087c5f9 100644 --- a/milena/doc/mln/convert.dox +++ b/milena/doc/mln/convert.dox @@ -14,14 +14,14 @@ image2d<value::int_u8> ima_gl; // Initialization of ima_gl. // ... - image2d<value::rgb8> ima_color = mln::data::convert(value::rgb8(), ima_gl); + image2d<value::rgb8> ima_color = mln::data::convert(ima_gl, value::rgb8()); \endcode \code image2d<value::int_u8> ima_gl; // Initialization of ima_gl. // ... - image2d<bool> ima_b = mln::data::convert(bool(), ima_gl); + image2d<bool> ima_b = mln::data::convert(ima_gl, bool()); \endcode @@ -41,7 +41,7 @@ image2d<value::rgb8> ima_color; // Initialization of ima_color // ... - image2d<value::int_u8> ima_gl = data::convert(value::int_u8(), ima_color); + image2d<value::int_u8> ima_gl = data::convert(ima_color, value::int_u8()); } \endcode \code @@ -72,7 +72,7 @@ image2d<value::rgb8> ima_color; // Initialization of ima_color // ... - image2d<value::int_u8> ima_gl = data::convert(fun::v2v::rgb_to_luma<value::int_u8>(), ima_color); + image2d<value::int_u8> ima_gl = data::convert(ima_color, value::int_u8(), fun::v2v::rgb_to_luma<value::int_u8>()); } \endcode @@ -109,7 +109,7 @@ image2d<value::rgb8> ima_color; // Initialization of ima_color // ... - image2d<value::int_u8> ima_red_gl = data::convert(only_red_component(), ima_color); + image2d<value::int_u8> ima_red_gl = data::convert(ima_color, value::int_u8(), only_red_component()); } \endcode @@ -144,7 +144,7 @@ image2d<value::rgb8> ima_color; // Initialization of ima_color // ... - image2d<value::int_u8> ima_red_gl = data::convert(value::int_u8(), ima_color); + image2d<value::int_u8> ima_red_gl = data::convert(ima_color, value::int_u8()); } \endcode diff --git a/milena/mln/data/convert.hh b/milena/mln/data/convert.hh index 1f7fce3..e186423 100644 --- a/milena/mln/data/convert.hh +++ b/milena/mln/data/convert.hh @@ -1,4 +1,4 @@ -// Copyright (C) 2008, 2009, 2012 EPITA Research and Development +// Copyright (C) 2008, 2009, 2012, 2013 EPITA Research and Development // Laboratory (LRDE) // // This file is part of Olena. @@ -36,6 +36,12 @@ # include <mln/core/routine/duplicate.hh> # include <mln/fun/v2v/convert.hh> # include <mln/data/transform.hh> +# include <mln/core/concept/function.hh> +# include <mln/core/concept/value.hh> + +#include <mln/core/image/image2d.hh> +#include <mln/value/int_u8.hh> +#include <mln/fun/v2v/rgb_to_luma.hh> namespace mln @@ -44,6 +50,11 @@ namespace mln namespace data { + // template <typename V, typename I> + // mln_ch_value(I, V) + // convert(const V& v, const I& input); + + /*! \brief Convert the image \p input by changing the value type. \param[in] v A value of the destination type. Its type is used @@ -55,9 +66,9 @@ namespace mln \ingroup mlndata convert */ - template <typename V, typename I> + template <typename I, typename V> mln_ch_value(I, V) - convert(const V& v, const Image<I>& input); + convert(const Image<I>& input, const V& v); /*! \overload \brief Convert the image \p input by changing the value type. @@ -68,9 +79,11 @@ namespace mln \ingroup mlndata convert */ - template <typename F, typename I> + template <typename I, typename F> mln_ch_value(I, mln_result(F)) - convert(const Function_v2v<F>& convert_function, const Image<I>& input); + convert(const Image<I>& input, const mln_result(F)& v, + const Function_v2v<F>& convert_function); + # ifndef MLN_INCLUDE_ONLY @@ -165,10 +178,10 @@ namespace mln // Facade. - template <typename V, typename I> + template <typename I, typename V> inline mln_ch_value(I, V) - convert(const V& v, const Image<I>& input) + convert(const Image<I>& input, const V& v) { mln_trace("data::convert"); @@ -179,13 +192,15 @@ namespace mln return output; } - template <typename F, typename I> + template <typename I, typename F> mln_ch_value(I, mln_result(F)) - convert(const Function_v2v<F>& convert_function, const Image<I>& input) + convert(const Image<I>& input, const mln_result(F)& v, + const Function_v2v<F>& convert_function) { mln_trace("data::convert"); typedef mln_result(F) V; internal::convert_tests(V(), input); + (void) v; mln_ch_value(I, V) output = data::transform(input, convert_function); diff --git a/milena/mln/debug/superpose.hh b/milena/mln/debug/superpose.hh index 736e4a9..b71b6d8 100644 --- a/milena/mln/debug/superpose.hh +++ b/milena/mln/debug/superpose.hh @@ -1,5 +1,5 @@ -// Copyright (C) 2009, 2012 EPITA Research and Development Laboratory -// (LRDE) +// Copyright (C) 2009, 2012, 2013 EPITA Research and Development +// Laboratory (LRDE) // // This file is part of Olena. // @@ -98,7 +98,7 @@ namespace mln mln_precondition(object.is_valid()); mln_precondition(input.domain() == object.domain()); - mln_ch_value(I,value::rgb8) output = data::convert(value::rgb8(), input); + mln_ch_value(I,value::rgb8) output = data::convert(input, value::rgb8()); data::fill((output | (pw::value(object) != pw::cst(literal::zero))).rw(), object_color); diff --git a/milena/mln/morpho/watershed/superpose.hh b/milena/mln/morpho/watershed/superpose.hh index d1ceb09..8f589e0 100644 --- a/milena/mln/morpho/watershed/superpose.hh +++ b/milena/mln/morpho/watershed/superpose.hh @@ -1,4 +1,5 @@ -// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE) +// Copyright (C) 2009, 2013 EPITA Research and Development Laboratory +// (LRDE) // // This file is part of Olena. // @@ -93,7 +94,7 @@ namespace mln mln_precondition(input.is_valid()); mln_precondition(ws_ima.is_valid()); - mln_ch_value(I,value::rgb8) output = data::convert(value::rgb8(), input); + mln_ch_value(I,value::rgb8) output = data::convert(input, value::rgb8()); data::fill((output | (pw::value(ws_ima) == pw::cst(literal::zero))).rw(), wsl_color); diff --git a/milena/mln/world/binary_2d/subsample.hh b/milena/mln/world/binary_2d/subsample.hh index d8d1aa3..5e94016 100644 --- a/milena/mln/world/binary_2d/subsample.hh +++ b/milena/mln/world/binary_2d/subsample.hh @@ -75,7 +75,7 @@ namespace mln if (n == 0) { image2d<value::int_u8> - output = data::convert(int_u8(), input); + output = data::convert(input, int_u8()); return output; } diff --git a/milena/tests/data/compute_in_window.cc b/milena/tests/data/compute_in_window.cc index 8df7f7a..ac359be 100644 --- a/milena/tests/data/compute_in_window.cc +++ b/milena/tests/data/compute_in_window.cc @@ -1,4 +1,5 @@ -// Copyright (C) 2011 EPITA Research and Development Laboratory (LRDE) +// Copyright (C) 2011, 2013 EPITA Research and Development Laboratory +// (LRDE) // // This file is part of Olena. // @@ -51,7 +52,7 @@ int main() accu::stat::mean<int> m; image2d<float> res = data::impl::generic::compute_in_window(m, ima, win_c8p()); - image2d<int> res_i = data::convert(int(), res); + image2d<int> res_i = data::convert(res, int()); image2d<int> ref = make::image2d(data); @@ -69,7 +70,7 @@ int main() accu::stat::mean<int> m; image2d<float> res = data::compute_in_window(m, ima, win_c8p()); - image2d<int> res_i = data::convert(int(), res); + image2d<int> res_i = data::convert(res, int()); image2d<int> ref = make::image2d(data); diff --git a/milena/tests/data/convert.cc b/milena/tests/data/convert.cc index c0caeb5..6bcafba 100644 --- a/milena/tests/data/convert.cc +++ b/milena/tests/data/convert.cc @@ -1,4 +1,5 @@ -// Copyright (C) 2008, 2009 EPITA Research and Development Laboratory (LRDE) +// Copyright (C) 2008, 2009, 2013 EPITA Research and Development +// Laboratory (LRDE) // // This file is part of Olena. // @@ -42,7 +43,7 @@ int main() image2d<bool> ima(1, 2); opt::at(ima, 0, 0) = false; opt::at(ima, 0, 1) = true; - image2d<rgb8> out = data::convert(rgb8(), ima); + image2d<rgb8> out = data::convert(ima, rgb8()); mln_assertion(opt::at(out, 0, 0) == literal::black); mln_assertion(opt::at(out, 0, 1) == literal::white); } @@ -51,9 +52,31 @@ int main() image2d<bool> ima(1, 2); data::fill(ima, true); opt::at(ima, 0, 0) = false; - image2d<bool> out = data::convert(bool(), ima); + image2d<bool> out = data::convert(ima, bool()); mln_assertion(out == ima); mln_assertion(out.buffer() != ima.buffer()); } + // bool -> rgb8 + { + image2d<bool> ima(1, 2); + opt::at(ima, 0, 0) = false; + opt::at(ima, 0, 1) = true; + fun::v2v::convert<value::rgb8> f; + image2d<rgb8> out = data::convert(ima, rgb8(), f); + mln_assertion(opt::at(out, 0, 0) == literal::black); + mln_assertion(opt::at(out, 0, 1) == literal::white); + } + // bool -> bool + { + image2d<bool> ima(1, 2); + data::fill(ima, true); + opt::at(ima, 0, 0) = false; + fun::v2v::convert<bool> f; + image2d<bool> out = data::convert(ima, bool(), f); + mln_assertion(out == ima); + mln_assertion(out.buffer() != ima.buffer()); + } + + } -- 1.7.2.5
participants (1)
-
Guillaume Lazzara