last-svn-commit-29-g4026193 Add a new test for object_image.

* tests/Makefile.am, * tests/core/Makefile.am: Update build system. * tests/core/object_image.cc: New test. --- scribo/ChangeLog | 9 ++++ scribo/tests/Makefile.am | 1 + scribo/tests/{preprocessing => core}/Makefile.am | 4 +- .../tests/core/object_image.cc | 51 +++++++++++++------- 4 files changed, 45 insertions(+), 20 deletions(-) copy scribo/tests/{preprocessing => core}/Makefile.am (93%) copy milena/tests/core/image/dmorph/unproject_image.cc => scribo/tests/core/object_image.cc (60%) diff --git a/scribo/ChangeLog b/scribo/ChangeLog index a11166a..745540f 100644 --- a/scribo/ChangeLog +++ b/scribo/ChangeLog @@ -1,5 +1,14 @@ 2009-12-15 Guillaume Lazzara <z@lrde.epita.fr> + Add a new test for object_image. + + * tests/Makefile.am, + * tests/core/Makefile.am: Update build system. + + * tests/core/object_image.cc: New test. + +2009-12-15 Guillaume Lazzara <z@lrde.epita.fr> + * primitive/extract/objects.hh: Compute and store mass centers. 2009-12-14 Guillaume Lazzara <z@lrde.epita.fr> diff --git a/scribo/tests/Makefile.am b/scribo/tests/Makefile.am index e36d250..67d6d25 100644 --- a/scribo/tests/Makefile.am +++ b/scribo/tests/Makefile.am @@ -19,6 +19,7 @@ include $(srcdir)/tests.mk ## Process this file through Automake to create Makefile.in. SUBDIRS = \ + core \ filter \ preprocessing \ table \ diff --git a/scribo/tests/preprocessing/Makefile.am b/scribo/tests/core/Makefile.am similarity index 93% copy from scribo/tests/preprocessing/Makefile.am copy to scribo/tests/core/Makefile.am index 4666033..a7773ec 100644 --- a/scribo/tests/preprocessing/Makefile.am +++ b/scribo/tests/core/Makefile.am @@ -20,8 +20,8 @@ include $(top_srcdir)/scribo/tests/tests.mk check_PROGRAMS = \ - unskew + object_image -unskew_SOURCES = unskew.cc +object_image_SOURCES = object_image.cc TESTS = $(check_PROGRAMS) diff --git a/milena/tests/core/image/dmorph/unproject_image.cc b/scribo/tests/core/object_image.cc similarity index 60% copy from milena/tests/core/image/dmorph/unproject_image.cc copy to scribo/tests/core/object_image.cc index bb7dbde..9ac6152 100644 --- a/milena/tests/core/image/dmorph/unproject_image.cc +++ b/scribo/tests/core/object_image.cc @@ -23,35 +23,50 @@ // exception does not however invalidate any other reasons why the // executable file might be covered by the GNU General Public License. -#include <mln/core/image/image1d.hh> +#include <iostream> + #include <mln/core/image/image2d.hh> -#include <mln/core/image/dmorph/unproject_image.hh> -#include <mln/core/var.hh> +#include <mln/make/image.hh> +#include <mln/fun/i2v/array.hh> -#include <mln/fun/v2v/projection.hh> +#include <scribo/core/object_image.hh> -#include <mln/debug/iota.hh> #include <mln/debug/println.hh> - - -int main() +int main(int argc, char* argv[]) { using namespace mln; - image1d<int> ima(3); - debug::iota(ima); + unsigned data[4][4] = { {1, 0, 0, 0}, + {0, 0, 2, 0}, + {3, 0, 0, 0}, + {0, 0, 4, 0} }; + + typedef image2d<unsigned> I; + I ima = make::image(data); + + object_image(I) lbl(ima, 4); + + fun::i2v::array<unsigned> f(5); + f(0) = 0; + f(1) = 1; + f(2) = 4; + f(3) = 3; + f(4) = 4; - debug::println(ima); - std::cout << std::endl; + // { {1, 0, 0, 0}, + // {0, 0, 2, 0}, + // {3, 0, 0, 0}, + // {0, 0, 2, 0} }; + lbl.relabel(f); - fun::v2v::projection<point2d, 0> f; - mln_VAR( ima_, unproject(ima, make::box2d(3, 3), f) ); - debug::println(ima_); + mln_assertion(lbl.bbox(1) == make::box2d(0, 0, 0,0)); + mln_assertion(lbl.mass_center(1) == point2d(0,0)); - ima_(point2d(1,1)) = 9; - debug::println(ima_); + mln_assertion(lbl.bbox(2) == make::box2d(1, 2, 3,2)); + mln_assertion(lbl.mass_center(2) == point2d(2,2)); - debug::println(ima); + mln_assertion(lbl.bbox(3) == make::box2d(2, 0, 2,0)); + mln_assertion(lbl.mass_center(3) == point2d(2,0)); } -- 1.5.6.5
participants (1)
-
Guillaume Lazzara