---
milena/apps/bench/Makefile.am | 31 +++++-
.../bench/dilation-lena-bench-fast.cc} | 22 ++--
.../bench/dilation-lena-bench-fast_static.cc} | 50 +++-----
.../bench/dilation-lena-bench-gen.cc} | 22 ++--
milena/apps/bench/dilation-lena-bench-macros.hh | 96 +++++++++++++++
.../bench/dilation-lena-bench-nongen.cc} | 22 ++--
.../bench/dilation-lena-bench-nongen_2ptr.cc} | 22 ++--
milena/apps/bench/dilation-lena-bench.cc | 127 --------------------
milena/apps/bench/test-dilation-lena-bench.in | 23 ++++
9 files changed, 211 insertions(+), 204 deletions(-)
copy milena/{sandbox/lazzara/igr/gui/src/main.cc => apps/bench/dilation-lena-bench-fast.cc} (80%)
copy milena/{tests/core/site_set/p_transformed.cc => apps/bench/dilation-lena-bench-fast_static.cc} (64%)
copy milena/{sandbox/lazzara/igr/gui/src/main.cc => apps/bench/dilation-lena-bench-gen.cc} (80%)
create mode 100644 milena/apps/bench/dilation-lena-bench-macros.hh
copy milena/{sandbox/lazzara/igr/gui/src/main.cc => apps/bench/dilation-lena-bench-nongen.cc} (79%)
copy milena/{sandbox/lazzara/igr/gui/src/main.cc => apps/bench/dilation-lena-bench-nongen_2ptr.cc} (79%)
delete mode 100644 milena/apps/bench/dilation-lena-bench.cc
create mode 100644 milena/apps/bench/test-dilation-lena-bench.in
diff --git a/milena/apps/bench/Makefile.am b/milena/apps/bench/Makefile.am
index 64bfc18..d2391c1 100644
--- a/milena/apps/bench/Makefile.am
+++ b/milena/apps/bench/Makefile.am
@@ -23,7 +23,11 @@ EXTRA_DIST = lena1024.pgm lena2048.pgm
noinst_PROGRAMS = \
dilation-lena \
- dilation-lena-bench \
+ dilation-lena-bench-nongen \
+ dilation-lena-bench-nongen_2ptr \
+ dilation-lena-bench-gen \
+ dilation-lena-bench-fast \
+ dilation-lena-bench-fast_static \
dilation-lena-table \
gradient-lena \
gradient-spe-lena
@@ -37,10 +41,14 @@ EXTRA_DIST += \
static_window.hh \
trait.hh
-noinst_HEADERS = dilation-lena.hh
+noinst_HEADERS = dilation-lena.hh dilation-lena-bench-macros.hh
dilation_lena_SOURCES = dilation-lena.cc
-dilation_lena_bench_SOURCES = dilation-lena-bench.cc
+dilation_lena_bench_nongen_SOURCES = dilation-lena-bench-nongen.cc
+dilation_lena_bench_nongen_2ptr_SOURCES = dilation-lena-bench-nongen_2ptr.cc
+dilation_lena_bench_gen_SOURCES = dilation-lena-bench-gen.cc
+dilation_lena_bench_fast_SOURCES = dilation-lena-bench-fast.cc
+dilation_lena_bench_fast_static_SOURCES = dilation-lena-bench-fast_static.cc
dilation_lena_table_SOURCES = dilation-lena-table.cc
gradient_lena_SOURCES = gradient-lena.cc
gradient_spe_lena_SOURCES = gradient-spe-lena.cc
@@ -99,3 +107,20 @@ MOSTLYCLEANFILES = \
gradient-spe-lena-out-2.pgm \
gradient-spe-lena-out-3.pgm \
gradient-spe-lena-out-4.pgm
+
+# Use Make to generate tests instead of `configure', as advised by
+# Autoconf's manual (see section ``Installation Directory
+# Variables'').
+edit = sed -e 's|@top_srcdir[@]|$(top_srcdir)|g' \
+ -e 's|@srcdir[@]|$(srcdir)|g'
+EXTRA_DIST += test-dilation-lena-bench.in
+test-dilation-lena-bench: test-dilation-lena-bench.in Makefile
+ rm -f $@ $@.tmp
+ srcdir=''; \
+ test -f ./$< || srcdir=$(srcdir)/; \
+ $(edit) $${srcdir}$< >>$@.tmp
+ chmod a-w,a+x $@.tmp
+ mv $@.tmp $@
+CLEANFILES = test-dilation-lena-bench
+
+TESTS = test-dilation-lena-bench
diff --git a/milena/sandbox/lazzara/igr/gui/src/main.cc b/milena/apps/bench/dilation-lena-bench-fast.cc
similarity index 80%
copy from milena/sandbox/lazzara/igr/gui/src/main.cc
copy to milena/apps/bench/dilation-lena-bench-fast.cc
index cbb4ec1..915c0c7 100644
--- a/milena/sandbox/lazzara/igr/gui/src/main.cc
+++ b/milena/apps/bench/dilation-lena-bench-fast.cc
@@ -1,4 +1,4 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2011 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -23,17 +23,17 @@
// exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
-#include <QApplication>
-#include <QtGui>
+#include "apps/bench/dilation-lena-bench-macros.hh"
-#include <src/main_window.hh>
-
-int main(int argc, char *argv[])
+void
+usage(const std::string& program)
{
- QApplication app(argc, argv);
-
- mln::demo::main_window win;
+ std::cerr << program << " input.pgm" << std::endl;
+ std::exit(1);
+}
- win.show();
- return app.exec();
+int
+main(int argc, char* argv[])
+{
+ DILATION(fast, win_c4p());
}
diff --git a/milena/tests/core/site_set/p_transformed.cc b/milena/apps/bench/dilation-lena-bench-fast_static.cc
similarity index 64%
copy from milena/tests/core/site_set/p_transformed.cc
copy to milena/apps/bench/dilation-lena-bench-fast_static.cc
index 6541614..68b3e80 100644
--- a/milena/tests/core/site_set/p_transformed.cc
+++ b/milena/apps/bench/dilation-lena-bench-fast_static.cc
@@ -1,4 +1,4 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2011 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -23,37 +23,27 @@
// exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
-#include <mln/core/alias/box2d.hh>
-#include <mln/core/site_set/p_transformed.hh>
-#include <mln/geom/bbox.hh>
+#include "apps/bench/dilation-lena-bench-macros.hh"
-
-
-
-struct wrap : mln::Function_v2v< wrap >
+void
+usage(const std::string& program)
{
- typedef mln::point2d result;
- typedef mln::point2d argument;
-
- result operator()(const result& p) const
- {
- return result(p.row() + 5, p.col() + 1);
- }
-
- result inverse(const result& p) const
- {
- return result(p.row() - 5, p.col() - 1);
- }
-};
-
+ std::cerr << program << " input.pgm" << std::endl;
+ std::exit(1);
+}
-int main()
+int
+main(int argc, char* argv[])
{
- using namespace mln;
-
- box2d b(2, 2);
- p_transformed<box2d,wrap> s(b, wrap());
- box2d b_ = geom::bbox(s);
-
- mln_assertion(b_.pmin() == point2d(5,1));
+ // Static windows and qixters.
+ const unsigned n = 5;
+ mln::dpoint2d dps[n] = { mln::dpoint2d( 0, -1),
+ mln::dpoint2d(-1, 0),
+ mln::dpoint2d( 0, 0),
+ mln::dpoint2d(+1, 0),
+ mln::dpoint2d( 0, +1) };
+ mln::util::static_array<mln::dpoint2d, n> sa(dps, dps + n);
+ mln::static_window<mln::dpoint2d, n> static_win_c4p(sa);
+
+ DILATION(fast_static, static_win_c4p);
}
diff --git a/milena/sandbox/lazzara/igr/gui/src/main.cc b/milena/apps/bench/dilation-lena-bench-gen.cc
similarity index 80%
copy from milena/sandbox/lazzara/igr/gui/src/main.cc
copy to milena/apps/bench/dilation-lena-bench-gen.cc
index cbb4ec1..d477847 100644
--- a/milena/sandbox/lazzara/igr/gui/src/main.cc
+++ b/milena/apps/bench/dilation-lena-bench-gen.cc
@@ -1,4 +1,4 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2011 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -23,17 +23,17 @@
// exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
-#include <QApplication>
-#include <QtGui>
+#include "apps/bench/dilation-lena-bench-macros.hh"
-#include <src/main_window.hh>
-
-int main(int argc, char *argv[])
+void
+usage(const std::string& program)
{
- QApplication app(argc, argv);
-
- mln::demo::main_window win;
+ std::cerr << program << " input.pgm" << std::endl;
+ std::exit(1);
+}
- win.show();
- return app.exec();
+int
+main(int argc, char* argv[])
+{
+ DILATION(gen, win_c4p());
}
diff --git a/milena/apps/bench/dilation-lena-bench-macros.hh b/milena/apps/bench/dilation-lena-bench-macros.hh
new file mode 100644
index 0000000..58deaad
--- /dev/null
+++ b/milena/apps/bench/dilation-lena-bench-macros.hh
@@ -0,0 +1,96 @@
+// Copyright (C) 2011 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of Olena.
+//
+// Olena is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation, version 2 of the License.
+//
+// Olena 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 Olena. If not, see <http://www.gnu.org/licenses/>.
+//
+// As a special exception, you may use this file as part of a free
+// software project 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 APPS_BENCH_DILATION_LENA_MACROS_HH
+# define APPS_BENCH_DILATION_LENA_MACROS_HH
+
+#include <cstdlib>
+
+#include <iostream>
+#include <iomanip>
+#include <string>
+
+#include "apps/bench/dilation-lena.hh"
+
+
+#define DILATION_WITH_BUILTIN_WINDOW(Namespace) \
+ do \
+ { \
+ using namespace mln; \
+ using value::int_u8; \
+ \
+ if (argc != 2) \
+ usage(argv[0]); \
+ \
+ std::string filename = argv[1]; \
+ \
+ border::thickness = 1; \
+ image2d<int_u8> lena; \
+ io::pgm::load(lena, filename); \
+ util::timer t; \
+ \
+ image2d<int_u8> d = lena; \
+ t.start(); \
+ for (unsigned i = 0; i < 10; ++i) \
+ d = Namespace::dilation(d); \
+ t.stop(); \
+ \
+ /* Fix the output format for floats. */ \
+ std::cout << std::fixed << std::setprecision(4); \
+ /* Display the elapsed time. */ \
+ std::cout << t.read() << std::endl; \
+ } \
+ while (0)
+
+#define DILATION(Namespace, Win) \
+ do \
+ { \
+ using namespace mln; \
+ using value::int_u8; \
+ \
+ if (argc != 2) \
+ usage(argv[0]); \
+ \
+ std::string filename = argv[1]; \
+ \
+ border::thickness = 1; \
+ image2d<int_u8> lena; \
+ io::pgm::load(lena, filename); \
+ util::timer t; \
+ \
+ image2d<int_u8> d = lena; \
+ t.start(); \
+ for (unsigned i = 0; i < 10; ++i) \
+ d = Namespace::dilation(d, Win); \
+ t.stop(); \
+ \
+ /* Fix the output format for floats. */ \
+ std::cout << std::fixed << std::setprecision(4); \
+ /* Display the elapsed time. */ \
+ std::cout << t.read() << std::endl; \
+ } \
+ while (0)
+
+#endif // ! APPS_BENCH_DILATION_LENA_MACROS_HH
diff --git a/milena/sandbox/lazzara/igr/gui/src/main.cc b/milena/apps/bench/dilation-lena-bench-nongen.cc
similarity index 79%
copy from milena/sandbox/lazzara/igr/gui/src/main.cc
copy to milena/apps/bench/dilation-lena-bench-nongen.cc
index cbb4ec1..00a0f05 100644
--- a/milena/sandbox/lazzara/igr/gui/src/main.cc
+++ b/milena/apps/bench/dilation-lena-bench-nongen.cc
@@ -1,4 +1,4 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2011 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -23,17 +23,17 @@
// exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
-#include <QApplication>
-#include <QtGui>
+#include "apps/bench/dilation-lena-bench-macros.hh"
-#include <src/main_window.hh>
-
-int main(int argc, char *argv[])
+void
+usage(const std::string& program)
{
- QApplication app(argc, argv);
-
- mln::demo::main_window win;
+ std::cerr << program << " input.pgm" << std::endl;
+ std::exit(1);
+}
- win.show();
- return app.exec();
+int
+main(int argc, char* argv[])
+{
+ DILATION_WITH_BUILTIN_WINDOW(nongen);
}
diff --git a/milena/sandbox/lazzara/igr/gui/src/main.cc b/milena/apps/bench/dilation-lena-bench-nongen_2ptr.cc
similarity index 79%
copy from milena/sandbox/lazzara/igr/gui/src/main.cc
copy to milena/apps/bench/dilation-lena-bench-nongen_2ptr.cc
index cbb4ec1..60dbdeb 100644
--- a/milena/sandbox/lazzara/igr/gui/src/main.cc
+++ b/milena/apps/bench/dilation-lena-bench-nongen_2ptr.cc
@@ -1,4 +1,4 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2011 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -23,17 +23,17 @@
// exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
-#include <QApplication>
-#include <QtGui>
+#include "apps/bench/dilation-lena-bench-macros.hh"
-#include <src/main_window.hh>
-
-int main(int argc, char *argv[])
+void
+usage(const std::string& program)
{
- QApplication app(argc, argv);
-
- mln::demo::main_window win;
+ std::cerr << program << " input.pgm" << std::endl;
+ std::exit(1);
+}
- win.show();
- return app.exec();
+int
+main(int argc, char* argv[])
+{
+ DILATION_WITH_BUILTIN_WINDOW(nongen_2ptr);
}
diff --git a/milena/apps/bench/dilation-lena-bench.cc b/milena/apps/bench/dilation-lena-bench.cc
deleted file mode 100644
index ce4cee0..0000000
--- a/milena/apps/bench/dilation-lena-bench.cc
+++ /dev/null
@@ -1,127 +0,0 @@
-// Copyright (C) 2011 EPITA Research and Development Laboratory (LRDE)
-//
-// This file is part of Olena.
-//
-// Olena is free software: you can redistribute it and/or modify it under
-// the terms of the GNU General Public License as published by the Free
-// Software Foundation, version 2 of the License.
-//
-// Olena 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 Olena. If not, see <http://www.gnu.org/licenses/>.
-//
-// As a special exception, you may use this file as part of a free
-// software project 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.
-
-#include <cstdlib>
-
-#include <iostream>
-#include <iomanip>
-#include <string>
-
-#include "apps/bench/dilation-lena.hh"
-
-
-namespace tag
-{
- enum dilation
- {
- nongen = 1,
- nongen_2ptr = 2,
- gen = 3,
- fast = 4,
- fast_static = 5
- };
-}
-
-void
-usage(const std::string& program)
-{
- std::cerr << program << " implementation input.pgm\n\n" <<
- " were implementation is\n"
- " 1 : nongen\n"
- " 2 : nongen_2ptr \n"
- " 3 : gen\n"
- " 4 : fast\n"
- " 5 : fast_static\n";
- std::exit(1);
-}
-
-
-#define DILATION_WITH_BUILTIN_WINDOW(Namespace) \
- do \
- { \
- image2d<int_u8> d = lena; \
- t.start(); \
- for (unsigned i = 0; i < 10; ++i) \
- d = Namespace::dilation(d); \
- t.stop(); \
- } \
- while (0)
-
-#define DILATION(Namespace, Win) \
- do \
- { \
- image2d<int_u8> d = lena; \
- t.start(); \
- for (unsigned i = 0; i < 10; ++i) \
- d = Namespace::dilation(d, Win); \
- t.stop(); \
- } \
- while (0)
-
-
-int
-main(int argc, char* argv[])
-{
- using namespace mln;
- using value::int_u8;
-
- if (argc != 3)
- usage(argv[0]);
-
- int method = atoi(argv[1]);
- std::string filename = argv[2];
-
- border::thickness = 1;
- image2d<int_u8> lena;
- io::pgm::load(lena, filename);
- util::timer t;
-
- // Static windows and qixters.
- const unsigned n = 5;
- mln::dpoint2d dps[n] = { mln::dpoint2d( 0, -1),
- mln::dpoint2d(-1, 0),
- mln::dpoint2d( 0, 0),
- mln::dpoint2d(+1, 0),
- mln::dpoint2d( 0, +1) };
- mln::util::static_array<mln::dpoint2d, n> sa(dps, dps + n);
- mln::static_window<mln::dpoint2d, n> static_win_c4p(sa);
-
- switch (method)
- {
- case ::tag::nongen: DILATION_WITH_BUILTIN_WINDOW(nongen); break;
- case ::tag::nongen_2ptr: DILATION_WITH_BUILTIN_WINDOW(nongen_2ptr); break;
- case ::tag::gen: DILATION(gen, win_c4p()); break;
- case ::tag::fast: DILATION(fast, win_c4p()); break;
- case ::tag::fast_static: DILATION(fast_static, static_win_c4p); break;
-
- default:
- usage(argv[0]);
- }
-
- // Fix the output format for floats.
- std::cout << std::fixed << std::setprecision(4);
- // Display the elapsed time.
- std::cout << t.read() << std::endl;
-}
diff --git a/milena/apps/bench/test-dilation-lena-bench.in b/milena/apps/bench/test-dilation-lena-bench.in
new file mode 100644
index 0000000..6eec79b
--- /dev/null
+++ b/milena/apps/bench/test-dilation-lena-bench.in
@@ -0,0 +1,23 @@
+#! /bin/sh
+
+./dilation-lena-bench-nongen @top_srcdir@/milena/img/lena.pgm
+./dilation-lena-bench-nongen_2ptr @top_srcdir@/milena/img/lena.pgm
+./dilation-lena-bench-gen @top_srcdir@/milena/img/lena.pgm
+./dilation-lena-bench-fast @top_srcdir@/milena/img/lena.pgm
+./dilation-lena-bench-fast_static @top_srcdir@/milena/img/lena.pgm
+
+echo
+
+./dilation-lena-bench-nongen @srcdir@/lena1024.pgm
+./dilation-lena-bench-nongen_2ptr @srcdir@/lena1024.pgm
+./dilation-lena-bench-gen @srcdir@/lena1024.pgm
+./dilation-lena-bench-fast @srcdir@/lena1024.pgm
+./dilation-lena-bench-fast_static @srcdir@/lena1024.pgm
+
+echo
+
+./dilation-lena-bench-nongen @srcdir@/lena2048.pgm
+./dilation-lena-bench-nongen_2ptr @srcdir@/lena2048.pgm
+./dilation-lena-bench-gen @srcdir@/lena2048.pgm
+./dilation-lena-bench-fast @srcdir@/lena2048.pgm
+./dilation-lena-bench-fast_static @srcdir@/lena2048.pgm
--
1.7.2.5
---
milena/apps/bench/Makefile.am | 8 ++-
milena/apps/bench/dilation-lena-bench.cc | 127 ++++++++++++++++++++++++++++++
2 files changed, 133 insertions(+), 2 deletions(-)
create mode 100644 milena/apps/bench/dilation-lena-bench.cc
diff --git a/milena/apps/bench/Makefile.am b/milena/apps/bench/Makefile.am
index b5919ce..64bfc18 100644
--- a/milena/apps/bench/Makefile.am
+++ b/milena/apps/bench/Makefile.am
@@ -23,6 +23,7 @@ EXTRA_DIST = lena1024.pgm lena2048.pgm
noinst_PROGRAMS = \
dilation-lena \
+ dilation-lena-bench \
dilation-lena-table \
gradient-lena \
gradient-spe-lena
@@ -36,8 +37,11 @@ EXTRA_DIST += \
static_window.hh \
trait.hh
-dilation_lena_SOURCES = dilation-lena.cc dilation-lena.hh
-dilation_lena_table_SOURCES = dilation-lena-table.cc dilation-lena.hh
+noinst_HEADERS = dilation-lena.hh
+
+dilation_lena_SOURCES = dilation-lena.cc
+dilation_lena_bench_SOURCES = dilation-lena-bench.cc
+dilation_lena_table_SOURCES = dilation-lena-table.cc
gradient_lena_SOURCES = gradient-lena.cc
gradient_spe_lena_SOURCES = gradient-spe-lena.cc
diff --git a/milena/apps/bench/dilation-lena-bench.cc b/milena/apps/bench/dilation-lena-bench.cc
new file mode 100644
index 0000000..ce4cee0
--- /dev/null
+++ b/milena/apps/bench/dilation-lena-bench.cc
@@ -0,0 +1,127 @@
+// Copyright (C) 2011 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of Olena.
+//
+// Olena is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation, version 2 of the License.
+//
+// Olena 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 Olena. If not, see <http://www.gnu.org/licenses/>.
+//
+// As a special exception, you may use this file as part of a free
+// software project 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.
+
+#include <cstdlib>
+
+#include <iostream>
+#include <iomanip>
+#include <string>
+
+#include "apps/bench/dilation-lena.hh"
+
+
+namespace tag
+{
+ enum dilation
+ {
+ nongen = 1,
+ nongen_2ptr = 2,
+ gen = 3,
+ fast = 4,
+ fast_static = 5
+ };
+}
+
+void
+usage(const std::string& program)
+{
+ std::cerr << program << " implementation input.pgm\n\n" <<
+ " were implementation is\n"
+ " 1 : nongen\n"
+ " 2 : nongen_2ptr \n"
+ " 3 : gen\n"
+ " 4 : fast\n"
+ " 5 : fast_static\n";
+ std::exit(1);
+}
+
+
+#define DILATION_WITH_BUILTIN_WINDOW(Namespace) \
+ do \
+ { \
+ image2d<int_u8> d = lena; \
+ t.start(); \
+ for (unsigned i = 0; i < 10; ++i) \
+ d = Namespace::dilation(d); \
+ t.stop(); \
+ } \
+ while (0)
+
+#define DILATION(Namespace, Win) \
+ do \
+ { \
+ image2d<int_u8> d = lena; \
+ t.start(); \
+ for (unsigned i = 0; i < 10; ++i) \
+ d = Namespace::dilation(d, Win); \
+ t.stop(); \
+ } \
+ while (0)
+
+
+int
+main(int argc, char* argv[])
+{
+ using namespace mln;
+ using value::int_u8;
+
+ if (argc != 3)
+ usage(argv[0]);
+
+ int method = atoi(argv[1]);
+ std::string filename = argv[2];
+
+ border::thickness = 1;
+ image2d<int_u8> lena;
+ io::pgm::load(lena, filename);
+ util::timer t;
+
+ // Static windows and qixters.
+ const unsigned n = 5;
+ mln::dpoint2d dps[n] = { mln::dpoint2d( 0, -1),
+ mln::dpoint2d(-1, 0),
+ mln::dpoint2d( 0, 0),
+ mln::dpoint2d(+1, 0),
+ mln::dpoint2d( 0, +1) };
+ mln::util::static_array<mln::dpoint2d, n> sa(dps, dps + n);
+ mln::static_window<mln::dpoint2d, n> static_win_c4p(sa);
+
+ switch (method)
+ {
+ case ::tag::nongen: DILATION_WITH_BUILTIN_WINDOW(nongen); break;
+ case ::tag::nongen_2ptr: DILATION_WITH_BUILTIN_WINDOW(nongen_2ptr); break;
+ case ::tag::gen: DILATION(gen, win_c4p()); break;
+ case ::tag::fast: DILATION(fast, win_c4p()); break;
+ case ::tag::fast_static: DILATION(fast_static, static_win_c4p); break;
+
+ default:
+ usage(argv[0]);
+ }
+
+ // Fix the output format for floats.
+ std::cout << std::fixed << std::setprecision(4);
+ // Display the elapsed time.
+ std::cout << t.read() << std::endl;
+}
--
1.7.2.5