Commit 4da0078b authored by Guillaume Lazzara's avatar Guillaume Lazzara
Browse files

Write a valid test for labeling::foreground.

	* tests/labeling/Makefile.am: Add more extra-dist files.

	* tests/labeling/foreground.cc: Rewrite.

	* tests/labeling/foreground.ref.pgm: New.
parent e4ad8e38
2013-03-18 Guillaume Lazzara <z@lrde.epita.fr>
Write a valid test for labeling::foreground.
* tests/labeling/Makefile.am: Add more extra-dist files.
* tests/labeling/foreground.cc: Rewrite.
* tests/labeling/foreground.ref.pgm: New.
2013-03-18 Guillaume Lazzara <z@lrde.epita.fr>
 
Fix compilation issues.
# Copyright (C) 2007, 2008, 2009, 2010 EPITA Research and Development
# Laboratory (LRDE).
# Copyright (C) 2007, 2008, 2009, 2010, 2013 EPITA Research and
# Development Laboratory (LRDE).
#
# This file is part of Olena.
#
......@@ -17,6 +17,10 @@
include $(top_srcdir)/milena/tests/tests.mk
EXTRA_DIST = \
foreground.ref.pgm
check_PROGRAMS = \
background \
blobs \
......
// Copyright (C) 2007, 2008, 2009, 2010 EPITA Research and Development
// Laboratory (LRDE)
// Copyright (C) 2007, 2008, 2009, 2010, 2013 EPITA Research and
// Development Laboratory (LRDE)
//
// This file is part of Olena.
//
......@@ -27,12 +27,15 @@
#include <mln/core/image/image2d.hh>
#include <mln/core/var.hh>
#include <mln/io/pbm/load.hh>
#include <mln/io/pgm/load.hh>
#include <mln/core/alias/neighb2d.hh>
#include <mln/data/compare.hh>
#include <mln/labeling/foreground.hh>
#include <mln/value/int_u8.hh>
#include "tests/data.hh"
#include <mln/io/pgm/save.hh>
int main()
{
......@@ -41,27 +44,18 @@ int main()
typedef image2d<bool> I;
neighb2d nbh = c4();
I pic = io::pbm::load(MLN_IMG_DIR "/picasso.pbm");
image2d<unsigned> out, ref;
// Load ref
image2d<value::int_u8> ref;
io::pgm::load(ref, MLN_TESTS_DIR "/labeling/foreground.ref.pgm");
unsigned n;
out = labeling::foreground(pic, nbh, n); // Calls the fastest 'video'
// version.
mln_assertion(n == 33);
{
// Note that labeling::foreground actually is labeling::value
// which calls canvas::labeling_video and its generic dispatch
// leads to canvas::impl::generic::labeling.
I input = io::pbm::load(MLN_IMG_DIR "/picasso.pbm");
image2d<value::int_u8> out;
labeling::impl::value_functor<I,unsigned> f(pic, true);
value::int_u8 n;
out = labeling::foreground(input, nbh, n);
unsigned n_;
ref = canvas::labeling::impl::generic::labeling(pic, nbh, n_,
pic.domain(),
f);
mln_invariant(n_ == n);
mln_invariant(ref == out);
}
mln_assertion(n == 33);
mln_assertion(ref == out);
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment