Commit ccb4093b authored by Roland Levillain's avatar Roland Levillain
Browse files

apps/bench: More comparisons on dilation (variants without accu).

	* apps/bench/dilation-lena.cc
	(fast_noaccu::dilation, faster_noaccu::dilation): New functions.
	Exercise them...
	(main): ...here.
	* apps/bench/Makefile.am (MOSTLYCLEANFILES): Update.
parent 1681fb5f
2010-12-14 Roland Levillain <roland@lrde.epita.fr>
apps/bench: More comparisons on dilation (variants without accu).
* apps/bench/dilation-lena.cc
(fast_noaccu::dilation, faster_noaccu::dilation): New functions.
Exercise them...
(main): ...here.
* apps/bench/Makefile.am (MOSTLYCLEANFILES): Update.
2010-12-14 Roland Levillain <roland@lrde.epita.fr>
 
apps/bench: More comparisons on dilation (static windows and qixters).
......@@ -34,7 +34,9 @@ MOSTLYCLEANFILES = \
dilation-lena-out-spe.pgm \
dilation-lena-out-gen.pgm \
dilation-lena-out-fast.pgm \
dilation-lena-out-fast_noaccu.pgm \
dilation-lena-out-faster.pgm \
dilation-lena-out-faster_noaccu.pgm \
dilation-lena-out-fast_static.pgm \
gradient-lena-out.pgm \
gradient-spe-lena-out-0.pgm \
......
......@@ -111,6 +111,33 @@ namespace fast
}
}
namespace fast_noaccu
{
using namespace mln;
template <typename I, typename W>
mln_concrete(I) dilation(const I& input, const W& win)
{
typedef mln_concrete(I) O;
O output; initialize(output, input); // Initialize output.
mln_pixter(const I) pi(input); // Iterator on the pixels of `input'.
mln_pixter(O) po(output); // Iterator on the pixels of `output'.
mln_qixter(const I, W) q(pi, win); // Iterator on the neighbors of `p' w.r.t. `win'.
for_all_2(pi, po)
{
// FIXME: Cheat: replace the accu::supremum by a maximum.
mln_value(I) sup = mln_min(mln_value(I));
for_all(q)
if (q.val() > sup)
sup = q.val();
po.val() = sup;
}
return output;
}
}
namespace faster
{
using namespace mln;
......@@ -136,6 +163,32 @@ namespace faster
}
}
namespace faster_noaccu
{
using namespace mln;
template <typename I, typename W>
mln_concrete(I) dilation(const I& input, const W& win)
{
typedef mln_concrete(I) O;
O output; initialize(output, input); // Initialize output.
mln_pixter(const I) p(input); // Iterator on the pixels of `input'.
mln_qixter(const I, W) q(p, win); // Iterator on the neighbors of `p' w.r.t. `win'.
for_all(p)
{
// FIXME: Cheat: replace the accu::supremum by a maximum.
mln_value(I) sup = mln_min(mln_value(I));
for_all(q)
if (q.val() > sup)
sup = q.val();
*(output.buffer() + p.offset()) = sup;
}
return output;
}
}
namespace fast_static
{
using namespace mln;
......@@ -194,12 +247,23 @@ int main()
std::cout << t.read() << std::endl;
io::pgm::save(d, "dilation-lena-out-fast.pgm");
t.start();
d = fast_noaccu::dilation(lena, win_c4p());
t.stop();
std::cout << t.read() << std::endl;
io::pgm::save(d, "dilation-lena-out-fast_noaccu.pgm");
t.start();
d = faster::dilation(lena, win_c4p());
t.stop();
std::cout << t.read() << std::endl;
io::pgm::save(d, "dilation-lena-out-faster.pgm");
t.start();
d = faster_noaccu::dilation(lena, win_c4p());
t.stop();
std::cout << t.read() << std::endl;
io::pgm::save(d, "dilation-lena-out-faster_noaccu.pgm");
const unsigned n = 5;
mln::dpoint2d dps[n] = { mln::dpoint2d( 0, -1),
......
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