
* levillain/double.cc, levillain/min-max.cc: New. * levillain/Makefile: New. --- milena/sandbox/ChangeLog | 7 +++++ milena/sandbox/levillain/.gitignore | 2 + milena/sandbox/levillain/double.cc | 47 ++++++++++++++++++++++++++++++++++ milena/sandbox/levillain/min-max.cc | 48 +++++++++++++++++++++++++++++++++++ 4 files changed, 104 insertions(+), 0 deletions(-) create mode 100644 milena/sandbox/levillain/.gitignore create mode 100644 milena/sandbox/levillain/double.cc create mode 100644 milena/sandbox/levillain/min-max.cc diff --git a/milena/sandbox/ChangeLog b/milena/sandbox/ChangeLog index dfba024..95e28a5 100644 --- a/milena/sandbox/ChangeLog +++ b/milena/sandbox/ChangeLog @@ -1,3 +1,10 @@ +2009-08-31 Roland Levillain <roland@lrde.epita.fr> + + Add some examples for Laurent. + + * levillain/double.cc, levillain/min-max.cc: New. + * levillain/Makefile: New. + 2009-08-31 Yann Jacquelet <jacquelet@lrde.epita.fr> Write the kmean main loop. diff --git a/milena/sandbox/levillain/.gitignore b/milena/sandbox/levillain/.gitignore new file mode 100644 index 0000000..627984b --- /dev/null +++ b/milena/sandbox/levillain/.gitignore @@ -0,0 +1,2 @@ +double +min-max diff --git a/milena/sandbox/levillain/double.cc b/milena/sandbox/levillain/double.cc new file mode 100644 index 0000000..67e931c --- /dev/null +++ b/milena/sandbox/levillain/double.cc @@ -0,0 +1,47 @@ +#include <mln/value/int_u8.hh> +#include <mln/core/image/image2d.hh> + +#include <mln/debug/iota.hh> +#include <mln/debug/println.hh> + +int main() +{ + using namespace mln; + using mln::value::int_u8; + + image2d<int_u8> ima(5, 5); + debug::iota(ima); + debug::println(ima); + /* ima = + + 1 2 3 4 5 + 6 7 8 9 10 + 11 12 13 14 15 + 16 17 18 19 20 + 21 22 23 24 25 */ + + image2d<int_u8> ima_x2 (10, 10); + mln_piter_(image2d<int_u8>) p(ima_x2.domain()); + for_all(p) + { + /* This conversion from ``piter'' to ``point'' is required, since + an iterator does not expose the interface of the underlying + point (among which the methods row(), col(), etc.). */ + point2d p_ = p; + point2d q(p_.row() / 2, p_.col() / 2); + ima_x2(p) = ima(q); + } + debug::println(ima_x2); + /* ima_x2 = + + 1 1 2 2 3 3 4 4 5 5 + 1 1 2 2 3 3 4 4 5 5 + 6 6 7 7 8 8 9 9 10 10 + 6 6 7 7 8 8 9 9 10 10 + 11 11 12 12 13 13 14 14 15 15 + 11 11 12 12 13 13 14 14 15 15 + 16 16 17 17 18 18 19 19 20 20 + 16 16 17 17 18 18 19 19 20 20 + 21 21 22 22 23 23 24 24 25 25 + 21 21 22 22 23 23 24 24 25 25 */ +} diff --git a/milena/sandbox/levillain/min-max.cc b/milena/sandbox/levillain/min-max.cc new file mode 100644 index 0000000..d9c473a --- /dev/null +++ b/milena/sandbox/levillain/min-max.cc @@ -0,0 +1,48 @@ +#include <iostream> + +#include <mln/value/int_u8.hh> +#include <mln/core/image/image2d.hh> +#include <mln/core/image/dmorph/image_if.hh> + +#include <mln/accu/stat/min_max.hh> + +#include <mln/debug/iota.hh> +#include <mln/debug/println.hh> + +#include <mln/core/var.hh> + +int main() +{ + using namespace mln; + using mln::value::int_u8; + + image2d<int_u8> ima(5, 5); + debug::iota(ima); + /* ima = + + 1 2 3 4 5 + 6 7 8 9 10 + 11 12 13 14 15 + 16 17 18 19 20 + 21 22 23 24 25 */ + + // A region delimited by a box (could also be something more complicated). + point2d x(1, 1); + point2d y(3, 4); + box2d region(x, y); + + // These lines are not really portable, because of `mln_VAR'... + mln_VAR(sub_ima, ima | region); + mln_piter_(sub_ima_t) p(sub_ima.domain()); + /* ...and are a shortcut for this (portable) code: + + typedef sub_image< image2d<int_u8>, box2d > sub_ima_t; + mln_piter_(sub_ima_t) p((ima | region).domain()); + + */ + accu::stat::min_max<int_u8> accu; + for_all(p) + accu.take(ima(p)); + std::cout << "min = " << accu.first() << std::endl; + std::cout << "max = " << accu.second() << std::endl; +} -- 1.6.3.1