$extrastylesheet
Olena  User documentation 2.1
An Image Processing Platform
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
dilation-lena-bench-macros.hh
1 // Copyright (C) 2011 EPITA Research and Development Laboratory (LRDE)
2 //
3 // This file is part of Olena.
4 //
5 // Olena is free software: you can redistribute it and/or modify it under
6 // the terms of the GNU General Public License as published by the Free
7 // Software Foundation, version 2 of the License.
8 //
9 // Olena is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with Olena. If not, see <http://www.gnu.org/licenses/>.
16 //
17 // As a special exception, you may use this file as part of a free
18 // software project without restriction. Specifically, if other files
19 // instantiate templates or use macros or inline functions from this
20 // file, or you compile this file and link it with other files to produce
21 // an executable, this file does not by itself cause the resulting
22 // executable to be covered by the GNU General Public License. This
23 // exception does not however invalidate any other reasons why the
24 // executable file might be covered by the GNU General Public License.
25 
26 #ifndef APPS_BENCH_DILATION_LENA_MACROS_HH
27 # define APPS_BENCH_DILATION_LENA_MACROS_HH
28 
29 #include <cstdlib>
30 
31 #include <iostream>
32 #include <iomanip>
33 #include <string>
34 
35 #include "apps/bench/dilation-lena.hh"
36 
37 
38 #define DILATION_WITH_BUILTIN_WINDOW(Namespace) \
39  do \
40  { \
41  using namespace mln; \
42  using value::int_u8; \
43  \
44  if (argc != 2) \
45  usage(argv[0]); \
46  \
47  std::string filename = argv[1]; \
48  \
49  border::thickness = 1; \
50  image2d<int_u8> lena; \
51  io::pgm::load(lena, filename); \
52  util::timer t; \
53  \
54  image2d<int_u8> d = lena; \
55  t.start(); \
56  for (unsigned i = 0; i < 10; ++i) \
57  d = Namespace::dilation(d); \
58  t.stop(); \
59  \
60  /* Fix the output format for floats. */ \
61  std::cout << std::fixed << std::setprecision(4); \
62  /* Display the elapsed time. */ \
63  std::cout << t.read() << std::endl; \
64  } \
65  while (0)
66 
67 #define DILATION(Namespace, Win) \
68  do \
69  { \
70  using namespace mln; \
71  using value::int_u8; \
72  \
73  if (argc != 2) \
74  usage(argv[0]); \
75  \
76  std::string filename = argv[1]; \
77  \
78  border::thickness = 1; \
79  image2d<int_u8> lena; \
80  io::pgm::load(lena, filename); \
81  util::timer t; \
82  \
83  image2d<int_u8> d = lena; \
84  t.start(); \
85  for (unsigned i = 0; i < 10; ++i) \
86  d = Namespace::dilation(d, Win); \
87  t.stop(); \
88  \
89  /* Fix the output format for floats. */ \
90  std::cout << std::fixed << std::setprecision(4); \
91  /* Display the elapsed time. */ \
92  std::cout << t.read() << std::endl; \
93  } \
94  while (0)
95 
96 #endif // ! APPS_BENCH_DILATION_LENA_MACROS_HH