Olena-patches
Threads by month
- ----- 2025 -----
- November
- October
- September
- 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 2008
- 14 participants
- 373 discussions
cleanup-2008 2558: Update dispatch in the transform algo according to image properties.
by Nicolas Ballas 15 Oct '08
by Nicolas Ballas 15 Oct '08
15 Oct '08
https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena
Index: ChangeLog
from Nicolas Ballas <ballas(a)lrde.epita.fr>
Update dispatch in the transform algo according to image properties.
* tests/level/transform.cc: Add tests.
* mln/trait/image/props.hh: Fix a mistakes.
* mln/level/transform.spe.hh: Add dispatch.
* mln/level/transform.hh: Add transform_tests function.
mln/level/transform.hh | 44 +++++-
mln/level/transform.spe.hh | 312 ++++++++++++++++++++++++++++++++++++++++-----
mln/trait/image/props.hh | 3
tests/level/transform.cc | 59 +++++++-
4 files changed, 378 insertions(+), 40 deletions(-)
Index: tests/level/transform.cc
--- tests/level/transform.cc (revision 2558)
+++ tests/level/transform.cc (working copy)
@@ -33,9 +33,14 @@
#include <cmath>
#include <mln/core/image/image2d.hh>
+#include <mln/core/image/flat_image.hh>
+#include <mln/core/image/image_if.hh>
+
#include <mln/level/transform.hh>
#include <mln/debug/iota.hh>
+#include <mln/core/var.hh>
+#include <mln/fun/p2b/chess.hh>
struct mysqrt : mln::Function_v2v<mysqrt>
{
@@ -51,12 +56,11 @@
int main()
{
using namespace mln;
-
const unsigned size = 1000;
- image2d<unsigned short>
- ima(size, size);
- image2d<unsigned short>
- out(size, size);
+
+ {
+ image2d<unsigned short> ima(size, size);
+ image2d<unsigned short> out(size, size);
(std::cout << "iota... ").flush();
debug::iota(ima);
@@ -72,3 +76,48 @@
mln_assertion((unsigned short)std::sqrt(ima(p)) == out(p));
std::cout << "done" << std::endl;
}
+
+ {
+ flat_image<short, box2d> ima(5, make::box2d(size, size));
+ image2d<unsigned short> out(size, size);
+
+ (std::cout << "fill... ").flush();
+ level::fill_with_value(ima, 51);
+ std::cout << "done" << std::endl;
+
+ (std::cout << "transform... ").flush();
+ level::transform(ima, mysqrt(), out);
+ std::cout << "done" << std::endl;
+
+ (std::cout << "checking... ").flush();
+ box2d::piter p(out.domain());
+ for_all(p)
+ mln_assertion((unsigned short)std::sqrt(ima(p)) == out(p));
+ std::cout << "done" << std::endl;
+ }
+
+ {
+ typedef image2d<unsigned short> I;
+ typedef image_if<I, fun::p2b::chess_t> II;
+
+ I ima(size, size);
+ I out(size, size);
+ II ima_if = ima | fun::p2b::chess;
+
+ level::fill_with_value(ima, 0);
+ (std::cout << "iota... ").flush();
+ debug::iota(ima);
+ std::cout << "done" << std::endl;;
+
+ (std::cout << "transform... ").flush();
+ level::transform(ima_if, mysqrt(), out);
+ std::cout << "done" << std::endl;
+
+ (std::cout << "checking... ").flush();
+ II::piter p(ima_if.domain());
+ for_all(p)
+ mln_assertion((unsigned short)std::sqrt(ima_if(p)) == out(p));
+ std::cout << "done" << std::endl;
+ }
+
+}
Index: mln/trait/image/props.hh
--- mln/trait/image/props.hh (revision 2558)
+++ mln/trait/image/props.hh (working copy)
@@ -424,7 +424,8 @@
{
struct any { protected: any() {} };
struct some : any { protected: some() {} };
- struct none : any { protected: none() {} };
+ struct none
+ : any { std::string name() const { return "vw_set::none";} };
struct uni
: some { std::string name() const { return "vw_set::uni";} };
struct multi
Index: mln/level/transform.spe.hh
--- mln/level/transform.spe.hh (revision 2558)
+++ mln/level/transform.spe.hh (working copy)
@@ -41,6 +41,8 @@
# include <mln/core/concept/image.hh>
# include <mln/core/concept/function.hh>
+# include <mln/level/fill_with_value.hh>
+
# include <mln/value/set.hh>
# include <mln/value/lut_vec.hh>
@@ -54,7 +56,18 @@
namespace level
{
+ namespace internal
+ {
+ template <typename I, typename F, typename O>
+ inline
+ void transform_tests(const Image<I>& input,
+ const Function_v2v<F>& f,
+ Image<O>& output);
+ }
+
+ // Implementation
+ // --------------
namespace impl
{
@@ -62,58 +75,295 @@
namespace generic
{
template <typename I, typename F, typename O>
- void transform_(const Image<I>& input_, const Function_v2v<F>& f_, Image<O>& output_);
+ void transform(const Image<I>& input_,
+ const Function_v2v<F>& f_,
+ Image<O>& output_);
}
+
+
template <typename I, typename F, typename O>
- inline
- void transform_(mln::trait::image::quant::any, // general case
- const Image<I>& input_, const Function_v2v<F>& f_, Image<O>& output_)
+ void transform_lowq(const Image<I>& input_,
+ const Function_v2v<F>& f_,
+ Image<O>& output_)
{
- generic::transform_(input_, f_, output_);
- }
+ trace::entering("level::impl::transform_lowq");
+
+ const I& input = exact(input_);
+ const F& f = exact(f_);
+ O& output = exact(output_);
+ level::internal::transform_tests(input, f, output);
+ mlc_is(mln_trait_image_pw_io(O),
+ trait::image::pw_io::read_write)::check();
+
+ value::lut_vec<mln_vset(I), mln_result(F)>
+ lut(input.values_eligible(), f);
+
+ mln_piter(I) p(input.domain());
+ for_all(p)
+ output(p) = lut(input(p));
+
+ trace::exiting("level::impl::transform_lowq");
+ }
template <typename I, typename F, typename O>
- inline
- void transform_(mln::trait::image::quant::low, // low quantization
- const Image<I>& input_, const Function_v2v<F>& f_, Image<O>& output_)
+ void transform_taken(const Image<I>& input_,
+ const Function_v2v<F>& f_,
+ Image<O>& output_)
{
- trace::entering("level::impl::transform");
+ trace::entering("level::impl::transform_taken");
const I& input = exact(input_);
const F& f = exact(f_);
O& output = exact(output_);
- value::lut_vec<mln_vset(I), mln_result(F)> lut(input.values_eligible(), f);
+ level::internal::transform_tests(input, f, output);
+ mlc_is(mln_trait_image_pw_io(O),
+ trait::image::pw_io::read_write)::check();
+
+ value::lut_vec<mln_vset(I), mln_result(F)>
+ lut(input.taken_values(), f);
+
mln_piter(I) p(input.domain());
for_all(p)
output(p) = lut(input(p));
- trace::exiting("level::impl::transform");
+ trace::exiting("level::impl::transform_taken");
+ }
+
+
+ template <typename I, typename F, typename O>
+ void transform_singleton(const Image<I>& input_,
+ const Function_v2v<F>& f_,
+ Image<O>& output_)
+ {
+ trace::entering("level::impl::transform_singleton");
+
+ const I& input = exact(input_);
+ const F& f = exact(f_);
+
+ level::internal::transform_tests(input_, f_, output_);
+ mln_precondition((mlc_is(mln_trait_image_pw_io(O),
+ trait::image::pw_io::read_write)::value ||
+ mlc_is(mln_trait_image_vw_io(O),
+ trait::image::vw_io::read_write)::value));
+
+ mln_result(F) val = f(input.val());
+ fill_with_value(output_, val);
+
+ trace::exiting("level::impl::transform_singleton");
+ }
+
+ template <typename I, typename F, typename O>
+ void transform_fast(const Image<I>& input_,
+ const Function_v2v<F>& f_,
+ Image<O>& output_)
+ {
+ trace::entering("level::impl::transform_fast");
+
+ const I& input = exact(input_);
+ const F& f = exact(f_);
+ O& output = exact(output_);
+
+ level::internal::transform_tests(input, f, output);
+
+ mln_pixter(const I) pi(input);
+ mln_pixter(O) po(output);
+
+ po.start();
+ for_all(pi)
+ {
+ po.val() = f(pi.val());
}
+ trace::exiting("level::impl::transform_fast");
+ }
+
+
+
+ template <typename I, typename F, typename O>
+ void transform_fast_lowq(const Image<I>& input_,
+ const Function_v2v<F>& f_,
+ Image<O>& output_)
+ {
+ trace::entering("level::impl::transform_fast_lowq");
+
+ const I& input = exact(input_);
+ const F& f = exact(f_);
+ O& output = exact(output_);
+
+ level::internal::transform_tests(input, f, output);
+
+ value::lut_vec<mln_vset(I), mln_result(F)>
+ lut(input.values_eligible(), f);
+
+ mln_pixter(const I) pi(input);
+ mln_pixter(O) po(output);
+
+ po.start();
+ for_all(pi)
+ {
+ //po.val() = lut(pi.val);
+ po.val() = f(pi.val());
+ }
+
+ trace::exiting("level::impl::transform_fast_lowq");
+ }
+
+
+
+ // Dispatch
+ // --------
+ namespace internal
+ {
+
+ /// Deal with image not updated
+ template <typename I, typename F, typename O>
+ void transform_dispatch(mln::trait::undef,
+ mln::trait::image::quant::any,
+ const Image<I>& input,
+ const Function_v2v<F>& f,
+ Image<O>& output)
+ {
+ impl::generic::transform(input, f, output);
+ }
+
+ template <typename I, typename F, typename O>
+ void transform_dispatch(mln::trait::image::vw_set::any,
+ mln::trait::image::quant::any,
+ const Image<I>& input,
+ const Function_v2v<F>& f,
+ Image<O>& output)
+ {
+ impl::generic::transform(input, f, output);
+ }
+
+ template <typename I, typename F, typename O>
+ void transform_dispatch(mln::trait::image::vw_set::uni,
+ mln::trait::image::quant::any,
+ const Image<I>& input,
+ const Function_v2v<F>& f,
+ Image<O>& output)
+ {
+ impl::transform_taken(input, f, output);
+ }
+
+
+ template <typename I, typename F, typename O>
+ void transform_dispatch(mln::trait::image::vw_set::none,
+ mln::trait::image::quant::low,
+ const Image<I>& input,
+ const Function_v2v<F>& f,
+ Image<O>& output)
+ {
+ impl::transform_lowq(input, f, output);
+ }
+
+ template <typename I, typename F, typename O>
+ void transform_dispatch_oneblock(mln::trait::image::quant::any,
+ const Image<I>& input,
+ const Function_v2v<F>& f,
+ Image<O>& output)
+ {
+ transform_fast(input, f, output);
+ }
+
+ template <typename I, typename F, typename O>
+ void transform_dispatch_oneblock(mln::trait::image::quant::low,
+ const Image<I>& input,
+ const Function_v2v<F>& f,
+ Image<O>& output)
+ {
+ transform_fast_lowq(input, f, output);
+ }
+
+
+ template <typename I, typename F, typename O>
+ void transform_dispatch(mln::trait::image::value_storage::any,
+ mln::trait::image::value_storage::any,
+ const Image<I>& input,
+ const Function_v2v<F>& f,
+ Image<O>& output)
+ {
+ transform_dispatch(mln_trait_image_vw_set(I)(),
+ mln_trait_image_quant(I)(),
+ input, f, output);
+ }
+
+ template <typename I, typename F, typename O>
+ void transform_dispatch(mln::trait::image::value_storage::singleton,
+ mln::trait::image::value_storage::any,
+ const Image<I>& input,
+ const Function_v2v<F>& f,
+ Image<O>& output)
+ {
+ transform_singleton(input, f, output);
+ }
+
+ template <typename I, typename F, typename O>
+ void transform_dispatch(mln::trait::image::value_storage::one_block,
+ mln::trait::image::value_storage::one_block,
+ const Image<I>& input_,
+ const Function_v2v<F>& f_,
+ Image<O>& output_)
+ {
+ const I& input = exact(input_);
+ O& output = exact(output_);
+
+ /// Check basic properties
+ if (mlc_is(mln_trait_image_value_access(O),
+ trait::image::value_access::direct)::value &&
+ mlc_is(mln_trait_image_value_access(I),
+ trait::image::value_access::direct)::value &&
+ mlc_is(mln_trait_image_value_alignement(I),
+ trait::image::value_alignement::with_grid)::value &&
+ mlc_is(mln_trait_image_value_alignement(O),
+ trait::image::value_alignement::with_grid)::value)
+ {
+ /// Check ext_domain
+ if (
+ ((mlc_is(mln_trait_image_ext_domain(I),
+ trait::image::ext_domain::fixed)::value ||
+ mlc_is(mln_trait_image_ext_domain(I),
+ trait::image::ext_domain::extendable)::value) &&
+ (mlc_is(mln_trait_image_ext_domain(O),
+ trait::image::ext_domain::fixed)::value ||
+ mlc_is(mln_trait_image_ext_domain(O),
+ trait::image::ext_domain::extendable)::value) &&
+ input.border() == output.border()) ||
+ (mlc_is(mln_trait_image_ext_domain(I),
+ trait::image::ext_domain::none)::value &&
+ mlc_is(mln_trait_image_ext_domain(O),
+ trait::image::ext_domain::none)::value))
+ {
+
+ /// Check domain
+ if (input.domain() == output.domain())
+ transform_dispatch_oneblock(mln_trait_image_quant(I)(),
+ input, f_, output);
+ }
+ }
+ transform_dispatch(mln_trait_image_vw_set(I)(),
+ mln_trait_image_quant(I)(),
+ input, f_, output);
+ }
+
+
+
+ template <typename I, typename F, typename O>
+ void transform_dispatch(const Image<I>& input,
+ const Function_v2v<F>& f,
+ Image<O>& output)
+ {
+ transform_dispatch(mln_trait_image_value_storage(I)(),
+ mln_trait_image_value_storage(O)(),
+ input, f, output);
+ }
+
+ }
- // FIXME: Handle the cases of fastest images.
-// template <typename I, typename F, typename O>
-// void transform(metal::true_, // low quantization
-// const Image<I>& input_, const Function_v2v<F>& f_, Image<O>& output_)
-// {
-// const I& input = exact(input_);
-// const F& f = exact(f_);
-// O& output = exact(output_);
-
-// value::lut_vec<mln_vset(I), mln_result(F)> lut(input.values(), f);
-// mln_pixter(const I) pi(input); // FIXME
-// mln_pixter(O) po(output);
-// po.start();
-// for_all(pi)
-// {
-// po.val() = lut(pi.val());
-// po.next();
-// }
-// }
} // end of namespace mln::level::impl
Index: mln/level/transform.hh
--- mln/level/transform.hh (revision 2558)
+++ mln/level/transform.hh (working copy)
@@ -76,23 +76,61 @@
# ifndef MLN_INCLUDE_ONLY
+ namespace internal
+ {
+ template <typename I, typename F, typename O>
+ inline
+ void transform_tests(const Image<I>& input,
+ const Function_v2v<F>& f,
+ Image<O>& output)
+ {
+ // Avoid a warning about an undefined variable when NDEBUG
+ // is not defined.
+ (void) input;
+ (void) f;
+ (void) output;
+
+ // Properties check
+ mln_precondition((mlc_is(mln_trait_image_pw_io(O),
+ trait::image::pw_io::read_write)::value ||
+ mlc_is(mln_trait_image_vw_io(O),
+ trait::image::vw_io::read_write)::value));
+
+ // FIXME Convert test
+ mlc_converts_to(mln_result(F), mln_value(O))::check();
+
+
+ // Dynamic tests
+ mln_precondition(exact(input).has_data());
+ mln_precondition(exact(output).domain() >= exact(input).domain());
+ }
+ } // end of namespace mln::level::internal
+
+
namespace impl
{
+
namespace generic
{
+ // Generic implementation.
template <typename I, typename F, typename O>
inline
- void transform_(const Image<I>& input_, const Function_v2v<F>& f_,
+ void transform(const Image<I>& input_, const Function_v2v<F>& f_,
Image<O>& output_)
{
trace::entering("level::impl::generic::transform");
+
const I& input = exact(input_);
const F& f = exact(f_);
O& output = exact(output_);
+ level::internal::transform_tests(input, f, output);
+ mlc_is(mln_trait_image_pw_io(O),
+ trait::image::pw_io::read_write)::check();
+
mln_piter(I) p(input.domain());
for_all(p)
output(p) = f( input(p) );
@@ -115,8 +153,8 @@
trace::entering("level::transform");
mln_precondition(exact(output).domain() >= exact(input).domain());
- impl::transform_(mln_trait_image_quant(I)(),
- exact(input), exact(f), exact(output));
+ impl::internal::transform_dispatch(exact(input), exact(f),
+ exact(output));
trace::exiting("level::transform");
}
1
0
https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Change requirements for accumulators.
Now an accumulator have to pass a qualified result as
super class parameter. In addition no result typedef is
required.
* doc/examples/tuto_bis.cc: Update.
* mln/core/macros.hh (mln_q_result, mln_q_result_): New.
* mln/core/concept/object.hh (unqualif): New include.
* mln/core/concept/accumulator.hh (q_result): New.
(to_result, operator): Update return type.
* mln/accu/min.hh: Update.
* mln/accu/internal/base.hh (result, q_result): Factor.
doc/examples/tuto_bis.cc | 3 ++-
mln/accu/internal/base.hh | 3 ++-
mln/accu/min.hh | 7 +++----
mln/core/concept/accumulator.hh | 11 ++++++-----
mln/core/concept/object.hh | 3 +++
mln/core/macros.hh | 6 ++++++
6 files changed, 22 insertions(+), 11 deletions(-)
Index: doc/examples/tuto_bis.cc
--- doc/examples/tuto_bis.cc (revision 2557)
+++ doc/examples/tuto_bis.cc (working copy)
@@ -215,6 +215,7 @@
// }
+ border::thickness = 0;
image2d<int> ima(3, 5);
@@ -337,7 +338,7 @@
fun::i2v::array<int> m(nbasins + 1);
- accu::compute<accu::mean>(cell, label, m);
+ accu::compute<accu::meta::mean>(cell, label, m);
for (unsigned i = 1; i <= nbasins; ++i)
std::cout << "mean value of basin #" << i << " is " << m(i) << std::endl;
Index: mln/core/macros.hh
--- mln/core/macros.hh (revision 2557)
+++ mln/core/macros.hh (working copy)
@@ -281,6 +281,12 @@
# define mln_qiter_(T) T::fwd_qiter
/// \}
+/// Shortcuts to access the qualified-result type associated to T.
+/// \{
+# define mln_q_result(T) typename T::q_result
+# define mln_q_result_(T) T::q_result
+/// \}
+
/// Shortcuts to access the qualified-subject type associated to T.
/// \{
# define mln_q_subject(T) typename T::q_subject
Index: mln/core/concept/object.hh
--- mln/core/concept/object.hh (revision 2557)
+++ mln/core/concept/object.hh (working copy)
@@ -41,10 +41,13 @@
# include <mln/core/contract.hh>
# include <mln/core/internal/fixme.hh>
# include <mln/trace/all.hh>
+
+// metal
# include <mln/metal/is_a.hh>
# include <mln/metal/is.hh>
# include <mln/metal/is_not.hh>
# include <mln/metal/ret.hh>
+# include <mln/metal/unqualif.hh>
/*! \mainpage Documentation of milena
Index: mln/core/concept/accumulator.hh
--- mln/core/concept/accumulator.hh (revision 2557)
+++ mln/core/concept/accumulator.hh (working copy)
@@ -68,13 +68,14 @@
/*
typedef argument;
typedef result;
+ typedef q_result;
void init();
void take(const argument& t);
void take(const E& other);
- result to_result() const;
- operator mlc_unqualif(result) const;
+ q_result to_result() const;
+ operator q_result const;
bool is_valid() const;
*/
@@ -96,6 +97,7 @@
{
typedef mln_argument(E) argument;
typedef mln_result(E) result;
+ typedef mln_q_result(E) q_result;
void (E::*m1)() = & E::init;
m1 = 0;
@@ -104,10 +106,9 @@
void (E::*m3)(const E&) = & E::take;
m3 = 0;
- result (E::*m4)() const = & E::to_result;
+ q_result (E::*m4)() const = & E::to_result;
m4 = 0;
- typedef mlc_fix_return(mlc_const_return(result)) result_;
- result_ (E::*m5)() const = & E::operator result_;
+ q_result (E::*m5)() const = & E::operator q_result;
m5 = 0;
bool (E::*m6)() const = & E::is_valid;
Index: mln/accu/min.hh
--- mln/accu/min.hh (revision 2557)
+++ mln/accu/min.hh (working copy)
@@ -51,10 +51,9 @@
* The parameter \c T is the type of values.
*/
template <typename T>
- struct min_ : public mln::accu::internal::base< T, min_<T> >
+ struct min_ : public mln::accu::internal::base< const T&, min_<T> >
{
typedef T argument;
- typedef T result;
min_();
@@ -67,7 +66,7 @@
/// \}
/// Get the value of the accumulator.
- T to_result() const;
+ const T& to_result() const;
/// Check whether this accu is able to return a result.
/// Always true here.
@@ -144,7 +143,7 @@
template <typename T>
inline
- T
+ const T&
min_<T>::to_result() const
{
return t_;
Index: mln/accu/internal/base.hh
--- mln/accu/internal/base.hh (revision 2557)
+++ mln/accu/internal/base.hh (working copy)
@@ -59,7 +59,8 @@
R subj_();
// As an accumulator:
- typedef R result;
+ typedef R q_result;
+ typedef mlc_unqualif(R) result;
protected:
base();
1
0
https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena/sandbox
Index: ChangeLog
from Ugo Jardonnet <ugo.jardonnet(a)lrde.epita.fr>
INIM Classification++.
* classif/iccvg04.cc: Revamp + Area Closure.
* classif/plotscript: Basic plotting script.
* classif/chiche.pgm: Revamp chiche.
iccvg04.cc | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++----------
plotscript | 4 ++++
2 files changed, 55 insertions(+), 10 deletions(-)
Index: classif/iccvg04.cc
--- classif/iccvg04.cc (revision 2556)
+++ classif/iccvg04.cc (working copy)
@@ -1,4 +1,3 @@
-
#include <iostream>
#include <mln/core/image/image2d.hh>
@@ -7,6 +6,10 @@
#include <mln/value/all.hh>
#include <mln/level/fill.hh>
+#include <mln/morpho/closing_area.hh>
+#include <mln/arith/revert.hh>
+#include <mln/morpho/meyer_wst.hh>
+#include <mln/core/alias/neighb2d.hh>
#include <mln/io/ppm/load.hh>
@@ -14,12 +17,15 @@
using namespace mln;
+unsigned max = 0;
+
template <typename I>
mln::image3d<unsigned>
fill_histo(const I& ima)
{
image3d<unsigned> histo(256,256,256);
level::fill(histo, 0);
+ unsigned i = 0;
mln_piter(I) p(ima.domain());
for_all(p)
@@ -30,21 +36,56 @@
return histo;
}
-int main(int argc, char **argv)
+template <typename I>
+void gplot(const I& ima)
{
- image2d<value::rgb8> ima;
- ima = io::ppm::load<value::rgb8>(argv[1]);
+ mln_piter(I) p(ima.domain());
+ for_all(p)
+ {
+ if (ima(p) != 0)
+ std::cout << p[0] << ' ' << p[1] << ' ' << p[2] << std::endl;
+ }
+}
- image3d<unsigned> histo = fill_histo(ima);
+template <typename I>
+void display_proj(const I& histo)
+{
+ image2d< unsigned long long > proj_histo(256,256);
+ level::fill(proj_histo, 0);
- image2d< value::int_u16 > out(256,256);
- level::fill(out, 0);
- mln_piter_(image2d< value::int_u16 >) p(out.domain());
+ mln_piter_(image2d< unsigned long long >) p(proj_histo.domain());
+ double max = 0;
for_all(p)
{
for (unsigned i = 0; i < 256; i++)
- if ((out(p) + histo(point3d(p[0],p[1],i))) < 65536)
- out(p) += histo(point3d(p[0],p[1],i));
+ proj_histo(p) += histo(point3d(p[0], p[1], i));
+
+ if (proj_histo(p) > max)
+ max = proj_histo(p);
+ }
+
+ image2d< value::int_u8 > out(256, 256);
+ for_all(p)
+ {
+ out(p) = (proj_histo(p) / max) * 255;
}
+
io::pgm::save(out,"./chiche.pgm");
}
+
+int main(int argc, char **argv)
+{
+ image2d<value::rgb8> ima;
+ ima = io::ppm::load<value::rgb8>(argv[1]);
+
+ image3d<unsigned> histo = fill_histo(ima);
+
+ histo = arith::revert(histo);
+ image3d<value::int_u8> histo_closed(histo.domain());
+
+ morpho::closing_area(histo, c4(), 510, histo_closed);
+
+ //display_proj(arith::revert(histo));
+
+ //display_proj(histo);
+}
Index: classif/plotscript
--- classif/plotscript (revision 0)
+++ classif/plotscript (revision 0)
@@ -0,0 +1,4 @@
+set xlabel "red"
+set ylabel "green"
+set zlabel "blue"
+splot "plot"
Index: classif/chiche.pgm
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
1
0
---
milena/ChangeLog | 8 ++
.../sandbox/scribo/{remove_tables.cc => demat.hh} | 110 ++++++++++++--------
milena/sandbox/scribo/main.cc | 45 ++++++++
3 files changed, 119 insertions(+), 44 deletions(-)
rename milena/sandbox/scribo/{remove_tables.cc => demat.hh} (55%)
create mode 100644 milena/sandbox/scribo/main.cc
diff --git a/milena/ChangeLog b/milena/ChangeLog
index dc4af1c..15c868f 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,13 @@
2008-10-14 Guillaume Lazzara <z(a)lrde.epita.fr>
+ Use labeling::compute for Scribo.
+ * milena/sandbox/scribo/remove_tables.hh: split in...
+ * milena/sandbox/scribo/demat.hh,
+ * milena/sandbox/scribo/main.cc: ...these two files.
+ Update the code in order to use labeling::compute.
+
+2008-10-14 Guillaume Lazzara <z(a)lrde.epita.fr>
+
Fix labeling::compute return type.
* milena/mln/labeling/compute.hh: Fix many compilation errors
while taking directly the result type of an accumulator as a template
diff --git a/milena/sandbox/scribo/remove_tables.cc b/milena/sandbox/scribo/demat.hh
similarity index 55%
rename from milena/sandbox/scribo/remove_tables.cc
rename to milena/sandbox/scribo/demat.hh
index 0ee0528..bba9105 100644
--- a/milena/sandbox/scribo/remove_tables.cc
+++ b/milena/sandbox/scribo/demat.hh
@@ -25,10 +25,8 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-/*! \file doc/examples/hit_or_miss.cc
- *
- * \brief Test on mln::morpho::hit_or_miss.
- */
+#ifndef DEMAT_HH_
+# define DEMAT_HH_
# include <mln/core/image/image2d.hh>
@@ -57,55 +55,79 @@
# include <mln/convert/to_fun.hh>
# include <mln/geom/bbox.hh>
-void clean_lines(mln::image2d<bool>& in,
- const mln::image2d<bool>& ima,
- unsigned bbox_larger)
-{
- using namespace mln;
- using value::int_u8;
+# include <mln/labeling/compute.hh>
+# include <mln/accu/bbox.hh>
- int_u8 nlabels;
- image2d<int_u8> lbl = labeling::blobs(ima, c4(), nlabels);
+namespace scribo
+{
- for (unsigned i = nlabels; i > 0; --i)
+ namespace internal
{
- level::paste(pw::cst(false)
- | geom::bbox(lbl | (pw::value(lbl) == pw::cst(i))),//.to_larger(bbox_larger),
- in);
- }
-}
-int main(int argc, char*argv[])
-{
- using namespace mln;
- using value::int_u8;
+ void filter_image(mln::image2d<bool>& ima,
+ const mln::image2d<bool>& filter,
+ unsigned bbox_larger)
+ {
+ using namespace mln;
+ using value::int_u8;
+
+ typedef image2d<int_u8> I;
+ typedef mln_accu_with_(accu::meta::bbox, mln_psite_(I)) A;
+ typedef p_array<mlc_unqualif_(A::result)> boxes_t;
+
+ int_u8 nlabels;
+ I lbl = labeling::blobs(filter, c4(), nlabels);
+
+ boxes_t boxes = labeling::compute(accu::meta::bbox(), lbl, nlabels);
+ mln_piter_(boxes_t) p(boxes);
+
+ for_all(p)
+ level::paste(pw::cst(false)
+ | p.to_site().to_larger(bbox_larger),
+ ima);
+ }
- if (argc < 2)
+ void remove_tables(mln::image2d<bool>& in, unsigned h, unsigned w, unsigned n)
+ {
+ using namespace mln;
+
+ // Lignes verticales
+ win::rectangle2d vwin(h, w);
+ image2d<bool> vfilter = morpho::opening(in, vwin);
+ io::pbm::save(vfilter, "./table-vfilter.pbm");
+ filter_image(in, vfilter, n);
+
+ // Lignes horizontales
+ win::rectangle2d hwin(w, h);
+ image2d<bool> hfilter = morpho::opening(in, hwin);
+ io::pbm::save(hfilter, "./table-hfilter.pbm");
+ filter_image(in, hfilter, n);
+ }
+
+ } // end of namespace scribo::internal
+
+
+
+ // Facade
+ void demat(char *argv[])
{
- std::cout << argv[0] << " <image.pgm> <h> <w>" << std::endl;
- return 1;
- }
+ using namespace mln;
+ using value::int_u8;
- image2d<bool> in;
- io::pbm::load(in, argv[1]);
+ //Useful debug variables
+ unsigned h = atoi(argv[2]);
+ unsigned w = atoi(argv[3]);
+ unsigned n = atoi(argv[4]);
- unsigned h = atoi(argv[2]);
- unsigned w = atoi(argv[3]);
- unsigned n = atoi(argv[4]);
+ //Load image
+ image2d<bool> in;
+ io::pbm::load(in, argv[1]);
- // Lignes verticales
- win::rectangle2d vwin(h, w);
- image2d<bool> vout = morpho::opening(in, vwin);
- io::pbm::save(vout, "./vout.pbm");
- clean_lines(in, vout, n);
+ internal::remove_tables(in, h, w, n);
- // Lignes horizontales
- win::rectangle2d hwin(w, h);
- image2d<bool> hout = morpho::opening(in, hwin);
- io::pbm::save(hout, "./hout.pbm");
- clean_lines(in, hout, n);
+ io::pbm::save(in, "./table-filtered.pbm");
+ }
- io::pbm::save(in, "./outt.pbm");
+} // end of namespace scribo
- return 0;
-}
+# endif // ! DEMAT_HH
diff --git a/milena/sandbox/scribo/main.cc b/milena/sandbox/scribo/main.cc
new file mode 100644
index 0000000..d49fee8
--- /dev/null
+++ b/milena/sandbox/scribo/main.cc
@@ -0,0 +1,45 @@
+// Copyright (C) 2008 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library 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 this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library 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 "demat.hh"
+
+int main(int argc, char*argv[])
+{
+ using namespace mln;
+ using value::int_u8;
+
+ if (argc < 2)
+ {
+ std::cout << argv[0] << " <image.pgm> <h> <w> <bbox_larger>" << std::endl;
+ return 1;
+ }
+
+ scribo::demat(argv);
+
+ return 0;
+}
--
1.5.6.5
1
0
---
milena/ChangeLog | 8 +++++++
milena/mln/labeling/compute.hh | 44 ++++++++++++++++++++++++---------------
2 files changed, 35 insertions(+), 17 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 088fa67..dc4af1c 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,13 @@
2008-10-14 Guillaume Lazzara <z(a)lrde.epita.fr>
+ Fix labeling::compute return type.
+ * milena/mln/labeling/compute.hh: Fix many compilation errors
+ while taking directly the result type of an accumulator as a template
+ parameter for p_array<>.
+ Use mlc_unqualif.
+
+2008-10-14 Guillaume Lazzara <z(a)lrde.epita.fr>
+
Add meta-accumulator for accu::bbox.
* milena/mln/accu/bbox.hh: add missing meta-accumulator.
diff --git a/milena/mln/labeling/compute.hh b/milena/mln/labeling/compute.hh
index d579c7e..e68ac30 100644
--- a/milena/mln/labeling/compute.hh
+++ b/milena/mln/labeling/compute.hh
@@ -30,14 +30,14 @@
/*! \file mln/labeling/compute.hh
*
- * \brief Compute an accumulator onto image pixel values.
+ * \brief Compute accumulators onto sites/values of each labeled component
+ * of an image.
*/
# include <mln/core/concept/meta_accumulator.hh>
# include <mln/util/array.hh>
-
namespace mln
{
@@ -57,7 +57,7 @@ namespace mln
* It fully relies on labeling::update.
*/
template <typename A, typename I, typename J>
- p_array<mln_result(A)>
+ p_array<mlc_unqualif(mln_result(A))>
compute(const Accumulator<A>& a,
const Image<I>& input,
const Image<J>& label, mln_value(J) nlabels);
@@ -75,12 +75,12 @@ namespace mln
* It fully relies on labeling::update.
*/
template <typename A, typename I, typename J>
- p_array<mln_accu_with(A, mln_value(I))::result>
+ p_array<mlc_unqualif(mln_accu_with(A, mln_value(I))::result)>
compute(const Meta_Accumulator<A>& a,
const Image<I>& input,
const Image<J>& label, mln_value(J) nlabels);
- /*! Compute an accumulator onto the sites of each component domain of
+ /*! Compute an accumulator onto the pixel sites of each component domain of
* \p label.
*
* \param[in] a An accumulator.
@@ -92,11 +92,11 @@ namespace mln
* It fully relies on labeling::update.
*/
template <typename A, typename J>
- p_array<mln_result(A)>
+ p_array<mlc_unqualif(mln_result(A))>
compute(const Accumulator<A>& a,
const Image<J>& label, mln_value(J) nlabels);
- /*! Compute an accumulator onto the sites of each component domain of
+ /*! Compute an accumulator onto the pixel sites of each component domain of
* \p label.
*
* \param[in] a A meta-accumulator.
@@ -108,7 +108,7 @@ namespace mln
* It fully relies on labeling::update.
*/
template <typename A, typename J>
- p_array<mln_accu_with(A, mln_psite(J))::result>
+ p_array<mlc_unqualif(mln_accu_with(A, mln_psite(J))::result)>
compute(const Meta_Accumulator<A>& a,
const Image<J>& label, mln_value(J) nlabels);
@@ -121,7 +121,7 @@ namespace mln
template <typename A, typename I, typename J>
inline
- p_array<mln_result(A)>
+ p_array<mlc_unqualif(mln_result(A))>
compute(const Accumulator<A>&,
const Image<I>& input_,
const Image<J>& label_, mln_value(J) nlabels)
@@ -132,12 +132,17 @@ namespace mln
const J& label = exact(label_);
util::array<A> accus;
- for (mln_value(J) i = 0; i <= nlabels; ++i)
+ for (mln_value(J) i = 0; i < nlabels; ++i)
accus.append(A());
mln_piter(I) p(input.domain());
+ mln_value(J) l;
for_all(p)
- accus[label(p)].take(input(p));
+ {
+ l = label(p) - 1;
+ if (l >= 0)
+ accus[l].take(input(p));
+ }
p_array<mln_result(A)> results;
for (unsigned i = 0; i < accus.nelements(); ++i)
@@ -149,7 +154,7 @@ namespace mln
template <typename A, typename I, typename J>
inline
- p_array<mln_accu_with(A, mln_value(I))::result>
+ p_array<mlc_unqualif(mln_accu_with(A, mln_value(I))::result)>
compute(const Meta_Accumulator<A>&,
const Image<I>& input,
const Image<J>& label, mln_value(J) nlabels)
@@ -161,7 +166,7 @@ namespace mln
template <typename A, typename J>
inline
- p_array<mln_result(A)>
+ p_array<mlc_unqualif(mln_result(A))>
compute(const Accumulator<A>& a,
const Image<J>& label_, mln_value(J) nlabels)
{
@@ -170,14 +175,19 @@ namespace mln
const J& label = exact(label_);
util::array<A> accus;
- for (mln_value(J) i = 0; i <= nlabels; ++i)
+ for (mln_value(J) i = 0; i < nlabels; ++i)
accus.append(exact(a));
mln_piter(J) p(label.domain());
+ mln_value(J) l;
for_all(p)
- accus[label(p)].take(p);
+ {
+ l = label(p) - 1;
+ if (l >= 0)
+ accus[l].take(p);
+ }
- p_array<mln_result(A)> results;
+ p_array<mlc_unqualif(mln_result(A))> results;
for (unsigned i = 0; i < accus.nelements(); ++i)
results.append(accus[i]);
@@ -188,7 +198,7 @@ namespace mln
template <typename A, typename J>
inline
- p_array<mln_accu_with(A, mln_psite(J))::result>
+ p_array<mlc_unqualif(mln_accu_with(A, mln_psite(J))::result)>
compute(const Meta_Accumulator<A>&,
const Image<J>& label, mln_value(J) nlabels)
{
--
1.5.6.5
1
0
---
milena/ChangeLog | 6 ++++++
milena/mln/accu/bbox.hh | 18 +++++++++++++++++-
2 files changed, 23 insertions(+), 1 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 5385c0f..088fa67 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,10 @@
2008-10-14 Guillaume Lazzara <z(a)lrde.epita.fr>
+ Add meta-accumulator for accu::bbox.
+ * milena/mln/accu/bbox.hh: add missing meta-accumulator.
+
+2008-10-14 Guillaume Lazzara <z(a)lrde.epita.fr>
+
Add is_valid() in the accumulator concept and move meta-accumulators
in meta namespace.
* milena/mln/accu/count.hh,
@@ -34,6 +39,7 @@
* milena/tests/accu/nil.cc:
Fix tests.
+ * milena/mln/morpho/gradient_elementary.hh: Fix compilation.
2008-10-14 Guillaume Lazzara <z(a)lrde.epita.fr>
diff --git a/milena/mln/accu/bbox.hh b/milena/mln/accu/bbox.hh
index 9327b0f..b9e8259 100644
--- a/milena/mln/accu/bbox.hh
+++ b/milena/mln/accu/bbox.hh
@@ -33,8 +33,9 @@
* \brief Define an accumulator that computes a bbox.
*/
-# include <mln/accu/internal/base.hh>
# include <mln/core/site_set/box.hh>
+# include <mln/core/concept/meta_accumulator.hh>
+# include <mln/accu/internal/base.hh>
namespace mln
@@ -79,6 +80,21 @@ namespace mln
};
+ namespace meta
+ {
+
+ /// Meta accumulator for bbox.
+ struct bbox : public Meta_Accumulator< bbox >
+ {
+ template <typename T>
+ struct with
+ {
+ typedef mln::accu::bbox<T> ret;
+ };
+ };
+
+ } // end of namespace mln::accu::meta
+
# ifndef MLN_INCLUDE_ONLY
--
1.5.6.5
1
0
2553: Add is_valid() to accus and move meta-accus in meta namespace.
by Guillaume Lazzara 14 Oct '08
by Guillaume Lazzara 14 Oct '08
14 Oct '08
---
milena/ChangeLog | 37 ++++++++++++++++
milena/mln/accu/bbox.hh | 6 +++
milena/mln/accu/count.hh | 32 +++++++++++----
milena/mln/accu/height.hh | 28 ++++++++++---
milena/mln/accu/histo.hh | 34 +++++++++++++++
milena/mln/accu/max.hh | 18 ++++++++-
milena/mln/accu/max_h.hh | 16 +++++++
milena/mln/accu/mean.hh | 16 +++++++
milena/mln/accu/median_alt.hh | 67 +++++++++++++++++++-----------
milena/mln/accu/median_h.hh | 16 +++++++
milena/mln/accu/min.hh | 18 ++++++++-
milena/mln/accu/min_h.hh | 17 ++++++++
milena/mln/accu/nil.hh | 39 +++++++++++++----
milena/mln/accu/p.hh | 18 ++++++++-
milena/mln/accu/pair.hh | 18 ++++++++
milena/mln/accu/rank.hh | 36 ++++++++++++----
milena/mln/accu/rank_bool.hh | 16 +++++++
milena/mln/accu/rank_high_quant.hh | 38 ++++++++++++-----
milena/mln/accu/sum.hh | 16 +++++++
milena/mln/accu/tuple.hh | 38 +++++++++++++----
milena/mln/accu/v.hh | 47 +++++++++++++++------
milena/mln/accu/volume.hh | 30 +++++++++++---
milena/mln/core/concept/accumulator.hh | 6 ++-
milena/mln/morpho/gradient_elementary.hh | 2 +-
milena/tests/accu/all_accus.cc | 2 +-
milena/tests/accu/max.cc | 15 +-----
milena/tests/accu/mean.cc | 4 +-
milena/tests/accu/min.cc | 13 +----
milena/tests/accu/min_max.cc | 4 +-
milena/tests/accu/nil.cc | 7 ++-
30 files changed, 523 insertions(+), 131 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 9ad63cc..5385c0f 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,42 @@
2008-10-14 Guillaume Lazzara <z(a)lrde.epita.fr>
+ Add is_valid() in the accumulator concept and move meta-accumulators
+ in meta namespace.
+ * milena/mln/accu/count.hh,
+ * milena/mln/accu/height.hh,
+ * milena/mln/accu/histo.hh,
+ * milena/mln/accu/max.hh,
+ * milena/mln/accu/max_h.hh,
+ * milena/mln/accu/mean.hh,
+ * milena/mln/accu/median_alt.hh,
+ * milena/mln/accu/min.hh,
+ * milena/mln/accu/min_h.hh,
+ * milena/mln/accu/nil.hh,
+ * milena/mln/accu/p.hh,
+ * milena/mln/accu/pair.hh,
+ * milena/mln/accu/rank.hh,
+ * milena/mln/accu/rank_bool.hh,
+ * milena/mln/accu/rank_high_quant.hh,
+ * milena/mln/accu/sum.hh,
+ * milena/mln/accu/tuple.hh,
+ * milena/mln/accu/v.hh,
+ * milena/mln/accu/volume.hh:
+ Add is_valid() and move meta-accumulators in meta namespace if needed.
+
+ * milena/mln/core/concept/accumulator.hh:
+ Add is_valid() static test.
+
+ * milena/tests/accu/all_accus.cc,
+ * milena/tests/accu/max.cc,
+ * milena/tests/accu/mean.cc,
+ * milena/tests/accu/min.cc,
+ * milena/tests/accu/min_max.cc,
+ * milena/tests/accu/nil.cc:
+ Fix tests.
+
+
+2008-10-14 Guillaume Lazzara <z(a)lrde.epita.fr>
+
Add labeling::compute.
* milena/mln/labeling/compute.hh: do it.
* milena/tests/labeling/Makefile.am,
diff --git a/milena/mln/accu/bbox.hh b/milena/mln/accu/bbox.hh
index bf83445..9327b0f 100644
--- a/milena/mln/accu/bbox.hh
+++ b/milena/mln/accu/bbox.hh
@@ -56,14 +56,20 @@ namespace mln
bbox();
+ /// Manipulators.
+ /// \{
void init();
void take_as_init(const P& p);
void take(const P& p);
void take(const bbox<P>& other);
void take(const box<P>& b);
+ /// \}
+ /// Get the value of the accumulator.
const box<P>& to_result() const;
+ /// Check whether this accu is able to return a result.
+ /// Always true here.
bool is_valid() const;
protected:
diff --git a/milena/mln/accu/count.hh b/milena/mln/accu/count.hh
index 608836d..c2c1f02 100644
--- a/milena/mln/accu/count.hh
+++ b/milena/mln/accu/count.hh
@@ -55,28 +55,36 @@ namespace mln
void take(const argument&);
void take(const count_<T>& other);
- /// Force the value of the counter to \a c.
+ /// Force the value of the counter to \a c.
void set_value(std::size_t c);
/// \}
/// Get the value of the accumulator.
std::size_t to_result() const;
+ /// Check whether this accu is able to return a result.
+ /// Always true here.
+ bool is_valid() const;
+
protected:
/// The value of the counter.
std::size_t count__;
};
-
- /// \brief Meta accumulator for count.
- struct count : public Meta_Accumulator< count >
+ namespace meta
{
- template <typename T>
- struct with
+
+ /// \brief Meta accumulator for count.
+ struct count : public Meta_Accumulator< count >
{
- typedef count_<T> ret;
+ template <typename T>
+ struct with
+ {
+ typedef count_<T> ret;
+ };
};
- };
+
+ } // end of namespace mln::accu::meta
# ifndef MLN_INCLUDE_ONLY
@@ -128,6 +136,14 @@ namespace mln
count__ = c;
}
+ template <typename T>
+ inline
+ bool
+ count_<T>::is_valid() const
+ {
+ return true;
+ }
+
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::accu
diff --git a/milena/mln/accu/height.hh b/milena/mln/accu/height.hh
index 38ae6be..80dc28d 100644
--- a/milena/mln/accu/height.hh
+++ b/milena/mln/accu/height.hh
@@ -86,6 +86,10 @@ namespace mln
/// Get the value of the accumulator.
std::size_t to_result() const;
+ /// Check whether this accu is able to return a result.
+ /// Always true here.
+ bool is_valid() const;
+
protected:
/// The minimum level in the component.
value min_level__;
@@ -96,16 +100,20 @@ namespace mln
};
- /// \brief Meta accumulator for height.
- struct height : public Meta_Accumulator< height >
+ namespace meta
{
- template <typename I>
- struct with
+
+ /// \brief Meta accumulator for height.
+ struct height : public Meta_Accumulator< height >
{
- typedef height_<I> ret;
+ template <typename I>
+ struct with
+ {
+ typedef height_<I> ret;
+ };
};
- };
+ } // end of namespace mln::accu::meta
# ifndef MLN_INCLUDE_ONLY
@@ -165,6 +173,14 @@ namespace mln
max_level__ = mln_min(value);
}
+ template <typename I>
+ inline
+ bool
+ height_<I>::is_valid() const
+ {
+ return true;
+ }
+
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::accu
diff --git a/milena/mln/accu/histo.hh b/milena/mln/accu/histo.hh
index d1152a2..564879d 100644
--- a/milena/mln/accu/histo.hh
+++ b/milena/mln/accu/histo.hh
@@ -39,6 +39,7 @@
# include <algorithm>
# include <mln/core/concept/value_set.hh>
+# include <mln/core/concept/meta_accumulator.hh>
# include <mln/accu/internal/base.hh>
# include <mln/value/set.hh>
# include <mln/histo/data.hh>
@@ -63,6 +64,8 @@ namespace mln
typedef V argument;
typedef const std::vector<std::size_t>& result;
+ /// Manipulators.
+ /// \{
void take(const argument& t);
void take(const histo<V>& other);
void untake(const argument& t);
@@ -72,12 +75,20 @@ namespace mln
std::size_t operator[](unsigned i) const;
unsigned nvalues() const;
std::size_t sum() const;
+ /// \}
+ /// Get the value of the accumulator.
+ /// \{
const std::vector<std::size_t>& vect() const;
const std::vector<std::size_t>& to_result() const;
+ /// \}
const value::set<V>& vset() const;
+ /// Check whether this accu is able to return a result.
+ /// Always true here.
+ bool is_valid() const;
+
protected:
mln::histo::data<V> h_;
@@ -87,6 +98,21 @@ namespace mln
template <typename V>
std::ostream& operator<<(std::ostream& ostr, const histo<V>& h);
+ namespace meta
+ {
+
+ /// Meta accumulator for histo.
+ struct histo : public Meta_Accumulator< histo >
+ {
+ template <typename V>
+ struct with
+ {
+ typedef mln::accu::histo<V> ret;
+ };
+ };
+
+ } // end of namespace mln::accu::meta
+
@@ -206,6 +232,14 @@ namespace mln
return ostr;
}
+ template <typename V>
+ inline
+ bool
+ histo<V>::is_valid() const
+ {
+ return true;
+ }
+
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::accu
diff --git a/milena/mln/accu/max.hh b/milena/mln/accu/max.hh
index 62ed3bf..7419a56 100644
--- a/milena/mln/accu/max.hh
+++ b/milena/mln/accu/max.hh
@@ -58,13 +58,21 @@ namespace mln
max_();
+ /// Manipulators.
+ /// \{
void init();
void take_as_init(const argument& t);
void take(const argument& t);
void take(const max_<T>& other);
+ /// \}
+ /// Get the value of the accumulator.
T to_result() const;
+ /// Check whether this accu is able to return a result.
+ /// Always true here.
+ bool is_valid() const;
+
protected:
T t_;
@@ -78,7 +86,7 @@ namespace mln
{
/// Meta accumulator for max.
-
+
struct max : public Meta_Accumulator< max >
{
template <typename T>
@@ -142,6 +150,14 @@ namespace mln
return t_;
}
+ template <typename T>
+ inline
+ bool
+ max_<T>::is_valid() const
+ {
+ return true;
+ }
+
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::accu
diff --git a/milena/mln/accu/max_h.hh b/milena/mln/accu/max_h.hh
index e393dcc..b5e19d2 100644
--- a/milena/mln/accu/max_h.hh
+++ b/milena/mln/accu/max_h.hh
@@ -56,18 +56,26 @@ namespace mln
max_h();
+ /// Manipulators.
+ /// \{
void init();
void take(const argument& t);
void take_as_init(const argument& t);
void take(const max_h<V>& other);
void untake(const argument& t);
+ /// \}
unsigned card() const { return h_.sum(); }
+ /// Get the value of the accumulator.
argument to_result() const;
const accu::histo<V>& histo() const;
+ /// Check whether this accu is able to return a result.
+ /// Always true here.
+ bool is_valid() const;
+
void debug_print_() const;
protected:
@@ -258,6 +266,14 @@ namespace mln
template <typename V>
inline
+ bool
+ max_h<V>::is_valid() const
+ {
+ return true;
+ }
+
+ template <typename V>
+ inline
void
max_h<V>::debug_print_() const
{
diff --git a/milena/mln/accu/mean.hh b/milena/mln/accu/mean.hh
index 85e5be6..afff048 100644
--- a/milena/mln/accu/mean.hh
+++ b/milena/mln/accu/mean.hh
@@ -65,12 +65,20 @@ namespace mln
mean_();
+ /// Manipulators.
+ /// \{
void init();
void take(const argument& t);
void take(const mean_<T,S,M>& other);
+ /// \}
+ /// Get the value of the accumulator.
M to_result() const;
+ /// Check whether this accu is able to return a result.
+ /// Always true here.
+ bool is_valid() const;
+
protected:
accu::count_<T> count_;
@@ -144,6 +152,14 @@ namespace mln
return sum_.to_result() / count_.to_result();
}
+ template <typename T, typename S, typename M>
+ inline
+ bool
+ mean_<T,S,M>::is_valid() const
+ {
+ return count_.to_result() != 0;
+ }
+
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::accu
diff --git a/milena/mln/accu/median_alt.hh b/milena/mln/accu/median_alt.hh
index bcf4fa0..2c84e10 100644
--- a/milena/mln/accu/median_alt.hh
+++ b/milena/mln/accu/median_alt.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -54,12 +54,20 @@ namespace mln
median_alt(const Value_Set<S>& s);
+ /// Manipulators.
+ /// \{
void take(const argument& t);
void untake(const argument& t);
void init();
+ /// \}
+ /// Get the value of the accumulator.
argument to_result() const;
+ /// Check whether this accu is able to return a result.
+ /// Always true here.
+ bool is_valid() const;
+
// FIXME: remove
void debug__() const
{
@@ -72,12 +80,15 @@ namespace mln
protected:
histo<S> h_;
- const S& s_; // derived from h_
+ /// derived from h_
+ const S& s_;
std::size_t sum_minus_, sum_plus_;
- std::size_t i_; // the median index
- argument t_; // the median argument
+ /// the median index
+ std::size_t i_;
+ /// the median argument
+ argument t_;
// Auxiliary methods
void go_minus_();
@@ -205,6 +216,33 @@ namespace mln
}
}
+ template <typename S>
+ inline
+ void
+ median_alt<S>::init()
+ {
+ h_.init();
+ sum_minus_ = 0;
+ sum_plus_ = 0;
+ i_ = (mln_max(argument) - mln_min(argument)) / 2;
+ t_ = s_[i_];
+ }
+
+ template <typename S>
+ inline
+ typename median_alt<S>::argument
+ median_alt<S>::to_result() const
+ {
+ return t_;
+ }
+
+ template <typename S>
+ inline
+ bool
+ median_alt<S>::is_valid() const
+ {
+ return true;
+ }
template <typename S>
inline
@@ -241,27 +279,6 @@ namespace mln
t_ = s_[i_];
}
-
- template <typename S>
- inline
- void
- median_alt<S>::init()
- {
- h_.init();
- sum_minus_ = 0;
- sum_plus_ = 0;
- i_ = (mln_max(argument) - mln_min(argument)) / 2;
- t_ = s_[i_];
- }
-
- template <typename S>
- inline
- typename median_alt<S>::argument
- median_alt<S>::to_result() const
- {
- return t_;
- }
-
template <typename S>
inline
std::ostream& operator<<(std::ostream& ostr, const median_alt<S>& m)
diff --git a/milena/mln/accu/median_h.hh b/milena/mln/accu/median_h.hh
index cb69030..32b5b3b 100644
--- a/milena/mln/accu/median_h.hh
+++ b/milena/mln/accu/median_h.hh
@@ -56,17 +56,25 @@ namespace mln
median_h();
+ /// Manipulators.
+ /// \{
void init();
void take(const argument& t);
void take(const median_h<V>& other);
void untake(const argument& t);
+ /// \}
unsigned card() const { return h_.sum(); }
+ /// Get the value of the accumulator.
argument to_result() const;
const accu::histo<V>& histo() const;
+ /// Check whether this accu is able to return a result.
+ /// Always true here.
+ bool is_valid() const;
+
protected:
mutable accu::histo<V> h_;
@@ -241,6 +249,14 @@ namespace mln
return h_;
}
+ template <typename V>
+ inline
+ bool
+ median_h<V>::is_valid() const
+ {
+ return true;
+ }
+
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::accu
diff --git a/milena/mln/accu/min.hh b/milena/mln/accu/min.hh
index a44d012..e7044de 100644
--- a/milena/mln/accu/min.hh
+++ b/milena/mln/accu/min.hh
@@ -58,13 +58,21 @@ namespace mln
min_();
+ /// Manipulators.
+ /// \{
void init();
void take_as_init(const argument& t);
void take(const argument& t);
void take(const min_<T>& other);
+ /// \}
+ /// Get the value of the accumulator.
T to_result() const;
+ /// Check whether this accu is able to return a result.
+ /// Always true here.
+ bool is_valid() const;
+
protected:
T t_;
@@ -79,7 +87,7 @@ namespace mln
{
/// Meta accumulator for min.
-
+
struct min : public Meta_Accumulator< min >
{
template <typename T>
@@ -142,6 +150,14 @@ namespace mln
return t_;
}
+ template <typename T>
+ inline
+ bool
+ min_<T>::is_valid() const
+ {
+ return true;
+ }
+
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::accu
diff --git a/milena/mln/accu/min_h.hh b/milena/mln/accu/min_h.hh
index f0e4968..8c9d5fa 100644
--- a/milena/mln/accu/min_h.hh
+++ b/milena/mln/accu/min_h.hh
@@ -57,18 +57,26 @@ namespace mln
min_h();
+ /// Manipulators.
+ /// \{
void init();
void take(const argument& t);
void take_as_init(const argument& t);
void take(const min_h<V>& other);
void untake(const argument& t);
+ /// \}
unsigned card() const { return h_.sum(); }
+ /// Get the value of the accumulator.
result to_result() const;
const accu::histo<V>& histo() const;
+ /// Check whether this accu is able to return a result.
+ /// Always true here.
+ bool is_valid() const;
+
void debug_print_() const;
protected:
@@ -259,6 +267,15 @@ namespace mln
template <typename V>
inline
+ bool
+ min_h<V>::is_valid() const
+ {
+ return true;
+ }
+
+
+ template <typename V>
+ inline
void
min_h<V>::debug_print_() const
{
diff --git a/milena/mln/accu/nil.hh b/milena/mln/accu/nil.hh
index 581d07e..5cd7791 100644
--- a/milena/mln/accu/nil.hh
+++ b/milena/mln/accu/nil.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -58,26 +58,38 @@ namespace mln
nil_();
+ /// Manipulators.
+ /// \{
void init();
void take_as_init(const argument&);
void take(const argument&);
void take(const nil_<T>&);
+ /// \}
+ /// Get the value of the accumulator.
util::ignore to_result() const;
+
+ /// Check whether this accu is able to return a result.
+ /// Always true here.
+ bool is_valid() const;
};
- /*!
- * \brief Meta accumulator for nil.
- */
- struct nil : public Meta_Accumulator< nil >
+ namespace meta
{
- template <typename V>
- struct with
+
+ /// Meta accumulator for nil.
+
+ struct nil : public Meta_Accumulator< nil >
{
- typedef nil_<V> ret;
+ template <typename V>
+ struct with
+ {
+ typedef nil_<V> ret;
+ };
};
- };
+
+ } // end of namespace mln::accu::meta
# ifndef MLN_INCLUDE_ONLY
@@ -124,6 +136,15 @@ namespace mln
return util::ignore();
}
+ template <typename T>
+ inline
+ bool
+ nil_<T>::is_valid() const
+ {
+ return true;
+ }
+
+
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::accu
diff --git a/milena/mln/accu/p.hh b/milena/mln/accu/p.hh
index 423399d..ce4d16c 100644
--- a/milena/mln/accu/p.hh
+++ b/milena/mln/accu/p.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -61,13 +61,21 @@ namespace mln
p_();
p_(const A& a);
+ /// Manipulators.
+ /// \{
void init();
void take_as_init(const argument& t);
void take(const argument& t);
void take(const p_<A>& other);
+ /// \}
+ /// Get the value of the accumulator.
result to_result() const;
+ /// Check whether this accu is able to return a result.
+ /// Always true here.
+ bool is_valid() const;
+
protected:
A a_;
};
@@ -144,6 +152,14 @@ namespace mln
return a_.to_result();
}
+ template <typename A>
+ inline
+ bool
+ p_<A>::is_valid() const
+ {
+ return a_.is_valid();
+ }
+
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::accu
diff --git a/milena/mln/accu/pair.hh b/milena/mln/accu/pair.hh
index 7b9402e..5e69c5f 100644
--- a/milena/mln/accu/pair.hh
+++ b/milena/mln/accu/pair.hh
@@ -67,17 +67,27 @@ namespace mln
pair_();
pair_(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);
+ /// \}
+ /// Get the value of the accumulator.
+ /// \{
result to_result() const;
void get_result(result_1& r1, result_2& r2) const;
+ /// \}
mln_result(A1) first() const;
mln_result(A2) second() const;
+ /// Check whether this accu is able to return a result.
+ /// Always true here.
+ bool is_valid() const;
+
protected:
A1 a1_;
@@ -184,6 +194,14 @@ namespace mln
return a2_.to_result();
}
+ template <typename A1, typename A2, typename T>
+ inline
+ bool
+ pair_<A1,A2,T>::is_valid() const
+ {
+ return a1_.is_valid() && a2_.is_valid();
+ }
+
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::accu
diff --git a/milena/mln/accu/rank.hh b/milena/mln/accu/rank.hh
index 5190e08..69f668c 100644
--- a/milena/mln/accu/rank.hh
+++ b/milena/mln/accu/rank.hh
@@ -61,15 +61,23 @@ namespace mln
rank_(unsigned k, unsigned n);
+ /// Manipulators.
+ /// \{
void init();
void take(const argument& t);
void take(const rank_<T>& other);
void untake(const argument& t);
+ /// \}
unsigned card() const { return h_.sum(); }
+ /// Get the value of the accumulator.
T to_result() const;
+ /// Check whether this accu is able to return a result.
+ /// Always true here.
+ bool is_valid() const;
+
protected:
unsigned k_; // 0 <= k_ < n
@@ -94,19 +102,21 @@ namespace mln
template <typename I> struct rank_< util::pix<I> >;
- /*!
- * \brief Meta accumulator for rank.
- */
- struct rank : public Meta_Accumulator< rank >
+ namespace meta
{
- template <typename T>
- struct with
+
+ /// Meta accumulator for rank.
+
+ struct rank : public Meta_Accumulator< rank >
{
- typedef rank_<T> ret;
+ template <typename T>
+ struct with
+ {
+ typedef rank_<T> ret;
+ };
};
- };
-
+ } // end of namespace mln::accu::meta
@@ -264,6 +274,14 @@ namespace mln
return t_;
}
+ template <typename T>
+ inline
+ bool
+ rank_<T>::is_valid() const
+ {
+ return valid_;
+ }
+
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::accu
diff --git a/milena/mln/accu/rank_bool.hh b/milena/mln/accu/rank_bool.hh
index 1537825..2ea878f 100644
--- a/milena/mln/accu/rank_bool.hh
+++ b/milena/mln/accu/rank_bool.hh
@@ -60,19 +60,28 @@ namespace mln
rank_(unsigned k, unsigned n);
+ /// Manipulators.
+ /// \{
void init();
void take_as_init(const argument& t);
void take(const argument& t);
void take(const rank_<bool>& other);
+ /// \}
+ /// Get the value of the accumulator.
bool to_result() const;
+ /// Check whether this accu is able to return a result.
+ /// Always true here.
+ bool is_valid() const;
+
protected:
unsigned nfalse_;
unsigned k_; // 0 <= k_ < n
unsigned n_;
};
+
# ifndef MLN_INCLUDE_ONLY
inline
@@ -124,6 +133,13 @@ namespace mln
return k_ >= nfalse_;
}
+ inline
+ bool
+ rank_<bool>::is_valid() const
+ {
+ return nfalse_ <= n_;
+ }
+
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::accu
diff --git a/milena/mln/accu/rank_high_quant.hh b/milena/mln/accu/rank_high_quant.hh
index fe3f02b..151c6e5 100644
--- a/milena/mln/accu/rank_high_quant.hh
+++ b/milena/mln/accu/rank_high_quant.hh
@@ -59,14 +59,22 @@ namespace mln
rank_(unsigned k, unsigned n);
+ /// Manipulators.
+ /// \{
void init();
void take_as_init(const argument& t);
void take(const argument& t);
void take(const rank_<T>& other);
void sort();
+ /// \}
+ /// Get the value of the accumulator.
T to_result() const;
+ /// Check whether this accu is able to return a result.
+ /// Always true here.
+ bool is_valid() const;
+
protected:
std::vector<T> elts_;
@@ -79,21 +87,21 @@ namespace mln
template <typename I> struct rank_< util::pix<I> >;
- /*!
- * \brief Meta accumulator for rank.
- */
- struct rank : public Meta_Accumulator< rank >
+ namespace meta
{
- template <typename T>
- struct with
- {
- typedef rank_<T> ret;
- };
- };
-
+ /// Meta accumulator for rank.
+ struct rank : public Meta_Accumulator< rank >
+ {
+ template <typename T>
+ struct with
+ {
+ typedef rank_<T> ret;
+ };
+ };
+ }
# ifndef MLN_INCLUDE_ONLY
@@ -160,6 +168,14 @@ namespace mln
template <typename T>
inline
+ bool
+ rank_<T>::is_valid() const
+ {
+ return true;
+ }
+
+ template <typename T>
+ inline
void
rank_<T>::sort()
{
diff --git a/milena/mln/accu/sum.hh b/milena/mln/accu/sum.hh
index 670b87d..2c0569a 100644
--- a/milena/mln/accu/sum.hh
+++ b/milena/mln/accu/sum.hh
@@ -64,12 +64,20 @@ namespace mln
sum_();
+ /// Manipulators.
+ /// \{
void init();
void take(const argument& t);
void take(const sum_<T,S>& other);
+ /// \}
+ /// Get the value of the accumulator.
S to_result() const;
+ /// Check whether this accu is able to return a result.
+ /// Always true here.
+ bool is_valid() const;
+
protected:
S s_;
@@ -135,6 +143,14 @@ namespace mln
return s_;
}
+ template <typename T, typename S>
+ inline
+ bool
+ sum_<T,S>::is_valid() const
+ {
+ return true;
+ }
+
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::accu
diff --git a/milena/mln/accu/tuple.hh b/milena/mln/accu/tuple.hh
index fa06331..d1cb1d1 100644
--- a/milena/mln/accu/tuple.hh
+++ b/milena/mln/accu/tuple.hh
@@ -82,32 +82,44 @@ namespace mln
tuple_();
+ /// Manipulators.
+ /// \{
void init();
void take_as_init(const argument& t);
void take(const argument& t);
void take(const tuple_<A, n, BOOST_PP_ENUM_PARAMS(10, T)>& other);
+ /// \}
+ /// Get the value of the accumulator.
result to_result() const;
+ /// Check whether this accu is able to return a result.
+ /// Always true here.
+ bool is_valid() const;
+
protected:
intern a_;
};
- /*!
- * \brief Meta accumulator for tuple.
- */
- template <unsigned n, BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT(10, typename T, boost::tuples::null_type)>
- struct tuple : public Meta_Accumulator< tuple<n, BOOST_PP_ENUM_PARAMS(10, T)> >
+ namespace meta
{
- template <typename A>
- struct with
+
+ ///Meta accumulator for tuple.
+
+ template <unsigned n, BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT(10, typename T, boost::tuples::null_type)>
+ struct tuple : public Meta_Accumulator< tuple<n, BOOST_PP_ENUM_PARAMS(10, T)> >
{
+ template <typename A>
+ struct with
+ {
# include BOOST_PP_LOCAL_ITERATE()
- typedef tuple_<A, n, BOOST_PP_ENUM_PARAMS(10, AT)> ret;
+ typedef tuple_<A, n, BOOST_PP_ENUM_PARAMS(10, AT)> ret;
+ };
};
- };
+
+ }
# ifndef MLN_INCLUDE_ONLY
@@ -221,6 +233,14 @@ namespace mln
return tmp;
}
+ template <typename A, unsigned n, BOOST_PP_ENUM_PARAMS(10, typename T)>
+ inline
+ bool
+ tuple_<A,n,BOOST_PP_ENUM_PARAMS(10,T) >::is_valid() const
+ {
+ return true;
+ }
+
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::accu
diff --git a/milena/mln/accu/v.hh b/milena/mln/accu/v.hh
index ddb6dd3..53676f1 100644
--- a/milena/mln/accu/v.hh
+++ b/milena/mln/accu/v.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -46,9 +46,8 @@ namespace mln
{
- /*!
- * \brief Generic val of accumulators.
- */
+
+ /// Generic val of accumulators.
template <typename A>
struct val_ : public mln::accu::internal::base< mln_result(A) , val_<A> >
{
@@ -58,10 +57,13 @@ namespace mln
val_();
val_(const A& a);
+ /// Manipulators.
+ /// \{
void init();
void take_as_init(const argument& t);
void take(const argument& t);
void take(const val_<A>& other);
+ /// \}
template <typename I>
void take_as_init(const util::pix<I>& pix)
@@ -75,27 +77,35 @@ namespace mln
a_.take(pix.v());
}
+ /// Get the value of the accumulator.
result to_result() const;
+ /// Check whether this accu is able to return a result.
+ /// Always true here.
+ bool is_valid() const;
+
protected:
A a_;
};
- /*!
- * \brief Meta accumulator for val.
- */
- template <typename mA>
- struct val : public Meta_Accumulator< val<mA> >
+ namespace meta
{
- template <typename V>
- struct with
+
+ /// Meta accumulator for val.
+
+ template <typename mA>
+ struct val : public Meta_Accumulator< val<mA> >
{
- typedef mln_accu_with(mA, mln_value(V)) A;
- typedef val_<A> ret;
+ template <typename V>
+ struct with
+ {
+ typedef mln_accu_with(mA, mln_value(V)) A;
+ typedef val_<A> ret;
+ };
};
- };
+ }
# ifndef MLN_INCLUDE_ONLY
@@ -154,6 +164,15 @@ namespace mln
return a_.to_result();
}
+ template <typename A>
+ inline
+ bool
+ val_<A>::is_valid() const
+ {
+ return a_.is_valid();
+ }
+
+
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::accu
diff --git a/milena/mln/accu/volume.hh b/milena/mln/accu/volume.hh
index aa1bcad..aed5a51 100644
--- a/milena/mln/accu/volume.hh
+++ b/milena/mln/accu/volume.hh
@@ -85,6 +85,10 @@ namespace mln
/// Get the value of the accumulator.
std::size_t to_result() const;
+ /// Check whether this accu is able to return a result.
+ /// Always true here.
+ bool is_valid() const;
+
protected:
/// The reference level (the level of the component's root).
value ref_level__;
@@ -95,15 +99,21 @@ namespace mln
};
- /// \brief Meta accumulator for volume.
- struct volume : public Meta_Accumulator< volume >
+ namespace meta
{
- template <typename I>
- struct with
+
+ /// Meta accumulator for volume.
+
+ struct volume : public Meta_Accumulator< volume >
{
- typedef volume_<I> ret;
+ template <typename I>
+ struct with
+ {
+ typedef volume_<I> ret;
+ };
};
- };
+
+ } // end of namespace mln::accu::meta
# ifndef MLN_INCLUDE_ONLY
@@ -182,6 +192,14 @@ namespace mln
area__ = 0;
}
+ template <typename I>
+ inline
+ bool
+ volume_<I>::is_valid() const
+ {
+ return true;
+ }
+
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::accu
diff --git a/milena/mln/core/concept/accumulator.hh b/milena/mln/core/concept/accumulator.hh
index 0578780..882341b 100644
--- a/milena/mln/core/concept/accumulator.hh
+++ b/milena/mln/core/concept/accumulator.hh
@@ -75,6 +75,8 @@ namespace mln
result to_result() const;
operator mlc_unqualif(result) const;
+
+ bool is_valid() const;
*/
// Default impl.
@@ -104,10 +106,12 @@ namespace mln
result (E::*m4)() const = & E::to_result;
m4 = 0;
-
typedef mlc_fix_return(mlc_const_return(result)) result_;
result_ (E::*m5)() const = & E::operator result_;
m5 = 0;
+
+ bool (E::*m6)() const = & E::is_valid;
+ m6 = 0;
}
template <typename E>
diff --git a/milena/mln/morpho/gradient_elementary.hh b/milena/mln/morpho/gradient_elementary.hh
index 8a5f944..282e494 100644
--- a/milena/mln/morpho/gradient_elementary.hh
+++ b/milena/mln/morpho/gradient_elementary.hh
@@ -84,7 +84,7 @@ namespace mln
trace::entering("morpho::impl::generic::gradient_elementary_on_function");
mln_concrete(I) output;
- output = internal::elementary< accu::min_max >(input, nbh, f_grad());
+ output = internal::elementary< accu::meta::min_max >(input, nbh, f_grad());
trace::exiting("morpho::impl::generic::gradient_elementary_on_function");
return output;
diff --git a/milena/tests/accu/all_accus.cc b/milena/tests/accu/all_accus.cc
index 82e51fa..394d750 100644
--- a/milena/tests/accu/all_accus.cc
+++ b/milena/tests/accu/all_accus.cc
@@ -48,7 +48,7 @@ int main()
// min_h< value::set<bool> > mh; // OK: do not work since bool has
// no min/max :)
min_max_<int> mm;
- nil n;
+ nil_<int> n;
pair_< min_<int>, max_<int> > p;
sum_<int> s;
}
diff --git a/milena/tests/accu/max.cc b/milena/tests/accu/max.cc
index 310ee1b..427f91f 100644
--- a/milena/tests/accu/max.cc
+++ b/milena/tests/accu/max.cc
@@ -47,16 +47,7 @@ int main()
using namespace mln;
image2d<int> ima(3, 3);
debug::iota(ima);
- mln_assertion(level::compute< accu::max >(ima) == 9);
- mln_assertion(level::compute< accu::max_<int> >(ima) == 9);
-
- accu::compute< accu::nil >(ima); // No-op.
-
- // FIXME : what's the difference between
- // accu::compute< accu::max >(ima);
-
- mln_assertion( accu::compute< accu::val<accu::max> >(ima) == 9);
-
-// std::cout << accu::compute< accu::max >(ima)
-// << std::endl;
+ mln_assertion(level::compute(accu::meta::max(), ima) == 9);
+ accu::max_<int> M;
+ mln_assertion(level::compute(M, ima) == 9);
}
diff --git a/milena/tests/accu/mean.cc b/milena/tests/accu/mean.cc
index eca1c04..7cd2ca7 100644
--- a/milena/tests/accu/mean.cc
+++ b/milena/tests/accu/mean.cc
@@ -40,7 +40,7 @@ int main()
using namespace mln;
{
- mln_accu_with_(accu::mean, int) mean;
+ mln_accu_with_(accu::meta::mean, int) mean;
mean.take(10);
mean.take(9);
@@ -58,7 +58,7 @@ int main()
}
{
- mln_accu_with_(accu::mean, int) mean;
+ mln_accu_with_(accu::meta::mean, int) mean;
mean.take(10);
mean.take(8);
diff --git a/milena/tests/accu/min.cc b/milena/tests/accu/min.cc
index e3769b8..0eba5ab 100644
--- a/milena/tests/accu/min.cc
+++ b/milena/tests/accu/min.cc
@@ -47,15 +47,8 @@ int main()
using namespace mln;
image2d<int> ima(3, 3);
debug::iota(ima);
- mln_assertion(level::compute< accu::min >(ima) == 1);
- mln_assertion(level::compute< accu::min_<int> >(ima) == 1);
+ mln_assertion(level::compute(accu::meta::min(), ima) == 1);
-// accu::compute< accu::nil >(ima); // No-op.
-
-// accu::compute< accu::min >(ima);
-
- mln_assertion(accu::compute< accu::val<accu::min> >(ima) == 1);
-
-// std::cout << accu::compute< accu::min >(ima)
-// << std::endl;
+ accu::min_<int> m;
+ mln_assertion(level::compute(m, ima) == 1);
}
diff --git a/milena/tests/accu/min_max.cc b/milena/tests/accu/min_max.cc
index cdcdb63..74b1ad0 100644
--- a/milena/tests/accu/min_max.cc
+++ b/milena/tests/accu/min_max.cc
@@ -40,7 +40,7 @@ int main()
using namespace mln;
{
- mln_accu_with_(accu::min_max, int) accu;
+ mln_accu_with_(accu::meta::min_max, int) accu;
accu.take(7);
@@ -49,7 +49,7 @@ int main()
}
{
- mln_accu_with_(accu::min_max, int) accu;
+ mln_accu_with_(accu::meta::min_max, int) accu;
accu.take(10);
accu.take(9);
diff --git a/milena/tests/accu/nil.cc b/milena/tests/accu/nil.cc
index 5ae0826..f2421ff 100644
--- a/milena/tests/accu/nil.cc
+++ b/milena/tests/accu/nil.cc
@@ -41,6 +41,9 @@ int main()
{
using namespace mln;
image2d<value::int_u8> ima(3, 3);
- accu::nil a;
- level::compute<accu::nil>(ima);
+
+ accu::nil_<value::int_u8> a;
+ level::compute(a, ima);
+
+ level::compute(accu::meta::nil(), ima);
}
--
1.5.6.5
1
0
---
milena/ChangeLog | 7 ++
milena/mln/labeling/compute.hh | 207 +++++++++++++++++++++++++++++++++++++
milena/tests/labeling/Makefile.am | 2 +
milena/tests/labeling/compute.cc | 83 +++++++++++++++
4 files changed, 299 insertions(+), 0 deletions(-)
create mode 100644 milena/mln/labeling/compute.hh
create mode 100644 milena/tests/labeling/compute.cc
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 734d001..9ad63cc 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,12 @@
2008-10-14 Guillaume Lazzara <z(a)lrde.epita.fr>
+ Add labeling::compute.
+ * milena/mln/labeling/compute.hh: do it.
+ * milena/tests/labeling/Makefile.am,
+ * milena/tests/labeling/compute.cc: Add the proper test.
+
+2008-10-14 Guillaume Lazzara <z(a)lrde.epita.fr>
+
Use geom::bbox instead of bbox().
* milena/mln/geom/max_col.hh,
* milena/mln/geom/max_row.hh,
diff --git a/milena/mln/labeling/compute.hh b/milena/mln/labeling/compute.hh
new file mode 100644
index 0000000..d579c7e
--- /dev/null
+++ b/milena/mln/labeling/compute.hh
@@ -0,0 +1,207 @@
+// Copyright (C) 2008 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library 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 this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library 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_LABELING_COMPUTE_HH
+# define MLN_LABELING_COMPUTE_HH
+
+/*! \file mln/labeling/compute.hh
+ *
+ * \brief Compute an accumulator onto image pixel values.
+ */
+
+# include <mln/core/concept/meta_accumulator.hh>
+# include <mln/util/array.hh>
+
+
+
+namespace mln
+{
+
+ namespace labeling
+ {
+
+ /*! Compute an accumulator onto the pixel values of the image \p input.
+ * for each component of the image \p label.
+ *
+ * \param[in] a An accumulator.
+ * \param[in] input The input image.
+ * \param[in] label The labeled image.
+ * \param[in] input The number of component in \p label.
+ * \return A mln::p_array of accumulator result. One result per component in
+ * \p label.
+ *
+ * It fully relies on labeling::update.
+ */
+ template <typename A, typename I, typename J>
+ p_array<mln_result(A)>
+ compute(const Accumulator<A>& a,
+ const Image<I>& input,
+ const Image<J>& label, mln_value(J) nlabels);
+
+ /*! Compute an accumulator onto the pixel values of the image \p input.
+ * for each component of the image \p label.
+ *
+ * \param[in] a A meta-accumulator.
+ * \param[in] input The input image.
+ * \param[in] label The labeled image.
+ * \param[in] input The number of component in \p label.
+ * \return A mln::p_array of accumulator result. One result per component in
+ * \p label.
+ *
+ * It fully relies on labeling::update.
+ */
+ template <typename A, typename I, typename J>
+ p_array<mln_accu_with(A, mln_value(I))::result>
+ compute(const Meta_Accumulator<A>& a,
+ const Image<I>& input,
+ const Image<J>& label, mln_value(J) nlabels);
+
+ /*! Compute an accumulator onto the sites of each component domain of
+ * \p label.
+ *
+ * \param[in] a An accumulator.
+ * \param[in] label The labeled image.
+ * \param[in] input The number of component in \p label.
+ * \return A mln::p_array of accumulator result. One result per component in
+ * \p label.
+ *
+ * It fully relies on labeling::update.
+ */
+ template <typename A, typename J>
+ p_array<mln_result(A)>
+ compute(const Accumulator<A>& a,
+ const Image<J>& label, mln_value(J) nlabels);
+
+ /*! Compute an accumulator onto the sites of each component domain of
+ * \p label.
+ *
+ * \param[in] a A meta-accumulator.
+ * \param[in] label The labeled image.
+ * \param[in] input The number of component in \p label.
+ * \return A mln::p_array of accumulator result. One result per component in
+ * \p label.
+ *
+ * It fully relies on labeling::update.
+ */
+ template <typename A, typename J>
+ p_array<mln_accu_with(A, mln_psite(J))::result>
+ compute(const Meta_Accumulator<A>& a,
+ const Image<J>& label, mln_value(J) nlabels);
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+
+ // Facades.
+
+ template <typename A, typename I, typename J>
+ inline
+ p_array<mln_result(A)>
+ compute(const Accumulator<A>&,
+ const Image<I>& input_,
+ const Image<J>& label_, mln_value(J) nlabels)
+ {
+ trace::entering("labeling::compute");
+
+ const I& input = exact(input_);
+ const J& label = exact(label_);
+
+ util::array<A> accus;
+ for (mln_value(J) i = 0; i <= nlabels; ++i)
+ accus.append(A());
+
+ mln_piter(I) p(input.domain());
+ for_all(p)
+ accus[label(p)].take(input(p));
+
+ p_array<mln_result(A)> results;
+ for (unsigned i = 0; i < accus.nelements(); ++i)
+ results.append(accus[i]);
+
+ trace::exiting("labeling::compute");
+ return results;
+ }
+
+ template <typename A, typename I, typename J>
+ inline
+ p_array<mln_accu_with(A, mln_value(I))::result>
+ compute(const Meta_Accumulator<A>&,
+ const Image<I>& input,
+ const Image<J>& label, mln_value(J) nlabels)
+ {
+ mln_accu_with(A, mln_value(I)) accu;
+ return compute(accu, input, label, nlabels);
+ }
+
+
+ template <typename A, typename J>
+ inline
+ p_array<mln_result(A)>
+ compute(const Accumulator<A>& a,
+ const Image<J>& label_, mln_value(J) nlabels)
+ {
+ trace::entering("labeling::compute");
+
+ const J& label = exact(label_);
+
+ util::array<A> accus;
+ for (mln_value(J) i = 0; i <= nlabels; ++i)
+ accus.append(exact(a));
+
+ mln_piter(J) p(label.domain());
+ for_all(p)
+ accus[label(p)].take(p);
+
+ p_array<mln_result(A)> results;
+ for (unsigned i = 0; i < accus.nelements(); ++i)
+ results.append(accus[i]);
+
+ trace::exiting("labeling::compute");
+ return results;
+ }
+
+
+ template <typename A, typename J>
+ inline
+ p_array<mln_accu_with(A, mln_psite(J))::result>
+ compute(const Meta_Accumulator<A>&,
+ const Image<J>& label, mln_value(J) nlabels)
+ {
+ mln_accu_with(A, mln_psite(J)) accu;
+ return compute(accu, label, nlabels);
+ }
+
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::labeling
+
+} // end of namespace mln
+
+
+#endif // ! MLN_LABELING_COMPUTE_HH
diff --git a/milena/tests/labeling/Makefile.am b/milena/tests/labeling/Makefile.am
index 212eb15..399a1eb 100644
--- a/milena/tests/labeling/Makefile.am
+++ b/milena/tests/labeling/Makefile.am
@@ -5,6 +5,7 @@ include $(top_srcdir)/milena/tests/tests.mk
check_PROGRAMS = \
background \
blobs \
+ compute \
flat_zones \
foreground \
level \
@@ -13,6 +14,7 @@ check_PROGRAMS = \
background_SOURCES = background.cc
blobs_SOURCES = blobs.cc
+compute_SOURCES = compute.cc
flat_zones_SOURCES = flat_zones.cc
foreground_SOURCES = foreground.cc
level_SOURCES = level.cc
diff --git a/milena/tests/labeling/compute.cc b/milena/tests/labeling/compute.cc
new file mode 100644
index 0000000..cd36ae3
--- /dev/null
+++ b/milena/tests/labeling/compute.cc
@@ -0,0 +1,83 @@
+// Copyright (C) 2008 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library 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 this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library 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.
+
+/*! \file tests/labeling/compute.cc
+ *
+ * \brief Tests on mln::labeling::compute.
+ */
+
+#include <mln/core/image/image2d.hh>
+#include <mln/core/alias/neighb2d.hh>
+#include <mln/labeling/blobs.hh>
+#include <mln/labeling/compute.hh>
+#include <mln/accu/count.hh>
+#include <mln/accu/sum.hh>
+#include <mln/value/int_u8.hh>
+
+int main()
+{
+ using namespace mln;
+ using value::int_u8;
+
+ int_u8 vals[6][5] = {
+ {0, 1, 1, 0, 0},
+ {0, 1, 1, 0, 0},
+ {0, 0, 0, 0, 0},
+ {2, 2, 0, 3, 0},
+ {2, 0, 3, 3, 3},
+ {2, 0, 0, 0, 0}
+ };
+ image2d<int_u8> ima = make::image2d(vals);
+ int_u8 nlabels = 3;
+
+ accu::sum_<int_u8> sum;
+ p_array<float> sums = labeling::compute(sum, ima, ima, nlabels);
+ mln_assertion(sums[0] == 0);
+ mln_assertion(sums[1] == 4);
+ mln_assertion(sums[2] == 8);
+ mln_assertion(sums[3] == 12);
+
+ sums = labeling::compute(accu::meta::sum(), ima, ima, nlabels);
+ mln_assertion(sums[0] == 0);
+ mln_assertion(sums[1] == 4);
+ mln_assertion(sums[2] == 8);
+ mln_assertion(sums[3] == 12);
+
+ accu::count_<mln_site_(image2d<int_u8>)> count;
+ p_array<unsigned int> counts = labeling::compute(count, ima, nlabels);
+ mln_assertion(counts[0] == 18);
+ mln_assertion(counts[1] == 4);
+ mln_assertion(counts[2] == 4);
+ mln_assertion(counts[3] == 4);
+
+ counts = labeling::compute(accu::meta::count(), ima, nlabels);
+ mln_assertion(counts[0] == 18);
+ mln_assertion(counts[1] == 4);
+ mln_assertion(counts[2] == 4);
+ mln_assertion(counts[3] == 4);
+}
+
--
1.5.6.5
1
0
---
milena/ChangeLog | 8 ++++++++
milena/mln/geom/max_col.hh | 3 ++-
milena/mln/geom/max_row.hh | 3 ++-
milena/mln/geom/min_col.hh | 3 ++-
milena/mln/geom/min_row.hh | 3 ++-
5 files changed, 16 insertions(+), 4 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index e1d1927..734d001 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,3 +1,11 @@
+2008-10-14 Guillaume Lazzara <z(a)lrde.epita.fr>
+
+ Use geom::bbox instead of bbox().
+ * milena/mln/geom/max_col.hh,
+ * milena/mln/geom/max_row.hh,
+ * milena/mln/geom/min_col.hh,
+ * milena/mln/geom/min_col.hh: Use geom::bbox().
+
2008-10-14 Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Some fixes on level update and compute.
diff --git a/milena/mln/geom/max_col.hh b/milena/mln/geom/max_col.hh
index fa1b644..31cbb9a 100644
--- a/milena/mln/geom/max_col.hh
+++ b/milena/mln/geom/max_col.hh
@@ -34,6 +34,7 @@
*/
# include <mln/core/concept/image.hh>
+# include <mln/geom/bbox.hh>
namespace mln
@@ -57,7 +58,7 @@ namespace mln
mln_deduce(I, site, coord) max_col(const Image<I>& ima)
{
mln_precondition(exact(ima).has_data());
- return exact(ima).bbox().pmax().col();
+ return geom::bbox(ima).pmax().col();
}
diff --git a/milena/mln/geom/max_row.hh b/milena/mln/geom/max_row.hh
index 1b51db5..5697a4a 100644
--- a/milena/mln/geom/max_row.hh
+++ b/milena/mln/geom/max_row.hh
@@ -34,6 +34,7 @@
*/
# include <mln/core/concept/image.hh>
+# include <mln/geom/bbox.hh>
namespace mln
@@ -58,7 +59,7 @@ namespace mln
mln_coord(I) max_row(const Image<I>& ima)
{
mln_precondition(exact(ima).has_data());
- return exact(ima).bbox().pmax().row();
+ return geom::bbox(ima).pmax().row();
}
diff --git a/milena/mln/geom/min_col.hh b/milena/mln/geom/min_col.hh
index 90fdc4b..6993d6f 100644
--- a/milena/mln/geom/min_col.hh
+++ b/milena/mln/geom/min_col.hh
@@ -34,6 +34,7 @@
*/
# include <mln/core/concept/image.hh>
+# include <mln/geom/bbox.hh>
namespace mln
@@ -58,7 +59,7 @@ namespace mln
mln_coord(I) min_col(const Image<I>& ima)
{
mln_precondition(exact(ima).has_data());
- return exact(ima).bbox().pmin().col();
+ return geom::bbox(ima).pmin().col();
}
diff --git a/milena/mln/geom/min_row.hh b/milena/mln/geom/min_row.hh
index 73089cd..5f2c191 100644
--- a/milena/mln/geom/min_row.hh
+++ b/milena/mln/geom/min_row.hh
@@ -34,6 +34,7 @@
*/
# include <mln/core/concept/image.hh>
+# include <mln/geom/bbox.hh>
# include <mln/metal/bexpr.hh>
# include <mln/metal/int.hh>
@@ -61,7 +62,7 @@ namespace mln
mln_deduce(I, site, coord) min_row(const Image<I>& ima)
{
mln_precondition(exact(ima).has_data());
- return exact(ima).bbox().pmin().row();
+ return geom::bbox(ima).pmin().row();
}
--
1.5.6.5
1
0
https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena/sandbox
Index: ChangeLog
from Ugo Jardonnet <ugo.jardonnet(a)lrde.epita.fr>
INIM Bootstrap Classification.
Bootstrap classification:
* classif/Makefile: New.
* classif/iccvg04.cc: New.
Add test image:
* classif/chiche.pgm: New.
* classif/images/caf_0009.jpg: New.
* classif/images/caf_0028.jpg: New.
* classif/images/edfverso06.JPG: New.
* classif/images/capture.png: New.
* classif/images/vpc_0001.jpg: New.
* classif/images/caf_0010.jpg: New.
* classif/images/caf_0013.jpg: New.
* classif/images/caf_0005.jpg: New.
* classif/images/caf_0034.jpg: New.
* classif/lena.ppm: New.
* classif/scoolNBR.ppm: New.
classif/Makefile | 2
classif/iccvg04.cc | 50
classif/lena.ppm | 541
classif/scoolNBR.ppm |960004
++++++++++++++++++++++++++++++++++++++
jardonnet/registration/center.hh | 7
jardonnet/registration/exp_val.hh | 6
6 files changed, 960601 insertions(+), 9 deletions(-)
Index: jardonnet/registration/exp_val.hh
--- jardonnet/registration/exp_val.hh (revision 2549)
+++ jardonnet/registration/exp_val.hh (working copy)
@@ -58,11 +58,7 @@
algebra::vec<P::dim,float> c(literal::zero);
for (unsigned i = 0; i < a.nsites(); ++i)
- {
- // FIXME : Ugly.
- algebra::vec<P::dim,float> ai = a[i];
- c += ai;
- }
+ c += convert::to< algebra::vec<P::dim,float> > (a[i]);
return c / a.nsites();
}
Index: jardonnet/registration/cross_cov.hh
Index: jardonnet/registration/center.hh
--- jardonnet/registration/center.hh (revision 2549)
+++ jardonnet/registration/center.hh (working copy)
@@ -55,9 +55,8 @@
algebra::vec<P::dim,float> c(literal::zero);
for (unsigned i = 0; i < a.nsites(); ++i)
{
- // FIXME : Ugly.
- algebra::vec<P::dim,float> ai = a[i];
- c += ai;
+ //algebra::vec<P::dim,float> ai = a[i];
+ c += convert::to< algebra::vec<P::dim,float> > (ai);
}
return algebra::to_point<P>(c / a.nsites());
@@ -70,4 +69,4 @@
} // end of namespace mln
-#endif // ! MLN_MATH_ABS_HH
+#endif // ! MLN_GEOM_CENTER_HH
Index: classif/iccvg04.cc
--- classif/iccvg04.cc (revision 0)
+++ classif/iccvg04.cc (revision 0)
@@ -0,0 +1,50 @@
+
+#include <iostream>
+
+#include <mln/core/image/image2d.hh>
+#include <mln/core/image/image3d.hh>
+#include <mln/histo/data.hh>
+#include <mln/value/all.hh>
+
+#include <mln/level/fill.hh>
+
+#include <mln/io/ppm/load.hh>
+
+#include <mln/io/pgm/save.hh>
+
+using namespace mln;
+
+template <typename I>
+mln::image3d<unsigned>
+fill_histo(const I& ima)
+{
+ image3d<unsigned> histo(256,256,256);
+ level::fill(histo, 0);
+
+ mln_piter(I) p(ima.domain());
+ for_all(p)
+ {
+ point3d p3(ima(p).red(),ima(p).green(), ima(p).blue());
+ histo(p3)++;
+ }
+ return histo;
+}
+
+int main(int argc, char **argv)
+{
+ image2d<value::rgb8> ima;
+ ima = io::ppm::load<value::rgb8>(argv[1]);
+
+ image3d<unsigned> histo = fill_histo(ima);
+
+ image2d< value::int_u16 > out(256,256);
+ level::fill(out, 0);
+ mln_piter_(image2d< value::int_u16 >) p(out.domain());
+ for_all(p)
+ {
+ for (unsigned i = 0; i < 256; i++)
+ if ((out(p) + histo(point3d(p[0],p[1],i))) < 65536)
+ out(p) += histo(point3d(p[0],p[1],i));
+ }
+ io::pgm::save(out,"./chiche.pgm");
+}
Index: classif/chiche.pgm
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes on: classif/chiche.pgm
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Index: classif/images/caf_0009.jpg
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes on: classif/images/caf_0009.jpg
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ application/octet-stream
Index: classif/images/caf_0028.jpg
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes on: classif/images/caf_0028.jpg
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ application/octet-stream
Index: classif/images/edfverso06.JPG
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes on: classif/images/edfverso06.JPG
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Index: classif/images/capture.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes on: classif/images/capture.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Index: classif/images/vpc_0001.jpg
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes on: classif/images/vpc_0001.jpg
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ application/octet-stream
Index: classif/images/caf_0010.jpg
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes on: classif/images/caf_0010.jpg
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ application/octet-stream
Index: classif/images/caf_0013.jpg
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes on: classif/images/caf_0013.jpg
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ application/octet-stream
Index: classif/images/caf_0005.jpg
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes on: classif/images/caf_0005.jpg
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ application/octet-stream
Index: classif/images/caf_0034.jpg
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes on: classif/images/caf_0034.jpg
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ application/octet-stream
Index: classif/lena.ppm
--- classif/lena.ppm (revision 0)
+++ classif/lena.ppm (revision 0)
Cannot display
Index: classif/Makefile
--- classif/Makefile (revision 0)
+++ classif/Makefile (revision 0)
@@ -0,0 +1,2 @@
+all:
+ g++ *.cc -I../../ -O3
\ No newline at end of file
1
0