Olena-patches
Threads by month
- ----- 2025 -----
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
October 2011
- 5 participants
- 78 discussions

last-svn-commit-548-g4762c47 WIP: More comparisons (2- and 1-pointer based non-gen impl.)
by Roland Levillain 14 Oct '11
by Roland Levillain 14 Oct '11
14 Oct '11
---
milena/apps/bench/Makefile.am | 15 +++-
milena/apps/bench/dilation-lena.cc | 119 +++++++++++++++++++++++++--
milena/apps/bench/static_dpoints_pixter.hh | 102 ++++++++++++-----------
milena/apps/bench/static_window.hh | 4 +-
milena/apps/bench/trait.hh | 99 +++++++++++++++++++++++
5 files changed, 277 insertions(+), 62 deletions(-)
create mode 100644 milena/apps/bench/trait.hh
diff --git a/milena/apps/bench/Makefile.am b/milena/apps/bench/Makefile.am
index adc0cdf..266b71b 100644
--- a/milena/apps/bench/Makefile.am
+++ b/milena/apps/bench/Makefile.am
@@ -1,4 +1,4 @@
-# Copyright (C) 2010 EPITA Research and Development Laboratory (LRDE).
+# Copyright (C) 2010, 2011 EPITA Research and Development Laboratory (LRDE).
#
# This file is part of Olena.
#
@@ -29,7 +29,12 @@ noinst_PROGRAMS = \
EXTRA_DIST += \
and_not.hh \
- minus.hh
+ minus.hh \
+ \
+ static_array.hh \
+ static_dpoints_pixter.hh \
+ static_window.hh \
+ trait.hh
dilation_lena_SOURCES = dilation-lena.cc
gradient_lena_SOURCES = gradient-lena.cc
@@ -37,6 +42,8 @@ gradient_spe_lena_SOURCES = gradient-spe-lena.cc
MOSTLYCLEANFILES = \
dilation-lena-out-512-nongen.pgm \
+ dilation-lena-out-512-nongen_2ptr.pgm \
+ dilation-lena-out-512-nongen_1ptr.pgm \
dilation-lena-out-512-gen.pgm \
dilation-lena-out-512-fast.pgm \
dilation-lena-out-512-fast_noaccu.pgm \
@@ -46,6 +53,8 @@ MOSTLYCLEANFILES = \
dilation-lena-out-512-faster_static.pgm \
\
dilation-lena-out-1024-nongen.pgm \
+ dilation-lena-out-1024-nongen_2ptr.pgm \
+ dilation-lena-out-1024-nongen_1ptr.pgm \
dilation-lena-out-1024-gen.pgm \
dilation-lena-out-1024-fast.pgm \
dilation-lena-out-1024-fast_noaccu.pgm \
@@ -55,6 +64,8 @@ MOSTLYCLEANFILES = \
dilation-lena-out-1024-faster_static.pgm \
\
dilation-lena-out-2048-nongen.pgm \
+ dilation-lena-out-2048-nongen_2ptr.pgm \
+ dilation-lena-out-2048-nongen_1ptr.pgm \
dilation-lena-out-2048-gen.pgm \
dilation-lena-out-2048-fast.pgm \
dilation-lena-out-2048-fast_noaccu.pgm \
diff --git a/milena/apps/bench/dilation-lena.cc b/milena/apps/bench/dilation-lena.cc
index 69c82a7..e4996fb 100644
--- a/milena/apps/bench/dilation-lena.cc
+++ b/milena/apps/bench/dilation-lena.cc
@@ -1,4 +1,4 @@
-// Copyright (C) 2010 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2010, 2011 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -23,6 +23,8 @@
// exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
+#include <cstddef>
+
#include <iostream>
#include <mln/core/image/image2d.hh>
@@ -39,9 +41,12 @@
#include "apps/bench/static_window.hh"
#include "apps/bench/static_dpoints_pixter.hh"
+#include "apps/bench/trait.hh"
+
#include "apps/data.hh"
+
namespace nongen
{
typedef mln::image2d<mln::value::int_u8> image;
@@ -63,6 +68,99 @@ namespace nongen
}
}
+namespace nongen_2ptr
+{
+ typedef mln::image2d<mln::value::int_u8> image;
+
+ image dilation(const image& input)
+ {
+ typedef mln::value::int_u8 val_t;
+ // Offsets corresponding to a 4-c window on INPUT.
+ ptrdiff_t win_offset[4] = { &input.at_(-1, 0) - &input.at_(0, 0),
+ &input.at_(+1, 0) - &input.at_(0, 0),
+ &input.at_( 0, -1) - &input.at_(0, 0),
+ &input.at_( 0, +1) - &input.at_(0, 0) };
+
+ image output (input.nrows(), input.ncols()); // Initialize an output image.
+ for (unsigned int r = 0; r < input.nrows(); ++r) // Iterate on rows.
+ {
+ const val_t* pi = &input.at_(r, 0);
+ val_t* po = &output.at_(r, 0);
+ for (; pi < &input.at_(r, 0) + input.ncols(); ++pi, ++po)
+ {
+ unsigned char sup = *pi;
+ // (-1, 0) neighbor.
+ if (r != 0
+ && *(pi + win_offset[0]) > sup)
+ sup = *(pi + win_offset[0]);
+ // (+1, 0) neighbor.
+ if (r != input.nrows() - 1
+ && *(pi + win_offset[1]) > sup)
+ sup = *(pi + win_offset[1]);
+ // (0, -1) neighbor.
+ if (pi != &input.at_(r, 0)
+ && *(pi + win_offset[2]) > sup)
+ sup = *(pi + win_offset[2]);
+ // (0, +1) neighbor.
+ if (pi != &input.at_(r, 0) + input.ncols() - 1
+ && *(pi + win_offset[3]) > sup)
+ sup = *(pi + win_offset[3]);
+ *po = sup;
+ }
+ }
+ return output;
+ }
+}
+
+namespace nongen_1ptr
+{
+ typedef mln::image2d<mln::value::int_u8> image;
+
+ image dilation(const image& input)
+ {
+ typedef mln::value::int_u8 val_t;
+ // Offsets corresponding to a 4-c window on INPUT.
+ ptrdiff_t win_offset[4] = { &input.at_(-1, 0) - &input.at_(0, 0),
+ &input.at_(+1, 0) - &input.at_(0, 0),
+ &input.at_( 0, -1) - &input.at_(0, 0),
+ &input.at_( 0, +1) - &input.at_(0, 0) };
+
+ image output;
+ initialize(output, input);
+ // Offset between a the pixel located at the same position in
+ // INPUT and OUTPUT.
+ ptrdiff_t output_offset = &output.at_(0, 0) - &input.at_(0, 0);
+
+ for (unsigned int r = 0; r < input.nrows(); ++r) // Iterate on rows.
+ {
+ for (const val_t* pi = &input.at_(r, 0);
+ pi < &input.at_(r, 0) + input.ncols();
+ ++pi)
+ {
+ unsigned char sup = *pi;
+ // (-1, 0) neighbor.
+ if (r != 0
+ && *(pi + win_offset[0]) > sup)
+ sup = *(pi + win_offset[0]);
+ // (+1, 0) neighbor.
+ if (r != input.nrows() - 1
+ && *(pi + win_offset[1]) > sup)
+ sup = *(pi + win_offset[1]);
+ // (0, -1) neighbor.
+ if (pi != &input.at_(r, 0)
+ && *(pi + win_offset[2]) > sup)
+ sup = *(pi + win_offset[2]);
+ // (0, +1) neighbor.
+ if (pi != &input.at_(r, 0) + input.ncols() - 1
+ && *(pi + win_offset[3]) > sup)
+ sup = *(pi + win_offset[3]);
+ const_cast<val_t&>(*(pi + output_offset)) = sup;
+ }
+ }
+ return output;
+ }
+}
+
namespace gen
{
using namespace mln;
@@ -201,9 +299,8 @@ namespace fast_static
mln_pixter(const I) pi(input); // Iterator on the pixels of `input'.
mln_pixter(O) po(output); // Iterator on the pixels of `output'.
+ mln_static_qixter(const I, W) q(pi, win); // Iterator on the neighbors of `p' w.r.t. `win'.
- typedef mln::static_dpoints_fwd_pixter<const I, W::Size> mln_static_qixter;
- mln_static_qixter q(pi, win);
for_all_2(pi, po)
{
// FIXME: Cheat: replace the accu::supremum by a maximum.
@@ -227,9 +324,8 @@ namespace faster_static
O output; initialize(output, input); // Initialize output.
mln_pixter(const I) p(input); // Iterator on the pixels of `input'.
+ mln_static_qixter(const I, W) q(p, win); // Iterator on the neighbors of `p' w.r.t. `win'.
- typedef mln::static_dpoints_fwd_pixter<const I, W::Size> mln_static_qixter;
- mln_static_qixter q(p, win);
for_all(p)
{
// FIXME: Cheat: replace the accu::supremum by a maximum.
@@ -288,9 +384,13 @@ run(const std::string& filename, const std::string& length, unsigned niters)
std::string prefix = "dilation-lena-out";
std::cout << "== " << filename << std::endl;
- DILATION_WITH_BUILTIN_WINDOW(nongen, "nongen", "nongen\t\t");
+ DILATION_WITH_BUILTIN_WINDOW(nongen, "nongen", "nongen\t\t");
+ DILATION_WITH_BUILTIN_WINDOW(nongen_2ptr, "nongen_2ptr", "nongen_2ptr\t");
+ DILATION_WITH_BUILTIN_WINDOW(nongen_1ptr, "nongen_1ptr", "nongen_1ptr\t");
DILATION(gen, win_c4p(), "gen", "gen\t\t");
+ // FIXME: Introduce a new test case, gen_static, using a static window
+ // and static_qiters.
DILATION(fast, win_c4p(), "fast", "fast\t\t");
DILATION(fast_noaccu, win_c4p(), "fast_noaccu", "fast_noaccu\t");
DILATION(faster, win_c4p(), "faster", "faster\t\t");
@@ -315,7 +415,8 @@ run(const std::string& filename, const std::string& length, unsigned niters)
int
main ()
{
- run(MLN_IMG_DIR "/lena.pgm", "512", 10);
- run(MLN_APPS_DIR "/bench/lena1024.pgm", "1024", 10);
- run(MLN_APPS_DIR "/bench/lena2048.pgm", "2048", 10);
+ unsigned niters = 10;
+ run(MLN_IMG_DIR "/lena.pgm", "512", niters);
+ run(MLN_APPS_DIR "/bench/lena1024.pgm", "1024", niters);
+ run(MLN_APPS_DIR "/bench/lena2048.pgm", "2048", niters);
}
diff --git a/milena/apps/bench/static_dpoints_pixter.hh b/milena/apps/bench/static_dpoints_pixter.hh
index d7823ac..ffa4a81 100644
--- a/milena/apps/bench/static_dpoints_pixter.hh
+++ b/milena/apps/bench/static_dpoints_pixter.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2007, 2008, 2009, 2010 EPITA Research and Development
+// Copyright (C) 2007, 2008, 2009, 2010, 2011 EPITA Research and Development
// Laboratory (LRDE)
//
// This file is part of Olena.
@@ -50,19 +50,19 @@ namespace mln
{
/*----------------------------------.
- | static_dpoints_fwd_pixter<I, n>. |
+ | static_dpoints_fwd_pixter<I, W>. |
`----------------------------------*/
/// \brief A generic forward iterator on the pixels of a
/// dpoint-based window or neighborhood.
///
/// Parameter \c I is the image type.
- template <typename I, unsigned n>
+ template <typename I, typename W>
class static_dpoints_fwd_pixter
- : public Pixel_Iterator< static_dpoints_fwd_pixter<I, n> >,
- public internal::pixel_impl_< I, static_dpoints_fwd_pixter<I, n> >
+ : public Pixel_Iterator< static_dpoints_fwd_pixter<I, W> >,
+ public internal::pixel_impl_< I, static_dpoints_fwd_pixter<I, W> >
{
- typedef typename internal::pixel_impl_< I, static_dpoints_fwd_pixter<I, n> > super_;
+ typedef typename internal::pixel_impl_< I, static_dpoints_fwd_pixter<I, W> > super_;
public:
/// \brief Constructor (using an image).
@@ -111,6 +111,8 @@ namespace mln
void init_(const Dps& dps);
private:
+ enum { n = W::length };
+
/// \brief Offset of each delta-point.
///
/// offset_[0] is absolute, while other offsets are relative
@@ -133,19 +135,19 @@ namespace mln
/*----------------------------------.
- | static_dpoints_bkd_pixter<I, n>. |
+ | static_dpoints_bkd_pixter<I, W>. |
`----------------------------------*/
/// \brief A generic backward iterator on the pixels of a
/// dpoint-based window or neighborhood.
///
/// Parameter \c I is the image type.
- template <typename I, unsigned n>
+ template <typename I, typename W>
class static_dpoints_bkd_pixter
- : public Pixel_Iterator< static_dpoints_bkd_pixter<I, n> >,
- public internal::pixel_impl_< I, static_dpoints_bkd_pixter<I, n> >
+ : public Pixel_Iterator< static_dpoints_bkd_pixter<I, W> >,
+ public internal::pixel_impl_< I, static_dpoints_bkd_pixter<I, W> >
{
- typedef typename internal::pixel_impl_< I, static_dpoints_bkd_pixter<I, n> > super_;
+ typedef typename internal::pixel_impl_< I, static_dpoints_bkd_pixter<I, W> > super_;
public:
/// \brief Constructor (using an image).
@@ -194,6 +196,8 @@ namespace mln
void init_(const Dps& dps);
private:
+ enum { n = W::length };
+
/// \brief Offset of each delta-point.
///
/// offset_[dps.size() - 1] is absolute, while other offsets
@@ -219,13 +223,13 @@ namespace mln
#ifndef MLN_INCLUDE_ONLY
/*----------------------------------.
- | static_dpoints_fwd_pixter<I, n>. |
+ | static_dpoints_fwd_pixter<I, W>. |
`----------------------------------*/
- template <typename I, unsigned n>
+ template <typename I, typename W>
template <typename Dps, typename Pref>
inline
- static_dpoints_fwd_pixter<I, n>::static_dpoints_fwd_pixter(I& image,
+ static_dpoints_fwd_pixter<I, W>::static_dpoints_fwd_pixter(I& image,
const Dps& dps,
const Pref& p_ref)
: super_(image)
@@ -239,10 +243,10 @@ namespace mln
init_(dps);
}
- template <typename I, unsigned n>
+ template <typename I, typename W>
template <typename Dps, typename Pref>
inline
- static_dpoints_fwd_pixter<I, n>::static_dpoints_fwd_pixter(const Generalized_Pixel<Pref>& pxl_ref_,
+ static_dpoints_fwd_pixter<I, W>::static_dpoints_fwd_pixter(const Generalized_Pixel<Pref>& pxl_ref_,
const Dps& dps)
: super_(internal::force_exact<Pref>(pxl_ref_).ima())
{
@@ -254,10 +258,10 @@ namespace mln
init_(dps);
}
- template <typename I, unsigned n>
+ template <typename I, typename W>
inline
const mln_value(I)&
- static_dpoints_fwd_pixter<I, n>::center_val() const
+ static_dpoints_fwd_pixter<I, W>::center_val() const
{
mln_invariant(value_ref_ != 0 || p_ref_ != 0);
if (p_ref_)
@@ -266,11 +270,11 @@ namespace mln
return **value_ref_;
}
- template <typename I, unsigned n>
+ template <typename I, typename W>
template <typename Dps>
inline
void
- static_dpoints_fwd_pixter<I, n>::init_(const Dps& dps)
+ static_dpoints_fwd_pixter<I, W>::init_(const Dps& dps)
{
for (unsigned i = 0; i < dps.size(); ++i)
offset_[i] = this->image_.delta_index(dps.dp(i));
@@ -282,10 +286,10 @@ namespace mln
invalidate();
}
- template <typename I, unsigned n>
+ template <typename I, typename W>
inline
void
- static_dpoints_fwd_pixter<I, n>::update()
+ static_dpoints_fwd_pixter<I, W>::update()
{
if (is_valid())
{
@@ -296,50 +300,50 @@ namespace mln
}
}
- template <typename I, unsigned n>
+ template <typename I, typename W>
inline
void
- static_dpoints_fwd_pixter<I, n>::start()
+ static_dpoints_fwd_pixter<I, W>::start()
{
i_ = 0;
update();
}
- template <typename I, unsigned n>
+ template <typename I, typename W>
inline
void
- static_dpoints_fwd_pixter<I, n>::next_()
+ static_dpoints_fwd_pixter<I, W>::next_()
{
++i_;
if (is_valid())
this->value_ptr_ += offset_[i_];
}
- template <typename I, unsigned n>
+ template <typename I, typename W>
inline
bool
- static_dpoints_fwd_pixter<I, n>::is_valid() const
+ static_dpoints_fwd_pixter<I, W>::is_valid() const
{
return i_ < n;
}
- template <typename I, unsigned n>
+ template <typename I, typename W>
inline
void
- static_dpoints_fwd_pixter<I, n>::invalidate()
+ static_dpoints_fwd_pixter<I, W>::invalidate()
{
i_ = n;
}
/*----------------------------------.
- | static_dpoints_bkd_pixter<I, n>. |
+ | static_dpoints_bkd_pixter<I, W>. |
`----------------------------------*/
- template <typename I, unsigned n>
+ template <typename I, typename W>
template <typename Dps, typename Pref>
inline
- static_dpoints_bkd_pixter<I, n>::static_dpoints_bkd_pixter(I& image,
+ static_dpoints_bkd_pixter<I, W>::static_dpoints_bkd_pixter(I& image,
const Dps& dps,
const Pref& p_ref)
: super_(image)
@@ -350,10 +354,10 @@ namespace mln
init_(dps);
}
- template <typename I, unsigned n>
+ template <typename I, typename W>
template <typename Dps, typename Pref>
inline
- static_dpoints_bkd_pixter<I, n>::static_dpoints_bkd_pixter(const Generalized_Pixel<Pref>& pxl_ref_,
+ static_dpoints_bkd_pixter<I, W>::static_dpoints_bkd_pixter(const Generalized_Pixel<Pref>& pxl_ref_,
const Dps& dps)
: super_(internal::force_exact<Pref>(pxl_ref_).ima())
{
@@ -365,10 +369,10 @@ namespace mln
init_(dps);
}
- template <typename I, unsigned n>
+ template <typename I, typename W>
inline
const mln_value(I)&
- static_dpoints_bkd_pixter<I, n>::center_val() const
+ static_dpoints_bkd_pixter<I, W>::center_val() const
{
mln_invariant(value_ref_ != 0 || p_ref_ != 0);
if (p_ref_)
@@ -377,11 +381,11 @@ namespace mln
return **value_ref_;
}
- template <typename I, unsigned n>
+ template <typename I, typename W>
template <typename Dps>
inline
void
- static_dpoints_bkd_pixter<I, n>::init_(const Dps& dps)
+ static_dpoints_bkd_pixter<I, W>::init_(const Dps& dps)
{
for (unsigned i = 0; i < dps.size(); ++i)
offset_[i] = this->image_.delta_index(dps.dp(i));
@@ -393,10 +397,10 @@ namespace mln
invalidate();
}
- template <typename I, unsigned n>
+ template <typename I, typename W>
inline
void
- static_dpoints_bkd_pixter<I, n>::update()
+ static_dpoints_bkd_pixter<I, W>::update()
{
if (is_valid())
{
@@ -407,37 +411,37 @@ namespace mln
}
}
- template <typename I, unsigned n>
+ template <typename I, typename W>
inline
void
- static_dpoints_bkd_pixter<I, n>::start()
+ static_dpoints_bkd_pixter<I, W>::start()
{
i_ = 0;
update();
}
- template <typename I, unsigned n>
+ template <typename I, typename W>
inline
void
- static_dpoints_bkd_pixter<I, n>::next_()
+ static_dpoints_bkd_pixter<I, W>::next_()
{
++i_;
if (is_valid())
this->value_ptr_ += offset_[n - 1 - i_];
}
- template <typename I, unsigned n>
+ template <typename I, typename W>
inline
bool
- static_dpoints_bkd_pixter<I, n>::is_valid() const
+ static_dpoints_bkd_pixter<I, W>::is_valid() const
{
return i_ < n;
}
- template <typename I, unsigned n>
+ template <typename I, typename W>
inline
void
- static_dpoints_bkd_pixter<I, n>::invalidate()
+ static_dpoints_bkd_pixter<I, W>::invalidate()
{
i_ = n;
}
diff --git a/milena/apps/bench/static_window.hh b/milena/apps/bench/static_window.hh
index fe8f791..5a8ce21 100644
--- a/milena/apps/bench/static_window.hh
+++ b/milena/apps/bench/static_window.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2007, 2008, 2009, 2010 EPITA Research and Development
+// Copyright (C) 2007, 2008, 2009, 2010, 2011 EPITA Research and Development
// Laboratory (LRDE)
//
// This file is part of Olena.
@@ -90,7 +90,7 @@ namespace mln
{
public:
- enum { Size = n };
+ enum { length = n };
/// Regular window associated type.
typedef static_window<D, n> regular;
diff --git a/milena/apps/bench/trait.hh b/milena/apps/bench/trait.hh
new file mode 100644
index 0000000..e3e5004
--- /dev/null
+++ b/milena/apps/bench/trait.hh
@@ -0,0 +1,99 @@
+// 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_TRAITS_HH
+# define APPS_BENCH_TRAITS_HH
+
+# include <mln/core/image/image2d.hh>
+# include <mln/metal/none.hh>
+
+# include "apps/bench/static_dpoints_pixter.hh"
+
+
+// FIXME: Move this into mln/core/macro.hh.
+# define mln_static_fwd_qixter(I, W) typename mln::trait::static_fwd_qixter< I, W >::ret
+# define mln_static_fwd_qixter_(I, W) mln::trait::static_fwd_qixter< I, W >::ret
+
+# define mln_static_bkd_qixter(I, W) typename mln::trait::static_bkd_qixter< I, W >::ret
+# define mln_static_bkd_qixter_(I, W) mln::trait::static_bkd_qixter< I, W >::ret
+
+# define mln_static_qixter(I, W) mln_static_fwd_qixter(I, W)
+# define mln_static_qixter_(I, W) mln_static_fwd_qixter_(I, W)
+
+
+// FIXME: Move this into mln/trait/ (and mln/core/image/?)
+namespace mln
+{
+
+ namespace trait
+ {
+
+ // qixter
+
+ template <typename I, typename W>
+ struct static_fwd_qixter
+ {
+ typedef metal::none ret;
+ };
+
+ template <typename I, typename W>
+ struct static_bkd_qixter
+ {
+ typedef metal::none ret;
+ };
+
+
+ template <typename T, typename W>
+ struct static_fwd_qixter< image2d<T>, W >
+ {
+ typedef static_dpoints_fwd_pixter< image2d<T>, W > ret;
+ };
+
+ template <typename T, typename W>
+ struct static_fwd_qixter< const image2d<T>, W >
+ {
+ typedef static_dpoints_fwd_pixter< const image2d<T>, W > ret;
+ };
+
+ template <typename T, typename W>
+ struct static_bkd_qixter< image2d<T>, W >
+ {
+ typedef static_dpoints_bkd_pixter< image2d<T>, W > ret;
+ };
+
+ template <typename T, typename W>
+ struct static_bkd_qixter< const image2d<T>, W >
+ {
+ typedef static_dpoints_bkd_pixter< const image2d<T>, W > ret;
+ };
+
+ // FIXME: Also handle mln::image1d<T> and mln::image3d<T>.
+
+
+ } // end of namespace mln::trait
+
+} // end of namespace mln
+
+#endif // ! APPS_BENCH_TRAITS_HH
--
1.7.2.5
1
0

last-svn-commit-546-ga7f8a8c WIP: More comparisons on dilation (static window + single pixter).
by Roland Levillain 14 Oct '11
by Roland Levillain 14 Oct '11
14 Oct '11
---
milena/apps/bench/Makefile.am | 1 +
milena/apps/bench/dilation-lena.cc | 32 ++++++++++++++++++++++++++++++++
2 files changed, 33 insertions(+), 0 deletions(-)
diff --git a/milena/apps/bench/Makefile.am b/milena/apps/bench/Makefile.am
index f106b23..1dcb18e 100644
--- a/milena/apps/bench/Makefile.am
+++ b/milena/apps/bench/Makefile.am
@@ -43,6 +43,7 @@ MOSTLYCLEANFILES = \
dilation-lena-out-faster.pgm \
dilation-lena-out-faster_noaccu.pgm \
dilation-lena-out-fast_static.pgm \
+ dilation-lena-out-faster_static.pgm \
gradient-lena-out.pgm \
gradient-spe-lena-out-0.pgm \
gradient-spe-lena-out-1.pgm \
diff --git a/milena/apps/bench/dilation-lena.cc b/milena/apps/bench/dilation-lena.cc
index 3557487..4372540 100644
--- a/milena/apps/bench/dilation-lena.cc
+++ b/milena/apps/bench/dilation-lena.cc
@@ -216,6 +216,32 @@ namespace fast_static
}
}
+namespace faster_static
+{
+ 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'.
+
+ typedef mln::static_dpoints_fwd_pixter<const I, W::Size> mln_static_qixter;
+ mln_static_qixter q(p, win);
+ for_all(p)
+ {
+ // FIXME: Cheat: replace the accu::supremum by a maximum.
+ mln::accu::stat::max<mln_value(I)> sup; // Accumulator computing the supremum.
+ for_all(q)
+ sup.take(q.val());
+ *(output.buffer() + p.offset()) = sup.to_result();
+ }
+ return output;
+ }
+}
+
int main()
{
@@ -279,4 +305,10 @@ int main()
t.stop();
std::cout << t.read() << std::endl;
io::pgm::save(d, "dilation-lena-out-fast_static.pgm");
+
+ t.start();
+ d = faster_static::dilation(lena, static_win_c4p);
+ t.stop();
+ std::cout << t.read() << std::endl;
+ io::pgm::save(d, "dilation-lena-out-faster_static.pgm");
}
--
1.7.2.5
1
0

last-svn-commit-545-ga8d13f2 WIP: More comparisons on dilation (variants without accu).
by Roland Levillain 14 Oct '11
by Roland Levillain 14 Oct '11
14 Oct '11
---
milena/apps/bench/Makefile.am | 2 +
milena/apps/bench/dilation-lena.cc | 64 ++++++++++++++++++++++++++++++++++++
2 files changed, 66 insertions(+), 0 deletions(-)
diff --git a/milena/apps/bench/Makefile.am b/milena/apps/bench/Makefile.am
index 766f620..f106b23 100644
--- a/milena/apps/bench/Makefile.am
+++ b/milena/apps/bench/Makefile.am
@@ -39,7 +39,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 \
diff --git a/milena/apps/bench/dilation-lena.cc b/milena/apps/bench/dilation-lena.cc
index ea37f19..3557487 100644
--- a/milena/apps/bench/dilation-lena.cc
+++ b/milena/apps/bench/dilation-lena.cc
@@ -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;
@@ -195,11 +248,22 @@ int main()
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),
--
1.7.2.5
1
0

last-svn-commit-544-g1dfe127 WIP: More comparisons on dilation (static windows and qixters).
by Roland Levillain 14 Oct '11
by Roland Levillain 14 Oct '11
14 Oct '11
---
milena/apps/bench/Makefile.am | 1 +
milena/apps/bench/dilation-lena.cc | 45 +++
milena/apps/bench/static_array.hh | 134 +++++++++
.../bench/static_dpoints_pixter.hh} | 196 +++++++-------
.../core/window.hh => apps/bench/static_window.hh} | 288 ++++++++++----------
5 files changed, 420 insertions(+), 244 deletions(-)
create mode 100644 milena/apps/bench/static_array.hh
copy milena/{mln/core/dpoints_pixter.hh => apps/bench/static_dpoints_pixter.hh} (66%)
copy milena/{mln/core/window.hh => apps/bench/static_window.hh} (51%)
diff --git a/milena/apps/bench/Makefile.am b/milena/apps/bench/Makefile.am
index 41b57f5..766f620 100644
--- a/milena/apps/bench/Makefile.am
+++ b/milena/apps/bench/Makefile.am
@@ -40,6 +40,7 @@ MOSTLYCLEANFILES = \
dilation-lena-out-gen.pgm \
dilation-lena-out-fast.pgm \
dilation-lena-out-faster.pgm \
+ dilation-lena-out-fast_static.pgm \
gradient-lena-out.pgm \
gradient-spe-lena-out-0.pgm \
gradient-spe-lena-out-1.pgm \
diff --git a/milena/apps/bench/dilation-lena.cc b/milena/apps/bench/dilation-lena.cc
index 1cb1198..ea37f19 100644
--- a/milena/apps/bench/dilation-lena.cc
+++ b/milena/apps/bench/dilation-lena.cc
@@ -37,6 +37,8 @@
#include <mln/util/timer.hh>
+#include "apps/bench/static_window.hh"
+#include "apps/bench/static_dpoints_pixter.hh"
#include "apps/data.hh"
@@ -134,6 +136,33 @@ namespace faster
}
}
+namespace fast_static
+{
+ 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'.
+
+ typedef mln::static_dpoints_fwd_pixter<const I, W::Size> mln_static_qixter;
+ mln_static_qixter q(pi, win);
+ for_all_2(pi, po)
+ {
+ // FIXME: Cheat: replace the accu::supremum by a maximum.
+ mln::accu::stat::max<mln_value(I)> sup; // Accumulator computing the supremum.
+ for_all(q)
+ sup.take(q.val());
+ po.val() = sup.to_result();
+ }
+ return output;
+ }
+}
+
int main()
{
@@ -170,4 +199,20 @@ int main()
t.stop();
std::cout << t.read() << std::endl;
io::pgm::save(d, "dilation-lena-out-faster.pgm");
+
+
+ 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);
+
+ t.start();
+ d = fast_static::dilation(lena, static_win_c4p);
+ t.stop();
+ std::cout << t.read() << std::endl;
+ io::pgm::save(d, "dilation-lena-out-fast_static.pgm");
}
diff --git a/milena/apps/bench/static_array.hh b/milena/apps/bench/static_array.hh
new file mode 100644
index 0000000..ddf42bd
--- /dev/null
+++ b/milena/apps/bench/static_array.hh
@@ -0,0 +1,134 @@
+// Copyright (C) 2010 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 MLN_UTIL_STATIC_ARRAY_HH
+# define MLN_UTIL_STATIC_ARRAY_HH
+
+// FIXME: Add documentation.
+
+# include <cstddef>
+# include <algorithm>
+
+# include <mln/core/internal/window_base.hh>
+# include <mln/core/concept/gdpoint.hh>
+
+# include <mln/metal/is_a.hh>
+# include <mln/util/set.hh>
+# include <mln/fun/i2v/all_to.hh>
+# include <mln/norm/linfty.hh>
+# include <mln/literal/zero.hh>
+
+namespace mln
+{
+
+ namespace util
+ {
+
+ template <typename T, std::size_t n>
+ class static_array
+ {
+ public:
+ // FIXME: Careful, this ctor initializes nothing.
+ static_array();
+
+ // FIXME: Find a better way to build this static array.
+ template <typename InputIterator>
+ static_array(InputIterator first, InputIterator last);
+
+ T& operator[](std::size_t i);
+ const T& operator[](std::size_t i) const;
+
+ bool has(const T& value) const;
+
+ private:
+ T data_[n];
+ };
+
+
+ template <typename D, std::size_t n>
+ bool
+ operator==(const static_array<D, n>& lhs, const static_array<D, n>& rhs);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename T, std::size_t n>
+ inline
+ static_array<T, n>::static_array()
+ {
+ }
+
+ template <typename T, std::size_t n>
+ template <typename InputIterator>
+ inline
+ static_array<T, n>::static_array(InputIterator first, InputIterator last)
+ {
+ mln_precondition(std::distance(first, last) == n);
+ std::copy(first, last, data_);
+ }
+
+ template <typename T, std::size_t n>
+ inline
+ T&
+ static_array<T, n>::operator[](std::size_t i)
+ {
+ return data_[i];
+ }
+
+ template <typename T, std::size_t n>
+ inline
+ const T&
+ static_array<T, n>::operator[](std::size_t i) const
+ {
+ return data_[i];
+ }
+
+ template <typename T, std::size_t n>
+ inline
+ bool
+ static_array<T, n>::has(const T& value) const
+ {
+ return std::find(data_, data_ + n, value) != data_ + n;
+ }
+
+
+ template <typename D, std::size_t n>
+ inline
+ bool
+ operator==(const static_array<D, n>& lhs, const static_array<D, n>& rhs)
+ {
+ for(std::size_t i = 0; i < n; ++i)
+ if (lhs[i] != rhs[i])
+ return false;
+ return true;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::util
+
+} // end of namespace mln
+
+#endif // ! MLN_UTIL_STATIC_ARRAY_HH
diff --git a/milena/mln/core/dpoints_pixter.hh b/milena/apps/bench/static_dpoints_pixter.hh
similarity index 66%
copy from milena/mln/core/dpoints_pixter.hh
copy to milena/apps/bench/static_dpoints_pixter.hh
index 8020fcc..d7823ac 100644
--- a/milena/mln/core/dpoints_pixter.hh
+++ b/milena/apps/bench/static_dpoints_pixter.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2007, 2008, 2009, 2010 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -23,8 +24,10 @@
// exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
-#ifndef MLN_CORE_DPOINTS_PIXTER_HH
-# define MLN_CORE_DPOINTS_PIXTER_HH
+#ifndef MLN_CORE_STATIC_DPOINTS_PIXTER_HH
+# define MLN_CORE_STATIC_DPOINTS_PIXTER_HH
+
+// FIXME: Review and update the documentation.
/// \file
///
@@ -41,24 +44,25 @@
# include <mln/core/internal/pixel_impl.hh>
# include <mln/metal/converts_to.hh>
+# include "apps/bench/static_array.hh"
namespace mln
{
- /*------------------------.
- | dpoints_fwd_pixter<I>. |
- `------------------------*/
+ /*----------------------------------.
+ | static_dpoints_fwd_pixter<I, n>. |
+ `----------------------------------*/
/// \brief A generic forward iterator on the pixels of a
/// dpoint-based window or neighborhood.
///
/// Parameter \c I is the image type.
- template <typename I>
- class dpoints_fwd_pixter
- : public Pixel_Iterator< dpoints_fwd_pixter<I> >,
- public internal::pixel_impl_< I, dpoints_fwd_pixter<I> >
+ template <typename I, unsigned n>
+ class static_dpoints_fwd_pixter
+ : public Pixel_Iterator< static_dpoints_fwd_pixter<I, n> >,
+ public internal::pixel_impl_< I, static_dpoints_fwd_pixter<I, n> >
{
- typedef typename internal::pixel_impl_< I, dpoints_fwd_pixter<I> > super_;
+ typedef typename internal::pixel_impl_< I, static_dpoints_fwd_pixter<I, n> > super_;
public:
/// \brief Constructor (using an image).
@@ -69,9 +73,9 @@ namespace mln
/// \param[in] p_ref Center (resp. reference) point of the
/// neighborhood (resp. window).
template <typename Dps, typename Pref>
- dpoints_fwd_pixter(I& image,
- const Dps& dps,
- const Pref& p_ref);
+ static_dpoints_fwd_pixter(I& image,
+ const Dps& dps,
+ const Pref& p_ref);
/// \brief Constructor (using a generalized pixel).
///
@@ -79,8 +83,8 @@ namespace mln
/// \param[in] dps An object (neighborhood or window) that can
/// provide a set of delta-points.
template <typename Dps, typename Pref>
- dpoints_fwd_pixter(const Generalized_Pixel<Pref>& pxl_ref,
- const Dps& dps);
+ static_dpoints_fwd_pixter(const Generalized_Pixel<Pref>& pxl_ref,
+ const Dps& dps);
/// Manipulation.
/// \{
@@ -112,9 +116,9 @@ namespace mln
/// offset_[0] is absolute, while other offsets are relative
/// (i.e., offset_[i] is the memory difference to go from pixel
/// i-1 to pixel i.
- std::vector<int> offset_;
+ util::static_array<int, n> offset_;
/// Current offset.
- typename std::vector<int>::const_iterator i_;
+ std::size_t i_;
/// \brief Reference value or pixel.
///
@@ -128,20 +132,20 @@ namespace mln
};
- /*------------------------.
- | dpoints_bkd_pixter<I>. |
- `------------------------*/
+ /*----------------------------------.
+ | static_dpoints_bkd_pixter<I, n>. |
+ `----------------------------------*/
/// \brief A generic backward iterator on the pixels of a
/// dpoint-based window or neighborhood.
///
/// Parameter \c I is the image type.
- template <typename I>
- class dpoints_bkd_pixter
- : public Pixel_Iterator< dpoints_bkd_pixter<I> >,
- public internal::pixel_impl_< I, dpoints_bkd_pixter<I> >
+ template <typename I, unsigned n>
+ class static_dpoints_bkd_pixter
+ : public Pixel_Iterator< static_dpoints_bkd_pixter<I, n> >,
+ public internal::pixel_impl_< I, static_dpoints_bkd_pixter<I, n> >
{
- typedef typename internal::pixel_impl_< I, dpoints_bkd_pixter<I> > super_;
+ typedef typename internal::pixel_impl_< I, static_dpoints_bkd_pixter<I, n> > super_;
public:
/// \brief Constructor (using an image).
@@ -152,9 +156,9 @@ namespace mln
/// \param[in] p_ref Center (resp. reference) point of the
/// neighborhood (resp. window).
template <typename Dps, typename Pref>
- dpoints_bkd_pixter(I& image,
- const Dps& dps,
- const Pref& p_ref);
+ static_dpoints_bkd_pixter(I& image,
+ const Dps& dps,
+ const Pref& p_ref);
/// \brief Constructor (using a generalized pixel).
///
@@ -162,8 +166,8 @@ namespace mln
/// \param[in] dps An object (neighborhood or window) that can
/// provide a set of delta-points.
template <typename Dps, typename Pref>
- dpoints_bkd_pixter(const Generalized_Pixel<Pref>& pxl_ref,
- const Dps& dps);
+ static_dpoints_bkd_pixter(const Generalized_Pixel<Pref>& pxl_ref,
+ const Dps& dps);
/// Manipulation.
/// \{
@@ -195,9 +199,9 @@ namespace mln
/// offset_[dps.size() - 1] is absolute, while other offsets
/// are relative (i.e., offset_[i] is the memory difference to go
/// from pixel i+1 to pixel i.
- std::vector<int> offset_;
+ util::static_array<int, n> offset_;
/// Current offset.
- typename std::vector<int>::const_reverse_iterator i_;
+ std::size_t i_;
/// \brief Reference value or pixel.
///
@@ -214,16 +218,16 @@ namespace mln
#ifndef MLN_INCLUDE_ONLY
- /*------------------------.
- | dpoints_fwd_pixter<I>. |
- `------------------------*/
+ /*----------------------------------.
+ | static_dpoints_fwd_pixter<I, n>. |
+ `----------------------------------*/
- template <typename I>
+ template <typename I, unsigned n>
template <typename Dps, typename Pref>
inline
- dpoints_fwd_pixter<I>::dpoints_fwd_pixter(I& image,
- const Dps& dps,
- const Pref& p_ref)
+ static_dpoints_fwd_pixter<I, n>::static_dpoints_fwd_pixter(I& image,
+ const Dps& dps,
+ const Pref& p_ref)
: super_(image)
{
mln_precondition(image.is_valid());
@@ -235,11 +239,11 @@ namespace mln
init_(dps);
}
- template <typename I>
+ template <typename I, unsigned n>
template <typename Dps, typename Pref>
inline
- dpoints_fwd_pixter<I>::dpoints_fwd_pixter(const Generalized_Pixel<Pref>& pxl_ref_,
- const Dps& dps)
+ static_dpoints_fwd_pixter<I, n>::static_dpoints_fwd_pixter(const Generalized_Pixel<Pref>& pxl_ref_,
+ const Dps& dps)
: super_(internal::force_exact<Pref>(pxl_ref_).ima())
{
const Pref& pxl_ref = internal::force_exact<Pref>(pxl_ref_);
@@ -250,10 +254,10 @@ namespace mln
init_(dps);
}
- template <typename I>
+ template <typename I, unsigned n>
inline
const mln_value(I)&
- dpoints_fwd_pixter<I>::center_val() const
+ static_dpoints_fwd_pixter<I, n>::center_val() const
{
mln_invariant(value_ref_ != 0 || p_ref_ != 0);
if (p_ref_)
@@ -262,14 +266,14 @@ namespace mln
return **value_ref_;
}
- template <typename I>
+ template <typename I, unsigned n>
template <typename Dps>
inline
void
- dpoints_fwd_pixter<I>::init_(const Dps& dps)
+ static_dpoints_fwd_pixter<I, n>::init_(const Dps& dps)
{
for (unsigned i = 0; i < dps.size(); ++i)
- offset_.push_back(this->image_.delta_index(dps.dp(i)));
+ offset_[i] = this->image_.delta_index(dps.dp(i));
// offset_[0] is absolute
// other offsets are relative:
if (dps.size() > 1)
@@ -278,66 +282,66 @@ namespace mln
invalidate();
}
- template <typename I>
+ template <typename I, unsigned n>
inline
void
- dpoints_fwd_pixter<I>::update()
+ static_dpoints_fwd_pixter<I, n>::update()
{
if (is_valid())
{
if (p_ref_)
- this->value_ptr_ = & image_(*p_ref_) + *i_;
+ this->value_ptr_ = & image_(*p_ref_) + offset_[i_];
else
- this->value_ptr_ = * value_ref_ + *i_;
+ this->value_ptr_ = * value_ref_ + offset_[i_];
}
}
- template <typename I>
+ template <typename I, unsigned n>
inline
void
- dpoints_fwd_pixter<I>::start()
+ static_dpoints_fwd_pixter<I, n>::start()
{
- i_ = offset_.begin();
+ i_ = 0;
update();
}
- template <typename I>
+ template <typename I, unsigned n>
inline
void
- dpoints_fwd_pixter<I>::next_()
+ static_dpoints_fwd_pixter<I, n>::next_()
{
++i_;
if (is_valid())
- this->value_ptr_ += *i_;
+ this->value_ptr_ += offset_[i_];
}
- template <typename I>
+ template <typename I, unsigned n>
inline
bool
- dpoints_fwd_pixter<I>::is_valid() const
+ static_dpoints_fwd_pixter<I, n>::is_valid() const
{
- return i_ != offset_.end();
+ return i_ < n;
}
- template <typename I>
+ template <typename I, unsigned n>
inline
void
- dpoints_fwd_pixter<I>::invalidate()
+ static_dpoints_fwd_pixter<I, n>::invalidate()
{
- i_ = offset_.end();
+ i_ = n;
}
- /*------------------------.
- | dpoints_bkd_pixter<I>. |
- `------------------------*/
+ /*----------------------------------.
+ | static_dpoints_bkd_pixter<I, n>. |
+ `----------------------------------*/
- template <typename I>
+ template <typename I, unsigned n>
template <typename Dps, typename Pref>
inline
- dpoints_bkd_pixter<I>::dpoints_bkd_pixter(I& image,
- const Dps& dps,
- const Pref& p_ref)
+ static_dpoints_bkd_pixter<I, n>::static_dpoints_bkd_pixter(I& image,
+ const Dps& dps,
+ const Pref& p_ref)
: super_(image)
{
mln_precondition(image.is_valid());
@@ -346,11 +350,11 @@ namespace mln
init_(dps);
}
- template <typename I>
+ template <typename I, unsigned n>
template <typename Dps, typename Pref>
inline
- dpoints_bkd_pixter<I>::dpoints_bkd_pixter(const Generalized_Pixel<Pref>& pxl_ref_,
- const Dps& dps)
+ static_dpoints_bkd_pixter<I, n>::static_dpoints_bkd_pixter(const Generalized_Pixel<Pref>& pxl_ref_,
+ const Dps& dps)
: super_(internal::force_exact<Pref>(pxl_ref_).ima())
{
const Pref& pxl_ref = internal::force_exact<Pref>(pxl_ref_);
@@ -361,10 +365,10 @@ namespace mln
init_(dps);
}
- template <typename I>
+ template <typename I, unsigned n>
inline
const mln_value(I)&
- dpoints_bkd_pixter<I>::center_val() const
+ static_dpoints_bkd_pixter<I, n>::center_val() const
{
mln_invariant(value_ref_ != 0 || p_ref_ != 0);
if (p_ref_)
@@ -373,14 +377,14 @@ namespace mln
return **value_ref_;
}
- template <typename I>
+ template <typename I, unsigned n>
template <typename Dps>
inline
void
- dpoints_bkd_pixter<I>::init_(const Dps& dps)
+ static_dpoints_bkd_pixter<I, n>::init_(const Dps& dps)
{
for (unsigned i = 0; i < dps.size(); ++i)
- offset_.push_back(this->image_.delta_index(dps.dp(i)));
+ offset_[i] = this->image_.delta_index(dps.dp(i));
// offset_[size() - 1] is absolute
// other offsets are relative:
if (dps.size() > 1)
@@ -389,53 +393,53 @@ namespace mln
invalidate();
}
- template <typename I>
+ template <typename I, unsigned n>
inline
void
- dpoints_bkd_pixter<I>::update()
+ static_dpoints_bkd_pixter<I, n>::update()
{
if (is_valid())
{
if (p_ref_)
- this->value_ptr_ = & image_(*p_ref_) + *i_;
+ this->value_ptr_ = & image_(*p_ref_) + offset_[n - 1 - i_];
else
- this->value_ptr_ = * value_ref_ + *i_;
+ this->value_ptr_ = * value_ref_ + offset_[n - 1 - i_];
}
}
- template <typename I>
+ template <typename I, unsigned n>
inline
void
- dpoints_bkd_pixter<I>::start()
+ static_dpoints_bkd_pixter<I, n>::start()
{
- i_ = offset_.rbegin();
+ i_ = 0;
update();
}
- template <typename I>
+ template <typename I, unsigned n>
inline
void
- dpoints_bkd_pixter<I>::next_()
+ static_dpoints_bkd_pixter<I, n>::next_()
{
++i_;
if (is_valid())
- this->value_ptr_ += *i_;
+ this->value_ptr_ += offset_[n - 1 - i_];
}
- template <typename I>
+ template <typename I, unsigned n>
inline
bool
- dpoints_bkd_pixter<I>::is_valid() const
+ static_dpoints_bkd_pixter<I, n>::is_valid() const
{
- return i_ != offset_.rend();
+ return i_ < n;
}
- template <typename I>
+ template <typename I, unsigned n>
inline
void
- dpoints_bkd_pixter<I>::invalidate()
+ static_dpoints_bkd_pixter<I, n>::invalidate()
{
- i_ = offset_.rend();
+ i_ = n;
}
#endif // ! MLN_INCLUDE_ONLY
@@ -443,4 +447,4 @@ namespace mln
} // end of namespace mln
-#endif // ! MLN_CORE_DPOINTS_PIXTER_HH
+#endif // ! MLN_CORE_STATIC_DPOINTS_PIXTER_HH
diff --git a/milena/mln/core/window.hh b/milena/apps/bench/static_window.hh
similarity index 51%
copy from milena/mln/core/window.hh
copy to milena/apps/bench/static_window.hh
index 87f1940..fe8f791 100644
--- a/milena/mln/core/window.hh
+++ b/milena/apps/bench/static_window.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2007, 2008, 2009 EPITA Research and Development
+// Copyright (C) 2007, 2008, 2009, 2010 EPITA Research and Development
// Laboratory (LRDE)
//
// This file is part of Olena.
@@ -24,8 +24,10 @@
// exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
-#ifndef MLN_CORE_WINDOW_HH
-# define MLN_CORE_WINDOW_HH
+#ifndef MLN_CORE_STATIC_WINDOW_HH
+# define MLN_CORE_STATIC_WINDOW_HH
+
+// FIXME: Review and update the documentation.
/*! \file
*
@@ -50,12 +52,14 @@
# include <mln/norm/linfty.hh>
# include <mln/literal/zero.hh>
+# include "apps/bench/static_array.hh"
+
namespace mln
{
// Forward declarations.
- template <typename D> class window;
+ template <typename D, unsigned n> class static_window;
template <typename V> class dpsites_fwd_piter;
template <typename V> class dpsites_bkd_piter;
@@ -64,8 +68,8 @@ namespace mln
namespace trait
{
- template <typename D>
- struct window_< mln::window<D> >
+ template <typename D, unsigned n>
+ struct window_< mln::static_window<D, n> >
{
typedef trait::window::size::fixed size;
typedef trait::window::support::regular support;
@@ -81,20 +85,18 @@ namespace mln
* This type of window is just like a set of delta-points. The
* parameter is \c D, type of delta-point.
*/
- template <typename D>
- class window : public internal::window_base< D, window<D> >
+ template <typename D, unsigned n>
+ class static_window : public internal::window_base< D, static_window<D, n> >
{
public:
+ enum { Size = n };
+
/// Regular window associated type.
- typedef window<D> regular;
+ typedef static_window<D, n> regular;
- /*! \brief Constructor without argument.
- *
- * The constructed window is empty.
- */
- window();
+ static_window(const mln::util::static_array<D, n>& dps);
/*! \brief Test if the window is centered.
*
@@ -116,12 +118,12 @@ namespace mln
/*! \brief Site_Iterator type to browse the points of a basic window
* w.r.t. the ordering of delta-points.
*/
- typedef dpsites_fwd_piter< window<D> > fwd_qiter;
+ typedef dpsites_fwd_piter< static_window<D, n> > fwd_qiter;
/*! \brief Site_Iterator type to browse the points of a basic window
* w.r.t. the reverse ordering of delta-points.
*/
- typedef dpsites_bkd_piter< window<D> > bkd_qiter;
+ typedef dpsites_bkd_piter< static_window<D, n> > bkd_qiter;
/*! \brief Site_Iterator type to browse the points of a basic window
* whatever the ordering of delta-points.
@@ -136,8 +138,8 @@ namespace mln
*/
bool is_empty() const;
- /// Clear the window.
- void clear();
+ // /// Clear the window.
+ // void clear();
/*! \brief Give the maximum coordinate gap between the window
center and a window point.
@@ -150,38 +152,35 @@ namespace mln
/// Test if \p dp is in this window definition.
bool has(const D& dp) const;
- /// Insert a delta-point \p dp.
- window<D>& insert(const D& dp);
+ // /// Insert a delta-point \p dp.
+ // static_window<D, n>& insert(const D& dp);
- /// Insert another window \p win.
- template <typename W>
- window<D>& insert(const Window<W>& win);
+ // /// Insert another window \p win.
+ // template <typename W>
+ // static_window<D, n>& insert(const Window<W>& win);
- /// \{ Insertion of a delta-point with different numbers of
- /// arguments (coordinates) w.r.t. the dimension.
- window<D>& insert(const mln_coord(D)& dind); // For 1D or index access.
+ // /// \{ Insertion of a delta-point with different numbers of
+ // /// arguments (coordinates) w.r.t. the dimension.
+ // static_window<D, n>& insert(const mln_coord(D)& dind); // For 1D or index access.
- window<D>& insert(const mln_coord(D)& drow,
- const mln_coord(D)& dcol); // For 2D.
+ // static_window<D, n>& insert(const mln_coord(D)& drow,
+ // const mln_coord(D)& dcol); // For 2D.
- window<D>& insert(const mln_coord(D)& dsli,
- const mln_coord(D)& drow,
- const mln_coord(D)& dcol); // For 3D.
+ // static_window<D, n>& insert(const mln_coord(D)& dsli,
+ // const mln_coord(D)& drow,
+ // const mln_coord(D)& dcol); // For 3D.
/// \}
- /// Give the std vector of delta-points.
- const std::vector<D>& std_vector() const;
-
/// Hook to the set of D.
- const mln::util::set<D>& dps_hook_() const;
+ const mln::util::static_array<D, n>& dps_hook_() const;
/// Print the window definition into \p ostr.
void print(std::ostream& ostr) const;
private:
- util::set<D> dps_;
+ mln::util::static_array<D, n> dps_;
unsigned delta_(int i) const; // For indices.
unsigned delta_(const Gdpoint<D>& dp) const; // For grids delta-points.
@@ -193,76 +192,77 @@ namespace mln
*
* \relates mln::window
*/
- template <typename D>
- bool operator==(const window<D>& lhs, const window<D>& rhs);
+ template <typename D, unsigned n>
+ bool operator==(const static_window<D, n>& lhs, const static_window<D, n>& rhs);
# ifndef MLN_INCLUDE_ONLY
- // window<D>
+ // static_window<D, n>
- template <typename D>
+ template <typename D, unsigned n>
inline
- window<D>::window()
+ static_window<D, n>::static_window(const mln::util::static_array<D, n>& dps)
+ : dps_(dps)
{
// FIXME HERE: Was: mln::metal::is_a<D, Dpoint>::check();
// mln::metal::is_a<D, Delta_Point_Site>::check();
}
- template <typename D>
+ template <typename D, unsigned n>
inline
bool
- window<D>::is_symmetric() const
+ static_window<D, n>::is_symmetric() const
{
- window<D> cpy = *this;
+ static_window<D, n> cpy = *this;
cpy.sym();
return cpy == *this;
}
- template <typename D>
+ template <typename D, unsigned n>
inline
bool
- window<D>::is_centered() const
+ static_window<D, n>::is_centered() const
{
return this->dps_.has(literal::zero);
}
- template <typename D>
+ template <typename D, unsigned n>
inline
void
- window<D>::sym()
+ static_window<D, n>::sym()
{
- window<D> tmp;
- const unsigned n = size();
- for (unsigned i = 0; i < n; ++i)
- tmp.insert(- this->dp(i));
+ util::static_array<D, n> rev;
+ // FIXME: Can't we use std::copy and reverse_iterators here?
+ for (std::size_t i = 0; i < n; ++i)
+ rev[i] = dps_[n - 1 - i];
+ static_window<D, n> tmp(rev);
*this = tmp;
}
- template <typename D>
+ template <typename D, unsigned n>
inline
bool
- window<D>::is_empty() const
+ static_window<D, n>::is_empty() const
{
- return dps_.is_empty();
+ return n == 0;
}
- template <typename D>
- inline
- void
- window<D>::clear()
- {
- dps_.clear();
- }
+ // template <typename D, unsigned n>
+ // inline
+ // void
+ // static_window<D, n>::clear()
+ // {
+ // dps_.clear();
+ // }
- template <typename D>
+ template <typename D, unsigned n>
inline
unsigned
- window<D>::delta() const
+ static_window<D, n>::delta() const
{
unsigned d = 0;
- const unsigned n = size();
for (unsigned i = 0; i < n; ++i)
{
unsigned dd = delta_(dp(i));
@@ -272,122 +272,114 @@ namespace mln
return d;
}
- template <typename D>
+ template <typename D, unsigned n>
inline
unsigned
- window<D>::delta_(int i) const
+ static_window<D, n>::delta_(int i) const
{
return i;
}
- template <typename D>
+ template <typename D, unsigned n>
inline
unsigned
- window<D>::delta_(const Gdpoint<D>& dp) const
+ static_window<D, n>::delta_(const Gdpoint<D>& dp) const
{
return norm::linfty(exact(dp).to_vec());
}
- template <typename D>
+ template <typename D, unsigned n>
inline
unsigned
- window<D>::size() const
+ static_window<D, n>::size() const
{
- return dps_.nelements();
+ return n;
}
- template <typename D>
+ template <typename D, unsigned n>
inline
const D&
- window<D>::dp(unsigned i) const
+ static_window<D, n>::dp(unsigned i) const
{
- mln_precondition(i < size());
+ mln_precondition(i < n);
return dps_[i];
}
- template <typename D>
+ template <typename D, unsigned n>
inline
bool
- window<D>::has(const D& dp) const
+ static_window<D, n>::has(const D& dp) const
{
return dps_.has(dp);
}
- template <typename D>
- inline
- const std::vector<D>&
- window<D>::std_vector() const
- {
- return dps_.std_vector();
- }
-
- template <typename D>
- inline
- window<D>&
- window<D>::insert(const D& dp)
- {
- dps_.insert(dp);
- return *this;
- }
-
- template <typename D>
- template <typename W>
- inline
- window<D>&
- window<D>::insert(const Window<W>& win_)
- {
- const W& win = exact(win_);
- const unsigned n = win.size();
- for (unsigned i = 0; i < n; ++i)
- dps_.insert(win.dp(i));
- return *this;
- }
-
- template <typename D>
- inline
- window<D>&
- window<D>::insert(const mln_coord(D)& dind)
- {
- mlc_bool(D::dim == 1)::check();
- D dp(dind);
- return insert(dp);
- }
-
- template <typename D>
- inline
- window<D>&
- window<D>::insert(const mln_coord(D)& drow,
- const mln_coord(D)& dcol)
- {
- mlc_bool(D::dim == 2)::check();
- D dp(drow, dcol);
- return insert(dp);
- }
-
- template <typename D>
- inline
- window<D>&
- window<D>::insert(const mln_coord(D)& dsli,
- const mln_coord(D)& drow,
- const mln_coord(D)& dcol)
- {
- mlc_bool(D::dim == 3)::check();
- D dp(dsli, drow, dcol);
- return insert(dp);
- }
-
- template <typename D>
+ // template <typename D, unsigned n>
+ // inline
+ // static_window<D, n>&
+ // static_window<D, n>::insert(const D& dp)
+ // {
+ // dps_.insert(dp);
+ // return *this;
+ // }
+
+ // template <typename D, unsigned n>
+ // template <typename W>
+ // inline
+ // static_window<D, n>&
+ // static_window<D, n>::insert(const Window<W>& win_)
+ // {
+ // const W& win = exact(win_);
+ // const unsigned n = win.size();
+ // for (unsigned i = 0; i < n; ++i)
+ // dps_.insert(win.dp(i));
+ // return *this;
+ // }
+
+ // template <typename D, unsigned n>
+ // inline
+ // static_window<D, n>&
+ // static_window<D, n>::insert(const mln_coord(D)& dind)
+ // {
+ // mlc_bool(D::dim == 1)::check();
+ // D dp(dind);
+ // return insert(dp);
+ // }
+
+ // template <typename D, unsigned n>
+ // inline
+ // static_window<D, n>&
+ // static_window<D, n>::insert(const mln_coord(D)& drow,
+ // const mln_coord(D)& dcol)
+ // {
+ // mlc_bool(D::dim == 2)::check();
+ // D dp(drow, dcol);
+ // return insert(dp);
+ // }
+
+ // template <typename D, unsigned n>
+ // inline
+ // static_window<D, n>&
+ // static_window<D, n>::insert(const mln_coord(D)& dsli,
+ // const mln_coord(D)& drow,
+ // const mln_coord(D)& dcol)
+ // {
+ // mlc_bool(D::dim == 3)::check();
+ // D dp(dsli, drow, dcol);
+ // return insert(dp);
+ // }
+
+ template <typename D, unsigned n>
inline
- const util::set<D>&
- window<D>::dps_hook_() const
+ const mln::util::static_array<D, n>&
+ static_window<D, n>::dps_hook_() const
{
return dps_;
}
- template <typename D>
+ template <typename D, unsigned n>
inline
void
- window<D>::print(std::ostream& ostr) const
+ static_window<D, n>::print(std::ostream& ostr) const
{
ostr << dps_;
}
@@ -395,9 +387,9 @@ namespace mln
// Operators.
- template <typename D>
+ template <typename D, unsigned n>
bool
- operator==(const window<D>& lhs, const window<D>& rhs)
+ operator==(const static_window<D, n>& lhs, const static_window<D, n>& rhs)
{
return lhs.dps_hook_() == rhs.dps_hook_();
}
@@ -410,4 +402,4 @@ namespace mln
# include <mln/core/dpsites_piter.hh>
-#endif // ! MLN_CORE_WINDOW_HH
+#endif // ! MLN_CORE_STATIC_WINDOW_HH
--
1.7.2.5
1
0

last-svn-commit-542-g613752c WIP: More (specialized) test/bench gradient on lena.pgm.
by Roland Levillain 14 Oct '11
by Roland Levillain 14 Oct '11
14 Oct '11
---
milena/apps/bench/Makefile.am | 15 +-
milena/{mln/accu/pair.hh => apps/bench/and_not.hh} | 74 +++--
milena/apps/bench/gradient-spe-lena.cc | 353 ++++++++++++++++++++
milena/{mln/accu/pair.hh => apps/bench/minus.hh} | 73 +++--
4 files changed, 450 insertions(+), 65 deletions(-)
copy milena/{mln/accu/pair.hh => apps/bench/and_not.hh} (74%)
create mode 100644 milena/apps/bench/gradient-spe-lena.cc
copy milena/{mln/accu/pair.hh => apps/bench/minus.hh} (74%)
diff --git a/milena/apps/bench/Makefile.am b/milena/apps/bench/Makefile.am
index 707f457..27a368e 100644
--- a/milena/apps/bench/Makefile.am
+++ b/milena/apps/bench/Makefile.am
@@ -21,9 +21,20 @@ APPS_CXXFLAGS = @APPS_CXXFLAGS@
AM_CXXFLAGS = $(APPS_CXXFLAGS)
noinst_PROGRAMS = \
- gradient-lena
+ gradient-lena \
+ gradient-spe-lena
+
+EXTRA_DIST = \
+ and_not.hh \
+ minus.hh
gradient_lena_SOURCES = gradient-lena.cc
+gradient_spe_lena_SOURCES = gradient-spe-lena.cc
MOSTLYCLEANFILES = \
- gradient-lena-out.pgm
+ gradient-lena-out.pgm \
+ gradient-spe-lena-out-0.pgm \
+ gradient-spe-lena-out-1.pgm \
+ gradient-spe-lena-out-2.pgm \
+ gradient-spe-lena-out-3.pgm \
+ gradient-spe-lena-out-4.pgm
diff --git a/milena/mln/accu/pair.hh b/milena/apps/bench/and_not.hh
similarity index 74%
copy from milena/mln/accu/pair.hh
copy to milena/apps/bench/and_not.hh
index 11f4dc6..c3ddf36 100644
--- a/milena/mln/accu/pair.hh
+++ b/milena/apps/bench/and_not.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2010 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.
-#ifndef MLN_ACCU_PAIR_HH
-# define MLN_ACCU_PAIR_HH
+#ifndef MLN_ACCU_AND_NOT_HH
+# define MLN_ACCU_AND_NOT_HH
/// \file
///
-/// Define a pair of accumulators.
-
-# include <utility>
+/// Define a logical "and not" of accumulators.
# include <mln/core/concept/meta_accumulator.hh>
+# include <mln/logical/and_not.hh>
+
# include <mln/accu/internal/base.hh>
# include <mln/metal/is_a.hh>
# include <mln/metal/unqualif.hh>
@@ -46,7 +46,7 @@ namespace mln
{
- /// \brief Generic pair of accumulators.
+ /// \brief Logical "and not" of accumulators.
///
/// The parameter \c T is the type of values.
///
@@ -55,29 +55,30 @@ namespace mln
/// \ingroup modaccumulti
//
template <typename A1, typename A2, typename T = mln_argument(A1)>
- struct pair : public mln::accu::internal::base< std::pair<mln_result(A1), mln_result(A2)>,
- pair<A1,A2,T> >
+ struct and_not
+ : public mln::accu::internal::base< bool, and_not<A1,A2,T> >
{
typedef T argument;
typedef mln_result(A1) result_1;
typedef mln_result(A2) result_2;
- pair();
+ and_not();
// FIXME: not implemented. Do we want it?
-// pair(const A1& a1, const A2& a2);
+// and_not(const A1& a1, const A2& a2);
/// Manipulators.
/// \{
void init();
void take_as_init_(const argument& t);
void take(const argument& t);
- void take(const pair<A1,A2,T>& other);
+ void take(const and_not<A1,A2,T>& other);
+ void untake(const argument& t);
/// \}
/// Get the value of the accumulator.
/// \{
- std::pair<mln_result(A1), mln_result(A2)> to_result() const;
+ bool to_result() const;
void get_result(result_1& r1, result_2& r2) const;
/// \}
@@ -105,16 +106,16 @@ namespace mln
namespace meta
{
- /// Meta accumulator for pair.
+ /// Meta accumulator for and_not.
template <typename A1, typename A2>
- struct pair : public Meta_Accumulator< pair<A1,A2> >
+ struct and_not : public Meta_Accumulator< and_not<A1,A2> >
{
template <typename T>
struct with
{
typedef mln_accu_with(A1, T) A1_T;
typedef mln_accu_with(A2, T) A2_T;
- typedef accu::pair<A1_T, A2_T, T> ret;
+ typedef accu::and_not<A1_T, A2_T, T> ret;
};
};
@@ -125,7 +126,7 @@ namespace mln
template <typename A1, typename A2, typename T>
inline
- pair<A1,A2,T>::pair()
+ and_not<A1,A2,T>::and_not()
{
init();
}
@@ -133,7 +134,7 @@ namespace mln
template <typename A1, typename A2, typename T>
inline
void
- pair<A1,A2,T>::init()
+ and_not<A1,A2,T>::init()
{
a1_.init();
a2_.init();
@@ -142,7 +143,7 @@ namespace mln
template <typename A1, typename A2, typename T>
inline
void
- pair<A1,A2,T>::take_as_init_(const argument& t)
+ and_not<A1,A2,T>::take_as_init_(const argument& t)
{
a1_.take_as_init_(t);
a2_.take_as_init_(t);
@@ -151,7 +152,7 @@ namespace mln
template <typename A1, typename A2, typename T>
inline
void
- pair<A1,A2,T>::take(const argument& t)
+ and_not<A1,A2,T>::take(const argument& t)
{
a1_.take(t);
a2_.take(t);
@@ -160,7 +161,7 @@ namespace mln
template <typename A1, typename A2, typename T>
inline
void
- pair<A1,A2,T>::take(const pair<A1,A2,T>& other)
+ and_not<A1,A2,T>::take(const and_not<A1,A2,T>& other)
{
a1_.take(other.a1_);
a2_.take(other.a2_);
@@ -168,18 +169,27 @@ namespace mln
template <typename A1, typename A2, typename T>
inline
- std::pair<mln_result(A1), mln_result(A2)>
- pair<A1,A2,T>::to_result() const
+ void
+ and_not<A1,A2,T>::untake(const argument& t)
+ {
+ a1_.untake(t);
+ a2_.untake(t);
+ }
+
+ template <typename A1, typename A2, typename T>
+ inline
+ bool
+ and_not<A1,A2,T>::to_result() const
{
- std::pair<mln_result(A1), mln_result(A2)> tmp(a1_.to_result(), a2_.to_result());
+ bool tmp = a1_.to_result() && ! a2_.to_result();
return tmp;
}
template <typename A1, typename A2, typename T>
inline
void
- pair<A1,A2,T>::get_result(result_1& r1,
- result_2& r2) const
+ and_not<A1,A2,T>::get_result(result_1& r1,
+ result_2& r2) const
{
r1 = a1_.to_result();
r2 = a2_.to_result();
@@ -188,7 +198,7 @@ namespace mln
template <typename A1, typename A2, typename T>
inline
mln_result(A1)
- pair<A1,A2,T>::first() const
+ and_not<A1,A2,T>::first() const
{
return a1_.to_result();
}
@@ -196,7 +206,7 @@ namespace mln
template <typename A1, typename A2, typename T>
inline
mln_result(A2)
- pair<A1,A2,T>::second() const
+ and_not<A1,A2,T>::second() const
{
return a2_.to_result();
}
@@ -206,7 +216,7 @@ namespace mln
template <typename A1, typename A2, typename T>
inline
A1
- pair<A1,A2,T>::first_accu() const
+ and_not<A1,A2,T>::first_accu() const
{
return a1_;
}
@@ -214,7 +224,7 @@ namespace mln
template <typename A1, typename A2, typename T>
inline
A2
- pair<A1,A2,T>::second_accu() const
+ and_not<A1,A2,T>::second_accu() const
{
return a2_;
}
@@ -223,7 +233,7 @@ namespace mln
template <typename A1, typename A2, typename T>
inline
bool
- pair<A1,A2,T>::is_valid() const
+ and_not<A1,A2,T>::is_valid() const
{
return a1_.is_valid() && a2_.is_valid();
}
@@ -235,4 +245,4 @@ namespace mln
} // end of namespace mln
-#endif // ! MLN_ACCU_PAIR_HH
+#endif // ! MLN_ACCU_AND_NOT_HH
diff --git a/milena/apps/bench/gradient-spe-lena.cc b/milena/apps/bench/gradient-spe-lena.cc
new file mode 100644
index 0000000..70dd58b
--- /dev/null
+++ b/milena/apps/bench/gradient-spe-lena.cc
@@ -0,0 +1,353 @@
+// Copyright (C) 2007, 2008, 2009, 2010 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 <iostream>
+
+#include <mln/core/image/image2d.hh>
+#include <mln/core/alias/window2d.hh>
+
+#include <mln/io/pgm/load.hh>
+#include <mln/io/pgm/save.hh>
+
+#include <mln/value/int_u8.hh>
+
+#include <mln/morpho/includes.hh>
+#include <mln/morpho/general.hh>
+
+#include <mln/accu/logic/lor.hh>
+#include <mln/accu/logic/land.hh>
+#include <mln/accu/logic/land_basic.hh>
+#include <mln/accu/logic/lor_basic.hh>
+#include <mln/accu/stat/max.hh>
+#include <mln/accu/stat/min.hh>
+#include <mln/accu/stat/max_h.hh>
+#include <mln/accu/stat/min_h.hh>
+
+#include "apps/bench/minus.hh"
+#include "apps/bench/and_not.hh"
+
+#include <mln/util/timer.hh>
+
+#include "apps/data.hh"
+
+// With hard-coded/inlined 4-c structuring element.
+template <typename I>
+mln_concrete(I)
+gradient_spe_0(const mln::Image<I>& ima_)
+{
+ using namespace mln;
+ typedef mln_value(I) V;
+ typedef mln_psite(I) P;
+
+ const I& ima = exact(ima_);
+
+ mln_concrete(I) result;
+ initialize(result, ima);
+
+ mln_piter(I) p(result.domain());
+ for_all(p)
+ {
+ // FIXME: Use one or two accu(s) instead?
+ V sup = ima(p);
+ V inf = ima(p);
+ {
+ P q(p.row() - 1, p.col());
+ if (ima.has(q))
+ {
+ if (ima(q) > sup) sup = ima(q);
+ if (ima(q) < inf) inf = ima(q);
+ }
+ }
+ {
+ P q(p.row(), p.col() - 1);
+ if (ima.has(q))
+ {
+ if (ima(q) > sup) sup = ima(q);
+ if (ima(q) < inf) inf = ima(q);
+ }
+ }
+ {
+ P q(p.row(), p.col() + 1);
+ if (ima.has(q))
+ {
+ if (ima(q) > sup) sup = ima(q);
+ if (ima(q) < inf) inf = ima(q);
+ }
+ }
+ {
+ P q(p.row() + 1, p.col());
+ if (ima.has(q))
+ {
+ if (ima(q) > sup) sup = ima(q);
+ if (ima(q) < inf) inf = ima(q);
+ }
+ }
+ result(p) = sup - inf;
+ }
+ return result;
+}
+
+template <typename I, typename W>
+mln_concrete(I)
+gradient_spe_1(const mln::Image<I>& ima_, const mln::Window<W>& win_)
+{
+ using namespace mln;
+ typedef mln_value(I) V;
+
+ const I& ima = exact(ima_);
+ const W& win = exact(win_);
+
+ mln_concrete(I) result;
+ initialize(result, ima);
+
+ mln_piter(I) p(result.domain());
+ mln_qiter(W) q(win, p);
+ for_all(p)
+ {
+ // FIXME: Use one or two accu(s) instead?
+ V sup = mln_min(V);
+ V inf = mln_max(V);
+ for_all(q)
+ if (ima.has(q))
+ {
+ if (ima(q) > sup)
+ sup = ima(q);
+ if (ima(q) < inf)
+ inf = ima(q);
+ }
+ result(p) = sup - inf;
+ }
+ return result;
+}
+
+template <typename I, typename W>
+mln_concrete(I)
+gradient_spe_2(const mln::Image<I>& ima_, const mln::Window<W>& win_)
+{
+ using namespace mln;
+ typedef mln_value(I) V;
+
+ const I& ima = exact(ima_);
+ const W& win = exact(win_);
+
+ typedef mln_concrete(I) O;
+ O result;
+ initialize(result, ima);
+
+ mln_pixter(const I) pi(ima);
+ mln_pixter(O) po(result);
+ // FIXME: The arguments of a qixter (p, win) are swapped compared to
+ // a qiter (win, p). Make this uniform?
+ mln_qixter(const I, W) q(pi, win);
+ for_all_2(pi, po)
+ {
+ // FIXME: Use one or two accu(s) instead?
+ V sup = mln_min(V);
+ V inf = mln_max(V);
+ for_all(q)
+ {
+ if (q.val() > sup)
+ sup = q.val();
+ if (q.val() < inf)
+ inf = q.val();
+ }
+ po.val() = sup - inf;
+ }
+ return result;
+}
+
+template <typename I, typename W>
+mln_concrete(I)
+gradient_spe_3(const mln::Image<I>& ima_, const mln::Window<W>& win_)
+{
+ using namespace mln;
+ typedef mln_value(I) V;
+
+ const I& ima = exact(ima_);
+ const W& win = exact(win_);
+
+ typedef mln_concrete(I) O;
+ O result;
+ initialize(result, ima);
+
+ mln_pixter(const I) pi(ima);
+ mln_pixter(O) po(result);
+ // FIXME: The arguments of a qixter (p, win) are swapped compared to
+ // a qiter (win, p). Make this uniform?
+ mln_qixter(const I, W) q(pi, win);
+ for_all_2(pi, po)
+ {
+ // FIXME: Use one or two accu(s) instead?
+ V sup = mln_min(V);
+ V inf = mln_max(V);
+ bool global_sup_reached_p = false;
+ bool global_inf_reached_p = false;
+ for_all(q)
+ {
+ if (!global_sup_reached_p && q.val() > sup)
+ {
+ sup = q.val();
+ if (sup == mln_max(V))
+ {
+ // Global sup reached.
+ if (global_inf_reached_p)
+ break;
+ global_sup_reached_p = true;
+ }
+ }
+ if (!global_inf_reached_p && q.val() < inf)
+ {
+ inf = q.val();
+ if (inf == mln_min(V))
+ {
+ // Global inf reached.
+ if (global_sup_reached_p)
+ break;
+ global_inf_reached_p = true;
+ }
+ }
+ }
+ po.val() = sup - inf;
+ }
+ return result;
+}
+
+
+// FIXME: Unify accumulators and_not and minus?
+
+namespace mln
+{
+ namespace accu
+ {
+ namespace meta
+ {
+ /// Accumulator for morphological gradient on sets.
+ typedef and_not<meta::logic::lor_basic, meta::logic::land_basic> lor_basic_minus_land_basic;
+ /// Accumulator for morphological gradient on functions.
+ typedef minus<meta::stat::max, meta::stat::min> max_minus_min;
+
+ /// Incremental accumulator for morphological gradient on sets.
+ typedef meta::and_not<meta::logic::lor, meta::logic::land> lor_minus_land;
+ /// Incremental accumulator for morphological gradient on functions.
+ typedef meta::minus<meta::stat::max_h, meta::stat::min_h> max_h_minus_min_h;
+ } // End of namespace mln::accu::meta.
+
+ } // End of namespace mln::accu.
+
+
+namespace morpho
+{
+
+ struct gradient_op
+ {
+ template <typename I>
+ mln_morpho_select_accu(I, lor_basic_minus_land_basic, max_minus_min)
+ accu(const Image<I>&) const
+ {
+ mln_morpho_select_accu(I, lor_basic_minus_land_basic, max_minus_min) tmp;
+ return tmp;
+ }
+
+ template <typename I>
+ mln_morpho_select_accu(I, lor_minus_land, max_h_minus_min_h)
+ accu_incr(const Image<I>&) const
+ {
+ mln_morpho_select_accu(I, lor_minus_land, max_h_minus_min_h) tmp;
+ return tmp;
+ }
+
+ // FIXME: Which neutral should we choose?
+ template <typename I>
+ mln_value(I) neutral(const Image<I>&) const
+ {
+ return internal::neutral<I>::infimum();
+ }
+ };
+
+ template <typename I, typename W>
+ inline
+ mln_concrete(I)
+ gradient_spe_4(const Image<I>& input, const Window<W>& win)
+ {
+ trace::entering("morpho::dilation");
+ mln_precondition(exact(input).is_valid());
+ mln_precondition(! exact(win).is_empty());
+
+ mln_concrete(I) output = general(gradient_op(), input, win);
+
+ mln_postcondition(test::positive(output));
+ trace::exiting("morpho::dilation");
+ return output;
+ }
+
+} // End of namespace mln::morpho.
+
+} // End of namespace mln.
+
+
+
+int main()
+{
+ using namespace mln;
+ using value::int_u8;
+
+ border::thickness = 1;
+ image2d<int_u8> lena;
+ io::pgm::load(lena, MLN_IMG_DIR "/lena.pgm");
+
+ image2d<int_u8> g;
+ util::timer t;
+
+ t.start();
+ g = gradient_spe_0(lena);
+ t.stop();
+ std::cout << t.read() << std::endl;
+ io::pgm::save(g, "gradient-spe-lena-out-0.pgm");
+
+ t.restart();
+ g = gradient_spe_1(lena, win_c4p());
+ t.stop();
+ std::cout << t.read() << std::endl;
+ io::pgm::save(g, "gradient-spe-lena-out-1.pgm");
+
+ t.restart();
+ g = gradient_spe_2(lena, win_c4p());
+ t.stop();
+ std::cout << t.read() << std::endl;
+ io::pgm::save(g, "gradient-spe-lena-out-2.pgm");
+
+ t.restart();
+ g = gradient_spe_3(lena, win_c4p());
+ t.stop();
+ std::cout << t.read() << std::endl;
+ io::pgm::save(g, "gradient-spe-lena-out-3.pgm");
+
+ t.restart();
+ g = mln::morpho::gradient_spe_4(lena, win_c4p());
+ t.stop();
+ std::cout << t.read() << std::endl;
+ io::pgm::save(g, "gradient-spe-lena-out-4.pgm");
+}
diff --git a/milena/mln/accu/pair.hh b/milena/apps/bench/minus.hh
similarity index 74%
copy from milena/mln/accu/pair.hh
copy to milena/apps/bench/minus.hh
index 11f4dc6..16b7b9d 100644
--- a/milena/mln/accu/pair.hh
+++ b/milena/apps/bench/minus.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2010 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.
-#ifndef MLN_ACCU_PAIR_HH
-# define MLN_ACCU_PAIR_HH
+#ifndef MLN_ACCU_MINUS_HH
+# define MLN_ACCU_MINUS_HH
/// \file
///
-/// Define a pair of accumulators.
-
-# include <utility>
+/// Define a difference of accumulators.
# include <mln/core/concept/meta_accumulator.hh>
+# include <mln/arith/minus.hh>
+
# include <mln/accu/internal/base.hh>
# include <mln/metal/is_a.hh>
# include <mln/metal/unqualif.hh>
@@ -46,38 +46,40 @@ namespace mln
{
- /// \brief Generic pair of accumulators.
+ /// \brief Difference of accumulators.
///
/// The parameter \c T is the type of values.
///
/// \todo Check that, when T is not provided, A1 and A2 have the same value.
+ /// \todo Compute the result type from both A1 and A2.
///
/// \ingroup modaccumulti
//
template <typename A1, typename A2, typename T = mln_argument(A1)>
- struct pair : public mln::accu::internal::base< std::pair<mln_result(A1), mln_result(A2)>,
- pair<A1,A2,T> >
+ struct minus
+ : public mln::accu::internal::base< mln_result(A1), minus<A1,A2,T> >
{
typedef T argument;
typedef mln_result(A1) result_1;
typedef mln_result(A2) result_2;
- pair();
+ minus();
// FIXME: not implemented. Do we want it?
-// pair(const A1& a1, const A2& a2);
+// minus(const A1& a1, const A2& a2);
/// Manipulators.
/// \{
void init();
void take_as_init_(const argument& t);
void take(const argument& t);
- void take(const pair<A1,A2,T>& other);
+ void take(const minus<A1,A2,T>& other);
+ void untake(const argument& t);
/// \}
/// Get the value of the accumulator.
/// \{
- std::pair<mln_result(A1), mln_result(A2)> to_result() const;
+ mln_result(A1) to_result() const;
void get_result(result_1& r1, result_2& r2) const;
/// \}
@@ -105,16 +107,16 @@ namespace mln
namespace meta
{
- /// Meta accumulator for pair.
+ /// Meta accumulator for minus.
template <typename A1, typename A2>
- struct pair : public Meta_Accumulator< pair<A1,A2> >
+ struct minus : public Meta_Accumulator< minus<A1,A2> >
{
template <typename T>
struct with
{
typedef mln_accu_with(A1, T) A1_T;
typedef mln_accu_with(A2, T) A2_T;
- typedef accu::pair<A1_T, A2_T, T> ret;
+ typedef accu::minus<A1_T, A2_T, T> ret;
};
};
@@ -125,7 +127,7 @@ namespace mln
template <typename A1, typename A2, typename T>
inline
- pair<A1,A2,T>::pair()
+ minus<A1,A2,T>::minus()
{
init();
}
@@ -133,7 +135,7 @@ namespace mln
template <typename A1, typename A2, typename T>
inline
void
- pair<A1,A2,T>::init()
+ minus<A1,A2,T>::init()
{
a1_.init();
a2_.init();
@@ -142,7 +144,7 @@ namespace mln
template <typename A1, typename A2, typename T>
inline
void
- pair<A1,A2,T>::take_as_init_(const argument& t)
+ minus<A1,A2,T>::take_as_init_(const argument& t)
{
a1_.take_as_init_(t);
a2_.take_as_init_(t);
@@ -151,7 +153,7 @@ namespace mln
template <typename A1, typename A2, typename T>
inline
void
- pair<A1,A2,T>::take(const argument& t)
+ minus<A1,A2,T>::take(const argument& t)
{
a1_.take(t);
a2_.take(t);
@@ -160,7 +162,7 @@ namespace mln
template <typename A1, typename A2, typename T>
inline
void
- pair<A1,A2,T>::take(const pair<A1,A2,T>& other)
+ minus<A1,A2,T>::take(const minus<A1,A2,T>& other)
{
a1_.take(other.a1_);
a2_.take(other.a2_);
@@ -168,17 +170,26 @@ namespace mln
template <typename A1, typename A2, typename T>
inline
- std::pair<mln_result(A1), mln_result(A2)>
- pair<A1,A2,T>::to_result() const
+ void
+ minus<A1,A2,T>::untake(const argument& t)
+ {
+ a1_.untake(t);
+ a2_.untake(t);
+ }
+
+ template <typename A1, typename A2, typename T>
+ inline
+ mln_result(A1)
+ minus<A1,A2,T>::to_result() const
{
- std::pair<mln_result(A1), mln_result(A2)> tmp(a1_.to_result(), a2_.to_result());
+ mln_result(A1) tmp = a1_.to_result() - a2_.to_result();
return tmp;
}
template <typename A1, typename A2, typename T>
inline
void
- pair<A1,A2,T>::get_result(result_1& r1,
+ minus<A1,A2,T>::get_result(result_1& r1,
result_2& r2) const
{
r1 = a1_.to_result();
@@ -188,7 +199,7 @@ namespace mln
template <typename A1, typename A2, typename T>
inline
mln_result(A1)
- pair<A1,A2,T>::first() const
+ minus<A1,A2,T>::first() const
{
return a1_.to_result();
}
@@ -196,7 +207,7 @@ namespace mln
template <typename A1, typename A2, typename T>
inline
mln_result(A2)
- pair<A1,A2,T>::second() const
+ minus<A1,A2,T>::second() const
{
return a2_.to_result();
}
@@ -206,7 +217,7 @@ namespace mln
template <typename A1, typename A2, typename T>
inline
A1
- pair<A1,A2,T>::first_accu() const
+ minus<A1,A2,T>::first_accu() const
{
return a1_;
}
@@ -214,7 +225,7 @@ namespace mln
template <typename A1, typename A2, typename T>
inline
A2
- pair<A1,A2,T>::second_accu() const
+ minus<A1,A2,T>::second_accu() const
{
return a2_;
}
@@ -223,7 +234,7 @@ namespace mln
template <typename A1, typename A2, typename T>
inline
bool
- pair<A1,A2,T>::is_valid() const
+ minus<A1,A2,T>::is_valid() const
{
return a1_.is_valid() && a2_.is_valid();
}
@@ -235,4 +246,4 @@ namespace mln
} // end of namespace mln
-#endif // ! MLN_ACCU_PAIR_HH
+#endif // ! MLN_ACCU_MINUS_HH
--
1.7.2.5
1
0

last-svn-commit-541-g80a95bd WIP: apps/Makefile.am (SUBDIRS): Add bench.
by Roland Levillain 14 Oct '11
by Roland Levillain 14 Oct '11
14 Oct '11
---
milena/apps/Makefile.am | 7 +++++--
1 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/milena/apps/Makefile.am b/milena/apps/Makefile.am
index c42ffd7..a6730db 100644
--- a/milena/apps/Makefile.am
+++ b/milena/apps/Makefile.am
@@ -1,4 +1,5 @@
-# Copyright (C) 2008, 2009 EPITA Research and Development Laboratory (LRDE).
+# Copyright (C) 2008, 2009, 2011 EPITA Research and Development
+# Laboratory (LRDE).
#
# This file is part of Olena.
#
@@ -13,10 +14,12 @@
#
# You should have received a copy of the GNU General Public License
# along with Olena. If not, see <http://www.gnu.org/licenses/>.
-#
# Applied examples of Milena.
SUBDIRS = mesh-segm-skel graph-morpho constrained-connectivity
+# Benchmarks.
+SUBDIRS += bench
+
# Examples from papers.
SUBDIRS += papers
--
1.7.2.5
1
0

last-svn-commit-540-g72256ba WIP: Configure milena/apps/bench/Makefile.am.
by Roland Levillain 14 Oct '11
by Roland Levillain 14 Oct '11
14 Oct '11
---
configure.ac | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/configure.ac b/configure.ac
index 1febf2c..a64f80d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -532,6 +532,7 @@ AM_CONDITIONAL([ENABLE_APPS], [test "x$enable_apps" = "xyes"])
# Ask for the creation of applications' Makefiles.
AC_CONFIG_FILES([
milena/apps/Makefile
+ milena/apps/bench/Makefile
milena/apps/constrained-connectivity/Makefile
milena/apps/graph-morpho/Makefile
milena/apps/mesh-segm-skel/Makefile
--
1.7.2.5
1
0

14 Oct '11
---
.../Makefile.am | 12 +++++-----
.../linear/lap.cc => apps/bench/gradient-lena.cc} | 24 +++++++++++++------
2 files changed, 22 insertions(+), 14 deletions(-)
copy milena/apps/{constrained-connectivity => bench}/Makefile.am (72%)
copy milena/{tests/linear/lap.cc => apps/bench/gradient-lena.cc} (82%)
diff --git a/milena/apps/constrained-connectivity/Makefile.am b/milena/apps/bench/Makefile.am
similarity index 72%
copy from milena/apps/constrained-connectivity/Makefile.am
copy to milena/apps/bench/Makefile.am
index 84a6ed2..707f457 100644
--- a/milena/apps/constrained-connectivity/Makefile.am
+++ b/milena/apps/bench/Makefile.am
@@ -1,4 +1,4 @@
-# Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE).
+# Copyright (C) 2010 EPITA Research and Development Laboratory (LRDE).
#
# This file is part of Olena.
#
@@ -20,10 +20,10 @@ AM_CPPFLAGS = -I$(top_srcdir)/milena -I$(top_builddir)/milena
APPS_CXXFLAGS = @APPS_CXXFLAGS@
AM_CXXFLAGS = $(APPS_CXXFLAGS)
-noinst_PROGRAMS = constrained-connectivity
-constrained_connectivity_SOURCES = constrained-connectivity.cc
+noinst_PROGRAMS = \
+ gradient-lena
-TESTS = test-constrained-connectivity
+gradient_lena_SOURCES = gradient-lena.cc
-# The sample image form Pierre Soille's PAMI 2008 article.
-EXTRA_DIST = soille.pgm
+MOSTLYCLEANFILES = \
+ gradient-lena-out.pgm
diff --git a/milena/tests/linear/lap.cc b/milena/apps/bench/gradient-lena.cc
similarity index 82%
copy from milena/tests/linear/lap.cc
copy to milena/apps/bench/gradient-lena.cc
index 2c0a2c7..f3f5d62 100644
--- a/milena/tests/linear/lap.cc
+++ b/milena/apps/bench/gradient-lena.cc
@@ -24,16 +24,20 @@
// exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
+#include <iostream>
+
#include <mln/core/image/image2d.hh>
-#include <mln/value/int_u8.hh>
+#include <mln/core/alias/window2d.hh>
+
#include <mln/io/pgm/load.hh>
#include <mln/io/pgm/save.hh>
-#include <mln/border/thickness.hh>
-#include <mln/linear/lap.hh>
-#include <mln/data/stretch.hh>
+#include <mln/value/int_u8.hh>
+#include <mln/morpho/gradient.hh>
-#include "tests/data.hh"
+#include <mln/util/timer.hh>
+
+#include "apps/data.hh"
int main()
@@ -42,10 +46,14 @@ int main()
using value::int_u8;
border::thickness = 1;
-
image2d<int_u8> lena;
io::pgm::load(lena, MLN_IMG_DIR "/lena.pgm");
- io::pgm::save(data::stretch(int_u8(), linear::lap_4(lena)),
- "lap-out.pgm");
+ util::timer t;
+ t.start();
+ image2d<int_u8> g = morpho::gradient(lena, win_c4p());
+ t.stop();
+ std::cout << t.read() << std::endl;
+
+ io::pgm::save(g, "gradient-lena-out.pgm");
}
--
1.7.2.5
1
0

14 Oct '11
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Olena, a generic and efficient image processing platform".
The branch unstable/scribo has been updated
via 0461de7a9a2d473326a09fa6d09fda03df9b6fd9 (commit)
via ad194b5f069f035d7624f748b6063baf2525cbde (commit)
via fc1b111887113926a038df4cc292561bf1d5f31e (commit)
via 674e43ac4187e2adf6a4826c9bc77c886d0cec89 (commit)
via 699326af505c203e1eeb4a2d67d2a0d85d5cd6d1 (commit)
via f31589e55f08e02a6b3f450015c892600024ec15 (commit)
via e097687e1c7cc778f217a1fcdc2d043af0f1ad41 (commit)
via 9c87359f0ff1e90b1ae40f1a17724cb5d137e86f (commit)
via 60f7a0fff74419b5e395925f46cc9258116b5823 (commit)
via 151bbf7fb689fc86abcfe85877770df87ceeaba0 (commit)
from dd67b61c24dfbce6a081a8831ac9d15e6d46fdce (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
0461de7 Add a new tool for global thresholding.
ad194b5 tests/binarization/global_threshold.cc: Fix test.
fc1b111 Add Otsu's binarization implementation.
674e43a Invert threshold function test.
699326a Add new crop routines.
f31589e mln/value/builtin/floatings.hh: Fix string name for builtin double type.
-----------------------------------------------------------------------
Summary of changes:
ANNOUNCE-2.0 | 69 +++++++++++++
ChangeLog | 4 +
NEWS | 3 +
configure.ac | 2 +-
milena/ChangeLog | 24 ++++-
milena/mln/fun/v2b/threshold.hh | 8 +-
milena/mln/geom/crop.hh | 73 +++++++++++++
milena/mln/geom/crop_without_localization.hh | 80 ++++++++++++++
milena/mln/value/builtin/floatings.hh | 5 +-
scribo/ChangeLog | 37 +++++++-
scribo/demo/viewer/Makefile.am | 2 +-
scribo/demo/viewer/demodir.hh.in | 4 +-
scribo/demo/viewer/runner.cc | 4 +-
scribo/scribo/binarization/otsu.hh | 137 +++++++++++++++++++++++++
scribo/src/binarization/Makefile.am | 19 +++-
scribo/src/binarization/global_threshold.cc | 104 +++++++++++++++++++
scribo/src/binarization/otsu.cc | 99 ++++++++++++++++++
scribo/tests/binarization/Makefile.am | 5 +-
scribo/tests/binarization/global_threshold.cc | 7 +-
scribo/tests/binarization/otsu.cc | 52 ++++++++++
scribo/tests/binarization/otsu.ref.pbm | Bin 0 -> 32884 bytes
21 files changed, 718 insertions(+), 20 deletions(-)
create mode 100644 ANNOUNCE-2.0
create mode 100644 milena/mln/geom/crop.hh
create mode 100644 milena/mln/geom/crop_without_localization.hh
create mode 100644 scribo/scribo/binarization/otsu.hh
create mode 100644 scribo/src/binarization/global_threshold.cc
create mode 100644 scribo/src/binarization/otsu.cc
create mode 100644 scribo/tests/binarization/otsu.cc
create mode 100644 scribo/tests/binarization/otsu.ref.pbm
hooks/post-receive
--
Olena, a generic and efficient image processing platform
1
0
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Olena, a generic and efficient image processing platform".
The branch stable/scribo has been updated
via e097687e1c7cc778f217a1fcdc2d043af0f1ad41 (commit)
via 9c87359f0ff1e90b1ae40f1a17724cb5d137e86f (commit)
via 60f7a0fff74419b5e395925f46cc9258116b5823 (commit)
via 151bbf7fb689fc86abcfe85877770df87ceeaba0 (commit)
from dd67b61c24dfbce6a081a8831ac9d15e6d46fdce (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
No new revisions were added by this update.
-----------------------------------------------------------------------
Summary of changes:
ANNOUNCE-2.0 | 69 ++++++++++++++++++++++++++++++++++++++
ChangeLog | 4 ++
NEWS | 3 ++
configure.ac | 2 +-
milena/ChangeLog | 6 ++--
scribo/ChangeLog | 12 ++++++-
scribo/demo/viewer/Makefile.am | 2 +-
scribo/demo/viewer/demodir.hh.in | 4 +-
scribo/demo/viewer/runner.cc | 4 +-
9 files changed, 96 insertions(+), 10 deletions(-)
create mode 100644 ANNOUNCE-2.0
hooks/post-receive
--
Olena, a generic and efficient image processing platform
1
0