3542: Add morpho::watershed::superpose.

* headers.mk, * tests/unit_test/unit-tests.mk: update. * mln/morpho/watershed/all.hh: add new include. * mln/morpho/watershed/superpose.hh: new routine. * tests/morpho/watershed/Makefile.am, * tests/morpho/watershed/superpose.cc: add associated test. --- milena/ChangeLog | 16 +++- milena/headers.mk | 12 ++ milena/mln/morpho/watershed/all.hh | 1 + milena/mln/morpho/watershed/superpose.hh | 127 ++++++++++++++++++++ milena/tests/morpho/watershed/Makefile.am | 4 +- .../all.hh => tests/morpho/watershed/superpose.cc} | 65 +++++++---- milena/tests/unit_test/unit-tests.mk | 22 ++++ 7 files changed, 222 insertions(+), 25 deletions(-) create mode 100644 milena/mln/morpho/watershed/superpose.hh copy milena/{mln/morpho/watershed/all.hh => tests/morpho/watershed/superpose.cc} (53%) diff --git a/milena/ChangeLog b/milena/ChangeLog index cda14ac..46e8b76 100644 --- a/milena/ChangeLog +++ b/milena/ChangeLog @@ -1,4 +1,18 @@ -2009-03-16 Guillaume Lazzara <lazzara@lrde.epita.fr> +2009-03-18 Guillaume Lazzara <lazzara@lrde.epita.fr> + + Add morpho::watershed::superpose. + + * headers.mk, + * tests/unit_test/unit-tests.mk: update. + + * mln/morpho/watershed/all.hh: add new include. + + * mln/morpho/watershed/superpose.hh: new routine. + + * tests/morpho/watershed/Makefile.am, + * tests/morpho/watershed/superpose.cc: add associated test. + +2009-03-18 Guillaume Lazzara <lazzara@lrde.epita.fr> Small fixes. diff --git a/milena/headers.mk b/milena/headers.mk index dfab609..a74f35f 100644 --- a/milena/headers.mk +++ b/milena/headers.mk @@ -234,6 +234,7 @@ mln/fun/v2v/cast.hh \ mln/fun/v2v/ch_function_value.hh \ mln/fun/v2v/rgb_to_hsi.hh \ mln/fun/v2v/enc.hh \ +mln/fun/v2v/projection.hh \ mln/fun/v2v/convert.hh \ mln/fun/v2v/essential.hh \ mln/fun/v2w2v/cos.hh \ @@ -410,6 +411,12 @@ mln/accu/lor_basic.hh \ mln/accu/transform_diagonal.hh \ mln/accu/nil.hh \ mln/accu/bbox.hh \ +mln/accu/image/init.hh \ +mln/accu/image/to_result.hh \ +mln/accu/image/all.hh \ +mln/accu/image/set_value.hh \ +mln/accu/image/take.hh \ +mln/accu/image/take_as_init.hh \ mln/accu/center.hh \ mln/accu/line.hh \ mln/accu/essential.hh \ @@ -652,6 +659,7 @@ mln/morpho/laplacian.hh \ mln/morpho/all.hh \ mln/morpho/watershed/flooding.hh \ mln/morpho/watershed/all.hh \ +mln/morpho/watershed/superpose.hh \ mln/morpho/opening/approx/all.hh \ mln/morpho/opening/approx/structural.hh \ mln/morpho/opening/all.hh \ @@ -812,6 +820,7 @@ mln/core/internal/image_domain_morpher.hh \ mln/core/internal/image_primary.hh \ mln/core/internal/set_of.hh \ mln/core/internal/complex_window_p_base.hh \ +mln/core/internal/piter_identity.hh \ mln/core/internal/graph_window_base.hh \ mln/core/internal/piter_adaptor.hh \ mln/core/internal/weighted_window_base.hh \ @@ -936,6 +945,7 @@ mln/core/clock_neighb2d.hh \ mln/core/pixter3d.hh \ mln/core/image/obased_rle_encode.hh \ mln/core/image/plain.hh \ +mln/core/image/unproject_image.hh \ mln/core/image/image3d.hh \ mln/core/image/decorated_image.hh \ mln/core/image/extension_ima.hh \ @@ -1047,6 +1057,8 @@ mln/io/cloud/load.hh \ mln/io/cloud/all.hh \ mln/io/cloud/save.hh \ mln/io/all.hh \ +mln/io/magick/load.hh \ +mln/io/magick/all.hh \ mln/io/dump/load.hh \ mln/io/dump/all.hh \ mln/io/dump/save.hh \ diff --git a/milena/mln/morpho/watershed/all.hh b/milena/mln/morpho/watershed/all.hh index 472ff20..cb2238e 100644 --- a/milena/mln/morpho/watershed/all.hh +++ b/milena/mln/morpho/watershed/all.hh @@ -60,6 +60,7 @@ namespace mln # include <mln/morpho/watershed/flooding.hh> +# include <mln/morpho/watershed/superpose.hh> #endif // ! MLN_MORPHO_WATERSHED_ALL_HH diff --git a/milena/mln/morpho/watershed/superpose.hh b/milena/mln/morpho/watershed/superpose.hh new file mode 100644 index 0000000..bad2a71 --- /dev/null +++ b/milena/mln/morpho/watershed/superpose.hh @@ -0,0 +1,127 @@ +// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE) +// +// This file is part of the Olena Library. This library is free +// software; you can redistribute it and/or modify it under the terms +// of the GNU General Public License version 2 as published by the +// Free Software Foundation. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this library; see the file COPYING. If not, write to +// the Free Software Foundation, 51 Franklin Street, Fifth Floor, +// Boston, MA 02111-1307, USA. +// +// As a special exception, you may use this file as part of a free +// software library without restriction. Specifically, if other files +// instantiate templates or use macros or inline functions from this +// file, or you compile this file and link it with other files to +// produce an executable, this file does not by itself cause the +// resulting executable to be covered by the GNU General Public +// License. This exception does not however invalidate any other +// reasons why the executable file might be covered by the GNU General +// Public License. + + +#ifndef MLN_MORPHO_WATERSHED_SUPERPOSE_HH +# define MLN_MORPHO_WATERSHED_SUPERPOSE_HH + +/// \file mln/morpho/watershed/superpose.hh +/// +/// Convert an image to a rgb8 image and draw the watershed lines. + +# include <mln/core/concept/image.hh> +# include <mln/core/image/image_if.hh> +# include <mln/level/convert.hh> +# include <mln/data/fill.hh> +# include <mln/value/rgb8.hh> +# include <mln/literal/colors.hh> +# include <mln/pw/all.hh> + + + +namespace mln +{ + + namespace morpho + { + + namespace watershed + { + + /// Convert an image to a rgb8 image and draw the watershed lines. + /* + ** \param[in] input_ An image. + ** \param[in] ws_ima_ The watershed transform of \p input_. + ** \param[in] wsl_color The color used for the watershed line. + */ + template <typename I, typename J> + inline + mln_ch_value(I,value::rgb8) + superpose(const Image<I>& input_, + const Image<J>& ws_ima_, + const value::rgb8& wsl_color); + + + /// Convert an image to a rgb8 image and draw the watershed lines. + /* + ** \param[in] input_ An image. + ** \param[in] ws_ima_ The watershed transform of \p input_. + ** + ** The watershed line is drawn in red. + */ + template <typename I, typename J> + inline + mln_ch_value(I,value::rgb8) + superpose(const Image<I>& input, + const Image<J>& ws_ima); + + +# ifndef MLN_INCLUDE_ONLY + + template <typename I, typename J> + inline + mln_ch_value(I,value::rgb8) + superpose(const Image<I>& input_, + const Image<J>& ws_ima_, + const value::rgb8& wsl_color) + { + trace::entering("morpho::watershed::superpose"); + + const I& input = exact(input_); + const J& ws_ima = exact(ws_ima_); + mln_precondition(input.is_valid()); + mln_precondition(ws_ima.is_valid()); + + mln_ch_value(I,value::rgb8) output = level::convert(value::rgb8(), input); + + data::fill((output | (pw::value(ws_ima) == pw::cst(literal::zero))).rw(), + wsl_color); + + trace::exiting("morpho::watershed::superpose"); + return output; + } + + + template <typename I, typename J> + inline + mln_ch_value(I,value::rgb8) + superpose(const Image<I>& input, + const Image<J>& ws_ima) + { + return superpose(input, ws_ima, literal::red); + } + +# endif // ! MLN_INCLUDE_ONLY + + + } // end of namespace mln::morpho::watershed + + } // end of namespace mln::morpho + +} // end of namespace mln + +#endif // ! MLN_MORPHO_WATERSHED_SUPERPOSE_HH diff --git a/milena/tests/morpho/watershed/Makefile.am b/milena/tests/morpho/watershed/Makefile.am index 2b022e8..63dc2a7 100644 --- a/milena/tests/morpho/watershed/Makefile.am +++ b/milena/tests/morpho/watershed/Makefile.am @@ -3,8 +3,10 @@ include $(top_srcdir)/milena/tests/tests.mk check_PROGRAMS = \ - flooding + flooding \ + superpose flooding_SOURCES = flooding.cc +superpose_SOURCES = superpose.cc TESTS = $(check_PROGRAMS) diff --git a/milena/mln/morpho/watershed/all.hh b/milena/tests/morpho/watershed/superpose.cc similarity index 53% copy from milena/mln/morpho/watershed/all.hh copy to milena/tests/morpho/watershed/superpose.cc index 472ff20..edace77 100644 --- a/milena/mln/morpho/watershed/all.hh +++ b/milena/tests/morpho/watershed/superpose.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE) +// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE) // // This file is part of the Olena Library. This library is free // software; you can redistribute it and/or modify it under the terms @@ -25,41 +25,60 @@ // reasons why the executable file might be covered by the GNU General // Public License. -#ifndef MLN_MORPHO_WATERSHED_ALL_HH -# define MLN_MORPHO_WATERSHED_ALL_HH - -/// \file mln/morpho/watershed/all.hh +/// \file tests/morpho/watershed/superpose.cc /// -/// File that includes all morphological watershed routines. +/// Test on mln::morpho::watershed::superpose. + +#include <iostream> + +#include <mln/core/image/image2d.hh> + +#include <mln/make/image2d.hh> + +#include <mln/value/label_8.hh> +#include <mln/value/int_u8.hh> + +#include <mln/morpho/watershed/superpose.hh> +#include <mln/level/compare.hh> +#include "tests/data.hh" + +#include <mln/debug/println.hh> +#include <mln/debug/iota.hh> namespace mln { - namespace morpho + struct ref_data : Function_p2v<ref_data> { + typedef value::rgb8 result; - /// Namespace of morphological watershed routines. - namespace watershed + value::rgb8 operator()(const point2d& p) const { + if (p.row() == 2 || p.col() == 2) + return literal::red; + unsigned val = p.col() + 1 + p.row() * 4; + return value::rgb8(val, val, val); + } - /// Namespace of morphological watershed routines - /// implementations. - namespace watershed - { + }; - /// Namespace of morphological watershed routines generic - /// implementations. - namespace generic - {} +} // end of namespace mln - } - } - } -} +int main() +{ + using namespace mln; + image2d<value::int_u8> ima(4,4); + debug::iota(ima); -# include <mln/morpho/watershed/flooding.hh> + value::label_8 data_ws[16] = { 1, 1, 0, 2, + 1, 1, 0, 2, + 0, 0, 0, 0, + 5, 5, 0, 4 }; + image2d<value::label_8> ima_ws = make::image2d(data_ws); -#endif // ! MLN_MORPHO_WATERSHED_ALL_HH + image2d<value::rgb8> sup = morpho::watershed::superpose(ima, ima_ws); + mln_assertion(sup == (ref_data() | sup.domain())); +} diff --git a/milena/tests/unit_test/unit-tests.mk b/milena/tests/unit_test/unit-tests.mk index f288f80..1449e41 100644 --- a/milena/tests/unit_test/unit-tests.mk +++ b/milena/tests/unit_test/unit-tests.mk @@ -229,6 +229,7 @@ mln_fun_v2v_cast \ mln_fun_v2v_ch_function_value \ mln_fun_v2v_rgb_to_hsi \ mln_fun_v2v_enc \ +mln_fun_v2v_projection \ mln_fun_v2v_convert \ mln_fun_v2v_essential \ mln_fun_v2w2v_cos \ @@ -405,6 +406,12 @@ mln_accu_lor_basic \ mln_accu_transform_diagonal \ mln_accu_nil \ mln_accu_bbox \ +mln_accu_image_init \ +mln_accu_image_to_result \ +mln_accu_image_all \ +mln_accu_image_set_value \ +mln_accu_image_take \ +mln_accu_image_take_as_init \ mln_accu_center \ mln_accu_line \ mln_accu_essential \ @@ -645,6 +652,7 @@ mln_morpho_laplacian \ mln_morpho_all \ mln_morpho_watershed_flooding \ mln_morpho_watershed_all \ +mln_morpho_watershed_superpose \ mln_morpho_opening_approx_all \ mln_morpho_opening_approx_structural \ mln_morpho_opening_all \ @@ -804,6 +812,7 @@ mln_core_internal_image_domain_morpher \ mln_core_internal_image_primary \ mln_core_internal_set_of \ mln_core_internal_complex_window_p_base \ +mln_core_internal_piter_identity \ mln_core_internal_graph_window_base \ mln_core_internal_piter_adaptor \ mln_core_internal_weighted_window_base \ @@ -911,6 +920,7 @@ mln_core_clock_neighb2d \ mln_core_pixter3d \ mln_core_image_obased_rle_encode \ mln_core_image_plain \ +mln_core_image_unproject_image \ mln_core_image_image3d \ mln_core_image_decorated_image \ mln_core_image_extension_ima \ @@ -1018,6 +1028,8 @@ mln_io_cloud_load \ mln_io_cloud_all \ mln_io_cloud_save \ mln_io_all \ +mln_io_magick_load \ +mln_io_magick_all \ mln_io_dump_load \ mln_io_dump_all \ mln_io_dump_save \ @@ -1326,6 +1338,7 @@ mln_fun_v2v_cast_SOURCES = mln_fun_v2v_cast.cc mln_fun_v2v_ch_function_value_SOURCES = mln_fun_v2v_ch_function_value.cc mln_fun_v2v_rgb_to_hsi_SOURCES = mln_fun_v2v_rgb_to_hsi.cc mln_fun_v2v_enc_SOURCES = mln_fun_v2v_enc.cc +mln_fun_v2v_projection_SOURCES = mln_fun_v2v_projection.cc mln_fun_v2v_convert_SOURCES = mln_fun_v2v_convert.cc mln_fun_v2v_essential_SOURCES = mln_fun_v2v_essential.cc mln_fun_v2w2v_cos_SOURCES = mln_fun_v2w2v_cos.cc @@ -1502,6 +1515,12 @@ mln_accu_lor_basic_SOURCES = mln_accu_lor_basic.cc mln_accu_transform_diagonal_SOURCES = mln_accu_transform_diagonal.cc mln_accu_nil_SOURCES = mln_accu_nil.cc mln_accu_bbox_SOURCES = mln_accu_bbox.cc +mln_accu_image_init_SOURCES = mln_accu_image_init.cc +mln_accu_image_to_result_SOURCES = mln_accu_image_to_result.cc +mln_accu_image_all_SOURCES = mln_accu_image_all.cc +mln_accu_image_set_value_SOURCES = mln_accu_image_set_value.cc +mln_accu_image_take_SOURCES = mln_accu_image_take.cc +mln_accu_image_take_as_init_SOURCES = mln_accu_image_take_as_init.cc mln_accu_center_SOURCES = mln_accu_center.cc mln_accu_line_SOURCES = mln_accu_line.cc mln_accu_essential_SOURCES = mln_accu_essential.cc @@ -1742,6 +1761,7 @@ mln_morpho_laplacian_SOURCES = mln_morpho_laplacian.cc mln_morpho_all_SOURCES = mln_morpho_all.cc mln_morpho_watershed_flooding_SOURCES = mln_morpho_watershed_flooding.cc mln_morpho_watershed_all_SOURCES = mln_morpho_watershed_all.cc +mln_morpho_watershed_superpose_SOURCES = mln_morpho_watershed_superpose.cc mln_morpho_opening_approx_all_SOURCES = mln_morpho_opening_approx_all.cc mln_morpho_opening_approx_structural_SOURCES = mln_morpho_opening_approx_structural.cc mln_morpho_opening_all_SOURCES = mln_morpho_opening_all.cc @@ -1901,6 +1921,7 @@ mln_core_internal_image_domain_morpher_SOURCES = mln_core_internal_image_domain_ mln_core_internal_image_primary_SOURCES = mln_core_internal_image_primary.cc mln_core_internal_set_of_SOURCES = mln_core_internal_set_of.cc mln_core_internal_complex_window_p_base_SOURCES = mln_core_internal_complex_window_p_base.cc +mln_core_internal_piter_identity_SOURCES = mln_core_internal_piter_identity.cc mln_core_internal_graph_window_base_SOURCES = mln_core_internal_graph_window_base.cc mln_core_internal_piter_adaptor_SOURCES = mln_core_internal_piter_adaptor.cc mln_core_internal_weighted_window_base_SOURCES = mln_core_internal_weighted_window_base.cc @@ -2008,6 +2029,7 @@ mln_core_clock_neighb2d_SOURCES = mln_core_clock_neighb2d.cc mln_core_pixter3d_SOURCES = mln_core_pixter3d.cc mln_core_image_obased_rle_encode_SOURCES = mln_core_image_obased_rle_encode.cc mln_core_image_plain_SOURCES = mln_core_image_plain.cc +mln_core_image_unproject_image_SOURCES = mln_core_image_unproject_image.cc mln_core_image_image3d_SOURCES = mln_core_image_image3d.cc mln_core_image_decorated_image_SOURCES = mln_core_image_decorated_image.cc mln_core_image_extension_ima_SOURCES = mln_core_image_extension_ima.cc -- 1.5.6.5
participants (1)
-
Guillaume Lazzara