https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog from Roland Levillain roland@lrde.epita.fr
More tests on Meyer's WST.
* tests/morpho/meyer_wst_long.cc: New test. * tests/morpho/Makefile.am (check_PROGRAMS): Add meyer_wst and meyer_wst_long. (meyer_wst_SOURCES) (meyer_wst_long_SOURCES, meyer_wst_long_CXXFLAGS): New.
Makefile.am | 21 ++++++++++++++++----- meyer_wst.cc | 1 - meyer_wst_long.cc | 29 +++++++++++++++++++++++------ 3 files changed, 39 insertions(+), 12 deletions(-)
Index: tests/morpho/meyer_wst.cc --- tests/morpho/meyer_wst.cc (revision 1696) +++ tests/morpho/meyer_wst.cc (working copy) @@ -55,7 +55,6 @@ io::pgm::load(input, MLN_IMG_DIR "/squares.pgm");
typedef int_u8 output_val; - unsigned nbasins; // FIXME: Do we really need to use a neighborood to express a 4-c window? image2d<int_u8> output = Index: tests/morpho/meyer_wst_long.cc --- tests/morpho/meyer_wst_long.cc (revision 1695) +++ tests/morpho/meyer_wst_long.cc (working copy) @@ -30,18 +30,26 @@
#include <iostream>
+#include <mln/core/image_if.hh> #include <mln/core/image2d.hh> #include <mln/core/window2d.hh> #include <mln/core/neighb2d.hh>
#include <mln/convert/to_window.hh> +#include <mln/level/stretch.hh>
#include <mln/value/int_u8.hh> +#include <mln/value/int_u16.hh>
+#include <mln/morpho/closing_area.hh> #include <mln/morpho/meyer_wst.hh>
+#include <mln/pw/cst.hh> +#include <mln/pw/value.hh> + +#include <mln/display/color_pretty.hh> #include <mln/io/pgm/load.hh> -#include <mln/io/pgm/save.hh> +#include <mln/io/ppm/save.hh>
#include "tests/data.hh"
@@ -50,16 +58,25 @@ { using namespace mln; using value::int_u8; + using value::int_u16;
image2d<int_u8> input; - io::pgm::load(input, MLN_IMG_DIR "/squares.pgm"); + io::pgm::load(input, MLN_IMG_DIR "/lena.pgm");
- typedef int_u8 output_val; + // Simplify the input image. + image2d<int_u8> work(input.domain()); + morpho::closing_area(input, c4(), 200, work);
+ // Perform a Watershed Transform. + typedef int_u16 wst_val; unsigned nbasins; // FIXME: Do we really need to use a neighborood to express a 4-c window? - image2d<int_u8> output = - morpho::meyer_wst<output_val>(input, convert::to_window(c4()), nbasins); + image2d<wst_val> ws = + morpho::meyer_wst<wst_val>(work, convert::to_window(c4()), nbasins); std::cout << "nbasins = " << nbasins << std::endl; - io::pgm::save(output, "out.pgm"); + + // Save the image in color. + image2dvalue::rgb8 input_plus_ws = + display::color_pretty(input | (pw::value(ws) != pw::cst(0))); + io::ppm::save(input_plus_ws, "out.ppm"); } Index: tests/morpho/Makefile.am --- tests/morpho/Makefile.am (revision 1696) +++ tests/morpho/Makefile.am (working copy) @@ -14,21 +14,32 @@ hit_or_miss \ laplacian \ level_components \ + meyer_wst \ + meyer_wst_long \ opening_area \ thinning
-closing_area_SOURCES = closing_area.cc -contrast_SOURCES = contrast.cc dilation_SOURCES = dilation.cc -dilation_max_h_SOURCES = dilation_max_h.cc erosion_SOURCES = erosion.cc + +dilation_max_h_SOURCES = dilation_max_h.cc erosion_min_h_SOURCES = erosion_min_h.cc + +opening_area_SOURCES = opening_area.cc +closing_area_SOURCES = closing_area.cc + +level_components_SOURCES = level_components.cc extrema_components_SOURCES = extrema_components.cc + +contrast_SOURCES = contrast.cc gradient_SOURCES = gradient.cc hit_or_miss_SOURCES = hit_or_miss.cc laplacian_SOURCES = laplacian.cc -level_components_SOURCES = level_components.cc -opening_area_SOURCES = opening_area.cc thinning_SOURCES = thinning.cc
+meyer_wst_SOURCES = meyer_wst.cc +# FIXME: We should isolate this test, as it takes a long time. +meyer_wst_long_SOURCES = meyer_wst_long.cc +meyer_wst_long_CXXFLAGS = -O3 + TESTS = $(check_PROGRAMS)