olena: olena-2.0-870-g5ea13e3 Remove trash/ directories.

* doc/examples/trash/accu.cc, * doc/examples/trash/box.cc, * doc/examples/trash/cpp_issue.cc, * doc/examples/trash/erosion.cc, * doc/examples/trash/for_Z.cc, * doc/examples/trash/graph.cc, * doc/examples/trash/image2d.cc, * doc/examples/trash/image_flat.cc, * doc/examples/trash/image_if.cc, * doc/examples/trash/image_plain.cc, * doc/examples/trash/image_safe.cc, * doc/examples/trash/labeling_algo.cc, * doc/examples/trash/mk_graph.cc, * doc/examples/trash/p_array.2.cc, * doc/examples/trash/p_array.cc, * doc/examples/trash/p_image.cc, * doc/examples/trash/p_key.2.cc, * doc/examples/trash/p_key.cc, * doc/examples/trash/p_line2d.cc, * doc/examples/trash/p_mutable_array_of.cc, * doc/examples/trash/p_queue.cc, * doc/examples/trash/p_run.cc, * doc/examples/trash/p_vaccess.cc, * doc/examples/trash/proxy.cc, * doc/examples/trash/sub_image.cc, * doc/examples/trash/sub_image_if.cc, * doc/examples/trash/tuto_bis.cc, * doc/examples/trash/tuto_one.cc, * doc/examples/trash/vec.cc, * doc/examples/trash/win_multiple.cc, * doc/examples/trash/window.cc, * trash/bgraph_image.cc, * trash/bgraph_image.hh, * trash/bgraph_psite.hh, * trash/boost_graph.cc, * trash/boost_graph.hh, * trash/boost_graph_access.hh, * trash/boost_graph_property.hh, * trash/boost_graph_structure.hh, * trash/clock_neighb.hh, * trash/clock_neighb2d.cc, * trash/clock_neighb2d.hh, * trash/clock_neighb2d_bis.cc, * trash/display_color_pretty.cc, * trash/display_color_pretty.hh, * trash/display_remove.hh, * trash/display_save.hh, * trash/display_save_and_show.hh, * trash/display_show.cc, * trash/display_show.hh, * trash/fi_adaptor.cc, * trash/fi_adaptor.hh, * trash/freeimageplus.mk, * trash/graph_image.hh, * trash/line_graph_image.hh, * trash/mono_obased_rle_encode.hh, * trash/mono_obased_rle_image.cc, * trash/mono_obased_rle_image.hh, * trash/mono_rle_encode.hh, * trash/mono_rle_image.cc, * trash/mono_rle_image.hh, * trash/neighb_get.hh, * trash/neighb_image.cc, * trash/neighb_image.hh, * trash/obased_rle_encode.hh, * trash/obased_rle_image.cc, * trash/obased_rle_image.hh, * trash/p_bgraph.cc, * trash/p_bgraph.hh, * trash/p_bgraph_piter.hh, * trash/rle_encode.hh, * trash/rle_image.cc, * trash/rle_image.hh, * trash/save_and_show.cc, * trash/sparse_encode.hh, * trash/sparse_image.cc, * trash/sparse_image.hh, * trash/t_image.cc, * trash/t_image.hh, * trash/to_tiles.cc, * trash/to_tiles.hh, * trash/translate_image.cc, * trash/translate_image.hh, * trash/value_enc_image.cc, * trash/value_enc_image.hh, * trash/value_encode.hh: Remove. Addresses Trac ticket #280. --- milena/ChangeLog | 93 +++++ milena/doc/examples/trash/accu.cc | 20 - milena/doc/examples/trash/box.cc | 36 -- milena/doc/examples/trash/cpp_issue.cc | 29 -- milena/doc/examples/trash/erosion.cc | 106 ----- milena/doc/examples/trash/for_Z.cc | 224 ----------- milena/doc/examples/trash/graph.cc | 159 -------- milena/doc/examples/trash/image2d.cc | 82 ---- milena/doc/examples/trash/image_flat.cc | 12 - milena/doc/examples/trash/image_if.cc | 93 ----- milena/doc/examples/trash/image_plain.cc | 42 -- milena/doc/examples/trash/image_safe.cc | 24 -- milena/doc/examples/trash/labeling_algo.cc | 80 ---- milena/doc/examples/trash/mk_graph.cc | 91 ----- milena/doc/examples/trash/p_array.2.cc | 93 ----- milena/doc/examples/trash/p_array.cc | 103 ----- milena/doc/examples/trash/p_image.cc | 52 --- milena/doc/examples/trash/p_key.2.cc | 34 -- milena/doc/examples/trash/p_key.cc | 96 ----- milena/doc/examples/trash/p_line2d.cc | 34 -- milena/doc/examples/trash/p_mutable_array_of.cc | 60 --- milena/doc/examples/trash/p_queue.cc | 93 ----- milena/doc/examples/trash/p_run.cc | 48 --- milena/doc/examples/trash/p_vaccess.cc | 157 -------- milena/doc/examples/trash/proxy.cc | 105 ----- milena/doc/examples/trash/sub_image.cc | 29 -- milena/doc/examples/trash/sub_image_if.cc | 101 ----- milena/doc/examples/trash/tuto_bis.cc | 273 ------------- milena/doc/examples/trash/tuto_one.cc | 128 ------ milena/doc/examples/trash/vec.cc | 14 - milena/doc/examples/trash/win_multiple.cc | 65 ---- milena/doc/examples/trash/window.cc | 92 ----- milena/trash/bgraph_image.cc | 105 ----- milena/trash/bgraph_image.hh | 288 -------------- milena/trash/bgraph_psite.hh | 176 --------- milena/trash/boost_graph.cc | 114 ------ milena/trash/boost_graph.hh | 218 ----------- milena/trash/boost_graph_access.hh | 292 -------------- milena/trash/boost_graph_property.hh | 170 -------- milena/trash/boost_graph_structure.hh | 288 -------------- milena/trash/clock_neighb.hh | 168 -------- milena/trash/clock_neighb2d.cc | 90 ----- milena/trash/clock_neighb2d.hh | 199 ---------- milena/trash/clock_neighb2d_bis.cc | 199 ---------- milena/trash/display_color_pretty.cc | 90 ----- milena/trash/display_color_pretty.hh | 221 ----------- milena/trash/display_remove.hh | 90 ----- milena/trash/display_save.hh | 132 ------- milena/trash/display_save_and_show.hh | 97 ----- milena/trash/display_show.cc | 86 ---- milena/trash/display_show.hh | 131 ------- milena/trash/fi_adaptor.cc | 87 ----- milena/trash/fi_adaptor.hh | 476 ----------------------- milena/trash/freeimageplus.mk | 9 - milena/trash/graph_image.hh | 300 -------------- milena/trash/line_graph_image.hh | 344 ---------------- milena/trash/mono_obased_rle_encode.hh | 120 ------ milena/trash/mono_obased_rle_image.cc | 78 ---- milena/trash/mono_obased_rle_image.hh | 266 ------------- milena/trash/mono_rle_encode.hh | 108 ----- milena/trash/mono_rle_image.cc | 84 ---- milena/trash/mono_rle_image.hh | 254 ------------ milena/trash/neighb_get.hh | 190 --------- milena/trash/neighb_image.cc | 57 --- milena/trash/neighb_image.hh | 255 ------------ milena/trash/obased_rle_encode.hh | 120 ------ milena/trash/obased_rle_image.cc | 78 ---- milena/trash/obased_rle_image.hh | 289 -------------- milena/trash/p_bgraph.cc | 85 ---- milena/trash/p_bgraph.hh | 220 ----------- milena/trash/p_bgraph_piter.hh | 245 ------------ milena/trash/rle_encode.hh | 113 ------ milena/trash/rle_image.cc | 78 ---- milena/trash/rle_image.hh | 230 ----------- milena/trash/save_and_show.cc | 79 ---- milena/trash/sparse_encode.hh | 118 ------ milena/trash/sparse_image.cc | 79 ---- milena/trash/sparse_image.hh | 261 ------------- milena/trash/t_image.cc | 53 --- milena/trash/t_image.hh | 304 --------------- milena/trash/to_tiles.cc | 88 ----- milena/trash/to_tiles.hh | 98 ----- milena/trash/translate_image.cc | 74 ---- milena/trash/translate_image.hh | 209 ---------- milena/trash/value_enc_image.cc | 155 -------- milena/trash/value_enc_image.hh | 254 ------------ milena/trash/value_encode.hh | 113 ------ 87 files changed, 93 insertions(+), 11700 deletions(-) delete mode 100644 milena/doc/examples/trash/accu.cc delete mode 100644 milena/doc/examples/trash/box.cc delete mode 100644 milena/doc/examples/trash/cpp_issue.cc delete mode 100644 milena/doc/examples/trash/erosion.cc delete mode 100644 milena/doc/examples/trash/for_Z.cc delete mode 100644 milena/doc/examples/trash/graph.cc delete mode 100644 milena/doc/examples/trash/image2d.cc delete mode 100644 milena/doc/examples/trash/image_flat.cc delete mode 100644 milena/doc/examples/trash/image_if.cc delete mode 100644 milena/doc/examples/trash/image_plain.cc delete mode 100644 milena/doc/examples/trash/image_safe.cc delete mode 100644 milena/doc/examples/trash/labeling_algo.cc delete mode 100644 milena/doc/examples/trash/mk_graph.cc delete mode 100644 milena/doc/examples/trash/p_array.2.cc delete mode 100644 milena/doc/examples/trash/p_array.cc delete mode 100644 milena/doc/examples/trash/p_image.cc delete mode 100644 milena/doc/examples/trash/p_key.2.cc delete mode 100644 milena/doc/examples/trash/p_key.cc delete mode 100644 milena/doc/examples/trash/p_line2d.cc delete mode 100644 milena/doc/examples/trash/p_mutable_array_of.cc delete mode 100644 milena/doc/examples/trash/p_queue.cc delete mode 100644 milena/doc/examples/trash/p_run.cc delete mode 100644 milena/doc/examples/trash/p_vaccess.cc delete mode 100644 milena/doc/examples/trash/proxy.cc delete mode 100644 milena/doc/examples/trash/sub_image.cc delete mode 100644 milena/doc/examples/trash/sub_image_if.cc delete mode 100644 milena/doc/examples/trash/tuto_bis.cc delete mode 100644 milena/doc/examples/trash/tuto_one.cc delete mode 100644 milena/doc/examples/trash/vec.cc delete mode 100644 milena/doc/examples/trash/win_multiple.cc delete mode 100644 milena/doc/examples/trash/window.cc delete mode 100644 milena/trash/bgraph_image.cc delete mode 100644 milena/trash/bgraph_image.hh delete mode 100644 milena/trash/bgraph_psite.hh delete mode 100644 milena/trash/boost_graph.cc delete mode 100644 milena/trash/boost_graph.hh delete mode 100644 milena/trash/boost_graph_access.hh delete mode 100644 milena/trash/boost_graph_property.hh delete mode 100644 milena/trash/boost_graph_structure.hh delete mode 100644 milena/trash/clock_neighb.hh delete mode 100644 milena/trash/clock_neighb2d.cc delete mode 100644 milena/trash/clock_neighb2d.hh delete mode 100644 milena/trash/clock_neighb2d_bis.cc delete mode 100644 milena/trash/display_color_pretty.cc delete mode 100644 milena/trash/display_color_pretty.hh delete mode 100644 milena/trash/display_remove.hh delete mode 100644 milena/trash/display_save.hh delete mode 100644 milena/trash/display_save_and_show.hh delete mode 100644 milena/trash/display_show.cc delete mode 100644 milena/trash/display_show.hh delete mode 100644 milena/trash/fi_adaptor.cc delete mode 100644 milena/trash/fi_adaptor.hh delete mode 100644 milena/trash/freeimageplus.mk delete mode 100644 milena/trash/graph_image.hh delete mode 100644 milena/trash/line_graph_image.hh delete mode 100644 milena/trash/mono_obased_rle_encode.hh delete mode 100644 milena/trash/mono_obased_rle_image.cc delete mode 100644 milena/trash/mono_obased_rle_image.hh delete mode 100644 milena/trash/mono_rle_encode.hh delete mode 100644 milena/trash/mono_rle_image.cc delete mode 100644 milena/trash/mono_rle_image.hh delete mode 100644 milena/trash/neighb_get.hh delete mode 100644 milena/trash/neighb_image.cc delete mode 100644 milena/trash/neighb_image.hh delete mode 100644 milena/trash/obased_rle_encode.hh delete mode 100644 milena/trash/obased_rle_image.cc delete mode 100644 milena/trash/obased_rle_image.hh delete mode 100644 milena/trash/p_bgraph.cc delete mode 100644 milena/trash/p_bgraph.hh delete mode 100644 milena/trash/p_bgraph_piter.hh delete mode 100644 milena/trash/rle_encode.hh delete mode 100644 milena/trash/rle_image.cc delete mode 100644 milena/trash/rle_image.hh delete mode 100644 milena/trash/save_and_show.cc delete mode 100644 milena/trash/sparse_encode.hh delete mode 100644 milena/trash/sparse_image.cc delete mode 100644 milena/trash/sparse_image.hh delete mode 100644 milena/trash/t_image.cc delete mode 100644 milena/trash/t_image.hh delete mode 100644 milena/trash/to_tiles.cc delete mode 100644 milena/trash/to_tiles.hh delete mode 100644 milena/trash/translate_image.cc delete mode 100644 milena/trash/translate_image.hh delete mode 100644 milena/trash/value_enc_image.cc delete mode 100644 milena/trash/value_enc_image.hh delete mode 100644 milena/trash/value_encode.hh diff --git a/milena/ChangeLog b/milena/ChangeLog index d1c7a4b..bd63611 100644 --- a/milena/ChangeLog +++ b/milena/ChangeLog @@ -1,3 +1,96 @@ +2014-06-20 Roland Levillain <roland@lrde.epita.fr> + + Remove trash/ directories. + + * doc/examples/trash/accu.cc, + * doc/examples/trash/box.cc, + * doc/examples/trash/cpp_issue.cc, + * doc/examples/trash/erosion.cc, + * doc/examples/trash/for_Z.cc, + * doc/examples/trash/graph.cc, + * doc/examples/trash/image2d.cc, + * doc/examples/trash/image_flat.cc, + * doc/examples/trash/image_if.cc, + * doc/examples/trash/image_plain.cc, + * doc/examples/trash/image_safe.cc, + * doc/examples/trash/labeling_algo.cc, + * doc/examples/trash/mk_graph.cc, + * doc/examples/trash/p_array.2.cc, + * doc/examples/trash/p_array.cc, + * doc/examples/trash/p_image.cc, + * doc/examples/trash/p_key.2.cc, + * doc/examples/trash/p_key.cc, + * doc/examples/trash/p_line2d.cc, + * doc/examples/trash/p_mutable_array_of.cc, + * doc/examples/trash/p_queue.cc, + * doc/examples/trash/p_run.cc, + * doc/examples/trash/p_vaccess.cc, + * doc/examples/trash/proxy.cc, + * doc/examples/trash/sub_image.cc, + * doc/examples/trash/sub_image_if.cc, + * doc/examples/trash/tuto_bis.cc, + * doc/examples/trash/tuto_one.cc, + * doc/examples/trash/vec.cc, + * doc/examples/trash/win_multiple.cc, + * doc/examples/trash/window.cc, + * trash/bgraph_image.cc, + * trash/bgraph_image.hh, + * trash/bgraph_psite.hh, + * trash/boost_graph.cc, + * trash/boost_graph.hh, + * trash/boost_graph_access.hh, + * trash/boost_graph_property.hh, + * trash/boost_graph_structure.hh, + * trash/clock_neighb.hh, + * trash/clock_neighb2d.cc, + * trash/clock_neighb2d.hh, + * trash/clock_neighb2d_bis.cc, + * trash/display_color_pretty.cc, + * trash/display_color_pretty.hh, + * trash/display_remove.hh, + * trash/display_save.hh, + * trash/display_save_and_show.hh, + * trash/display_show.cc, + * trash/display_show.hh, + * trash/fi_adaptor.cc, + * trash/fi_adaptor.hh, + * trash/freeimageplus.mk, + * trash/graph_image.hh, + * trash/line_graph_image.hh, + * trash/mono_obased_rle_encode.hh, + * trash/mono_obased_rle_image.cc, + * trash/mono_obased_rle_image.hh, + * trash/mono_rle_encode.hh, + * trash/mono_rle_image.cc, + * trash/mono_rle_image.hh, + * trash/neighb_get.hh, + * trash/neighb_image.cc, + * trash/neighb_image.hh, + * trash/obased_rle_encode.hh, + * trash/obased_rle_image.cc, + * trash/obased_rle_image.hh, + * trash/p_bgraph.cc, + * trash/p_bgraph.hh, + * trash/p_bgraph_piter.hh, + * trash/rle_encode.hh, + * trash/rle_image.cc, + * trash/rle_image.hh, + * trash/save_and_show.cc, + * trash/sparse_encode.hh, + * trash/sparse_image.cc, + * trash/sparse_image.hh, + * trash/t_image.cc, + * trash/t_image.hh, + * trash/to_tiles.cc, + * trash/to_tiles.hh, + * trash/translate_image.cc, + * trash/translate_image.hh, + * trash/value_enc_image.cc, + * trash/value_enc_image.hh, + * trash/value_encode.hh: + Remove. + Addresses Trac ticket #280. + 2014-06-19 Roland Levillain <roland@lrde.epita.fr> Re-enable Milena test world/inter_pixel/display_edge. diff --git a/milena/doc/examples/trash/accu.cc b/milena/doc/examples/trash/accu.cc deleted file mode 100644 index 6c4ee5d..0000000 --- a/milena/doc/examples/trash/accu.cc +++ /dev/null @@ -1,20 +0,0 @@ -# include <mln/accu/stat/mean.hh> - - -int main() -{ - using namespace mln; - - mlc_bool(accu::stat::mean<int>::proxy_level == 1)::check(); - - accu::stat::mean<int> m; - m.take(100); - m.take(2); - mln_assertion(m == 51); - - // Just for fun: - mln_assertion(literal::zero != m); - mln_assertion(m != literal::zero); - - std::cout << (-m) << std::endl; -} diff --git a/milena/doc/examples/trash/box.cc b/milena/doc/examples/trash/box.cc deleted file mode 100644 index 7f92bdc..0000000 --- a/milena/doc/examples/trash/box.cc +++ /dev/null @@ -1,36 +0,0 @@ -# include <mln/core/image/image2d.hh> -# include <mln/debug/println.hh> -# include <mln/data/fill.hh> - - -template <typename B> -void picture(const B& b) -{ - using namespace mln; - - image2d<char> ima(5, 5); - data::fill(ima, '-'); - - unsigned i = 0; - mln_piter(B) p(b); - for_all(p) - ima(p) = '0' + i++; - - debug::println(ima); -} - - - -int main() -{ - using namespace mln; - - { - box2d b = make::box2d(2, 3); - picture(b); - } - { - box2d b = make::box2d(1,1, 3,2); - picture(b); - } -} diff --git a/milena/doc/examples/trash/cpp_issue.cc b/milena/doc/examples/trash/cpp_issue.cc deleted file mode 100644 index 7f42a01..0000000 --- a/milena/doc/examples/trash/cpp_issue.cc +++ /dev/null @@ -1,29 +0,0 @@ - -template <typename E> -struct base -{ - typedef const E& box; - typedef const E& box_; - box bbox() const { return *(E*)(void*)(this); } -}; - - -struct box : base<box> -{ - box() {} -}; - - -template <typename S> -void foo(const S&) -{ - typename S::box b; -// void* v = b; - typename S::box_ b_; -} - -int main() -{ - box b; - foo(b); -} diff --git a/milena/doc/examples/trash/erosion.cc b/milena/doc/examples/trash/erosion.cc deleted file mode 100644 index a49917e..0000000 --- a/milena/doc/examples/trash/erosion.cc +++ /dev/null @@ -1,106 +0,0 @@ -// Copyright (C) 2008 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. - -/// \file doc/examples/erosion.cc -/// -/// Test on mln::morpho::hit_or_miss. - -# include <mln/core/image/image2d.hh> - -# include <mln/core/image/image_if.hh> -# include <mln/core/image/sub_image.hh> -# include <mln/core/alias/neighb2d.hh> -# include <mln/core/var.hh> -# include <mln/core/site_set/p_vaccess.hh> - -# include <mln/binarization/threshold.hh> -# include <mln/morpho/hit_or_miss.hh> -# include <mln/border/fill.hh> -# include <mln/io/pbm/load.hh> -# include <mln/io/pgm/load.hh> -# include <mln/io/pbm/save.hh> -# include <mln/io/pgm/save.hh> -# include <mln/debug/println.hh> -# include <mln/morpho/opening.hh> -# include <mln/trait/value_.hh> -# include <mln/value/int_u8.hh> -# include <mln/data/paste.hh> -# include <mln/labeling/blobs.hh> -# include <mln/pw/all.hh> -# 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::label_8; - - label_8 nlabels; - image2d<label_8> lbl = labeling::blobs(ima, c4(), nlabels); - - for (unsigned i = nlabels; i > 0; --i) - { - data::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; - - if (argc < 2) - { - std::cout << argv[0] << " <image.pgm> <height> <width>" << std::endl; - return 1; - } - - image2d<bool> in; - io::pbm::load(in, argv[1]); - - unsigned h = atoi(argv[2]); - unsigned w = atoi(argv[3]); - unsigned n = atoi(argv[4]); - - // Remove vertical lines. - win::rectangle2d vwin(h, w); - image2d<bool> vout = morpho::opening(in, vwin); - io::pbm::save(vout, "./vout.pbm"); - clean_lines(in, vout, n); - - // Remove Horizontal lines. - 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, "./out.pbm"); -} diff --git a/milena/doc/examples/trash/for_Z.cc b/milena/doc/examples/trash/for_Z.cc deleted file mode 100644 index 3b34a72..0000000 --- a/milena/doc/examples/trash/for_Z.cc +++ /dev/null @@ -1,224 +0,0 @@ -# include <mln/core/image/image2d.hh> - -# include <mln/core/image/image_if.hh> -# include <mln/core/image/sub_image.hh> - -# include <mln/core/site_set/p_vaccess.hh> -# include <mln/convert/from_to.hh> -# include <mln/core/alias/p_runs2d.hh> - -# include <mln/core/alias/neighb2d.hh> -# include <mln/core/var.hh> -# include <mln/value/int_u8.hh> -# include <mln/value/rgb8.hh> -# include <mln/literal/colors.hh> - -# include <mln/pw/all.hh> -# include <mln/convert/to_fun.hh> -# include <mln/debug/println.hh> -# include <mln/labeling/blobs.hh> -# include <mln/data/fill.hh> -# include <mln/geom/bbox.hh> - - -namespace mln -{ - - namespace trait - { - -// template <template <class, class> class Op, -// typename F, typename S> -// struct set_binary_< Op, mln::Function_v2v, F, mln::value::Scalar, S > -// { -// typedef Op< F, pw::cst_<mln_value_equiv(S)> > Op_; -// typedef typename Op_::ret ret; -// }; - - template <template <class, class> class Op, - typename F, - typename R, typename A> - struct set_precise_binary_< Op, F, R (*)(A) > - { - typedef Op< F, fun::C<R (*)(A)> > Op_; - typedef typename Op_::ret ret; - }; - - template <typename F, typename S> - struct set_binary_< op::eq, mln::Function_v2v, F, mln::value::Scalar, S > - { - typedef mln_trait_op_eq(F, pw::cst_<mln_value_equiv(S)>) ret; - }; - - - // const Image | Function_v2v - -// template <typename I, typename F> -// struct set_binary_< op::lor, mln::Image, /* FIXME: const */ I, mln::Function_v2v, F > -// { -// typedef image_if<const I, F> ret; -// }; - - } // end of namespace mln::trait - - - template <typename F, typename S> - mln_trait_op_eq(F,S) - operator == (const Function_v2v<F>& fun, const value::Scalar<S>& s) - { - return exact(fun) == pw::cst( value::equiv(s) ); - } - - - template <typename I, typename R, typename A> - image_if< const I, fun::C<R(*)(A)> > - operator | (const Image<I>& ima, R (*f)(A) ) - { - return exact(ima) | convert::to_fun(f); - } - - -// template <typename O, typename R, typename A> -// mln_trait_op_lor(const O, fun::C<R(*)(A)>) -// operator | (const Object<O>& lhs, R (*rhs)(A) ) -// { -// return exact(lhs) | convert::to_fun(rhs); -// } - -} // end of namespace mln - - -bool row_oddity(mln::point2d p) -{ - return p.row() % 2; -} - - - -namespace my -{ - - template <typename I> - void fill(I& ima, mln_value(I) v) - { - mln_piter(I) p(ima.domain()); - for_all(p) - ima(p) = v; - } - - template <typename I, typename J> - void paste(const I& data, J& dest) - { - mln_piter(I) p(data.domain()); - for_all(p) - dest(p) = data(p); - } - -} // end of namespace my - - - - - -int main() -{ - using namespace mln; - using value::int_u8; - using value::rgb8; - - - bool vals[6][5] = { - {0, 1, 1, 0, 0}, - {0, 1, 1, 0, 0}, - {0, 0, 0, 0, 0}, - {1, 1, 0, 1, 0}, - {1, 0, 1, 1, 1}, - {1, 0, 0, 0, 0} - }; - image2d<bool> ima = make::image(vals); - debug::println(ima); - - int_u8 nlabels; - image2d<int_u8> lab = labeling::blobs(ima, c4(), nlabels); - debug::println(lab); - - - mln_VAR(lab_0, lab | (pw::value(lab) != 0u)); - debug::println(lab_0); - - -// box2d b3 = geom::bbox(lab | (pw::value(lab) == 3u)); -// std::cout << b3 << std::endl -// << std::endl; - -// // mln_VAR(lab3, lab | b3); -// // debug::println(lab3); -// // std::cout << lab3.domain() << std::endl -// // << std::endl; - - -// { -// std::cout << "(ima | sub_D) | pred" << std::endl << std::endl; - -// mln_VAR(pred, pw::value(lab) == 3u); - -// std::cout << (lab | b3).domain() << std::endl; -// debug::println(lab | b3); - -// std::cout << ((lab | b3) | pred).domain() << std::endl; -// debug::println((lab | b3) | pred); -// } - - -// // il existe une difference entre: -// // -// // - ima | sub_D ou le sub_D DOIT etre inclus dans ima.domain -// // et -// // - ima / sub_D qui reste a ecrire... -// // ou dans ce cas, on aurait (ima / sub_D).domain() == sub_D | f:p->b = ima.domain().has(p) - - -// { -// std::cout << "(ima | pred) | sub_D" << std::endl << std::endl; - -// mln_VAR(pred, pw::value(lab) == 3u); - -// // OK :-) -// std::cout << (lab | pred).domain() << std::endl; -// debug::println(lab | pred); - -// // KO :-) -// // Cf. commentaire plus haut -// // ici l'erreur est que b3 n'est pas un sous-domaine de celui de "lab | pred"... -// /* -// std::cout << ((lab | pred) | b3).domain() << std::endl; -// debug::println((lab | pred) | b3); -// */ -// } - - -// debug::println(lab | row_oddity); - -// my::fill(lab_0, 9); -// debug::println(lab_0); -// debug::println(lab); - - -// image2d<rgb8> cool(ima.domain()); -// data::fill(cool, literal::black); - -// data::fill( (cool | (pw::value(lab) == 1u)).rw(), -// literal::red ); - -// debug::println(cool); - - - { - p_vaccess< int_u8, p_runs2d > s; - convert::from_to(lab_0, s); - std::cout << s << std::endl; - std::cout << s(3) << std::endl; - std::cout << s(3).bbox() << std::endl; - } - -} diff --git a/milena/doc/examples/trash/graph.cc b/milena/doc/examples/trash/graph.cc deleted file mode 100644 index d712e69..0000000 --- a/milena/doc/examples/trash/graph.cc +++ /dev/null @@ -1,159 +0,0 @@ -// Copyright (C) 2008 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 <cmath> -#include <mln/essential/2d.hh> -#include <mln/transform/influence_zone_geodesic.hh> -#include <mln/make/graph.hh> -#include <mln/util/graph.hh> -#include <mln/util/line_graph.hh> -#include <mln/debug/draw_graph.hh> -#include <mln/debug/colorize.hh> - - -template <typename P> -struct lg_vertex_values : public mln::Function_v2v< lg_vertex_values<P> > -{ - typedef float result; - - float operator()(const P& p) const - { - mln::algebra::vec<2,float> v; - v[0] = 0; - v[1] = 1; - float norm = mln::math::sqrt(std::pow(p.to_vec()[0], 2) - + std::pow(p.to_vec()[1], 2)); - // FIXME: missing proxy_impl for point and line2d? - float res = (v * p.to_vec()) / norm; - return res; - } - -}; - - - -int main(int argc, char *argv[]) -{ - using namespace mln; - using value::label_16; - using value::rgb8; - - if (argc < 2) - { - std::cout << "Usage: " << argv[0] << " <image> <max cosinus>" << std::endl; - return 1; - } - - float max_cos = atof(argv[2]); - - image2d<bool> ima; - io::pbm::load(ima, argv[1]); - logical::not_inplace(ima); - - label_16 nlabels; - image2d<label_16> lbl = labeling::blobs(ima, c8(), nlabels); - -#ifndef NOUT - io::ppm::save(debug::colorize(rgb8(), lbl, nlabels), "01-lbl.ppm"); -#endif - - image2d<label_16> iz = transform::influence_zone_geodesic(lbl, c8(), mln_max(int)); - -#ifndef NOUT - io::ppm::save(debug::colorize(rgb8(), iz, nlabels), "02-iz.ppm"); -#endif - - typedef util::graph G; - G g = make::graph(iz | (pw::value(iz) != pw::cst(0u)), nlabels); - - // Compute the component centers and use them as vertex. - //FIXME: Add fun::vertex2p - typedef fun::i2v::array<point2d> fv2p_t; - util::array<point2d> centers = labeling::compute(accu::center<point2d>(), iz, nlabels); - fv2p_t fv2p = convert::to<fv2p_t>(centers); - - // Create a p_vertices. - p_vertices<G, fv2p_t> pv(g, fv2p); - -#ifndef NOUT - image2d<rgb8> gima = data::convert(rgb8(), ima); - debug::draw_graph(gima, - pv, - pw::cst(literal::cyan), - pw::cst(literal::olive)); - io::ppm::save(gima, "03-graph.ppm"); -#endif - - typedef util::line_graph<G> LG; - LG lg(g); - - // Find lines (sites) associated to edges in g. - typedef fun::i2v::array<p_line2d> i2e_t; - util::array<p_line2d> lines; - mln_edge_iter_(G) e(g); - for_all(e) - lines.append(p_line2d(fv2p(e.v1()), fv2p(e.v2()))); - - // Map lines to vertices in lg. - typedef p_vertices<LG, i2e_t> pvlg_t; - pvlg_t pvlg(lg, convert::to<i2e_t>(lines)); - -#ifndef NOUT - image2d<rgb8> lgima = data::convert(rgb8(), ima); - debug::draw_graph(lgima, - pvlg, - pw::cst(literal::cyan), - pw::cst(literal::olive)); - io::ppm::save(lgima, "04-line-graph.ppm"); -#endif - - // Construct an image from a p_edges and a function mapping - // lines to angles. - typedef lg_vertex_values<p_line2d> lgv2v_t; - lgv2v_t lgv2v; - - mln_VAR(lg_ima, lgv2v | pvlg); - - - // Colorize lg's vertices (i.e. g's edges) according their angle. - // - // literal::olive: cos(angle) < max_cos and cos(angle) > - max_cos - // literal::red: cos(angle) > max_cos or cos(angle) < - max_cos - typedef fun::i2v::array<value::rgb8> lgcolor_t; - lgcolor_t ecolor(pvlg.nsites()); - mln_piter_(lg_ima_t) p(lg_ima.domain()); - for_all (p) - if ((lg_ima(p) > max_cos) || (lg_ima(p) < - max_cos)) - ecolor(p) = literal::red; - else - ecolor(p) = literal::olive; - - -#ifndef NOUT - image2d<rgb8> lgima2 = data::convert(rgb8(), ima); - debug::draw_graph(lgima2, pvlg, pw::cst(literal::cyan), ecolor); - io::ppm::save(lgima2, "05-line-graph-cleanup.ppm"); -#endif -} diff --git a/milena/doc/examples/trash/image2d.cc b/milena/doc/examples/trash/image2d.cc deleted file mode 100644 index 88b76e2..0000000 --- a/milena/doc/examples/trash/image2d.cc +++ /dev/null @@ -1,82 +0,0 @@ -# include <mln/core/image/image2d.hh> -# include <mln/core/alias/window2d.hh> -# include <mln/core/site_set/p_array.hh> - -# include <mln/debug/iota.hh> -# include <mln/debug/println.hh> - -# include <mln/core/alias/neighb2d.hh> -# include <mln/geom/nsites.hh> - - -template <typename I, typename W, typename P> -void picture(const I& ima, const W& win, const P& p) -{ - std::cout << ima(p) << ": "; - mln_qiter(W) q(win, p); - for_all(q) - if (ima.has(q)) - std::cout << ima(q) << ' '; - else - std::cout << "- "; - std::cout << std::endl; -} - - -template <typename I, typename W> -void fill_null(I& ima, const W& win) -{ - mln_piter(I) p(ima.domain()); - mln_qiter(W) q(win, p); - for_all(p) - for_all(q) - if (ima.has(q)) - ima(q) = 0; -} - - -int main() -{ - using namespace mln; - - typedef image2d<unsigned> I; - I ima(2, 3, 0); // no border - - debug::iota(ima); - debug::println(ima); - mln_assertion(ima.nsites() == 6); - mln_assertion(geom::nsites(ima) == ima.nsites()); - - window2d win; - win - .insert(-1, 0) - .insert(0, -1) - .insert(-1,-1); - std::cout << win << std::endl; - - { - mln_fwd_piter_(I) p(ima.domain()); - for_all(p) - picture(ima, win, p); - } - - { - typedef p_array<point2d> A; - A arr; - arr += ima.domain(); - mln_fwd_piter_(A) p(arr); - for_all(p) - picture(ima, win, p); - - // FIXME: Move this new test in a separate file. - mln_psite_(A) c(arr, 0); - window2d it; it.insert(0,0); - mln_qiter_(window2d) q(it, c); - q.start(); - q.to_site() == c.to_site(); - c.inc_index(); - mln_assertion(q.update().to_site() == c.to_site()); - } - - fill_null(ima, win); -} diff --git a/milena/doc/examples/trash/image_flat.cc b/milena/doc/examples/trash/image_flat.cc deleted file mode 100644 index 4bc8fd3..0000000 --- a/milena/doc/examples/trash/image_flat.cc +++ /dev/null @@ -1,12 +0,0 @@ -# include <mln/core/image/image2d.hh> -# include <mln/core/image/flat_image.hh> -# include <mln/debug/println.hh> - - -int main() -{ - using namespace mln; - - flat_image<unsigned, box2d> ima(3, box2d(3,3)); - debug::println(ima); -} diff --git a/milena/doc/examples/trash/image_if.cc b/milena/doc/examples/trash/image_if.cc deleted file mode 100644 index d24ab31..0000000 --- a/milena/doc/examples/trash/image_if.cc +++ /dev/null @@ -1,93 +0,0 @@ -# include <mln/core/image/image2d.hh> -# include <mln/core/alias/neighb2d.hh> -# include <mln/core/image/image_if.hh> - -# include <mln/debug/iota.hh> -# include <mln/debug/println.hh> -# include <mln/fun/p2b/chess.hh> - -# include <mln/border/fill.hh> -# include <mln/core/var.hh> -# include <mln/core/routine/extend.hh> -# include <mln/pw/all.hh> - - -template <typename It, typename S> -void ch_target(It it, const S& s) -{ - it.change_target(s); -} - - -template <typename I, typename N> -void browse(const I& ima, const N& nbh) -{ - // Relies on "ima.has(p)". - mln_fwd_piter(I) p(ima.domain()); - mln_fwd_niter(N) n(nbh, p); - for_all(p) - { - std::cout << ima(p) << ": "; - for_all(n) - if (ima.has(n)) - std::cout << ima(n) << ' '; - std::cout << std::endl; - } -} - -template <typename I, typename N> -void browse_domain(const I& ima, const N& nbh) -{ - // Relies on "ima.domain().has(p)". - mln_fwd_piter(I) p(ima.domain()); - mln_fwd_niter(N) n(nbh, p); - for_all(p) - { - std::cout << ima(p) << ": "; - for_all(n) - if (ima.domain().has(n)) - std::cout << ima(n) << ' '; - std::cout << std::endl; - } -} - -template <typename I> -void algo(const I& input) -{ - using namespace mln; - mln_ch_value(I, float) output; - initialize(output, input); -} - - - -int main() -{ - using namespace mln; - - trace::quiet = false; - - typedef image2d<unsigned> I; - I ima(3, 3, 1); - // FIXME: border::fill(ima, 0); - debug::iota(ima); - - mln_VAR(ima_, ima | fun::p2b::chess()); - - debug::println(ima); - debug::println(ima_); - - trait::image::print(ima_); - std::cout << std::endl; - - typedef p_if<box2d, fun::p2b::chess> S; - ch_target(mln_fwd_piter_(S)(), ima_.domain()); - - // mln_VAR(ima_e, extend(ima_, pw::value(ima))); - // mln_VAR(ima_e, extend(ima_, 8)); - mln_VAR(ima_e, extend(ima_, ima)); - debug::println(ima_e); - browse(ima_e, c4()); - - algo(ima_e); -} diff --git a/milena/doc/examples/trash/image_plain.cc b/milena/doc/examples/trash/image_plain.cc deleted file mode 100644 index 4bfdf79..0000000 --- a/milena/doc/examples/trash/image_plain.cc +++ /dev/null @@ -1,42 +0,0 @@ -# include <mln/core/image/image2d.hh> -# include <mln/core/image/plain.hh> -# include <mln/debug/println.hh> -# include <mln/debug/iota.hh> -# include <mln/data/fill_with_value.hh> -# include <mln/opt/at.hh> - - -template <typename I> -void picture(const I& ima) -{ - using namespace mln; - const unsigned - nr = opt::at(ima, 0,0).domain().nrows(), - nc = opt::at(ima, 0,0).domain().ncols(); - for (unsigned row = 0; row < ima.nrows(); ++row) - for (unsigned r = 0; r < nr; ++r) - { - for (unsigned col = 0; col < ima.ncols(); ++col) - for (unsigned c = 0; c < nc; ++c) - std::cout << opt::at(ima, row, col)(point2d(r,c)) << ' '; - std::cout << std::endl; - } -} - - -int main() -{ - using namespace mln; - - typedef image2d<int> I; - typedef plain<I> I_; - - I ima(3, 3); - debug::iota(ima); - debug::println(ima); - - image2d<I_> mos(2, 2); - data::fill_with_value(mos, ima); - data::fill_with_value(opt::at(mos, 1,1), 0); - picture(mos); -} diff --git a/milena/doc/examples/trash/image_safe.cc b/milena/doc/examples/trash/image_safe.cc deleted file mode 100644 index ddad1f9..0000000 --- a/milena/doc/examples/trash/image_safe.cc +++ /dev/null @@ -1,24 +0,0 @@ -# include <mln/core/image/image2d.hh> -# include <mln/core/site_set/p_line2d.hh> -# include <mln/core/image/safe.hh> -# include <mln/debug/println.hh> -# include <mln/data/fill.hh> -# include <mln/data/paste.hh> -# include <mln/pw/all.hh> - - - -int main() -{ - using namespace mln; - - typedef image2d<int> I; - I ima(3, 3); - data::fill(ima, 0); - - safe_image<I> ima_(ima); - data::paste(pw::cst(8) | p_line2d(point2d(-1,-1), - point2d( 3, 3)), - ima_); - debug::println(ima); -} diff --git a/milena/doc/examples/trash/labeling_algo.cc b/milena/doc/examples/trash/labeling_algo.cc deleted file mode 100644 index b622731..0000000 --- a/milena/doc/examples/trash/labeling_algo.cc +++ /dev/null @@ -1,80 +0,0 @@ -// Copyright (C) 2007, 2008 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. - -/// \file doc/examples/labeling_algo.cc -/// -/// Test on mln::geom::seeds2tiling. - -# include <mln/core/image/image2d.hh> -# include <mln/core/image/sub_image.hh> -# include <mln/core/alias/neighb2d.hh> -# include <mln/value/int_u8.hh> -# include <mln/data/fill.hh> -# include <mln/data/stretch.hh> -# include <mln/border/fill.hh> -# include <mln/io/pbm/load.hh> -# include <mln/io/pgm/save.hh> -# include <mln/labeling/foreground.hh> -# include <mln/debug/println.hh> -# include <mln/draw/mesh.hh> -# include <mln/geom/seeds2tiling.hh> -# include <mln/make/voronoi.hh> -# include <mln/make/voronoi.hh> -# include <mln/opt/at.hh> - -int main() -{ - using namespace mln; - using value::int_u8; - - image2d<bool> in = io::pbm::load("../img/toto.pbm"); - - - unsigned n; - image2d<unsigned> lab = labeling::foreground(in, c8(), n); - std::cout << "number of labels = " << n << std::endl; - std::vector<int_u8> vec; - - image2d<int> input(in.domain()); - data::fill(input, lab); - opt::at(lab, 0,0) = 0; - - image2d<unsigned> inte = geom::seeds2tiling(lab, c4 ()); - border::fill(inte, 0); - - image2d<int_u8> inte2(inte.domain()); - - data::stretch(inte, inte2); - - io::pgm::save(inte2, "inte.pgm"); - - mesh_p<point2d> m = make::voronoi(inte, lab, c4()); - std::cout << "OK : generate inte.pgm and out.pgm" << std::endl; - - image2d<int_u8> out(in.domain()); - draw::mesh(out, m, 255, 128); - - io::pgm::save(out, "out.pgm"); -} diff --git a/milena/doc/examples/trash/mk_graph.cc b/milena/doc/examples/trash/mk_graph.cc deleted file mode 100644 index a294dd0..0000000 --- a/milena/doc/examples/trash/mk_graph.cc +++ /dev/null @@ -1,91 +0,0 @@ -// Copyright (C) 2008 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. - -/// \file doc/examples/mk_graph.cc -/// -/// This example shows how to create a graph from an influence zone image - -# include <mln/essential/2d.hh> - -# include <mln/core/site_set/p_vertices.hh> -# include <mln/core/site_set/p_edges.hh> - -# include <mln/debug/colorize.hh> -# include <mln/debug/draw_graph.hh> - -# include <mln/make/graph.hh> - -# include <mln/transform/influence_zone_geodesic.hh> - -# include <mln/util/graph.hh> - - -int main(int argc, char *argv[]) -{ - using namespace mln; - using value::int_u16; - - if (argc < 2) - { - std::cout << "Usage: " << argv[0] << " <image.pbm>" << std::endl; - return 1; - } - - image2d<bool> ima = io::pbm::load(argv[1]); - logical::not_inplace(ima); - - // Create a label image and compute the influence zones. - int_u16 nlabels; - image2d<int_u16> lbl = labeling::blobs(ima, c8(), nlabels); - io::ppm::save(debug::colorize< image2d<value::rgb8> >(lbl, nlabels), - "1_blobs.ppm"); - image2d<int_u16> iz = transform::influence_zone_geodesic(lbl, - c8(), - lbl.ncols()); - io::ppm::save(debug::colorize< image2d<value::rgb8> >(iz, nlabels), - "2_influence_zone_geodesic.ppm"); - - /// Make a graph from the influence zone image. - util::graph g = make::graph(iz, nlabels); - - // Use the center of each bbox component as vertex in the graph. - typedef fun::i2v::array<point2d> i2v_t; - util::array<point2d> centers = labeling::compute(accu::center<point2d>(), iz, nlabels); - i2v_t f = convert::to<i2v_t>(centers); - p_vertices<util::graph, i2v_t> pv(g, f); - - // Find lines (sites) associated to edges. - typedef fun::i2v::array<p_line2d> i2e_t; - util::array<p_line2d> lines; - mln_edge_iter_(util::graph) e(g); - for_all(e) - lines.append(p_line2d(f(e.v1()), f(e.v2()))); - p_edges<util::graph, i2e_t> pe(g, convert::to<i2e_t>(lines)); - - // Draw graph. - image2d<value::rgb8> out(ima.domain()); - debug::draw_graph(out, pv, literal::red, literal::green); - io::ppm::save(out, "3_graph.ppm"); -} diff --git a/milena/doc/examples/trash/p_array.2.cc b/milena/doc/examples/trash/p_array.2.cc deleted file mode 100644 index 182e293..0000000 --- a/milena/doc/examples/trash/p_array.2.cc +++ /dev/null @@ -1,93 +0,0 @@ -# include <mln/core/image/image2d.hh> -# include <mln/core/site_set/p_array.hh> -# include <mln/core/window.hh> - -# include <mln/debug/println.hh> -# include <mln/data/fill.hh> - - -template <typename A> -mln::image2d<char> picture(const A& arr) -{ - using namespace mln; - - image2d<char> ima(5, 5); - data::fill(ima, '-'); - - unsigned i = 0; - mln_piter(A) p(arr); - for_all(p) - ima(p) = '0' + i++; - - debug::println(ima); - return ima; -} - - -template <typename I, typename W, typename P> -void picture(const I& ima, const W& win, const P& p) -{ - std::cout << ima(p) << ": "; - mln_qiter(W) q(win, p); - for_all(q) - if (ima.has(q)) - std::cout << ima(q) << ' '; - else - std::cout << "- "; - std::cout << std::endl; -} - - -int main() -{ - using namespace mln; - - typedef p_array<point2d> Arr; - Arr arr; - - point2d p(1,1); - arr.append(p); - dpoint2d dp[] = { right, right, down, down, left, left, up }; - for (unsigned i = 0; i < 7; ++i) - p += dp[i], arr.append(p); - - std::cout << "arr = " << arr << std::endl; - image2d<char> ima = picture(arr); - - typedef window<util::dindex> W; - W win; - win.insert(-1).insert(0).insert(1); - std::cout << "win = " << win << std::endl - << std::endl; - - mln_assertion(win == win); - - util::index i; - mln_qiter_(W) j(win, i); - int n = arr.nsites(); - for (i = 0; i < n; i = i + 1) - { - std::cout << "i=" << i << ": "; - for_all(j) - if (arr.has(j)) - { - mln_invariant( ima(arr[j]) == '0' + j.to_site()); - std::cout << j << ' '; - } - else - std::cout << "- "; - std::cout << std::endl; - } - - // FIXME: j does NOT convert to int because index is NOT a proxy - // NOTA: make index be a proxy, so equip it with every op it needs. - - for (i = 0; i < n; i = i + 1) - { - std::cout << "i=" << i << ": "; - for_all(j) - std::cout << arr[(int(j.to_site()) + n) % n] << ' '; - std::cout << std::endl; - } - -} diff --git a/milena/doc/examples/trash/p_array.cc b/milena/doc/examples/trash/p_array.cc deleted file mode 100644 index 3a4186a..0000000 --- a/milena/doc/examples/trash/p_array.cc +++ /dev/null @@ -1,103 +0,0 @@ -# include <mln/core/image/image2d.hh> -# include <mln/core/site_set/p_array.hh> -# include <mln/debug/println.hh> -# include <mln/data/fill.hh> - - -template <typename A> -void picture(const A& arr) -{ - using namespace mln; - - image2d<char> ima(5, 5); - data::fill(ima, '-'); - - unsigned i = 0; - mln_piter(A) p(arr); - for_all(p) - ima(p) = '0' + i++; - - debug::println(ima); -} - - - -int main() -{ - using namespace mln; - - typedef p_array<point2d> Arr1; - typedef p_array<mln_psite_(Arr1)> Arr2; - - - { - mlc_bool(mln_psite_(Arr1)::proxy_level == 1)::check(); - mlc_bool(mln_piter_(Arr1)::proxy_level == 2)::check(); - mlc_bool(mln_psite_(Arr2)::proxy_level == 2)::check(); - mlc_bool(mln_piter_(Arr2)::proxy_level == 3)::check(); - } - - Arr1 arr1; - - { - point2d p(1,1); - arr1.append(p); - dpoint2d dp[] = { right, right, down, down, left, left, up }; - for (unsigned i = 0; i < 7; ++i) - p += dp[i], arr1.append(p); - - std::cout << "arr1 = " << arr1 << std::endl; - picture(arr1); - } - - { - - Arr2 arr2; - - // Fill arr2 from arr1 contents. - { - mln_piter_(Arr1) p(arr1); - for_all(p) - if (p.row() % 2 && p.col() % 2) - arr2.append(p); - } - - std::cout << "arr2 = " << arr2 << std::endl; - picture(arr2); - - // Display indices. - { - mln_piter_(Arr2) p(arr2); - for_all(p) - { - mln_assertion(point2d(p.row(), p.col()) == p); - std::cout << "point " << p << ": #" - << index_of_in(p, arr2) << " in arr2, #" - << index_of_in(p, arr1) << " in arr1" << std::endl; - } - std::cout << std::endl; - } - - mln_invariant(arr2 < arr1); - - { - mln_piter_(Arr1) p1(arr1); - mln_piter_(Arr2) p2(arr2); - for_all_2(p1, p2) - { - mln_assertion(p2 == p1); // same as: p2.to_site() == p1.to_site() - p1.next(); // p1 goes twice fast as p2. - } - } - - { - // Fun stuff: - - arr1[0] = point2d(0,0); - picture(arr1); - picture(arr2); - } - - } - -} diff --git a/milena/doc/examples/trash/p_image.cc b/milena/doc/examples/trash/p_image.cc deleted file mode 100644 index 462ba61..0000000 --- a/milena/doc/examples/trash/p_image.cc +++ /dev/null @@ -1,52 +0,0 @@ -# include <mln/core/image/image2d.hh> -# include <mln/core/site_set/p_array.hh> -# include <mln/core/site_set/p_image.hh> -# include <mln/debug/println.hh> -# include <mln/data/fill.hh> - - -template <typename A> -void picture(const A& arr) -{ - using namespace mln; - - image2d<char> ima(5, 5); - data::fill(ima, '-'); - - unsigned i = 0; - mln_piter(A) p(arr); - for_all(p) - ima(p) = '0' + i++; - - debug::println(ima); -} - - - -int main() -{ - using namespace mln; - - typedef p_array<point2d> Arr; - Arr arr; - - { - point2d p(1,1); - arr.append(p); - dpoint2d dp[] = { right, right, down, down, left, left, up }; - for (unsigned i = 0; i < 7; ++i) - p += dp[i], arr.append(p); - - std::cout << "arr = " << arr << std::endl; - picture(arr); - } - - typedef image2d<bool> I; - I ima(5, 5); - p_image<I> s(ima); - s += arr; - std::cout << "ima = " << s << std::endl; - picture(s); - - debug::println(s.image_hook_()); -} diff --git a/milena/doc/examples/trash/p_key.2.cc b/milena/doc/examples/trash/p_key.2.cc deleted file mode 100644 index 102ff3e..0000000 --- a/milena/doc/examples/trash/p_key.2.cc +++ /dev/null @@ -1,34 +0,0 @@ -# include <mln/core/image/image2d.hh> -# include <mln/core/site_set/p_key.hh> -# include <mln/value/int_u8.hh> -# include <mln/io/pgm/load.hh> -# include <mln/io/pgm/save.hh> - - - -int main() -{ - using namespace mln; - using value::int_u8; - - typedef image2d<int_u8> I; - I lena; - io::pgm::load(lena, "../../../img/lena.pgm"); - - typedef p_key<unsigned, point2d> S; - S s; - mln_piter_(I) p(lena.domain()); - for_all(p) - s.insert(lena(p), p); - - mln_assertion(lena.nsites() == s.nsites()); - - { - I out(lena.domain()); - mln_piter_(I) p(lena.domain()); - mln_piter_(S) q(s); - for_all_2(p, q) - out(p) = lena(q); - io::pgm::save(out, "out.pgm"); - } -} diff --git a/milena/doc/examples/trash/p_key.cc b/milena/doc/examples/trash/p_key.cc deleted file mode 100644 index bcf58eb..0000000 --- a/milena/doc/examples/trash/p_key.cc +++ /dev/null @@ -1,96 +0,0 @@ -# include <mln/core/image/image2d.hh> -# include <mln/core/site_set/p_key.hh> -# include <mln/debug/println.hh> -# include <mln/data/fill.hh> - -# include <mln/fun/v2v/inc.hh> -# include <mln/fun/v2v/dec.hh> - - -template <typename S> -void picture(const S& s) -{ - using namespace mln; - - image2d<char> ima(5, 5); - data::fill(ima, '-'); - - mln_piter(S) p(s); - for_all(p) - ima(p) = '0' + s.key(p); - - debug::println(ima); -} - - - -int main() -{ - using namespace mln; - - // FIXME: Do not work with 'char' as a key! - typedef p_key<unsigned, point2d> S; - S s; - - { - point2d p(1,1); - s.insert(p.row(), p); - mln_assertion(s.has(p)); - - dpoint2d dp[] = { right, right, down, down, left, left, up }; - for (unsigned i = 0; i < 7; ++i) - p += dp[i], s.insert(p.row(), p); - - picture(s); - - std::cout << s.keys() << std::endl; - std::cout << s << std::endl; - } - - - std::cout << "insert(2, (1,1))" << std::endl; - s.insert(2, point2d(1,1)); - std::cout << s << std::endl; - - std::cout << "insert(5, (1,1))" << std::endl; - s.insert(5, point2d(1,1)); - std::cout << s << std::endl; - - std::cout << "inc keys" << std::endl; - s.change_keys(fun::v2v::inc<unsigned>()); - std::cout << s << std::endl; - - std::cout << "dec keys" << std::endl; - s.change_keys(fun::v2v::dec<unsigned>()); - std::cout << s << std::endl; - - std::cout << "remove (0,0)" << std::endl; - s.remove(point2d(0,0)); - std::cout << s << std::endl; - - std::cout << "remove (1,2)" << std::endl; - s.remove(point2d(1,2)); - std::cout << s << std::endl; - - std::cout << "remove (1,3)" << std::endl; - s.remove(point2d(1,3)); - std::cout << s << std::endl; - - std::cout << "remove key 0" << std::endl; - s.remove_key(0); - std::cout << s << std::endl; - - std::cout << "change key 2 -> 5" << std::endl; - s.change_key(2, 5); - std::cout << s << std::endl; - - std::cout << "remove key 3" << std::endl; - s.remove_key(3); - std::cout << s << std::endl; - - picture(s); - - std::cout << "clear" << std::endl; - s.clear(); - std::cout << s << std::endl; -} diff --git a/milena/doc/examples/trash/p_line2d.cc b/milena/doc/examples/trash/p_line2d.cc deleted file mode 100644 index 928c908..0000000 --- a/milena/doc/examples/trash/p_line2d.cc +++ /dev/null @@ -1,34 +0,0 @@ -# include <mln/core/image/image2d.hh> -# include <mln/pw/all.hh> - -# include <mln/core/site_set/p_line2d.hh> -# include <mln/core/site_set/p_set.hh> - -# include <mln/core/image/sub_image.hh> -# include <mln/data/fill.hh> -# include <mln/debug/println.hh> - - - -int main() -{ - using namespace mln; - - image2d<char> ima(6, 11); - data::fill(ima, '.'); - - p_line2d line(point2d(4,10), - point2d(1,1)); - std::cout << line << std::endl; - - data::fill((ima | line).rw(), 'x'); - debug::println(ima); - - p_set<point2d> s; - s += line; - mln_assertion(s.has(line.begin()) && s.has(line.end())); - std::cout << s << std::endl; - - debug::println(pw::cst('o') | line); - // ... -} diff --git a/milena/doc/examples/trash/p_mutable_array_of.cc b/milena/doc/examples/trash/p_mutable_array_of.cc deleted file mode 100644 index 4f93cb1..0000000 --- a/milena/doc/examples/trash/p_mutable_array_of.cc +++ /dev/null @@ -1,60 +0,0 @@ -# include <mln/core/image/image2d.hh> -# include <mln/core/site_set/p_mutable_array_of.hh> -# include <mln/core/site_set/p_run.hh> -# include <mln/convert/from_to.hh> - -// Used by display. -# include <mln/geom/bbox.hh> -# include <mln/debug/println.hh> -# include <mln/core/image/sub_image.hh> - - -template <typename S> -void display(const S& s) -{ - using namespace mln; - - image2d<unsigned> ima(geom::bbox(s)); - mln_fwd_piter(S) p(s); - unsigned c = 0; - for_all(p) - ima(p) = ++c; - debug::println(ima | s); -} - - -int main() -{ - using namespace mln; - - bool vals[6][5] = { - {1, 1, 1, 1, 1}, - {0, 0, 0, 0, 0}, - {1, 0, 1, 0, 1}, - {0, 1, 0, 1, 0}, - {0, 0, 1, 1, 1}, - {1, 1, 1, 0, 0} - }; - image2d<bool> ima = make::image(vals); - debug::println(ima); - - typedef p_mutable_array_of< p_run<point2d> > Runs; - Runs rs; - convert::from_to(ima, rs); - std::cout << rs << std::endl; - - display(rs); - - // FIXME: Use the "mutable" feature of rs... - - - { - typedef p_mutable_array_of<Runs> Arr; // Array of arrays of runs. - Arr arr; - arr.insert(rs); - arr.insert(rs); - std::cout << arr << std::endl; - display(arr); - } - -} diff --git a/milena/doc/examples/trash/p_queue.cc b/milena/doc/examples/trash/p_queue.cc deleted file mode 100644 index 5701961..0000000 --- a/milena/doc/examples/trash/p_queue.cc +++ /dev/null @@ -1,93 +0,0 @@ -# include <mln/core/image/image2d.hh> -# include <mln/core/site_set/p_queue.hh> -# include <mln/core/site_set/p_queue_fast.hh> -# include <mln/debug/println.hh> -# include <mln/data/fill.hh> - -# include <mln/core/site_set/p_priority.hh> - - - -template <typename S> -void picture(const S& s) -{ - using namespace mln; - - image2d<char> ima(5, 5); - data::fill(ima, '-'); - - unsigned i = 0; - mln_piter(S) p(s); - for_all(p) - ima(p) = '0' + i++; - - debug::println(ima); -} - - - -template <typename P> -void try_purge(mln::p_queue<P>&) -{ - // No-op. -} - -template <typename P> -void try_purge(mln::p_queue_fast<P>& q) -{ - std::cout << "purge!" << std::endl; - q.purge(); - picture(q); -} - - -template <typename Q> -void run() -{ - using namespace mln; - - Q q; - - { - point2d p(1,1); - q.push(p); - dpoint2d dp[] = { right, right, down, down, left, left, up }; - for (unsigned i = 0; i < 7; ++i) - p += dp[i], q.push(p); - } - - picture(q); - q.pop(); - picture(q); - - { - mln_psite(Q) p(q, 0); - mln_assertion(q.has(p)); - p.change_index(6); - mln_assertion(q.has(p)); - - p.change_index(7); - mln_assertion(! q.has(p)); - } - - try_purge(q); - - { - typedef p_priority<unsigned, Q> PQ; - PQ pq; - mln_piter(Q) p(q); - for_all(p) - pq.push(p.row() + p.col(), p); - std::cout << pq << std::endl; - } - -} - - -int main() -{ - using namespace mln; - // typedef p_queue<point2d> Q; - typedef p_queue_fast<point2d> Q; - run<Q>(); -} diff --git a/milena/doc/examples/trash/p_run.cc b/milena/doc/examples/trash/p_run.cc deleted file mode 100644 index 9f634d7..0000000 --- a/milena/doc/examples/trash/p_run.cc +++ /dev/null @@ -1,48 +0,0 @@ -# include <mln/core/image/image2d.hh> -# include <mln/core/alias/p_run2d.hh> -# include <mln/core/site_set/p_set_of.hh> - -# include <mln/convert/from_to.hh> -# include <mln/debug/println.hh> -// # include <mln/core/image/sparse_image.hh> - - -template <typename I> -void display(I& ima) -{ - mln_fwd_piter(I) p(ima.domain()); - unsigned i = 0; - for_all(p) - ima(p) = i++; - mln::debug::println(ima); -} - - -int main() -{ - using namespace mln; - - typedef p_set_of<p_run2d> Runs; - - bool vals[6][5] = { - {1, 1, 1, 1, 1}, - {0, 0, 0, 0, 0}, - {1, 0, 1, 0, 1}, - {0, 1, 0, 1, 0}, - {0, 0, 1, 1, 1}, - {1, 1, 1, 0, 0} - }; - image2d<bool> ima = make::image(vals); - debug::println(ima); - - Runs rs; - convert::from_to(ima, rs); - std::cout << rs << std::endl; - - mln_assertion(rs.nelements() == 8); - mln_assertion(rs.nsites() == 16); -// mln_assertion(rs.zratio() < 1); - -// sparse_image<point2d,int> ima_(rs); -// display(ima_); -} diff --git a/milena/doc/examples/trash/p_vaccess.cc b/milena/doc/examples/trash/p_vaccess.cc deleted file mode 100644 index 051edfb..0000000 --- a/milena/doc/examples/trash/p_vaccess.cc +++ /dev/null @@ -1,157 +0,0 @@ -# include <mln/core/image/image2d.hh> -# include <mln/core/alias/neighb2d.hh> -# include <mln/value/int_u8.hh> - -# include <mln/data/fill.hh> -# include <mln/data/paste.hh> -# include <mln/debug/println.hh> -# include <mln/util/timer.hh> -# include <mln/labeling/blobs.hh> - -# include <mln/core/alias/p_runs2d.hh> -# include <mln/core/site_set/p_vaccess.hh> -# include <mln/core/image/image_if.hh> -# include <mln/pw/all.hh> -# include <mln/convert/from_to.hh> - -# include <mln/core/var.hh> - - - -template <typename I, typename S> -void fill(S& s, const I& ima) -{ - mln_piter(I) p(ima.domain()); - for_all(p) - s.insert(ima(p), p); - mln_postcondition(s.nsites() == ima.nsites()); -} - - - -int main() -{ - using namespace mln; - using value::int_u8; - - bool vals[4][4] = { - {1, 1, 0, 1}, - {1, 0, 1, 0}, - {0, 1, 1, 0}, - {1, 1, 0, 1} - }; - image2d<bool> ima = make::image(vals); - debug::println(ima); - - unsigned n; - - { - typedef p_vaccess<bool, p_array<point2d> > Arr; - mlc_equal(Arr::element, point2d)::check(); - Arr arr; - fill(arr, ima); - n = arr(true).nsites(); - mln_assertion(arr(true).nsites() + arr(false).nsites() == ima.nsites()); - - std::cout << "{-} = " << arr(false) << std::endl - << "{|} = " << arr(true) << std::endl - << std::endl; - } - - int_u8 nlabels; - image2d<int_u8> lab = labeling::blobs(ima, c4(), nlabels); - debug::println(lab); - - { - typedef p_vaccess<int_u8, p_runs2d> Arr; - mlc_equal(Arr::element, p_run2d)::check(); - Arr arr; - - mln_VAR(sub, lab | (pw::value(lab) != pw::cst(0u))); - debug::println(sub); - - convert::from_to(sub, arr); - mln_assertion(arr.nsites() == n); - - { - std::cout << "arr = "; - mln_piter_(Arr) p(arr); - for_all(p) - std::cout << p << ' '; - std::cout << std::endl; - } - - std::cout << std::endl; - - { - for (unsigned l = 0; l <= nlabels; ++l) - { - std::cout << "arr(" << l << ") = "; - mln_piter_(p_runs2d) p(arr(l)); - for_all(p) - std::cout << p << ' '; - std::cout << std::endl; - } - } - - std::cout << std::endl; - - { - for (unsigned l = 0; l <= nlabels; ++l) - { - std::cout << "arr(" << l << ") = "; - util::set<p_run2d>::eiter r(arr(l).set_hook_()); - for_all(r) - std::cout << r << ' '; - std::cout << std::endl; - } - } - - std::cout << std::endl; - - std::cout << "arr in " << arr.bbox() << std::endl; - for (unsigned l = 0; l <= nlabels; ++l) - { - std::cout << l << ": #" << arr(l).nsites(); - if (! arr(l).is_empty()) - std::cout << " in " << arr(l).bbox(); - std::cout << std::endl; - } - std::cout << std::endl; - - { - image2d<int> ima_(arr.bbox()); - data::fill(ima_, 0); - for (unsigned l = 1; l <= nlabels; ++l) - for (unsigned r = 0; r < arr(l).nelements(); ++r) - data::paste(pw::cst(10 * l + r) | arr(l)[r], ima_); - debug::println(ima_); - } - - { - image2d<int> ima_(arr.bbox()); - data::fill(ima_, 0); - for (unsigned l = 1; l <= nlabels; ++l) - if (arr(l).nsites() > 1) - data::paste(pw::cst(l) | arr(l), ima_); - debug::println(ima_); - } - } - -// { -// p_runs2d rs; -// convert::from_to(ima, rs); -// mln_assertion(rs.bbox() == ima.bbox()); - -// image2d<int_u8> ima_(ima.domain()); -// data::fill(ima_, 0); -// for (unsigned r = 0; r < rs.nelements(); ++r) -// { -// mln_piter_(p_run2d) p(rs[r]); -// for_all(p) -// ima_(p) = r + 1; -// } -// debug::println(ima_); -// } - -} diff --git a/milena/doc/examples/trash/proxy.cc b/milena/doc/examples/trash/proxy.cc deleted file mode 100644 index 0437b1c..0000000 --- a/milena/doc/examples/trash/proxy.cc +++ /dev/null @@ -1,105 +0,0 @@ -# include <mln/core/image/image2d.hh> -# include <mln/core/site_set/p_array.hh> -# include <mln/debug/println.hh> -# include <mln/data/fill.hh> - - -template <typename A> -void picture(const A& arr) -{ - using namespace mln; - - image2d<char> ima(5, 5); - data::fill(ima, '-'); - - unsigned i = 0; - mln_piter(A) p(arr); - for_all(p) - ima(p) = '0' + i++; - - debug::println(ima); -} - - - -int main() -{ - using namespace mln; - - typedef p_array<point2d> Arr1; - Arr1 arr1; - - { - point2d p(1,1); - arr1.append(p); - p = unproxy_rec(p); - } - - { - mln_psite_(Arr1) p(arr1, 0); - std::cout << p << ' ' << arr1[0] << std::endl; - - std::cout << &(arr1[0]) << ' ' << &(unproxy_rec(p)) << std::endl; - - std::cout << p.get_subject() << std::endl; - std::cout << p.to_site() << std::endl; - } - -// { -// mln_piter_(Arr1) p(arr1); -// p.start(); -// std::cout << p.get_subject() << std::endl; -// std::cout << p.to_site() << std::endl; -// } - -// { -// mln_psite_(Arr1) p(arr1, 0); -// typedef typeof(mln_psite_(Arr1)::q_subject) TT; -// TT var; -// } - - - typedef p_array<mln_psite_(Arr1)> Arr2; - -// { - -// Arr2 arr2; - -// // Fill arr2 from arr1 contents. -// { -// mln_piter_(Arr1) p(arr1); -// for_all(p) -// if (p.row() % 2 && p.col() % 2) -// arr2.append(p); -// } - -// std::cout << "arr2 = " << arr2 << std::endl; -// picture(arr2); - -// // Display indices. -// { -// mln_piter_(Arr2) p(arr2); -// for_all(p) -// { -// mln_assertion(point2d(p.row(), p.col()) == p); -// std::cout << "point " << p << ": #" -// << index_of_in(p, arr2) << " in arr2, #" -// << index_of_in(p, arr1) << " in arr1" << std::endl; -// } -// } - -// mln_invariant(arr2 < arr1); - -// { -// mln_piter_(Arr1) p1(arr1); -// mln_piter_(Arr2) p2(arr2); -// for_all_2(p1, p2) -// { -// mln_assertion(p2 == p1); // same as: p2.to_site() == p1.to_site() -// p1.next(); // p1 goes twice fast as p2. -// } -// } - -// } - -} diff --git a/milena/doc/examples/trash/sub_image.cc b/milena/doc/examples/trash/sub_image.cc deleted file mode 100644 index 0321d30..0000000 --- a/milena/doc/examples/trash/sub_image.cc +++ /dev/null @@ -1,29 +0,0 @@ -# include <mln/core/image/image2d.hh> -# include <mln/core/alias/neighb2d.hh> -# include <mln/core/image/sub_image.hh> - -# include <mln/debug/iota.hh> -# include <mln/debug/println.hh> - -# include <mln/morpho/elementary/gradient.hh> -# include <mln/data/fill_with_value.hh> - - -int main() -{ - using namespace mln; - - typedef image2d<unsigned> I; - I ima(3, 5); - debug::iota(ima); - debug::println(ima); - - sub_image<I, box2d> sub = ima | box2d(2,3); - debug::println(sub); - debug::println(morpho::elementary::gradient(sub, c4())); - - data::fill_with_value((ima | box2d(2,3)).rw(), 0); - debug::println(ima); - - trait::image::print(sub); -} diff --git a/milena/doc/examples/trash/sub_image_if.cc b/milena/doc/examples/trash/sub_image_if.cc deleted file mode 100644 index e5a69f3..0000000 --- a/milena/doc/examples/trash/sub_image_if.cc +++ /dev/null @@ -1,101 +0,0 @@ -# include <mln/core/image/image2d.hh> -# include <mln/core/image/sub_image_if.hh> - -# include <mln/core/image/sub_image.hh> -# include <mln/core/image/image_if.hh> - -# include <mln/pw/all.hh> -# include <mln/core/var.hh> - -# include <mln/core/alias/neighb2d.hh> -# include <mln/labeling/blobs.hh> -# include <mln/geom/bbox.hh> - -# include <mln/data/fill.hh> -# include <mln/debug/println.hh> - - -template <typename I> -void foo(const I& input) -{ - using namespace mln; - - std::cout << std::endl << "foo!" << std::endl << std::endl; - - typedef mln_ch_value(I, float) O; - -// p_if< box2d, -// fun::p2b::has< image_if< image2d<float>, F> > -// > - -// p_if< box2d, -// fun::p2b::has< image_if< image2d_int_u8, F > > -// > - - - - // type of " mln_ch_value(I, float) " - -// sub_image_if< I = image_if< image2d<float>, F > -// S = box2d > -// -// where: -// -// F = fun::neq_p2b_expr_< pw::value_< image2d<value::int_u<8u> > >, -// pw::cst_<unsigned int> > -// >, - - O output; - initialize(output, input); - data::fill(output, 9); - - std::cout << geom::bbox(output) << std::endl; - debug::println(output); -} - - - -int main() -{ - using namespace mln; - using value::int_u8; - - bool vals[6][5] = { - {0, 1, 1, 0, 0}, - {0, 1, 1, 0, 0}, - {0, 0, 0, 0, 0}, - {1, 1, 0, 1, 0}, - {1, 0, 1, 1, 1}, - {1, 0, 0, 0, 0} - }; - image2d<bool> ima = make::image(vals); - debug::println(ima); - - int_u8 nlabels; - image2d<int_u8> lab = labeling::blobs(ima, c4(), nlabels); - debug::println(lab); - - mln_VAR(lab_0, lab | (pw::value(lab) != pw::cst(0u))); - debug::println(lab_0); - -// box2d b = geom::bbox(lab | (pw::value(lab) == pw::cst(3u))); -// std::cout << b << std::endl; - - -// { -// mln_VAR(temp, lab | (pw::value(lab) == pw::cst(3u))); -// std::cout << temp.un_if().bbox() << std::endl; -// debug::println(temp); -// std::cout << geom::bbox(lab | (pw::value(lab) == pw::cst(3u))) << std::endl; - -// foo(temp); -// } - - box2d bb = make::box2d(2,1, 5,4); - debug::println(lab / bb); - - mln_VAR(lab_3, lab_0 / bb); - debug::println(lab_3); - - foo(lab_3); -} diff --git a/milena/doc/examples/trash/tuto_bis.cc b/milena/doc/examples/trash/tuto_bis.cc deleted file mode 100644 index 893e7e3..0000000 --- a/milena/doc/examples/trash/tuto_bis.cc +++ /dev/null @@ -1,273 +0,0 @@ -# include <mln/core/var.hh> - -# include <mln/core/image/image2d.hh> -# include <mln/core/image/image_if.hh> -# include <mln/core/image/sub_image.hh> -# include <mln/core/image/extended.hh> -# include <mln/core/routine/extend.hh> - -# include <mln/core/alias/window2d.hh> -# include <mln/core/alias/neighb2d.hh> -# include <mln/make/double_neighb2d.hh> -# include <mln/core/site_set/p_centered.hh> -# include <mln/literal/origin.hh> - -# include <mln/accu/stat/min_max.hh> -# include <mln/accu/stat/mean.hh> - -# include <mln/fun/i2v/array.hh> -# include <mln/fun/p2v/iota.hh> - -# include <mln/data/paste.hh> -# include <mln/data/fill.hh> -# include <mln/data/transform.hh> -# include <mln/extension/fill.hh> - -# include <mln/morpho/watershed/flooding.hh> -# include <mln/morpho/gradient.hh> -# include <mln/morpho/dilation.hh> - -# include <mln/debug/println.hh> - - - -namespace mln -{ - - namespace accu - { - - template <typename A_, typename I, typename L, typename V> - inline - void - compute(const Image<I>& input_, - const Image<L>& label_, - V& v) - { - mlc_is_a(A_, Meta_Accumulator)::check(); - mln_trace("accu::compute"); - - const I& input = exact(input_); - const L& label = exact(label_); - - typedef mln_accu_with(A_, mln_value(I)) A; - const unsigned n = v.size(); - std::vector<A> a(n); - - mln_piter(I) p(input.domain()); - for_all(p) - a[label(p)].take(input(p)); - - for (unsigned l = 1; l < n; ++l) - v(l) = a[l]; - - } - - } // mln::accu - - -} // mln - - - - -// Functions - -inline -bool is_row_odd(const mln::point2d& p) -{ - return p.row() % 2; -} - -inline -bool is_cell(const mln::point2d& p) -{ - return p.row() % 2 == 0 && p.col() % 2 == 0; -} - -inline -bool is_edge(const mln::point2d& p) -{ - return p.row() % 2 + p.col() % 2 == 1; -} - -inline -bool is_point(const mln::point2d& p) -{ - return p.row() % 2 && p.col() % 2; -} - - -inline -bool is_not_edge(const mln::point2d& p) -{ - return ! is_edge(p); -} - - - -int main() -{ - using namespace mln; - - - // e2c - - bool e2c_h[] = { 0, 1, 0, - 0, 0, 0, - 0, 1, 0 }; - - bool e2c_v[] = { 0, 0, 0, - 1, 0, 1, - 0, 0, 0 }; - - mln_VAR( e2c, make::double_neighb2d(is_row_odd, e2c_h, e2c_v) ); - - bool e2e_h[] = { 0, 0, 1, 0, 0, - 0, 1, 0, 1, 0, - 0, 0, 0, 0, 0, - 0, 1, 0, 1, 0, - 0, 0, 1, 0, 0 }; - - bool e2e_v[] = { 0, 0, 0, 0, 0, - 0, 1, 0, 1, 0, - 1, 0, 0, 0, 1, - 0, 1, 0, 1, 0, - 0, 0, 0, 0, 0 }; - - mln_VAR( e2e, make::double_neighb2d(is_row_odd, e2e_h, e2e_v) ); - - - box2d domain(3, 5); - image2d<unsigned> ima_(domain); - mln_VAR(ima, ima_ | domain); - - mln_VAR(cell, ima | is_cell); - data::fill(cell, fun::p2v::iota()); - debug::println(cell); - // 1 2 3 - // - // 4 5 6 - - mln_VAR(edge, extend((ima | is_edge).rw(), ima)); - - data::paste(morpho::gradient(edge, e2c.win()), edge); - // ^^^ - // edge -> neighboring cells - debug::println(edge); - // 1 1 - // 3 3 3 - // 1 1 - - image2d<unsigned> label(domain, 0); - data::fill(label, 9); - debug::println(label); - // 9 9 9 9 9 - // 9 9 9 9 9 - // 9 9 9 9 9 - - - mln_VAR(wst, label | is_edge); - debug::println(wst); - // 9 9 - // 9 9 9 - // 9 9 - - - unsigned nbasins; - data::fill(wst, morpho::watershed::flooding(edge, e2e, nbasins)); - // ^^^ - // edge -> neighboring edges - debug::println(wst); - // 2 2 - // 0 0 0 - // 1 1 - - std::cout << nbasins << " bassins" << std::endl; - // 2 bassins - - - - - // '0' IS THE TAG VALUE FOR THE WATERSHED LINE - // THE OTHER VALUES ARE THE REGION LABELS - - - mln_VAR(wst_line, wst | (pw::value(wst) == pw::cst(0u))); // FIXME: wst | 0 - std::cout << "the watershed line = " << wst_line.domain() << std::endl - << std::endl; - // the watershed line = {(1,0)(1,2)(1,4)} - // ^^^^^ - // meaning (row = 1, col = 0) - - // Actually wst is: - // - // 0 1 2 3 4 <- col - // +-----------+ - // 0 | 2 2 | - // 1 | 0 0 0 | - // 2 | 1 1 | - // +-----------+ - // ^ - // | - // row - - - - // YET THOSE VALUES ARE ON EDGES, NOT ON CELLS... - - debug::println(label); - // 9 2 9 2 9 - // 0 9 0 9 0 - // 9 1 9 1 9 - - - mln_VAR(lab, label | is_cell); - debug::println(lab); - // 9 9 9 - // - // 9 9 9 - - - data::paste(morpho::dilation(extend(lab, label), - c4().win()), - label); - - debug::println(label); - // 2 2 2 2 2 - // 0 9 0 9 0 - // 1 1 1 1 1 - - debug::println(lab); - // 2 2 2 - // - // 1 1 1 - - - // ABOVE, WE HAVE THE LABEL IMAGE (POINTS-ONLY). - // BELOW, THE ORIGINAL IMAGE (POINTS-ONLY). - - - debug::println(cell); - // 1 2 3 - // - // 4 5 6 - - - // NOW WE WANT TO MODIFY THE INPUT IMAGE TO FLATTEN REGIONS... - - - fun::i2v::array<int> m(nbasins + 1); - accu::compute<accu::meta::stat::mean>(cell, label, m); - for (unsigned i = 1; i <= nbasins; ++i) - std::cout << "mean value of basin #" << i << " is " << m(i) << std::endl; - -// data::fill(cell, data::transform(lab, m)); -// debug::println(cell); -// // 2 2 2 -// // -// // 5 5 5 - - // DONE! - -} diff --git a/milena/doc/examples/trash/tuto_one.cc b/milena/doc/examples/trash/tuto_one.cc deleted file mode 100644 index 1ce11bf..0000000 --- a/milena/doc/examples/trash/tuto_one.cc +++ /dev/null @@ -1,128 +0,0 @@ -# include <cstdlib> - -# include <mln/value/int_u8.hh> -# include <mln/value/rgb8.hh> - -# include <mln/io/pgm/load.hh> -# include <mln/io/ppm/save.hh> - -# include <mln/core/var.hh> -# include <mln/core/image/image2d.hh> -# include <mln/core/alias/neighb2d.hh> -# include <mln/make/double_neighb2d.hh> - -# include <mln/data/transform.hh> -# include <mln/literal/black.hh> -# include <mln/debug/println.hh> - -# include <mln/morpho/closing_area.hh> -# include <mln/morpho/gradient.hh> -# include <mln/morpho/watershed/flooding.hh> - - -using namespace mln; -using value::int_u8; - - - -struct colorize : Function_v2v< colorize > -{ - typedef value::rgb8 result; - colorize(unsigned max) - : lut(max + 1) - { - lut[0] = literal::black; - for (unsigned i = 1; i <= max; ++i) - lut[i] = result(100 + std::rand() % 150, - 100 + std::rand() % 150, - 100 + std::rand() % 150); - } - result operator()(unsigned i) const - { - return lut[i]; - } - std::vector<result> lut; -}; - - -bool is_chess(const point2d& p) -{ - return p.col() % 2 == p.row() % 2; -} - - -void usage(char* argv[]) -{ - std::cerr << "usage: " << argv[0] << " input.pgm nbh lambda output.ppm" << std::endl; - std::cerr << " nbh in {4, 6, 8}; lambda >= 0" << std::endl; - abort(); -} - - -template <typename I, typename N> -void do_it(const I& ima, - const N& nbh, - int lambda, - const std::string& filename) -{ - I grad = morpho::gradient(ima, nbh.win()); - - I clo; - if (lambda > 1) - clo = morpho::closing_area(grad, nbh, lambda); - else - clo = grad; - - unsigned l; - mln_ch_value(I, unsigned) wst = morpho::watershed::flooding(clo, nbh, l); - - debug::println(labeling::regional_minima(clo, nbh, l)); - debug::println(wst); - - io::ppm::save(data::transform(wst, colorize(l)), filename); -} - - -int main(int argc, char* argv[]) -{ - if (argc != 5) - usage(argv); - - image2d<int_u8> ima; - - io::pgm::load(ima, argv[1]); - - int nbh_ = atoi(argv[2]); - if (! (nbh_ == 4 || nbh_ == 6 || nbh_ == 8)) - usage(argv); - - int lambda = atoi(argv[3]); - if (lambda < 0) - usage(argv); - - std::string filename(argv[4]); - - if (nbh_ == 4) - { - mln_VAR(nbh, c4()); - do_it(ima, nbh, lambda, filename); - } - else if (nbh_ == 8) - { - mln_VAR(nbh, c8()); - do_it(ima, nbh, lambda, filename); - } - else if (nbh_ == 6) - { - bool vert[] = { 1, 1, 0, - 1, 0, 1, - 0, 1, 1 }; - - bool hori[] = { 0, 1, 1, - 1, 0, 1, - 1, 1, 0 }; - - mln_VAR(nbh, make::double_neighb2d(is_chess, vert, hori)); - do_it(ima, nbh, lambda, filename); - } -} diff --git a/milena/doc/examples/trash/vec.cc b/milena/doc/examples/trash/vec.cc deleted file mode 100644 index b0156fe..0000000 --- a/milena/doc/examples/trash/vec.cc +++ /dev/null @@ -1,14 +0,0 @@ -# include <mln/convert/to.hh> -# include <mln/core/alias/point2d.hh> - - - -int main() -{ - using namespace mln; - - algebra::vec<2,float> v; - v[0] = 5.14; - v[1] = 1.99; - std::cout << convert::to<point2d>(v) << std::endl; -} diff --git a/milena/doc/examples/trash/win_multiple.cc b/milena/doc/examples/trash/win_multiple.cc deleted file mode 100644 index 352e3b8..0000000 --- a/milena/doc/examples/trash/win_multiple.cc +++ /dev/null @@ -1,65 +0,0 @@ -# include <mln/core/image/image2d.hh> -# include <mln/core/alias/window2d.hh> -# include <mln/win/multiple.hh> - -// # include <mln/border/fill.hh> -# include <mln/debug/iota.hh> -# include <mln/debug/println.hh> - -# include <mln/core/alias/neighb2d.hh> -# include <mln/convert/to.hh> - - - -template <typename I, typename W> -void browse(const I& ima, const W& win) -{ - mln_fwd_piter(I) p(ima.domain()); - mln_fwd_qiter(W) q(win, p); - for_all(p) - { - std::cout << ima(p) << ": "; - for_all(q) - if (ima.has(q)) - std::cout << ima(q) << ' '; - std::cout << std::endl; - } -} - - -struct row_oddity -{ - unsigned operator()(const mln::point2d& p) const - { - return p.row() % 2; - } -}; - - -int main() -{ - using namespace mln; - - typedef image2d<unsigned> I; - I ima(3, 3, 0); // 1); - // border::fill(ima, 0); - debug::iota(ima); - debug::println(ima); - - win::multiple<window2d, row_oddity> w; - - bool vert[] = { 0, 1, 0, - 0, 0, 0, - 0, 1, 0 }; - - convert::to<window2d>(vert); - -// w.set_window(0, convert::to<window2d>(vert)); -// bool horiz[] = { 0, 0, 0, -// 1, 0, 1, -// 0, 0, 0 }; -// w.set_window(1, convert::to<window2d>(horiz)); -// mln_assertion(w.size() == 2); - -// browse(ima, w); -} diff --git a/milena/doc/examples/trash/window.cc b/milena/doc/examples/trash/window.cc deleted file mode 100644 index 9077d48..0000000 --- a/milena/doc/examples/trash/window.cc +++ /dev/null @@ -1,92 +0,0 @@ -# include <mln/core/image/image2d.hh> -# include <mln/core/alias/window2d.hh> -# include <mln/core/site_set/p_array.hh> - -# include <mln/debug/iota.hh> -# include <mln/debug/println.hh> - -# include <mln/core/alias/neighb2d.hh> -# include <mln/convert/to.hh> - - -template <typename I, typename W, typename P> -void picture(const I& ima, const W& win, const P& p) -{ - std::cout << ima(p) << ": "; - mln_qiter(W) q(win, p); - for_all(q) - if (ima.has(q)) - std::cout << ima(q) << ' '; - else - std::cout << "- "; - std::cout << std::endl; -} - - -template <typename I, typename W> -void fill_null(I& ima, const W& win) -{ - mln_piter(I) p(ima.domain()); - mln_qiter(W) q(win, p); - for_all(p) - for_all(q) - if (ima.has(q)) - ima(q) = 0; -} - - - -int main() -{ - using namespace mln; - - typedef image2d<unsigned> I; - I ima(2, 3, 0); // no border - debug::iota(ima); - debug::println(ima); - mln_invariant(ima.nsites() == 6); - - window2d win; - win - .insert(-1, 0) - .insert(0, -1) - .insert(-1,-1); - std::cout << win << std::endl; - - { - bool b[9] = { 1, 1, 0, - 1, 0, 0, - 0, 0, 0 }; - bool b2[3][3] = { { 1, 1, 0 }, - { 1, 0, 0 }, - { 0, 0, 0 } }; - mln_assertion(convert::to<window2d>(b) == convert::to<window2d>(b2)); - mln_assertion(convert::to<window2d>(b) == win); - } - - { - mln_fwd_piter_(I) p(ima.domain()); - for_all(p) - picture(ima, win, p); - } - - { - typedef p_array<point2d> A; - A arr; - arr += ima.domain(); - mln_fwd_piter_(A) p(arr); - for_all(p) - picture(ima, win, p); - - // FIXME: Move this new test in a separate file. - mln_psite_(A) c(arr, 0); - window2d it; it.insert(0,0); - mln_qiter_(window2d) q(it, c); - q.start(); - q.to_site() == c.to_site(); - c.inc_index(); - mln_assertion(q.update().to_site() == c.to_site()); - } - - fill_null(ima, win); -} diff --git a/milena/trash/bgraph_image.cc b/milena/trash/bgraph_image.cc deleted file mode 100644 index 5987401..0000000 --- a/milena/trash/bgraph_image.cc +++ /dev/null @@ -1,105 +0,0 @@ -// Copyright (C) 2007, 2008 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. - -/// \file tests/core/image/bgraph_image.cc -/// \brief Tests on mln::bgraph_image. - -#include <vector> - -#include <mln/value/int_u8.hh> -#include <mln/core/image/image2d.hh> -#include <mln/core/image/bgraph_image.hh> -#include <mln/data/fill.hh> -#include <mln/data/paste.hh> -#include <mln/debug/println.hh> - - - -int main() -{ - using namespace mln; - - /*--------. - | Graph. | - `--------*/ - using namespace mln; - typedef util::internal::boost_graph<point2d, util::empty> Graph; - - // Make convenient labels for the vertices - const int num_vertices = 5; - - // writing out the edges in the graph - typedef std::pair<int, int> Edge; - Edge edge_array[] = { - Edge(0, 1), Edge(0, 3), Edge(2, 0), Edge(3, 2), - Edge(2, 4), Edge(1, 3), Edge(3, 4) - }; - - const int num_edges = sizeof(edge_array)/sizeof(edge_array[0]); - // declare a graph object - Graph& g = *new Graph(num_vertices); - - // add the edges to the graph object - for (int i = 0; i < num_edges; ++i) - boost::add_edge(edge_array[i].first, edge_array[i].second, g); - - g[0] = point2d(0, 0); - g[1] = point2d(0, 1); - g[2] = point2d(1, 0); - g[3] = point2d(1, 1); - g[4] = point2d(0, 2); - - /*------------------. - | Boost Graph Image | - `-------------------*/ - - /*--------------. - | Vector values | - `--------------*/ - - typedef bgraph_image<point2d, int> ima_type; - - std::vector<int> values; - values.push_back(1); - values.push_back(2); - values.push_back(3); - values.push_back(4); - values.push_back(5); - - ima_type ima(&g, values); - mln_piter_(ima_type) p(ima.domain()); - for_all(p) - std::cout << p << ' ' << ima(p) << std::endl; - - { - using value::int_u8; - image2d<int_u8> ima_(ima.bbox()); - data::fill(ima_, 0); - data::paste(ima, ima_); - debug::println(ima_); - } - - delete &g; -} diff --git a/milena/trash/bgraph_image.hh b/milena/trash/bgraph_image.hh deleted file mode 100644 index c936b92..0000000 --- a/milena/trash/bgraph_image.hh +++ /dev/null @@ -1,288 +0,0 @@ -// Copyright (C) 2007, 2008 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_CORE_IMAGE_BGRAPH_IMAGE_HH -# define MLN_CORE_IMAGE_BGRAPH_IMAGE_HH - -/// \file mln/core/image/bgraph_image.hh -/// -/// Definition of a boost-graph-based image. - -# include <mln/trait/images.hh> -# include <mln/core/internal/image_primary.hh> -# include <mln/algebra/vec.hh> - -# include <mln/core/site_set/p_bgraph.hh> -# include <mln/core/image/bgraph_psite.hh> -# include <mln/value/set.hh> -# include <vector> - -namespace mln -{ - - // Forward declaration - template <typename P, typename V> struct bgraph_image; - - namespace internal - { - - /// Data structure for \c mln::bgraph_image<P,V>. - template <typename P, typename V> - struct data< bgraph_image<P, V> > - { - /// Data stores a **copy** of the pset g. - /// But, the pset g and the data_ copy will shared the same - /// underlaying graph. - data(const p_bgraph<P>& g, const std::vector<V>& val); - - - p_bgraph<P> pg_; - - std::vector<V> val_; - }; - - } // end of namespace mln::internal - - - namespace trait - { - - template <typename P, typename V> - struct image_< bgraph_image<P, V> > : - default_image_< V, bgraph_image<P, V> > - { - typedef trait::image::category::primary category; - - // FIXME: update with new properties. -// typedef trait::image::access::random access; -// typedef typename trait::image::space_from_point<P>::ret space; -// typedef trait::image::size::regular size; -// typedef trait::image::support::irregular support; -// -// typedef trait::image::border::none border; -// typedef trait::image::data::stored data; -// typedef trait::image::io::read_write io; -// typedef trait::image::speed::fast speed; - }; - - } // end of namespace mln::trait - - /// Kind of image based on a boost graph structure. - /// - /// \ingroup modimageconcrete - // - template <typename P, typename V> - struct bgraph_image : - public internal::image_primary< V, p_bgraph<P>, bgraph_image<P, V> > - { - - typedef mln::internal::image_primary< V, p_bgraph<P>, bgraph_image<P, V> > - super_; - - /// Value associated type. - typedef V value; - - /// Return type of read-write access. - /// - /// We use the associated type \c reference instead of a plain - /// reference on the value type (\p V), because it's the only way - /// to safely form a reference on the element in the case of a - /// std::vector<bool>. - typedef typename std::vector<V>::reference lvalue; - - /// Return type of read-only access. - typedef typename std::vector<V>::const_reference rvalue; - - /// Skeleton. - typedef bgraph_image< tag::psite_<P>, tag::value_<V> > skeleton; - - /// Constructors. - /// \{ - bgraph_image(); - bgraph_image(const p_bgraph<P>& g); - bgraph_image(const p_bgraph<P>& g, const std::vector<V>& val); - /// \} - - /// Initialize an empty image. - void init_(const p_bgraph<P>& g, const std::vector<V>& val); - - /// Read-only access of pixel value at point site \p p. - rvalue operator()(const bgraph_psite<P>& p) const; - - /// Read-write access of pixel value at point site \p p. - lvalue operator()(const bgraph_psite<P>& p); - - /// Accessors. - /// \{ - /// Return the domain of psites od the image. - const p_bgraph<P>& domain() const; - - /// Return the array of values associated to the nodes. - const std::vector<V>& node_values() const; - /// \} - - - /// Return the point of the first node adjacent to the edge with - /// id \a e. - const P& node1(const typename p_bgraph<P>::edge_id& e) const; - /// Return the point of the second node adjacent to the edge with - /// id \a e. - const P& node2(const typename p_bgraph<P>::edge_id& e) const; -}; - - // Initialization routine. - template <typename P, typename V> - void init_(tag::image_t, - bgraph_image<P, V>& target, const bgraph_image<P, V>& model); - - -# ifndef MLN_INCLUDE_ONLY - - /*-----------------. - | Initialization. | - `-----------------*/ - - template <typename P, typename V> - inline - void init_(tag::image_t, - bgraph_image<P, V>& target, const bgraph_image<P, V>& model) - { - target.init_(model.domain(), model.node_values ()); - } - - /*-------. - | Data. | - `-------*/ - - namespace internal - { - template <typename P, typename V> - inline - data< bgraph_image<P, V> >::data(const p_bgraph<P>& g, - const std::vector<V>& val) - : pg_ (g), - val_ (val) - { - } - - } // end of namespace mln::internal - - /*---------------. - | Construction. | - `---------------*/ - - template <typename P, typename V> - inline - bgraph_image<P, V>::bgraph_image() - { - } - - template <typename P, typename V> - inline - bgraph_image<P, V>::bgraph_image(const p_bgraph<P>& g) - { - init_(g, std::vector<V>(g.nsites())); - } - - template <typename P, typename V> - inline - bgraph_image<P, V>::bgraph_image(const p_bgraph<P>& g, - const std::vector<V>& val) - { - init_(g, val); - } - - template <typename P, typename V> - inline - void - bgraph_image<P, V>::init_(const p_bgraph<P>& g, const std::vector<V>& val) - { - this->data_ = new internal::data< bgraph_image<P, V> > (g, val); - } - - /*---------------. - | Manipulation. | - `---------------*/ - - template <typename P, typename V> - inline - typename bgraph_image<P, V>::rvalue - bgraph_image<P, V>::operator()(const bgraph_psite<P>& p) const - { - mln_precondition(&p.pg().to_graph() == &this->data_->pg_.to_graph()); - mln_precondition(p.id() < this->data_->val_.size()); - return this->data_->val_[p.id()]; - } - - template <typename P, typename V> - inline - typename bgraph_image<P, V>::lvalue - bgraph_image<P, V>::operator()(const bgraph_psite<P>& p) - { - mln_precondition(&p.pg().to_graph() == &this->data_->pg_.to_graph()); - mln_precondition(p.id() < this->data_->val_.size()); - return this->data_->val_[p.id()]; - } - - template <typename P, typename V> - inline - const std::vector<V>& - bgraph_image<P, V>::node_values() const - { - return this->data_->val_; - } - - template <typename P, typename V> - inline - const p_bgraph<P>& - bgraph_image<P, V>::domain() const - { - mln_precondition(this->is_valid()); - return this->data_->pg_; - } - - template <typename P, typename V> - inline - const P& - bgraph_image<P, V>::node1(const typename p_bgraph<P>::edge_id& e) const - { - return this->domain().node1(e); - } - - template <typename P, typename V> - inline - const P& - bgraph_image<P, V>::node2(const typename p_bgraph<P>::edge_id& e) const - { - return this->domain().node2(e); - } - -# endif // ! MLN_INCLUDE_ONLY - -} // end of namespace mln - - -#endif // ! MLN_CORE_IMAGE_BGRAPH_IMAGE_HH diff --git a/milena/trash/bgraph_psite.hh b/milena/trash/bgraph_psite.hh deleted file mode 100644 index de04425..0000000 --- a/milena/trash/bgraph_psite.hh +++ /dev/null @@ -1,176 +0,0 @@ -// Copyright (C) 2007, 2008 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_CORE_IMAGE_BGRAPH_PSITE_HH -# define MLN_CORE_IMAGE_BGRAPH_PSITE_HH - -/// \file mln/core/image/bgraph_psite.hh -/// -/// Definition of a boost-graph-based point site. - -# include <mln/core/site_set/p_bgraph.hh> - - -namespace mln -{ - - // Fwd decl. - template<typename P> class p_bgraph; - - - /// Point site associated to a mln::graph_image. - template<typename P> - class bgraph_psite : public Point_Site< bgraph_psite<P> > - { - typedef bgraph_psite<P> self_; - typedef Point_Site< bgraph_psite<P> > super_; - - public: - typedef mln_mesh(P) mesh; - enum { dim = P::dim }; - typedef P point; - typedef mln_dpoint(P) dpoint; - typedef mln_coord(P) coord; - - /// Construction and assignment. - /// \{ - bgraph_psite(const p_bgraph<P>& pg_, typename p_bgraph<P>::node_id id); - bgraph_psite(const self_& rhs); - /// \pre This psite must have the same graph point set as \a rhs. - self_& operator= (const self_& rhs); - /// \} - - /// Access to psite. - const self_& to_psite() const; - - /// Access to point. - /// \{ - operator P() const; - const point& to_point() const; - coord operator[](unsigned id) const; - /// \} - - /// Return the p_graph this point site belongs to. - const p_bgraph<P>& pg() const; - /// Return the node id of this point site. - typename p_bgraph<P>::node_id id() const; - - private: - /// The p_graph this point site belongs to. - const p_bgraph<P>& pg_; - /// The id of the node this psite is pointing towards. - typename p_bgraph<P>::node_id id_; - }; - -# ifndef MLN_INCLUDE_ONLY - - template<typename P> - inline - bgraph_psite<P>::bgraph_psite(const p_bgraph<P>& g, - typename p_bgraph<P>::node_id id) - : pg_(g), - id_(id) - { - } - - - /// FIXME: Is it normal to have to call super_() ? - template<typename P> - inline - bgraph_psite<P>::bgraph_psite(const self_& rhs) - : super_(), - pg_(rhs.pg_), - id_(rhs.id_) - { - } - - template<typename P> - inline - bgraph_psite<P>& - bgraph_psite<P>::operator= (const self_& rhs) - { - if (&rhs == this) - return *this; - // Assigning a psite from a graph point set to a psite from - // another graph point set is meaningless. - mln_assertion(&pg_.to_graph() == &rhs.pg_.to_graph()); - id_ = rhs.id_; - return *this; - } - - template<typename P> - inline - const bgraph_psite<P>& - bgraph_psite<P>::to_psite() const - { - return *this; - } - - template<typename P> - inline - bgraph_psite<P>::operator P() const - { - return pg_.point_from_id(id_); - } - - template<typename P> - inline - const P& - bgraph_psite<P>::to_point() const - { - return pg_.point_from_id(id_); - } - - template<typename P> - inline - mln_coord(P) - bgraph_psite<P>::operator[](unsigned i) const - { - return to_point()[i]; - } - - template<typename P> - inline - const p_bgraph<P>& - bgraph_psite<P>::pg() const - { - return pg_; - } - - template<typename P> - inline - typename p_bgraph<P>::node_id - bgraph_psite<P>::id() const - { - return id_; - } - -# endif // ! MLN_INCLUDE_ONLY - - -} // end of mln - -#endif // MLN_CORE_IMAGE_BGRAPH_PSITE_HH diff --git a/milena/trash/boost_graph.cc b/milena/trash/boost_graph.cc deleted file mode 100644 index 9db9b82..0000000 --- a/milena/trash/boost_graph.cc +++ /dev/null @@ -1,114 +0,0 @@ -// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory -// -// 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. - -/// \file tests/util/graph.cc -/// \brief test of mln::util::graph -/// This test is a copy of the BGL quick tours example. - -#include <mln/util/internal/boost_graph.hh> -#include <iostream> - -using namespace mln::util::internal; -using namespace boost; - -struct empty {}; - -template <class Graph> -struct exercise_vertex -{ - typedef typename graph_traits<Graph>::vertex_descriptor Vertex; - exercise_vertex(Graph& g_) : g(g_) {} - - void operator()(const Vertex& v) const - { - typedef graph_traits<Graph> GraphTraits; - typename property_map<Graph, vertex_index_t>::type - index = get(vertex_index, g); - - std::cout << "out-edges: "; - typename GraphTraits::out_edge_iterator out_i, out_end; - typename GraphTraits::edge_descriptor e; - for (tie(out_i, out_end) = out_edges(v, g); out_i != out_end; ++out_i) - { - e = *out_i; - Vertex src = source(e, g), targ = target(e, g); - std::cout << "(" << index[src] << "," << index[targ] << ") "; - } - std::cout << std::endl; - - std::cout << "adjacent vertices: "; - typename graph_traits<Graph>::adjacency_iterator ai; - typename graph_traits<Graph>::adjacency_iterator ai_end; - for (tie(ai, ai_end) = adjacent_vertices(v, g); ai != ai_end; ++ai) - std::cout << index[*ai] << " "; - std::cout << std::endl; - } - - Graph& g; -}; - -int main () -{ - - typedef boost_graph<empty, empty> Graph; - - // Make convenient labels for the vertices - const int num_vertices = 5; - - // writing out the edges in the graph - typedef std::pair<int, int> Edge; - Edge edge_array[] = { - Edge(0, 1), Edge(0, 3), Edge(2, 0), Edge(3, 2), - Edge(2, 4), Edge(1, 3), Edge(3, 4) - }; - const int num_edges = sizeof(edge_array)/sizeof(edge_array[0]); - - // declare a graph object - Graph g(num_vertices); - typedef property_map<Graph, vertex_index_t>::type IndexMap; - IndexMap index = get(vertex_index, g); - - // add the edges to the graph object - for (int i = 0; i < num_edges; ++i) - add_edge(edge_array[i].first, edge_array[i].second, g); - - std::cout << "vertices(g) = "; - typedef graph_traits<Graph>::vertex_iterator vertex_iter; - std::pair<vertex_iter, vertex_iter> vp; - for (vp = vertices(g); vp.first != vp.second; ++vp.first) - std::cout << index[*vp.first] << " "; - std::cout << std::endl; - - std::cout << "edges(g) = "; - graph_traits<Graph>::edge_iterator ei, ei_end; - for (tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) - std::cout << "(" << index[source(*ei, g)] - << "," << index[target(*ei, g)] << ") "; - std::cout << std::endl; - - std::for_each(vertices(g).first, vertices(g).second, - exercise_vertex<Graph>(g)); - return 0; -} diff --git a/milena/trash/boost_graph.hh b/milena/trash/boost_graph.hh deleted file mode 100644 index 62107fa..0000000 --- a/milena/trash/boost_graph.hh +++ /dev/null @@ -1,218 +0,0 @@ -// Copyright (C) 2007, 2008 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_INTERNAL_BOOST_GRAPH_HH -# define MLN_UTIL_INTERNAL_BOOST_GRAPH_HH - -/// \file mln/util/internal/boost_graph.hh -/// -/// Definition of the boost::adjacenly_list decorator. - -# include <boost/graph/adjacency_list.hpp> - -namespace mln -{ - - namespace util - { - - struct empty {}; - - namespace internal - { - - /// Boost graph decorator base - /// Graph class which rests on boost::adjacency_list class. - template <typename VertexProperty = empty, - typename EdgeProperty = empty> - class boost_graph - { - typedef boost_graph<VertexProperty, EdgeProperty> self_type; - - public: - /// Types declartation. - typedef boost::adjacency_list<boost::setS, boost::vecS, - boost::undirectedS, - VertexProperty, EdgeProperty> decorated; - - /// Descriptors. - typedef typename decorated::vertex_descriptor vertex_descriptor; - typedef typename decorated::edge_descriptor edge_descriptor; - - /// Iterators. - typedef typename decorated::vertex_iterator vertex_iterator; - typedef typename decorated::edge_iterator edge_iterator; - typedef typename decorated::out_edge_iterator out_edge_iterator; - typedef typename decorated::in_edge_iterator in_edge_iterator; - typedef typename decorated::adjacency_iterator adjacency_iterator; - typedef typename decorated::inv_adjacency_iterator - inv_adjacency_iterator; - - /// Categories. - typedef typename decorated::directed_category directed_category; - typedef typename decorated::traversal_category traversal_category; - typedef typename decorated::edge_parallel_category - edge_parallel_category; - typedef typename decorated::vertex_property_type vertex_property_type; - typedef typename decorated::edge_property_type edge_property_type; - typedef typename decorated::graph_tag graph_tag; - - /// Properties. - typedef typename decorated::vertex_bundled vertex_bundled; - - /// Sizes. - typedef typename decorated::vertices_size_type vertices_size_type; - typedef typename decorated::edges_size_type edges_size_type; - typedef typename decorated::degree_size_type degree_size_type; - - - /// Constructor(s). - boost_graph(); - boost_graph(const boost_graph& lhs); - boost_graph(vertices_size_type n); - - /// Assignment operator. - boost_graph& - operator=(const boost_graph& lhs); - - /// Remove all of the edges and vertices from the graph. - void clear(); - - /// Swap the vertices, edges, and properties of this graph with - /// the vertices, edges, and properties of graph x. - void swap(boost_graph& rhs); - - /// Internal methods: - - /// Return the boost decorated graph. - decorated& - graph(); - - /// Return the boost decorated graph (const version). - const decorated& - graph() const; - - /// Provides acces to the graph bundle properties - vertex_bundled& operator[](vertex_descriptor v); - const vertex_bundled& operator[](vertex_descriptor v) const; - - - protected: - decorated graph_; - /// add index on need - }; - - /// Graph method declaration - - /// Implementation - -# ifndef MLN_INCLUDE_ONLY - - template <typename VertexProp, typename EdgeProp> - boost_graph<VertexProp, EdgeProp>::boost_graph() - { - } - - template <typename VertexProp, typename EdgeProp> - boost_graph<VertexProp, EdgeProp>::boost_graph(const boost_graph& lhs) : - graph_(lhs.graph_) - { - } - - template <typename VertexProp, typename EdgeProp> - boost_graph<VertexProp, EdgeProp>::boost_graph(vertices_size_type n) : - graph_(n) - { - } - - template <typename VertexProp, typename EdgeProp> - boost_graph<VertexProp, EdgeProp>& - boost_graph<VertexProp, EdgeProp>::operator=(const boost_graph& lhs) - { - if (&lhs == this) - return *this; - this->graph_ = lhs.graph_; - } - - template <typename VertexProp, typename EdgeProp> - void - boost_graph<VertexProp, EdgeProp>::clear() - { - this->graph_.clear(); - } - - template <typename VertexProp, typename EdgeProp> - void - boost_graph<VertexProp, EdgeProp>::swap(boost_graph& rhs) - { - this->graph_.swap(rhs.graph_); - } - - template <typename VertexProp, typename EdgeProp> - inline - typename boost_graph<VertexProp, EdgeProp>::decorated& - boost_graph<VertexProp, EdgeProp>::graph() - { - return this->graph_; - } - - template <typename VertexProp, typename EdgeProp> - inline - const typename boost_graph<VertexProp, EdgeProp>::decorated& - boost_graph<VertexProp, EdgeProp>::graph() const - { - return this->graph_; - } - - template <typename V, typename E> - inline - typename boost_graph<V, E>::vertex_bundled& - boost_graph<V, E>::operator[](vertex_descriptor v) - { - return this->graph_[v]; - } - - template <typename V, typename E> - inline - const typename boost_graph<V, E>::vertex_bundled& - boost_graph<V, E>::operator[](vertex_descriptor v) const - { - return this->graph_[v]; - } - -# endif // ! MLN_INCLUDE_ONLY - - } // end of namespace mln::util::internal - - } // end of namespace mln::util - -} // end of namespace mln - -# include "boost_graph_access.hh" -# include "boost_graph_structure.hh" -# include "boost_graph_property.hh" - -#endif // ! MLN_UTIL_INTERNAL_BOOST_GRAPH_HH diff --git a/milena/trash/boost_graph_access.hh b/milena/trash/boost_graph_access.hh deleted file mode 100644 index ce40eff..0000000 --- a/milena/trash/boost_graph_access.hh +++ /dev/null @@ -1,292 +0,0 @@ -// Copyright (C) 2007, 2008 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. - -/// \file mln/util/internal/boost_graph_access.hh -/// \brief boost_graph access operations. - -#ifndef MLN_UTIL_INTERNAL_BOOST_GRAPH_ACCESS_HH_ -# define MLN_UTIL_INTERNAL_BOOST_GRAPH_ACCESS_HH_ - - -# include <utility> - -/// fwd declaration -namespace mln -{ - namespace util - { - namespace internal - { - template <typename VertexProperty, typename EdgeProperty> - class boost_graph; - } - } -} - -namespace boost -{ - namespace mlnu = mln::util::internal; - - /// \brief Returns an iterator-range providing access to the vertex - /// set of graph g. - template <typename VProp, typename EProp> - std::pair<typename mlnu::boost_graph<VProp, EProp>::vertex_iterator, - typename mlnu::boost_graph<VProp, EProp>::vertex_iterator> - vertices(const mlnu::boost_graph<VProp, EProp>& g); - - - /// \brief Returns an iterator-range providing access to - /// the edge set of graph g. - template <typename VProp, typename EProp> - std::pair<typename mlnu::boost_graph<VProp, EProp>::edge_iterator, - typename mlnu::boost_graph<VProp, EProp>::edge_iterator> - edges(const mlnu::boost_graph<VProp, EProp>& g); - - - /// \brief Returns an iterator-range providing access to the vertices - /// adjacent to vertex u in graph g. - template <typename VProp, typename EProp> - std::pair<typename mlnu::boost_graph<VProp, EProp>::adjacency_iterator, - typename mlnu::boost_graph<VProp, EProp>::adjacency_iterator> - adjacent_vertices(typename mlnu::boost_graph<VProp, EProp>::vertex_descriptor u, - const mlnu::boost_graph<VProp, EProp>& g); - - - /// \brief Returns an iterator-range providing access to the vertices in - /// graph g to which u is adjacent. (inv is for inverse.) - template <typename VProp, typename EProp> - std::pair<typename mlnu::boost_graph<VProp, EProp>::inv_adjacency_iterator, - typename mlnu::boost_graph<VProp, EProp>::inv_adjacency_iterator> - inv_adjacent_vertices(typename mlnu::boost_graph<VProp, EProp>::vertex_descriptor u, - const mlnu::boost_graph<VProp, EProp>& g); - - /// \brief Returns an iterator-range providing access access to - /// all edges incident on vertex u. - template <typename VProp, typename EProp> - std::pair<typename mlnu::boost_graph<VProp, EProp>::out_edge_iterator, - typename mlnu::boost_graph<VProp, EProp>::out_edge_iterator> - out_edges(typename mlnu::boost_graph<VProp, EProp>::vertex_descriptor u, - const mlnu::boost_graph<VProp, EProp>& g); - - /// FIXME: this operation is undefined for undirected graph - template <typename VProp, typename EProp> - std::pair<typename mlnu::boost_graph<VProp, EProp>::in_edge_iterator, - typename mlnu::boost_graph<VProp, EProp>::in_edge_iterator> - in_edges(typename mlnu::boost_graph<VProp, EProp>::vertex_descriptor v, - const mlnu::boost_graph<VProp, EProp>& g); - - - /// \brief Returns the source vertex of edge e. - template <typename VProp, typename EProp> - typename mlnu::boost_graph<VProp, EProp>::vertex_descriptor - source(typename mlnu::boost_graph<VProp, EProp>::edge_descriptor e, - const mlnu::boost_graph<VProp, EProp>& g); - - /// \brief Returns the target vertex of edge e. - template <typename VProp, typename EProp> - typename mlnu::boost_graph<VProp, EProp>::vertex_descriptor - target(typename mlnu::boost_graph<VProp, EProp>::edge_descriptor e, - const mlnu::boost_graph<VProp, EProp>& g); - - /// \brief Returns the number of edges leaving vertex u. - template <typename V, typename E> - typename mlnu::boost_graph<V, E>::degree_size_type - out_degree(typename mlnu::boost_graph<V, E>::vertex_descriptor u, - const mlnu::boost_graph<V, E>& g); - - /// FIXME this operation is unavalaible for undirected graph. - template <typename VProp, typename EProp> - typename mlnu::boost_graph<VProp, EProp>::degree_size_type - in_degree(typename mlnu::boost_graph<VProp, EProp>::vertex_descriptor u, - const mlnu::boost_graph<VProp, EProp>& g); - - /// \brief Returns the number of vertices in the graph g. - template <typename VProp, typename EProp> - typename mlnu::boost_graph<VProp, EProp>::vertices_size_type - num_vertices(const mlnu::boost_graph<VProp, EProp>& g); - - /// \brief Returns the number of edges in the graph g. - template <typename VProp, typename EProp> - typename mlnu::boost_graph<VProp, EProp>::edges_size_type - num_edges(const mlnu::boost_graph<VProp, EProp>& g); - - - /// \brief Returns the nth vertex in the graph's vertex list. - template <typename VProp, typename EProp> - typename mlnu::boost_graph<VProp, EProp>::vertex_descriptor - vertex(typename mlnu::boost_graph<VProp, EProp>::vertices_size_type n, - const typename mlnu::boost_graph<VProp, EProp>& g); - - - /// \brief Returns an edge connecting vertex u to vertex v in graph g. - template <typename VProp, typename EProp> - std::pair<typename mlnu::boost_graph<VProp, EProp>::edge_descriptor, bool> - edge(typename mlnu::boost_graph<VProp, EProp>::vertex_descriptor u, - typename mlnu::boost_graph<VProp, EProp>::vertex_descriptor v, - const mlnu::boost_graph<VProp, EProp>& g); - - /// \brief Returns a pair of out-edge iterators that give the range for all - /// the parallel edges from u to v. - template <typename VProp, typename EProp> - std::pair<typename mlnu::boost_graph<VProp, EProp>::out_edge_iterator, - typename mlnu::boost_graph<VProp, EProp>::out_edge_iterator> - edge_range(typename mlnu::boost_graph<VProp, EProp>::vertex_descriptor u, - typename mlnu::boost_graph<VProp, EProp>::vertex_descriptor v, - const mlnu::boost_graph<VProp, EProp>& g); - -# ifndef MLN_INCLUDE_ONLY - - template <typename VProp, typename EProp> - std::pair<typename mlnu::boost_graph<VProp, EProp>::vertex_iterator, - typename mlnu::boost_graph<VProp, EProp>::vertex_iterator> - vertices(const mlnu::boost_graph<VProp, EProp>& g) - { - return vertices(g.graph()); - } - - template <typename VProp, typename EProp> - std::pair<typename mlnu::boost_graph<VProp, EProp>::edge_iterator, - typename mlnu::boost_graph<VProp, EProp>::edge_iterator> - edges(const mlnu::boost_graph<VProp, EProp>& g) - { - return edges(g.graph()); - } - - template <typename VProp, typename EProp> - std::pair<typename mlnu::boost_graph<VProp, EProp>::adjacency_iterator, - typename mlnu::boost_graph<VProp, EProp>::adjacency_iterator> - adjacent_vertices(typename mlnu::boost_graph<VProp, EProp>::vertex_descriptor u, - const mlnu::boost_graph<VProp, EProp>& g) - { - return adjacent_vertices(u, g.graph()); - } - - template <typename VProp, typename EProp> - std::pair<typename mlnu::boost_graph<VProp, EProp>::inv_adjacency_iterator, - typename mlnu::boost_graph<VProp, EProp>::inv_adjacency_iterator> - inv_adjacent_vertices(typename mlnu::boost_graph<VProp, EProp>::vertex_descriptor u, - const mlnu::boost_graph<VProp, EProp>& g) - { - return inv_adjacent_vertices(u, g.graph()); - } - - template <typename VProp, typename EProp> - std::pair<typename mlnu::boost_graph<VProp, EProp>::out_edge_iterator, - typename mlnu::boost_graph<VProp, EProp>::out_edge_iterator> - out_edges(typename mlnu::boost_graph<VProp, EProp>::vertex_descriptor u, - const mlnu::boost_graph<VProp, EProp>& g) - { - return out_edges(u, g.graph()); - } - - template <typename VProp, typename EProp> - std::pair<typename mlnu::boost_graph<VProp, EProp>::in_edge_iterator, - typename mlnu::boost_graph<VProp, EProp>::in_edge_iterator> - in_edges(typename mlnu::boost_graph<VProp, EProp>::vertex_descriptor v, - const mlnu::boost_graph<VProp, EProp>& g) - { - return in_edges(v, g.graph()); - } - - template <typename VProp, typename EProp> - typename mlnu::boost_graph<VProp, EProp>::vertex_descriptor - source(typename mlnu::boost_graph<VProp, EProp>::edge_descriptor e, - const mlnu::boost_graph<VProp, EProp>& g) - { - return source(e, g.graph()); - } - - template <typename VProp, typename EProp> - typename mlnu::boost_graph<VProp, EProp>::vertex_descriptor - target(typename mlnu::boost_graph<VProp, EProp>::edge_descriptor e, - const mlnu::boost_graph<VProp, EProp>& g) - { - return target(e, g.graph()); - } - - template <typename VProp, typename EProp> - typename mlnu::boost_graph<VProp, EProp>::degree_size_type - out_degree(typename mlnu::boost_graph<VProp, EProp>::vertex_descriptor u, - const mlnu::boost_graph<VProp, EProp>& g) - { - return out_degree(u, g.graph()); - } - - template <typename VProp, typename EProp> - typename mlnu::boost_graph<VProp, EProp>::degree_size_type - in_degree(typename mlnu::boost_graph<VProp, EProp>::vertex_descriptor u, - const mlnu::boost_graph<VProp, EProp>& g) - { - return in_degree(u, g.graph()); - } - - template <typename VProp, typename EProp> - typename mlnu::boost_graph<VProp, EProp>::vertices_size_type - num_vertices(const mlnu::boost_graph<VProp, EProp>& g) - { - return num_vertices(g.graph()); - } - - template <typename VProp, typename EProp> - typename mlnu::boost_graph<VProp, EProp>::edges_size_type - num_edges(const mlnu::boost_graph<VProp, EProp>& g) - { - return num_edges(g.graph()); - } - - template <typename VProp, typename EProp> - typename mlnu::boost_graph<VProp, EProp>::vertex_descriptor - vertex(typename mlnu::boost_graph<VProp, EProp>::vertices_size_type n, - const typename mlnu::boost_graph<VProp, EProp>& g) - { - return vertex(n, g.graph()); - } - - template <typename VProp, typename EProp> - std::pair<typename mlnu::boost_graph<VProp, EProp>::edge_descriptor, - bool> - edge(typename mlnu::boost_graph<VProp, EProp>::vertex_descriptor u, - typename mlnu::boost_graph<VProp, EProp>::vertex_descriptor v, - const mlnu::boost_graph<VProp, EProp>& g) - { - return edge(u, v, g.graph()); - } - - template <typename VProp, typename EProp> - std::pair<typename mlnu::boost_graph<VProp, EProp>::out_edge_iterator, - typename mlnu::boost_graph<VProp, EProp>::out_edge_iterator> - edge_range(typename mlnu::boost_graph<VProp, EProp>::vertex_descriptor u, - typename mlnu::boost_graph<VProp, EProp>::vertex_descriptor v, - const mlnu::boost_graph<VProp, EProp>& g) - { - return edge_range(u, v, g.graph()); - } - -# endif // ! MLN_INCLUDE_ONLY - -} // end of namespace boost - -#endif // ! MLN_UTIL_INTERNAL_BOOST_GRAPH_ACCESS_HH_ diff --git a/milena/trash/boost_graph_property.hh b/milena/trash/boost_graph_property.hh deleted file mode 100644 index 6db6a8e..0000000 --- a/milena/trash/boost_graph_property.hh +++ /dev/null @@ -1,170 +0,0 @@ -// Copyright (C) 2007, 2008 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. - -/// \file mln/util/internal/boost_graph_property.hh -/// \brief boost_graph properties access operations. - -#ifndef MLN_UTIL_INTERNAL_BOOST_GRAPH_PROPERTY_HH_ -# define MLN_UTIL_INTERNAL_BOOST_GRAPH_PROPERTY_HH_ - -# include <utility> -# include <boost/graph/adjacency_list.hpp> - -/// fwd declaration -namespace mln -{ - namespace util - { - namespace internal - { - template <typename VertexProperty, typename EdgeProperty> - class boost_graph; - } - } -} - -namespace boost -{ - namespace mlnu = mln::util::internal; - - - /// \brief Returns the property map object for the vertex property - /// specified by PropertyTag. - template <typename VProp, typename EProp, typename PropertyTag> - typename property_map<typename mlnu::boost_graph<EProp, VProp>::decorated, - PropertyTag>::type - get(PropertyTag, typename mlnu::boost_graph<VProp, EProp>& g); - - - /// \brief Returns the property map object for the vertex property - /// specified by PropertyTag (const version). - template <typename VProp, typename EProp, typename PropertyTag> - typename property_map<typename mlnu::boost_graph<EProp, VProp>::decorated, - PropertyTag>::const_type - get(PropertyTag, const mlnu::boost_graph<VProp, EProp>& g); - - - /// \brief This returns the property value for x. - /// x is either a vertex or edge descriptor. - template <typename VProp, typename EProp, typename PropertyTag, typename X> - typename property_traits< - typename property_map<typename mlnu::boost_graph<EProp, VProp>::decorated, - PropertyTag>::const_type >::value_type - get(PropertyTag, const mlnu::boost_graph<VProp, EProp>& g, X x); - - - /// \brief This sets the property value for x to value. - /// x is either a vertex or edge descriptor. - template <typename VProp, typename EProp, - typename PropertyTag, typename X, typename Value> - void - put(PropertyTag, const mlnu::boost_graph<VProp, EProp>& g, - X x, const Value& value); - - - /// \brief Return the property specified by GraphPropertyTag. - template <typename EProp, typename VProp, typename GraphProperties, - typename GraphPropertyTag> - typename graph_property<typename mlnu::boost_graph<EProp, VProp>::decorated, - GraphPropertyTag>::type& - get_property(mlnu::boost_graph<VProp, EProp>& g, GraphPropertyTag); - - - /// \brief Return the property specified by GraphPropertyTag. - template <typename VProp, typename EProp, - typename GraphProperties, typename GraphPropertyTag> - const typename graph_property< - typename mlnu::boost_graph<EProp, VProp>::decorated, - GraphPropertyTag>::type& - get_property(const mlnu::boost_graph<VProp, EProp>& g, - GraphPropertyTag); - -# ifndef MLN_INCLUDE_ONLY - - template <typename VProp, typename EProp, typename PropertyTag> - typename property_map<typename mlnu::boost_graph<EProp, VProp>::decorated, - PropertyTag>::type - get(PropertyTag property_tag, - typename mlnu::boost_graph<VProp, EProp>& g) - { - return get(property_tag, g.graph()); - } - - template <typename VProp, typename EProp, typename PropertyTag> - typename property_map<typename mlnu::boost_graph<EProp, VProp>::decorated, - PropertyTag>::const_type - get(PropertyTag property_tag, - const mlnu::boost_graph<VProp, EProp>& g) - { - return get(property_tag, g.graph()); - } - - template <typename VProp, typename EProp, - typename PropertyTag, typename X> - typename property_traits< - typename property_map< - typename mlnu::boost_graph<EProp, VProp>::decorated, - PropertyTag>::const_type>::value_type - get(PropertyTag property_tag, const mlnu::boost_graph<VProp, EProp>& g, X x) - { - return get(property_tag, g.graph(), x); - } - - template <typename VProp, typename EProp, - typename PropertyTag, typename X, typename Value> - void - put(PropertyTag property_tag, const mlnu::boost_graph<VProp, EProp>& g, - X x, const Value& value) - { - put(property_tag, g.graph(), x, value); - } - - template <typename EProp, typename VProp, - typename GraphProperties, typename GraphPropertyTag> - typename graph_property<typename mlnu::boost_graph<EProp, VProp>::decorated, - GraphPropertyTag>::type& - get_property(mlnu::boost_graph<VProp, EProp>& g, - GraphPropertyTag property_tag) - { - return get_property(g.graph(), property_tag); - } - - template <typename VProp, typename EProp, - typename GraphProperties, typename GraphPropertyTag> - const typename graph_property< - typename mlnu::boost_graph<EProp, VProp>::decorated, - GraphPropertyTag>::type& - get_property(const mlnu::boost_graph<VProp, EProp>& g, - GraphPropertyTag property_tag) - { - return get_property(g.graph(), property_tag); - } - -# endif // ! MLN_INCLUDE_ONLY - -} - -#endif // ! MLN_UTIL_INTERNAL_BOOST_GRAPH_PROPERTY_HH_ diff --git a/milena/trash/boost_graph_structure.hh b/milena/trash/boost_graph_structure.hh deleted file mode 100644 index 079bac8..0000000 --- a/milena/trash/boost_graph_structure.hh +++ /dev/null @@ -1,288 +0,0 @@ -// Copyright (C) 2007, 2008 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. - -/// \file mln/util/internal/boost_graph_structure.hh -/// -/// Operations that interract with the boost_graph structure. - -#ifndef MLN_UTIL_INTERNAL_BOOST_GRAPH_STRUCTURE_HH_ -# define MLN_UTIL_INTERNAL_BOOST_GRAPH_STRUCTURE_HH_ - -# include <mln/util/internal/boost_graph.hh> - - -/// forward declaration. -namespace mln -{ - namespace util - { - namespace internal - { - template <typename VertexProperty, typename EdgeProperty> - class boost_graph; - } - } -} - - -namespace boost -{ - namespace mlnu = mln::util::internal; - - /// Adds edge (u,v) to the graph and returns the edge descriptor for - /// the new edge. - template <typename VProp, typename EProp> - std::pair<typename mlnu::boost_graph<VProp, EProp>::edge_descriptor, bool> - add_edge(typename mlnu::boost_graph<VProp, EProp>::vertex_descriptor u, - typename mlnu::boost_graph<VProp, EProp>::vertex_descriptor v, - typename mlnu::boost_graph<VProp, EProp>& g); - - - /// Adds edge (u,v) to the graph and attaches p as the value of the - /// edge's internal property storage. - template <typename VProp, typename EProp> - std::pair<typename mlnu::boost_graph<VProp, EProp>::edge_descriptor, bool> - add_edge(typename mlnu::boost_graph<VProp, EProp>::vertex_descriptor u, - typename mlnu::boost_graph<VProp, EProp>::vertex_descriptor v, - const typename mlnu::boost_graph<VProp, EProp>:: - edge_property_type& p, - typename mlnu::boost_graph<VProp, EProp>& g); - - /// Removes the edge (u,v) from the graph. - template <typename VProp, typename EProp> - void - remove_edge(typename mlnu::boost_graph<VProp, EProp>::vertex_descriptor u, - typename mlnu::boost_graph<VProp, EProp>::vertex_descriptor v, - typename mlnu::boost_graph<VProp, EProp>& g); - - /// Removes the edge e from the graph. - /// This differs from the remove_edge(u, v, g) function in the case of - /// a multigraph. This remove_edge(e, g) function removes a single edge, - /// whereas the remove_edge(u, v, g) function removes all edges (u,v). - template <typename VProp, typename EProp> - void - remove_edge(typename mlnu::boost_graph<VProp, EProp>::edge_descriptor e, - typename mlnu::boost_graph<VProp, EProp>& g); - - - /// Same as remove_edge(*iter, g) - template <typename VProp, typename EProp> - void - remove_edge(typename mlnu::boost_graph<VProp, EProp>::out_edge_iterator iter, - typename mlnu::boost_graph<VProp, EProp>& g); - - - /// Removes all out-edges of vertex u from the graph that - /// satisfy the predicate. - template <typename VProp, typename EProp, class Predicate> - void - remove_out_edge_if(typename mlnu::boost_graph<VProp, EProp>::vertex_descriptor u, - Predicate predicate, - typename mlnu::boost_graph<VProp, EProp>& g); - - /// FIXME only available on directed graph - template <typename VProp, typename EProp, class Predicate> - void - remove_in_edge_if(typename mlnu::boost_graph<VProp, EProp>::vertex_descriptor v, - Predicate predicate, - typename mlnu::boost_graph<VProp, EProp>& g); - - /// Removes all edges of vertex u from the graph that - /// satisfy the predicate. - template <typename VProp, typename EProp, class Predicate> - void remove_edge_if(Predicate predicate, - typename mlnu::boost_graph<VProp, EProp>& g); - - /// Adds a vertex to the graph. - /// Returns the vertex descriptor for the new vertex. - template <typename VProp, typename EProp> - typename mlnu::boost_graph<VProp, EProp>::vertex_descriptor - add_vertex(typename mlnu::boost_graph<VProp, EProp>& g); - - /// Adds a vertex to the graph with the specified properties. - /// Returns the vertex descriptor for the new vertex. - template <typename VProp, typename EProp> - typename mlnu::boost_graph<VProp, EProp>::vertex_descriptor - add_vertex(const typename mlnu::boost_graph<VProp, EProp>:: - vertex_property_type& p, - typename mlnu::boost_graph<VProp, EProp>& g); - - /// Removes all edges to and from vertex u. - template <typename VProp, typename EProp> - void - clear_vertex(typename mlnu::boost_graph<VProp, EProp>::vertex_descriptor u, - typename mlnu::boost_graph<VProp, EProp>& g); - - /// Removes all out-edges to and from vertex u. - template <typename VProp, typename EProp> - void - clear_out_edges(typename mlnu::boost_graph<VProp, EProp>::vertex_descriptor u, - typename mlnu::boost_graph<VProp, EProp>& g); - - /// FIXME: only define for the directed graphs. - template <typename VProp, typename EProp> - void - clear_in_edges(typename mlnu::boost_graph<VProp, EProp>::vertex_descriptor u, - typename mlnu::boost_graph<VProp, EProp>& g); - - - /// Remove vertex u from the vertex set of the graph. - /// It is assumed that there are no edges to or from vertex u - /// when it is removed - template <typename VProp, typename EProp> - void - remove_vertex(typename mlnu::boost_graph<VProp, EProp>::vertex_descriptor u, - typename mlnu::boost_graph<VProp, EProp>& g); - -# ifndef MLN_INCLUDE_ONLY - - template <typename VProp, typename EProp> - std::pair<typename mlnu::boost_graph<VProp, EProp>::edge_descriptor, - bool> - add_edge(typename mlnu::boost_graph<VProp, EProp>::vertex_descriptor u, - typename mlnu::boost_graph<VProp, EProp>::vertex_descriptor v, - typename mlnu::boost_graph<VProp, EProp>& g) - { - return add_edge(u, v, g.graph()); - } - - - template <typename VProp, typename EProp> - std::pair<typename mlnu::boost_graph<VProp, EProp>::edge_descriptor, - bool> - add_edge(typename mlnu::boost_graph<VProp, EProp>::vertex_descriptor u, - typename mlnu::boost_graph<VProp, EProp>::vertex_descriptor v, - const typename mlnu::boost_graph<VProp, EProp>:: - edge_property_type& p, - typename mlnu::boost_graph<VProp, EProp>& g) - { - return add_edge(u, v, p, g.graph()); - } - - template <typename VProp, typename EProp> - void - remove_edge(typename mlnu::boost_graph<VProp, EProp>::vertex_descriptor u, - typename mlnu::boost_graph<VProp, EProp>::vertex_descriptor v, - typename mlnu::boost_graph<VProp, EProp>& g) - { - return remove_edge(u, v, g.graph()); - } - - template <typename VProp, typename EProp> - void - remove_edge(typename mlnu::boost_graph<VProp, EProp>::edge_descriptor e, - typename mlnu::boost_graph<VProp, EProp>& g) - { - return remove_edge(e, g.graph()); - } - - template <typename VProp, typename EProp> - void - remove_edge(typename mlnu::boost_graph<VProp, EProp>::out_edge_iterator iter, - typename mlnu::boost_graph<VProp, EProp>& g) - { - return remove_edge(iter, g.graph()); - } - - template <typename VProp, typename EProp, class Predicate> - void - remove_out_edge_if(typename mlnu::boost_graph<VProp, EProp>::vertex_descriptor u, - Predicate predicate, - typename mlnu::boost_graph<VProp, EProp>& g) - { - return remove_out_edge_if(u, predicate, g.graph()); - } - - template <typename VProp, typename EProp, class Predicate> - void - remove_in_edge_if(typename mlnu::boost_graph<VProp, EProp>::vertex_descriptor v, - Predicate predicate, - typename mlnu::boost_graph<VProp, EProp>& g) - { - return remove_in_edge_if(v, predicate, g.graph()); - } - - template <typename VProp, typename EProp, class Predicate> - void remove_edge_if(Predicate predicate, - typename mlnu::boost_graph<VProp, EProp>& g) - { - return remove_edge_if(predicate, g.graph()); - } - - template <typename VProp, typename EProp> - typename mlnu::boost_graph<VProp, EProp>::vertex_descriptor - add_vertex(typename mlnu::boost_graph<VProp, EProp>& g) - { - return add_vertex(g.graph()); - } - - template <typename VProp, typename EProp> - typename mlnu::boost_graph<VProp, EProp>::vertex_descriptor - add_vertex(const typename mlnu::boost_graph<VProp, EProp>:: - vertex_property_type& p, - typename mlnu::boost_graph<VProp, EProp>& g) - { - return add_vertex(p, g.graph()); - } - - template <typename VProp, typename EProp> - void - clear_vertex(typename mlnu::boost_graph<VProp, EProp>::vertex_descriptor u, - typename mlnu::boost_graph<VProp, EProp>& g) - { - return clear_vertex(u, g.graph()); - } - - template <typename VProp, typename EProp> - void - clear_out_edges(typename mlnu::boost_graph<VProp, EProp>::vertex_descriptor u, - typename mlnu::boost_graph<VProp, EProp>& g) - { - return clear_out_edges(u, g.graph()); - } - - template <typename VProp, typename EProp> - void - clear_in_edges(typename mlnu::boost_graph<VProp, EProp>::vertex_descriptor u, - typename mlnu::boost_graph<VProp, EProp>& g) - { - return clear_in_edges(u, g.graph()); - } - - - template <typename VProp, typename EProp> - void - remove_vertex(typename mlnu::boost_graph<VProp, EProp>::vertex_descriptor u, - typename mlnu::boost_graph<VProp, EProp>& g) - { - return remove_vertex(u, g); - } - -# endif // ! MLN_INCLUDE_ONLY - -} // end of namespace boost - -#endif // ! MLN_UTIL_INTERNAL_BOOST_GRAPH_STRUCTURE_HH_ diff --git a/milena/trash/clock_neighb.hh b/milena/trash/clock_neighb.hh deleted file mode 100644 index 429f807..0000000 --- a/milena/trash/clock_neighb.hh +++ /dev/null @@ -1,168 +0,0 @@ -// Copyright (C) 2007, 2008, 2009 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_CORE_CLOCK_NEIGHB_HH -# define MLN_CORE_CLOCK_NEIGHB_HH - -/// \file mln/core/clock_neighb.hh -/// -/// Definition of the generic neighborhood class mln::clock_neighb. - - -# include <mln/core/concept/neighborhood.hh> -# include <mln/core/window.hh> -# include <mln/core/dpoint.hh> -# include <mln/core/site_set/p_array.hh> - -namespace mln -{ - - // forward declarations - template <typename D> class dpsites_fwd_piter; - template <typename D> class dpsites_bkd_piter; - - - /// Generic neighborhood class. - /// - /// This neighborhood of window is just like a set of delta-psites. - /// The parameter is \c D, type of delta-psite. - /// - template <typename D> - struct clock_neighb : public Neighborhood< clock_neighb <D> > - { - /// Dpsite associated type. - typedef D dpsite; - - /// Site associated type. - typedef mln_psite(D) site; - - /// Window associated type. - typedef mln::window<dpsite> window; - - /// Site_Iterator type to browse the psites of a generic - /// neighborhood w.r.t. the ordering of delta-psites. - /// - typedef dpsites_fwd_piter<D> fwd_niter; - - /// Site_Iterator type to browse the psites of a generic - /// neighborhood w.r.t. the reverse ordering of delta-psites. - /// - /// !!! Be careful the start delta psite become the last now. - /// - typedef dpsites_bkd_piter<D> bkd_niter; - - /// Same as fwd_niter. - typedef fwd_niter niter; - - /// Constructor without argument. - /// - /// The constructed neighborhood is empty. You have to use insert() - /// to proceed to the neighborhood definition. - /// - clock_neighb(); - - /// Insert a delta-psite \p dp in the neighborhood - /// definition. - /// - /// \param[in] dp The delta-psite to insert. - /// - /// This method also insert the symmetrical delta-psite, - \p dp, - /// in the neighborhood definition; thus the client has not to - /// ensure the symmetry property; that is automatic. - /// - clock_neighb<D>& append(const D& dp); - /// \} - - /// Return the dpsites of this neighborhood. - const std::vector<D>& vect() const; - - /// Return the corresponding window. - /// FIXME: not in constant time! - mln::window<D> win() const; - - /// Return whether this neighborhood is valid. - bool is_valid() const; - - private: - std::vector<D> vec_; - }; - - -# ifndef MLN_INCLUDE_ONLY - - template <typename D> - inline - clock_neighb<D>::clock_neighb() - { - } - - template <typename D> - inline - clock_neighb<D>& - clock_neighb<D>::append(const D& dp) - { - vec_.push_back(dp); - return *this; - } - - template <typename D> - inline - const std::vector<D>& - clock_neighb<D>::vect() const - { - return vec_; - } - - template <typename D> - inline - mln::window<D> - clock_neighb<D>::win() const - { - mln::window<D> result; - for (unsigned i = 0; i < vec_.size(); ++i) - result.insert(vec_[i]); - return result; - } - - template <typename D> - inline - bool - clock_neighb<D>::is_valid() const - { - //FIXME: correct? - return true; - } - - -# endif // ! MLN_INCLUDE_ONLY - -} // end of namespace mln - - -# include <mln/core/dpsites_piter.hh> - - -#endif // ! MLN_CORE_CLOCK_NEIGHB_HH diff --git a/milena/trash/clock_neighb2d.cc b/milena/trash/clock_neighb2d.cc deleted file mode 100644 index 1677089..0000000 --- a/milena/trash/clock_neighb2d.cc +++ /dev/null @@ -1,90 +0,0 @@ -// Copyright (C) 2007 EPITA Research and Development Laboratory -// -// 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 <mln/core/image/image2d.hh> -#include <mln/core/clock_neighb2d.hh> -#include <mln/debug/println.hh> - -namespace mln -{ - template <typename I, typename N> - void test_fwd(Image<I>& input_, - const Neighborhood<N>& nbh) - { - I& input = exact (input_); - point2d p (1,1); - int v = 1; - - mln_fwd_niter(N) n (nbh, p); - for_all (n) - { - std::cout << n << std::endl; - input(n) = v++; - } - - } - - template <typename I, typename N> - void test_bkd(Image<I>& input_, - const Neighborhood<N>& nbh) - { - I& input = exact (input_); - point2d p (1,1); - int v = 1; - - mln_bkd_niter(N) n (nbh, p); - for_all (n) - { - std::cout << n << std::endl; - input(n) = v++; - } - - } - -} - - -int main () -{ - using namespace mln; - - - image2d<int> ima(3,3); - dpoint2d dp (1,0); - - test_fwd(ima, cc4(dp)); - debug::println(ima); - test_bkd(ima, cc4(dp)); - debug::println(ima); - - - dpoint2d dp2 (-1,-1); - - test_fwd(ima, cc8(dp2)); - debug::println(ima); - test_bkd(ima, cc8(dp2)); - debug::println(ima); - -} diff --git a/milena/trash/clock_neighb2d.hh b/milena/trash/clock_neighb2d.hh deleted file mode 100644 index 7771a8c..0000000 --- a/milena/trash/clock_neighb2d.hh +++ /dev/null @@ -1,199 +0,0 @@ -// Copyright (C) 2007, 2008 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_CORE_CLOCK_NEIGHB2D_HH -# define MLN_CORE_CLOCK_NEIGHB2D_HH - -/// \file mln/core/clock_neighb2d.hh -/// -/// Definition of the mln::clock_neighb2d alias and of some classical -/// 2D clock_neighborhoods. - -# include <cmath> -# include <mln/core/clock_neighb.hh> -# include <mln/core/alias/dpoint2d.hh> - - -namespace mln -{ - - /// Type alias for a clock_neighborhood defined on the 2D square - /// grid with integer coordinates. - /// - typedef clock_neighb<dpoint2d> clock_neighb2d; - - - /// 4-connectivity clock_neighborhood on the 2D grid. - /// - /// - o - - /// o x o - /// - o - - /// - /// \return A clock_neighb2d. - const clock_neighb2d cc4(dpoint2d& dp); - - - /// 8-connectivity clock_neighborhood on the 2D grid. - /// - /// o o o - /// o x o - /// o o o - /// - /// \return A clock_neighb2d. - const clock_neighb2d cc8(dpoint2d& dp); - - -// /// Horizontal 2-connectivity clock_neighborhood on the 2D grid. -// /// -// /// - - - -// /// o x o -// /// - - - -// /// -// /// \return A clock_neighb2d. -// /// -// const clock_neighb2d& c2_row(); - - -// /// Vertical 2-connectivity clock_neighborhood on the 2D grid. -// /// -// /// - o - -// /// - x - -// /// - o - -// /// -// /// \return A clock_neighb2d. -// /// -// const clock_neighb2d& c2_col(); - - - -# ifndef MLN_INCLUDE_ONLY - - inline - const clock_neighb2d cc4(dpoint2d& dp) - { - static bool flower = true; - static clock_neighb2d it; - if (flower) - { - unsigned begin = 0; - std::vector<dpoint2d> v; - v.push_back(dpoint2d(0, 1)); - v.push_back(dpoint2d(-1, 0)); - v.push_back(dpoint2d(0, -1)); - v.push_back(dpoint2d(1, 0)); - - std::vector<dpoint2d>::const_iterator ite = v.begin (); - for (; (ite != v.end ()) && (dp != *ite); ++ite, ++begin) - ; - mln_assertion (ite != v.end ()); - for (unsigned i = begin; i < v.size(); ++i) - it.append(v[i]); - for (unsigned i = 0; i < begin; ++i) - it.append(v[i]); - - flower = false; - } - return it; - } - - - inline - const clock_neighb2d cc8(dpoint2d& dp) - { -// static bool flower = true; - clock_neighb2d it; -// if (flower) -// { - unsigned begin = 0; - std::vector<dpoint2d> v; - v.push_back(dpoint2d(0, 1)); - v.push_back(dpoint2d(-1, 1)); - v.push_back(dpoint2d(-1, 0)); - v.push_back(dpoint2d(-1, -1)); - v.push_back(dpoint2d(0, -1)); - v.push_back(dpoint2d(1, -1)); - v.push_back(dpoint2d(1, 0)); - v.push_back(dpoint2d(1, 1)); - - std::vector<dpoint2d>::const_iterator ite = v.begin (); - for (; (ite != v.end ()) && (dp != *ite); ++ite, ++begin) - ; - // mln_assertion (*ite != v.end ()); - for (unsigned i = begin; i < v.size(); ++i) - it.append(v[i]); - for (unsigned i = 0; i < begin; ++i) - it.append(v[i]); - -// flower = false; -// } - return it; - } - -// const clock_neighb2d& c8() -// { -// static bool flower = true; -// static clock_neighb2d it; -// if (flower) -// { -// it.insert(dpoint2d(0, 1)); -// it.insert(dpoint2d(1,-1)); -// it.insert(dpoint2d(1, 0)); -// it.insert(dpoint2d(1, 1)); -// flower = false; -// } -// return it; -// } - -// const clock_neighb2d& c2_row() -// { -// static bool flower = true; -// static clock_neighb2d it; -// if (flower) -// { -// it.insert(dpoint2d(0, 1)); -// flower = false; -// } -// return it; -// } - -// const clock_neighb2d& c2_col() -// { -// static bool flower = true; -// static clock_neighb2d it; -// if (flower) -// { -// it.insert(dpoint2d(1, 0)); -// flower = false; -// } -// return it; -// } - -# endif // ! MLN_INCLUDE_ONLY - -} // end of namespace mln - - -#endif // ! MLN_CORE_CLOCK_NEIGHB2D_HH diff --git a/milena/trash/clock_neighb2d_bis.cc b/milena/trash/clock_neighb2d_bis.cc deleted file mode 100644 index 95bbcc9..0000000 --- a/milena/trash/clock_neighb2d_bis.cc +++ /dev/null @@ -1,199 +0,0 @@ -// Copyright (C) 2007 EPITA Research and Development Laboratory -// -// 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 <mln/core/image/image2d.hh> -#include <mln/core/clock_neighb2d.hh> -#include <mln/debug/println.hh> -#include <mln/data/fill.hh> -#include <mln/labeling/level.hh> -#include <mln/core/alias/neighb2d.hh> - -namespace mln -{ - template <typename I> - unsigned testc4(const Image<I>& input_, - point2d p) - { - const I& input = exact (input_); - bool previous_is_false; - unsigned res = 0; - - dpoint2d dp(-1,-1); - clock_neighb2d nbh = cc8(dp); - - - // just to get the last previous_is_false. - { - mln_bkd_niter(clock_neighb2d) b(nbh , p); - b.start(); - previous_is_false = !input(b); - } - - { - mln_fwd_niter(clock_neighb2d) n(nbh , p); - for_all(n) - { - //y in c4 - bool x = input(n); - n.next(); - mln_assertion(n.is_valid()); - bool y = input(n); - if (!x && y) - ++res; - else - if (x && y && previous_is_false) - ++res; - - previous_is_false = !y; - - } - } - return res == 0 ? 1 : res; - } - - template <typename I> - unsigned testc8(const Image<I>& input_, - point2d p) - { - const I& input = exact (input_); - bool previous_is_false; - unsigned res = 0; - - dpoint2d dp(-1,0); - clock_neighb2d nbh = cc8(dp); - - - // just to get the last previous_is_false. - { - mln_bkd_niter(clock_neighb2d) b(nbh , p); - b.start (); - bool x = input(b); - b.next(); - mln_assertion(b.is_valid()); - bool y = input(b); - previous_is_false = !y && !x; - } - - - { - mln_fwd_niter(clock_neighb2d) n(nbh , p); - for_all(n) - { - //y in c4 - bool x = input(n); - n.next(); - mln_assertion(n.is_valid()); - bool y = input(n); - - if (!x && y) - ++res; - else - if (x && previous_is_false) - ++res; - previous_is_false = !y && !x; - } - } - return res == 0 ? 0 : res - 1; - } - -} - -int main () -{ - using namespace mln; - - unsigned tmp = 0; - - image2d<bool> ima(3,3); - dpoint2d dp (1,0); - point2d p (1,1); - - - for (int a0 = 0; a0 < 2; ++a0) - for (int a1 = 0; a1 < 2; ++a1) - for (int a2 = 0; a2 < 2; ++a2) - for (int a3 = 0; a3 < 2; ++a3) - for (int a4 = 0; a4 < 2; ++a4) - for (int a5 = 0; a5 < 2; ++a5) - for (int a6 = 0; a6 < 2; ++a6) - for (int a7 = 0; a7 < 2; ++a7) - - { - unsigned n; - unsigned m; - bool t[9] = {a0, a1, a2, - a3, 1, a4, - a5, a6, a7}; - - - data::fill(ima, t); - - image2d<unsigned> out = labeling::value(ima, false, c8(), n); - tmp = testc4(ima, p); - if (tmp != n) - { - std::cout << "C4--------------"<< std::endl; - debug::println(ima); - debug::println(out); - std::cout << "tmp = " << tmp << std::endl; - std::cout << "n = " << n << std::endl; - std::cout << "C4--------------"<< std::endl; - } - - - bool u[9] = {a0, a1, a2, - a3, 0, a4, - a5, a6, a7}; - - - /// 0 before - data::fill(ima, u); - out = labeling::value(ima, false, c4(), m); - - /// 1 after - data::fill(ima, t); - image2d<unsigned> out2 = labeling::value(ima, false, c4(), n); - - int diff = n - m; - if (diff < 0) - diff = 0; - tmp = testc8(ima, p); - int temp = tmp; - if (temp != diff) - { - std::cout << "C8--------------"<< std::endl; - debug::println(ima); - debug::println(out); - debug::println(out2); - std::cout << "tmp = " << tmp << std::endl; - - std::cout << "n = " << n << std::endl; - std::cout << "m = " << m << std::endl; - std::cout << "diff = " << diff << std::endl; - std::cout << "C8--------------"<< std::endl; - } - - } -} diff --git a/milena/trash/display_color_pretty.cc b/milena/trash/display_color_pretty.cc deleted file mode 100644 index d084b07..0000000 --- a/milena/trash/display_color_pretty.cc +++ /dev/null @@ -1,90 +0,0 @@ -// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory -// -// 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. - -/// \file tests/display/color_pretty.cc -/// -/// Tests on mln::display::color::pretty. - -# include <mln/core/image/image2d.hh> -# include <mln/value/int_u8.hh> -# include <mln/data/fill.hh> -# include <mln/core/site_set/p_set.hh> -# include <mln/core/image/sub_image.hh> - -# include <mln/value/rgb8.hh> -# include <mln/display/color_pretty.hh> -# include <mln/data/compare.hh> - - -int main() -{ - using namespace mln; - using value::int_u8; - - /// Test on color_pretty. - { - image2d<int_u8> ima (2, 2); - data::fill (ima, 51); - - p_set<point2d > s; - s.insert(point2d(0, 0)); - s.insert(point2d(1, 1)); - - sub_image<image2d<int_u8>, p_set<point2d > > input = ima | s; - image2d<value::rgb8> out = display::color_pretty(input); - - value::rgb8 vs[2][2] = { - {value::rgb8(51, 51, 51), value::rgb8(255, 0, 0) }, - {value::rgb8(255, 0, 0), value::rgb8(51, 51, 51)} - }; - - image2d<value::rgb8> ref (make::image(vs)); - mln_assertion (ref == out); - } - - - /// Test on color_pretty_rgb. - { - image2d<value::rgb8> ima (2, 2); - - p_set<point2d > s1; - p_set<point2d > s2; - p_set<point2d > s3; - - s1.insert(point2d(0, 0)); - s2.insert(point2d(0, 1)); - s3.insert(point2d(1, 0)); - - image2d<value::rgb8> out = display::color_pretty_rgb(ima, s1, s2, s3); - - value::rgb8 vs[2][2] = { - {value::rgb8(255, 0, 0), value::rgb8(0, 255, 0) }, - {value::rgb8(0, 0, 255), value::rgb8(0, 0, 0)} - }; - - image2d<value::rgb8> ref (make::image(vs)); - mln_assertion (ref == out); - } -} diff --git a/milena/trash/display_color_pretty.hh b/milena/trash/display_color_pretty.hh deleted file mode 100644 index 9e2a8ea..0000000 --- a/milena/trash/display_color_pretty.hh +++ /dev/null @@ -1,221 +0,0 @@ -// Copyright (C) 2007, 2013 EPITA Research and Development Laboratory -// -// 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_DISPLAY_COLOR_PRETTY_HH -# define MLN_DISPLAY_COLOR_PRETTY_HH - -/*! \file mln/display/color_pretty.hh - * - * \brief Create a pretty image, which display its content - * with red value for undefined point site. - */ - -# include <mln/trait/image_from_grid.hh> -# include <mln/core/image/image2d.hh> -# include <mln/value/rgb8.hh> -# include <mln/data/fill.hh> -# include <mln/data/paste.hh> -# include <mln/core/site_set/p_set.hh> -# include <mln/metal/is_not.hh> - -namespace mln -{ - - namespace display - { - - /*! Return new image colored from an image \p input_. with the - * color red for the pixels not in the domain of \p input_. - * - * \param[in] input_ The image in gray level to color. - * - * \return colored image from \p input_ in rgb8 with red for the - * color filled when the point is in bounding box of \p input_ but - * not defined. - * - * \pre \p input_ has to be initialized. - * \pre \p input_ values isn't color. - * - */ - template <typename I> - typename trait::image_from_grid < mln_mesh(I), value::rgb8 >::ret - color_pretty(const Image<I>& input_); - - - /*! Return new image colored from an image \p input_. with the - * color red for the pixels not in the domain of \p input_. - * - * \param[in] input_ The image whose domain let to define the domain - * of the returned image. - * \param[in] s1_ The p_set where the points will be colored in red. - * \param[in] s2_ The p_set where the points will be colored in green. - * \param[in] s3_ The p_set where the points will be colored in blue. - * - * \return colored image from \p input_ domain which be filled in rgb8. - * - */ - template <typename I> - typename trait::image_from_grid < mln_mesh(I), value::rgb8 >::ret - color_pretty_rgb(const Image<I>& input_, - const p_set<mln_psite(I) >& s1_, - const p_set<mln_psite(I) >& s2_, - const p_set<mln_psite(I) >& s3_); - -# ifndef MLN_INCLUDE_ONLY - - namespace impl - { - template <typename V> - inline - value::rgb8 - color_value(V v) - { - return value::rgb8(v, v, v); - } - - template <unsigned int n> - inline - value::rgb8 - color_value(value::rgb<n> v) - { - return v; - } - - inline - value::rgb8 - color_value(bool b) - { - value::int_u8 r = b ? 255 : 0; - return value::rgb8(r, r, r); - } - - - template <typename I> - inline - typename trait::image_from_grid < mln_mesh(I), value::rgb8 >::ret - color_pretty(const Image<I>& input_) - { - mln_trace("display::impl::color_pretty"); - - const I& input = exact (input_); - - image2d<value::rgb8> output(input.domain().bbox()); - data::fill(output, value::rgb8(255, 0, 0)); - - { - mln_piter(I) p(input.domain()); - - for_all(p) - output(p) = value::rgb8(color_value(input(p))); - } - - return output; - } - - template <typename I> - inline - typename trait::image_from_grid < mln_mesh(I), value::rgb8 >::ret - color_pretty_rgb(const Image<I>& input_, - const p_set<mln_psite(I) >& s1_, - const p_set<mln_psite(I) >& s2_, - const p_set<mln_psite(I) >& s3_) - { - mln_trace("display::impl::color_pretty_rgb"); - - const I& input = exact (input_); - - image2d<value::rgb8> output(input.domain().bbox()); - data::fill(output, value::rgb8(0, 0, 0)); - - { - mln_piter(p_set<mln_psite(I) >) p(s1_); - - for_all(p) - output(p).red() = 255; - } - - { - mln_piter(p_set<mln_psite(I) >) p(s2_); - - for_all(p) - output(p).green() = 255; - } - - { - mln_piter(p_set<mln_psite(I) >) p(s3_); - - for_all(p) - output(p).blue() = 255; - } - - return output; - } - - - } // end of namespace mln::display::impl - - - /// Facade. - - template <typename I> - inline - typename trait::image_from_grid < mln_mesh(I), value::rgb8 >::ret - color_pretty(const Image<I>& input_) - { - mln_trace("display::color_pretty"); - - const I& input = exact(input_); - mln_precondition(input.is_valid()); - - mlc_is_not(mln_trait_value_kind(mln_value(I)) (), - trait::value::kind::color)::check(); - - image2d<value::rgb8> output = impl::color_pretty(input); - - return output; - } - - template <typename I> - inline - typename trait::image_from_grid < mln_mesh(I), value::rgb8 >::ret - color_pretty_rgb(const Image<I>& input_, - const p_set<mln_psite(I) >& s1_, - const p_set<mln_psite(I) >& s2_, - const p_set<mln_psite(I) >& s3_) - { - mln_trace("display::color_pretty_rgb"); - - image2d<value::rgb8> output = impl::color_pretty_rgb(input_, s1_, s2_, s3_); - return output; - } - -# endif // !MLN_INCLUDE_ONLY - - } // end of namespace mln::display - -} // end of namespace mln - - -#endif // ! MLN_DISPLAY_COLOR_PRETTY_HH diff --git a/milena/trash/display_remove.hh b/milena/trash/display_remove.hh deleted file mode 100644 index 96e990e..0000000 --- a/milena/trash/display_remove.hh +++ /dev/null @@ -1,90 +0,0 @@ -// Copyright (C) 2007, 2008, 2013 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_DISPLAY_REMOVE_HH -# define MLN_DISPLAY_REMOVE_HH - -/// \file mln/display/remove.hh -/// -/// Remove all temporary files create by display::save. - -# include <map> -# include <string> - -# include <mln/debug/trace.hh> - - -namespace mln -{ - - namespace display - { - - /// Remove all temporary images which are created by the routine - /// save. - void remove(); - - -# ifndef MLN_INCLUDE_ONLY - - namespace impl - { - - inline - void - remove() - { - mln_trace("display::impl::remove"); - - for (std::map<void*, std::string>::const_iterator it = map_saved_image_tmp_.begin (); - it != map_saved_image_tmp_.end (); - ++it) - { - std::string s = "rm -f " + (*it).second; - system (s.c_str ()); - } - } - - } // end of namespace mln::display::impl - - /// Facade. - inline - void - remove() - { - mln_trace("display::remove"); - - impl::remove(); - } - -# endif // !MLN_INCLUDE_ONLY - - } // end of namespace mln::display - -} // end of namespace mln - - -#endif // ! MLN_DISPLAY_REMOVE_HH diff --git a/milena/trash/display_save.hh b/milena/trash/display_save.hh deleted file mode 100644 index e51e14d..0000000 --- a/milena/trash/display_save.hh +++ /dev/null @@ -1,132 +0,0 @@ -// Copyright (C) 2007, 2008, 2013 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_DISPLAY_SAVE_HH -# define MLN_DISPLAY_SAVE_HH - -/// \file mln/display/save.hh -/// -/// Definition of function which saves an image on a temporary -/// files. - -# include <mln/trait/image_from_grid.hh> -# include <mln/core/image/image_if.hh> -# include <mln/core/image/image2d.hh> -# include <mln/value/rgb8.hh> -# include <mln/data/fill.hh> -# include <mln/data/paste.hh> -# include <mln/display/color_pretty.hh> -# include <mln/io/ppm/save.hh> - -namespace mln -{ - - namespace display - { - - /// Map which stocks the location of the saved file by the id of - /// the image. - extern std::map<void*, std::string> map_saved_image_tmp_; - - /// Save an image in a temporary file in ppm format. - /// - /// \param[in] input_ the image to save. - template <typename I> - void - save(const Image<I>& input_); - -# ifndef MLN_INCLUDE_ONLY - - std::map<void*, std::string> map_saved_image_tmp_; - - namespace impl - { - template <typename I> - inline - void - save(trait::value::kind::any, const Image<I>& input_) - { - mln_trace("display::impl::save"); - - const I& input = exact (input_); - image2d<value::rgb8> out = display::color_pretty(input); - - /// Use of mkstemp instead tempmap. - char *tmp = (char*)malloc (12 * sizeof (char)); - strcpy(tmp, "/tmp/XXXXXX"); - if (mkstemp(tmp) == -1) - return; - std::string path_tmp = tmp; - - io::ppm::save(out, path_tmp); - - map_saved_image_tmp_[(void*)input.id_ ()] = path_tmp; - } - - template <typename I> - inline - void - save(trait::value::kind::color, const Image<I>& input_) - { - mln_trace("display::impl::save"); - - const I& input = exact (input_); - - /// Use of mkstemp instead tempmap. - char *tmp = (char*)malloc (12 * sizeof (char)); - strcpy(tmp, "/tmp/XXXXXX"); - if (mkstemp(tmp) == -1) - return; - std::string path_tmp = tmp; - - io::ppm::save(input, path_tmp); - - map_saved_image_tmp_[(void*)input.id_ ()] = path_tmp; - } - - } // end of namespace mln::display::impl - - /// Facade. - template <typename I> - inline - void - save(const Image<I>& input_) - { - mln_trace("display::save"); - - const I& input = exact(input_); - mln_precondition(input.is_valid()); - impl::save(mln_trait_value_kind(mln_value(I)) (), input); - } - -# endif // !MLN_INCLUDE_ONLY - - } // end of namespace mln::display - -} // end of namespace mln - - -#endif // ! MLN_DISPLAY_SAVE_HH diff --git a/milena/trash/display_save_and_show.hh b/milena/trash/display_save_and_show.hh deleted file mode 100644 index 8685114..0000000 --- a/milena/trash/display_save_and_show.hh +++ /dev/null @@ -1,97 +0,0 @@ -// Copyright (C) 2007, 2013 EPITA Research and Development Laboratory -// -// 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_DISPLAY_SAVE_AND_SHOW_HH -# define MLN_DISPLAY_SAVE_AND_SHOW_HH - -/*! \file mln/display/save_and_show.hh - * - * \brief Definition of function which saves and shows an image in the - * same call. - */ - -# include <mln/display/save.hh> -# include <mln/display/show.hh> - -namespace mln -{ - - namespace display - { - - /*! Save and show an image \p input_, which displays whith \p cmd - * viewer in \p time seconds. - * - * \param[in] input_ the image to show. - * \param[in] cmd The string which contains the programm of the - * viewer which the user want to display with. By default its - * value is "display". - * \param[in] time The number of second of - * display, 0 display permanently. By default the value is 0. - * - * \warning This routine doesn't erase the temporary created file. - * - */ - template <typename I> - void - save_and_show(const Image<I>& input_, std::string cmd = "display", int time = 0); - -# ifndef MLN_INCLUDE_ONLY - - namespace impl - { - template <typename I> - inline - void - save_and_show_(const Image<I>& input, - std::string cmd, int time) - { - mln_trace("display::impl::save_and_show_"); - - display::save(input); - show(input, cmd, time); - } - - } // end of namespace mln::display::impl - - /// Facade. - template <typename I> - inline - void - save_and_show(const Image<I>& input_, std::string cmd = "display", int time = 0) - { - mln_trace("display::save_and_show"); - - impl::save_and_show_(input_, cmd, time); - } - -# endif // !MLN_INCLUDE_ONLY - - } // end of namespace mln::display - -} // end of namespace mln - - -#endif // ! MLN_DISPLAY_SAVE_AND_SHOW_HH diff --git a/milena/trash/display_show.cc b/milena/trash/display_show.cc deleted file mode 100644 index 98872ac..0000000 --- a/milena/trash/display_show.cc +++ /dev/null @@ -1,86 +0,0 @@ -// Copyright (C) 2007, 2008 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. - -/*! \file tests/display/show.cc - * - * \brief Tests on mln::display::show. - */ - -#include <mln/core/image/image2d.hh> -#include <mln/io/pbm/load.hh> -#include <mln/make/win_chamfer.hh> -#include <mln/geom/chamfer.hh> -#include <mln/value/rgb8.hh> -#include <mln/core/image/sub_image.hh> -#include <mln/core/image_if_value.hh> - -#include <mln/core/alias/w_window2d_int.hh> -#include <mln/display/show.hh> -#include <mln/display/save.hh> -#include <mln/display/remove.hh> -#include <mln/display/color_pretty.hh> -#include <mln/io/ppm/save.hh> - -#include "tests/data.hh" - - -int main() -{ - using namespace mln; - - unsigned max = 51; - - - image2d<bool> input = io::pbm::load(MLN_IMG_DIR "/toto.pbm"); - - // Create a weighted windows : - // 0 2 0 - // 2 p 2 - // 0 2 0 - const w_window2d_int& w_win = make::mk_chamfer_3x3_int<2, 0> (); - - // Call chamfer for a distance image. - image2d<unsigned> tmp = geom::chamfer(input, w_win, max); - - // Call color_pretty for sub_image. - for (unsigned i = 2; i < 6; i += 2) - { - image_if_value<image2d<unsigned> > t = tmp | i; - display::save (t); - display::show (t, "display", 1); - } - - /// Test with color image. - { - image2d<value::rgb8> color_image (16, 16); - for (int i = 0; i < 16; ++i) - for (int j = 0; j < 16; ++j) - color_image(point2d(i, j)) = value::rgb8(0,0,255); - display::save (color_image); - display::show (color_image, "display", 1); - } - - display::remove (); -} diff --git a/milena/trash/display_show.hh b/milena/trash/display_show.hh deleted file mode 100644 index 8fab8fe..0000000 --- a/milena/trash/display_show.hh +++ /dev/null @@ -1,131 +0,0 @@ -// Copyright (C) 2007, 2013 EPITA Research and Development Laboratory -// -// 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_DISPLAY_SHOW_HH -# define MLN_DISPLAY_SHOW_HH - -/*! \file mln/display/show.hh - * - * \brief Display the temporary image which has just been saved with - * given viewer (default display). - */ - -# include <mln/trait/image_from_grid.hh> -# include <mln/core/image/image_if.hh> -# include <mln/core/image/image2d.hh> -# include <mln/display/save.hh> - -# include <map> - -namespace mln -{ - - namespace display - { - - /*! Show an image \p input_ previously saved by display::save, - * which displays whith \p cmd viewer in \p time seconds. - * - * \param[in] input_ the image to show. - * \param[in] cmd The string which contains the programm of the - * viewer which the user want to display with. By default its - * value is "display". - * \param[in] time The number of second of - * display, 0 display permanently. By default the value is 0. - * - * \pre the image \p input_ is previously saved is map_saved_image_tmp_. - * - */ - template <typename I> - void - show(const Image<I>& input_, std::string cmd = "display", int time = 0); - -# ifndef MLN_INCLUDE_ONLY - - namespace impl - { - - template <typename I> - inline - bool - check_saved(const Image<I>& input_) - { - const I& input = exact(input_); - - typename std::map<void*, std::string>::iterator it = map_saved_image_tmp_.begin(); - - for (; it != map_saved_image_tmp_.end(); ++it) - if ((*it).first == input.id_()) - return true; - return false; - } - - template <typename I> - inline - void - show(const Image<I>& input_, std::string cmd, int time) - { - mln_trace("display::impl::show"); - - const I& input = exact(input_); - - std::stringstream st; - if (time) - { - st << cmd << " " << map_saved_image_tmp_[(void*)input.id_()] << " &"; - system(st.str().c_str()); - st.str(""); - st << "sleep " << time << " && pkill " << cmd; - system(st.str().c_str()); - } - else - { - st << cmd << " " << map_saved_image_tmp_[(void*)input.id_()]; - system(st.str().c_str()); - } - } - - } // end of namespace mln::display::impl - - /// Facade. - template <typename I> - inline - void - show(const Image<I>& input_, std::string cmd = "display", int time = 0) - { - mln_trace("display::show"); - - mln_precondition(impl::check_saved(input_)); - impl::show(input_, cmd, time); - } - -# endif // !MLN_INCLUDE_ONLY - - } // end of namespace mln::display - -} // end of namespace mln - - -#endif // ! MLN_DISPLAY_SHOW_HH diff --git a/milena/trash/fi_adaptor.cc b/milena/trash/fi_adaptor.cc deleted file mode 100644 index bf48858..0000000 --- a/milena/trash/fi_adaptor.cc +++ /dev/null @@ -1,87 +0,0 @@ -// Copyright (C) 2007, 2008 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. - -/// \file tests/core/image/fi_adaptor.cc -/// \brief Test on mln::fi_adaptor. - -#include <mln/core/image/fi_adaptor.hh> -#include <mln/core/image/image2d.hh> -#include <mln/win/rectangle2d.hh> - -#include <mln/value/int_u8.hh> -#include <mln/value/rgb8.hh> - -#include <mln/data/paste.hh> -#include <mln/data/median.hh> - -#include <mln/display/show.hh> -#include <mln/display/save.hh> - -#include "tests/data.hh" - - -using namespace mln; - -using namespace mln::value; - -int main() -{ - using value::int_u8; - using value::rgb8; - - { - /* FIXME: Under GNU/Linux or under any *nix OS (i.e. under Unix or - Mac OS X), you need to call FreeImage_Initialise at the - beginning of your main function and you need to call - FreeImage_DeInitialise at the end of this main function (this - is not needed when using FreeImage as a shared library - (*.so)). */ -// FreeImage_Initialise(); - - win::rectangle2d rect(3, 3); - - fi_adaptor< image2d< int_u<8> > > adaptor; - - adaptor.load(MLN_IMG_DIR "/lena.pgm"); - display::save (adaptor); - // FIXME: Don't use display::show in batch tests. -// display::show (adaptor, "xv"); - - image2d<int_u8> ima(adaptor.domain()); - - data::median(adaptor, rect, ima); - - data::paste(ima, adaptor); - - display::save (adaptor); - // FIXME: Don't use display::show in batch tests. -// display::show (adaptor, "xv"); - - // FIXME: Likewise. - /* Check if this statement holds in our case. Maybe we need to - involve Libtool in to handle FreeImagePlus properly. */ -// FreeImage_DeInitialise(); - } -} diff --git a/milena/trash/fi_adaptor.hh b/milena/trash/fi_adaptor.hh deleted file mode 100644 index e8f274d..0000000 --- a/milena/trash/fi_adaptor.hh +++ /dev/null @@ -1,476 +0,0 @@ -// Copyright (C) 2007, 2008 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_CORE_IMAGE_FI_ADAPTOR_HH -# define MLN_CORE_IMAGE_FI_ADAPTOR_HH - - -/*! \file mln/core/image/fi_adaptor.hh - * - * \brief Definition of the fi_adaptor image class. This class aims - * to use the fipImage class (Main FreeImagePlus class) through one of - * our class. Then we can pass image data as argument to our algorithms and - * FreeImagePlus's ones. - * - * For compatibility reasons, images from FreeImage library which - * doesn't take more than 7bits per pixel are converted to fill 8 bits - * per pixel. - * - * - * COMPILATION: - * If you need this class you will need to install FreeImagePlus then - * compile you software with the flag -lfreeimageplus. - * - */ - - -# include <FreeImagePlus.h> - -# include <mln/core/internal/image_primary.hh> -# include <mln/core/alias/box2d.hh> -# include <mln/core/line_piter.hh> -# include <mln/value/set.hh> - -namespace mln -{ - // Fwd decl. - template <typename I> struct fi_adaptor; - - namespace internal - { - /// Data structure for \c mln::fi_adaptor<I>. - template <typename I> - struct data< fi_adaptor<I> > - { - /// Constructor. - data(); - - /// Destructor. - ~data(); - - /// Adaptee image - fipImage fi_ima_; - - /// Pointer to pixel buffer. - mln_value(I)* buffer_; - - /// Pointer to an array of pointer on images lines. - mln_value(I)** array_; - - /// theoretical box - box2d b_; - - /// Synchronise buffer_, array_ and b_ with actual adaptee image. - void sync_with_adaptee_(); - - /// Desallocate allocated datas of this structure. - void deallocate_(); - - /// Swap data between images. - void swap_(data< fi_adaptor<I> >& other_); - }; - - } // end of namespace mln::internal - - - - namespace trait - { - - template <typename I> - struct image_< fi_adaptor<I> > - : default_image_< mln_value(I), fi_adaptor<I> > - { - typedef trait::image::category::primary category; - - typedef trait::image::access::random access; - typedef trait::image::space::two_d space; - typedef trait::image::size::regular size; - typedef trait::image::support::aligned support; - - typedef trait::image::border::none border; - typedef trait::image::data::raw data; - typedef trait::image::io::read_write io; - typedef trait::image::speed::fast speed; - }; - - } // end of namespace mln::trait - - - /*! \brief fi_adaptor class. - * - * The parameter \c I is the type of image through Milena will see - * the Freeimage's class. This class aims to load images using - * Freeimage library. - */ - - template <typename I> - struct fi_adaptor : public internal::image_primary< mln_value(I), box2d, - fi_adaptor<I> > - { - // Warning: just to make effective types appear in Doxygen: - typedef box2d pset; - typedef point2d psite; - typedef point2d point; - typedef dpoint2d dpoint; - typedef mln_fwd_piter(box2d) fwd_piter; - typedef mln_bkd_piter(box2d) bkd_piter; - typedef line_piter_<point> line_piter; - // End of warning. - - /// Typedef T. - typedef mln_value(I) T; - - /// Value associated type. - typedef T value; - - /// Return type of read-only access. - typedef const T& rvalue; - - /// Return type of read-write access. - typedef T& lvalue; - - /// Skeleton. - typedef fi_adaptor< tag::value_<T> > skeleton; - - /// Constructor without argument. - fi_adaptor(); - - /// Constructor with a fipImage - fi_adaptor(fipImage& ima); - - /// Initialize an empty image. - void init_(); - - /// Give the definition domain. - const box2d& domain() const; - - /// Give the number of cells. - unsigned nelements() const; - - /// Read-only access to the image value located at point \p p. - const T& operator()(const point2d& p) const; - - /// Read-write access to the image value located at point \p p. - T& operator()(const point2d& p); - - /// Read-only access to the image value located at offset \p o. - const T& operator[](unsigned o) const; - - /// Read-write access to the image value located at offset \p o. - T& operator[](unsigned o); - - /// Read-only access to the image value located at (\p row, \p col). - const T& at(int row, int col) const; - - /// Read-write access to the image value located at (\p row, \p col). - T& at(int row, int col); - - - /// Fast Image method - - /// Give the offset corresponding to the delta-point \p dp. - int delta_index(const dpoint2d& dp) const; - - /// Give the point corresponding to the offset \p o. - point2d point_at_index(unsigned o) const; - - /// Give a hook to the value buffer. - const T* buffer() const; - - /// Give a hook to the value buffer. - T* buffer(); - - /// \{ Access to adaptee. - fipImage& adaptee(); - const fipImage& adaptee() const; - /// \} - - /// \{ Delegatee functions to construct the image. Should be use it - /// before calling adaptee() method. - BOOL load(const char* lpszPathName, int flag = 0); - BOOL loadU(const wchar_t* lpszPathName, int flag = 0); - BOOL loadFromHandle(FreeImageIO *io, fi_handle handle, int flag = 0); - BOOL loadFromMemory(fipMemoryIO& memIO, int flag = 0); - /// \} - }; - - - // internal::data< fi_adaptor<I> > - - namespace internal - { - template <typename I> - data< fi_adaptor<I> >::data() - { - } - - template <typename I> - data< fi_adaptor<I> >::~data() - { - deallocate_(); - } - - template <typename I> - void - data< fi_adaptor<I> >::sync_with_adaptee_() - { - mln_precondition(fi_ima_.isValid()); - // FIXME: doesnt work for rgb: - // mln_precondition(fi_ima_.getBitsPerPixel() == - // 8 * sizeof(mln_value(I))); - - deallocate_(); - b_ = make::box2d(fi_ima_.getHeight(), - fi_ima_.getWidth()); - unsigned - nr = fi_ima_.getHeight(), - nc = fi_ima_.getWidth(); - buffer_ = (mln_value(I)*) fi_ima_.accessPixels(); - array_ = new mln_value(I)*[nr]; - mln_value(I)* buf = buffer_; - for (unsigned i = 0; i < nr; ++i) - { - array_[i] = buf; - buf += nc; - } - } - - template <typename I> - void - data< fi_adaptor<I> >::deallocate_() - { - if (array_) - { - delete[] array_; - array_ = 0; - } - } - - template <typename I> - void - data< fi_adaptor<I> >::swap_(data< fi_adaptor<I> >& other_) - { - data< fi_adaptor<I> > self_ = *this; - *this = other_; - other_ = self_; - } - - } // end of namespace mln::internal - - - // fi_adaptor<I> - - template <typename I> - fi_adaptor<I>::fi_adaptor() - { - } - - template <typename I> - void - fi_adaptor<I>::init_() - { - this->data_ = new internal::data< fi_adaptor<I> >(); - } - - template <typename I> - const box2d& - fi_adaptor<I>::domain() const - { - mln_precondition(this->is_valid()); - return this->data_->b_; - } - - template <typename I> - unsigned - fi_adaptor<I>::nelements() const - { - mln_precondition(this->is_valid()); - return this->data_->b_.nsites(); - } - - template <typename I> - const mln_value(I)& - fi_adaptor<I>::operator()(const point2d& p) const - { - mln_precondition(this->has(p)); - - // Because Freeimage stores lena upside down. - return this->data_->array_[this->domain().len(0) - 1 - p.row()][p.col()]; - } - - template <typename I> - mln_value(I)& - fi_adaptor<I>::operator()(const point2d& p) - { - mln_precondition(this->has(p)); - - // Because Freeimage stores lena upside down. - return this->data_->array_[this->domain().len(0) - 1 - p.row()][p.col()]; - } - - template <typename I> - const mln_value(I)& - fi_adaptor<I>::operator[](unsigned o) const - { - mln_precondition(o < nelements()); - return *(this->data_->buffer_ + o); - } - - template <typename I> - mln_value(I)& - fi_adaptor<I>::operator[](unsigned o) - { - mln_precondition(o < nelements()); - return *(this->data_->buffer_ + o); - } - - template <typename I> - const mln_value(I)& - fi_adaptor<I>::at(int row, int col) const - { - mln_precondition(this->has(point2d(row, col))); - - // Because Freeimage stores lena upside down. - return this->data_->array_[this->domain().len(0) - 1 - row][col]; - } - - template <typename I> - mln_value(I)& - fi_adaptor<I>::at(int row, int col) - { - mln_precondition(this->has(point2d(row, col))); - - // Because Freeimage stores lena upside down. - return this->data_->array_[this->domain().len(0) - 1 - row][col]; - } - - template <typename I> - const mln_value(I)* - fi_adaptor<I>::buffer() const - { - mln_precondition(this->is_valid()); - return this->data_->buffer_; - } - - template <typename I> - mln_value(I)* - fi_adaptor<I>::buffer() - { - mln_precondition(this->is_valid()); - return this->data_->buffer_; - } - - template <typename I> - int - fi_adaptor<I>::delta_index(const dpoint2d& dp) const - { - mln_precondition(this->is_valid()); - int o = dp[0] * this->data_->b_.len(1) + dp[1]; - return o; - } - - template <typename I> - point2d - fi_adaptor<I>::point_at_index(unsigned o) const - { - mln_precondition(o < nelements()); - point2d p = point2d(this->data_->b_.max_row() - o / this->data_->b_.len(1) - this->data_->b_.min_row(), - o % this->data_->b_.len(1) + this->data_->b_.min_col()); - mln_postcondition(& this->operator()(p) == this->data_->buffer_ + o); - - return p; - } - - template <typename I> - fipImage& - fi_adaptor<I>::adaptee() - { - mln_precondition(this->is_valid()); - return this->data_->fi_ima_; - } - - template <typename I> - const fipImage& - fi_adaptor<I>::adaptee() const - { - mln_precondition(this->is_valid()); - return this->data_->fi_ima_; - } - - template <typename I> - BOOL - fi_adaptor<I>::load(const char* lpszPathName, int flag) - { - init_(); - BOOL r = this->data_->fi_ima_.load(lpszPathName, flag); - mln_assertion(this->data_->fi_ima_.isValid()); - if (this->data_->fi_ima_.getBitsPerPixel() < 8) - this->data_->fi_ima_.convertTo8Bits(); - this->data_->sync_with_adaptee_(); - return r; - } - - template <typename I> - BOOL - fi_adaptor<I>::loadU(const wchar_t* lpszPathName, int flag) - { - init_(); - BOOL r = this->data_->fi_ima_.loadU(lpszPathName, flag); - if (this->data_->fi_ima_.getBitsPerPixel() < 8) - this->data_->fi_ima_.convertTo8Bits(); - this->data_->sync_with_adaptee_(); - return r; - } - - template <typename I> - BOOL - fi_adaptor<I>::loadFromHandle(FreeImageIO *io, fi_handle handle, int flag) - { - init_(); - BOOL r = this->data_->fi_ima_.loadFromHandle(io, handle, flag); - if (this->data_->fi_ima_.getBitsPerPixel() < 8) - this->data_->fi_ima_.convertTo8Bits(); - this->data_->sync_with_adaptee_(); - return r; - } - - template <typename I> - BOOL - fi_adaptor<I>::loadFromMemory(fipMemoryIO& memIO, int flag) - { - init_(); - BOOL r = this->data_->fi_ima_.loadFromMemory(memIO, flag); - if (this->data_->fi_ima_.getBitsPerPixel() < 8) - this->data_->fi_ima_.convertTo8Bits(); - this->data_->sync_with_adaptee_(); - return r; - } - -} // end of namespace mln - - -#endif // ! MLN_CORE_IMAGE_FI_ADAPTOR_HH diff --git a/milena/trash/freeimageplus.mk b/milena/trash/freeimageplus.mk deleted file mode 100644 index fee203c..0000000 --- a/milena/trash/freeimageplus.mk +++ /dev/null @@ -1,9 +0,0 @@ -## To be added to Makefile.am when support for FreeImagePlus is restored. - -# Tests depending on the FreeImagePlus library. -if HAVE_FREEIMAGEPLUS - check_PROGRAMS += fi_adaptor - fi_adaptor_SOURCES = fi_adaptor.cc - fi_adaptor_CPPFLAGS = $(AM_CPPFLAGS) $(FREEIMAGEPLUS_CPPFLAGS) - fi_adaptor_LDFLAGS = $(AM_LDFLAGS) $(FREEIMAGEPLUS_LDFLAGS) -endif HAVE_FREEIMAGEPLUS diff --git a/milena/trash/graph_image.hh b/milena/trash/graph_image.hh deleted file mode 100644 index 8143b29..0000000 --- a/milena/trash/graph_image.hh +++ /dev/null @@ -1,300 +0,0 @@ -// Copyright (C) 2007, 2008 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_CORE_IMAGE_GRAPH_IMAGE_HH -# define MLN_CORE_IMAGE_GRAPH_IMAGE_HH - -/// \file mln/core/image/graph_image.hh -/// \brief Definition of a graph-based image. - -# include <vector> - -# include <mln/trait/images.hh> - -# include <mln/core/internal/image_primary.hh> -# include <mln/algebra/vec.hh> -# include <mln/core/site_set/p_graph.hh> -# include <mln/core/image/bgraph_psite.hh> -# include <mln/value/set.hh> - -/* FIXME: This class shares a lot with line_graph_image. Factor as - much as possible. */ - - -namespace mln -{ - - // Fwd decl. - template <typename P, typename V> struct graph_image; - - namespace internal - { - - /// Data structure for \c mln::graph_image<P,V>. - template <typename P, typename V> - struct data< graph_image<P, V> > - { - data(const p_graph<P>& pg, const std::vector<V>& val); - - std::vector<V> val_; - const p_graph<P> pg_; - }; - - } // end of namespace mln::internal - - - namespace trait - { - - template <typename P, typename V> - struct image_< graph_image<P, V> > : default_image_< V, graph_image<P, V> > - { - // Misc. - typedef trait::image::category::primary category; - // FIXME: Is that right? - typedef trait::image::speed::fast speed; - typedef trait::image::size::regular size; - - // Value. - typedef trait::image::value_access::direct value_access; - // FIXME: Is that right? - typedef trait::image::value_storage::one_block value_storage; - typedef trait::image::value_browsing::site_wise_only value_browsing; - typedef trait::image::value_io::read_write value_io; - - // Site / domain. - // FIXME: Depends on P. - typedef trait::image::localization::basic_grid localization; - // FIXME: Likewise. - typedef typename trait::image::space_from_point<P>::ret dimension; - - // Extended domain - typedef trait::image::ext_domain::none ext_domain; - typedef trait::image::ext_value::irrelevant ext_value; - typedef trait::image::ext_io::irrelevant ext_io; - }; - - } // end of namespace mln::trait - - - /// \brief Image based on a graph. - /// - /// Values are stored on the edges of the graph, not on its vertices. - template <typename P, typename V> - class graph_image : - public internal::image_primary< V, p_graph<P>, graph_image<P, V> > - { - public: - /// Value associated type. - typedef V value; - - /// \brief Return type of read-write access. - /// - /// We use the associated type \c reference instead of a plain - /// reference on the value type (\p V), because it's the only way - /// to safely form a reference on the element in the case of a - /// std::vector<bool>. - typedef typename std::vector<V>::reference lvalue; - - /// Return type of read-only access. - typedef typename std::vector<V>::const_reference rvalue; - - /// Skeleton. - typedef graph_image< tag::psite_<P>, tag::value_<V> > skeleton; - - public: - /// Constructors. - /// \{ - graph_image(); - graph_image(const p_graph<P>& pg); - graph_image(const p_graph<P>& pg, const std::vector<V>& val); - /// \} - - /// Initialize an empty image. - void init_(const p_graph<P>& pg, const std::vector<V>& val); - - /// Read-only access of pixel value at point site \p p. - rvalue operator()(const graph_psite<P>& p) const; - - /// Read-write access of pixel value at point site \p p. - lvalue operator()(const graph_psite<P>& p); - - /// Accessors. - /// \{ - /// Return the domain of psites od the image. - const p_graph<P>& domain() const; - - /// Return the array of values associated to the vertices. - const std::vector<V>& vertex_values() const; - /// \} - - /* FIXME: Do we want to provide these two methods? (at least, in - the interface of the class? */ - - /// Return the point of the first vertex adjacent to the edge with - /// id \a e. - const P& vertex1(const util::edge_id& e) const; - /// Return the point of the second vertex adjacent to the edge with - /// id \a e. - const P& vertex2(const util::edge_id& e) const; - }; - - // Fwd decl. - template <typename P, typename V, typename W> - void init_(tag::image_t, - graph_image<P, V>& target, const graph_image<P, W>& model); - - -# ifndef MLN_INCLUDE_ONLY - - /*-----------------. - | Initialization. | - `-----------------*/ - - template <typename P, typename V, typename W> - inline - void init_(tag::image_t, - graph_image<P, V>& target, const graph_image<P, W>& model) - { - target.init_(model.domain(), - std::vector<V>(model.vertex_values().size())); - } - - /*-------. - | Data. | - `-------*/ - - namespace internal - { - template <typename P, typename V> - inline - data< graph_image<P, V> >::data(const p_graph<P>& pg, - const std::vector<V>& val) - : val_ (val), - pg_ (pg) - { - mln_precondition(pg.nvertices() == val.size()); - } - - } // end of namespace mln::internal - - /*---------------. - | Construction. | - `---------------*/ - - template <typename P, typename V> - inline - graph_image<P, V>::graph_image() - { - } - - template <typename P, typename V> - inline - graph_image<P, V>::graph_image(const p_graph<P>& pg) - { - init_(pg, std::vector<V>(pg.nvertices())); - } - - template <typename P, typename V> - inline - graph_image<P, V>::graph_image(const p_graph<P>& pg, - const std::vector<V>& val) - { - init_(pg, val); - } - - template <typename P, typename V> - inline - void - graph_image<P, V>::init_(const p_graph<P>& pg, const std::vector<V>& val) - { - mln_precondition(! this->is_valid()); - this->data_ = new internal::data< graph_image<P, V> > (pg, val); - } - - /*---------------. - | Manipulation. | - `---------------*/ - - template <typename P, typename V> - inline - typename graph_image<P, V>::rvalue - graph_image<P, V>::operator()(const graph_psite<P>& p) const - { - mln_precondition(p.is_valid()); - mln_precondition(p.site_set() == this->data_->pg_); - return this->data_->val_[p.vertex_id()]; - } - - template <typename P, typename V> - inline - typename graph_image<P, V>::lvalue - graph_image<P, V>::operator()(const graph_psite<P>& p) - { - mln_precondition(p.is_valid()); - mln_precondition(p.site_set() == this->data_->pg_); - return this->data_->val_[p.vertex_id()]; - } - - template <typename P, typename V> - inline - const std::vector<V>& - graph_image<P, V>::vertex_values() const - { - return this->data_->val_; - } - - template <typename P, typename V> - inline - const p_graph<P>& - graph_image<P, V>::domain() const - { - mln_precondition(this->is_valid()); - return this->data_->pg_; - } - - template <typename P, typename V> - inline - const P& - graph_image<P, V>::vertex1(const util::edge_id& e) const - { - return this->domain().vertex1(e); - } - - template <typename P, typename V> - inline - const P& - graph_image<P, V>::vertex2(const util::edge_id& e) const - { - return this->domain().vertex2(e); - } - -# endif // ! MLN_INCLUDE_ONLY - -} // end of namespace mln - - -#endif // ! MLN_CORE_IMAGE_GRAPH_IMAGE_HH diff --git a/milena/trash/line_graph_image.hh b/milena/trash/line_graph_image.hh deleted file mode 100644 index d2ddcb0..0000000 --- a/milena/trash/line_graph_image.hh +++ /dev/null @@ -1,344 +0,0 @@ -// Copyright (C) 2007, 2008 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_CORE_IMAGE_LINE_GRAPH_IMAGE_HH -# define MLN_CORE_IMAGE_LINE_GRAPH_IMAGE_HH - -/// \file mln/core/image/line_graph_image.hh -/// \brief Definition of a line graph-based image. - -# include <vector> - -# include <mln/trait/images.hh> - -# include <mln/core/internal/image_primary.hh> -# include <mln/algebra/vec.hh> -# include <mln/core/site_set/p_line_graph.hh> -# include <mln/core/image/line_graph_psite.hh> -# include <mln/value/set.hh> - -/* FIXME: This class shares a lot with graph_image. Factor as much as - possible. */ - -/* FIXME: This is only a very naive prototype. For instance, this - image associates values to both the vertices and the edges of the - graph, but only values on edges are accessible. We probably want - to fork this class to have a pure image of line graph (with no data - on vertices) and one having data on both vertices and edges. - - Moreover, in the current implementation, the type of values on - vertices and edges is necessarily the same (V). We should allow - different data types for vertices and edges. */ - - -namespace mln -{ - - // Forward declaration. - template <typename P, typename V> struct line_graph_image; - - namespace internal - { - - /// Data structure for \c mln::line_graph_image<P,V>. - template <typename P, typename V> - struct data< line_graph_image<P, V> > - { - data(const p_line_graph<P>& plg, - const std::vector<V>& vertex_val, const std::vector<V>& edge_val); - - std::vector<V> vertex_val_; - std::vector<V> edge_val_; - const p_line_graph<P> plg_; - }; - - } // end of namespace mln::internal - - - namespace trait - { - - template <typename P, typename V> - struct image_< line_graph_image<P, V> > - : default_image_< V, line_graph_image<P, V> > - { - // Misc. - typedef trait::image::category::primary category; - // FIXME: Is that right? - typedef trait::image::speed::fast speed; - typedef trait::image::size::regular size; - - // Value. - typedef trait::image::value_access::direct value_access; - // FIXME: Is that right? - typedef trait::image::value_storage::one_block value_storage; - typedef trait::image::value_browsing::site_wise_only value_browsing; - typedef trait::image::value_io::read_write value_io; - - // Site / domain. - // FIXME: Depends on P. - typedef trait::image::localization::basic_grid localization; - // FIXME: Likewise. - typedef typename trait::image::space_from_point<P>::ret dimension; - - // Extended domain - typedef trait::image::ext_domain::none ext_domain; - typedef trait::image::ext_value::irrelevant ext_value; - typedef trait::image::ext_io::irrelevant ext_io; - }; - - } // end of namespace mln::trait - - - /// \brief Image based on a graph. - /// - /// Values are stored on the edges of the graph. - template <typename P, typename V> - class line_graph_image - : public internal::image_primary< V, p_line_graph<P>, - line_graph_image<P, V> > - { - public: - /// Value associated type. - typedef V value; - - /// \brief Return type of read-write access. - /// - /// We use the associated type \c reference instead of a plain - /// reference on the value type (\p V), because it's the only way - /// to safely form a reference on the element in the case of a - /// std::vector<bool>. - typedef typename std::vector<V>::reference lvalue; - - /// Return type of read-only access. - typedef typename std::vector<V>::const_reference rvalue; - - /// Skeleton. - typedef line_graph_image< tag::psite_<P>, tag::value_<V> > skeleton; - - public: - /// Constructors. - /// \{ - line_graph_image(); - line_graph_image(const p_line_graph<P>& plg); - line_graph_image(const p_line_graph<P>& plg, - const std::vector<V>& vertex_val, - const std::vector<V>& edge_val); - /// \} - - /// Initialize an empty image. - void init_(const p_line_graph<P>& plg, - const std::vector<V>& vertex_val, - const std::vector<V>& edge_val); - - /// Read-only access of pixel value at point site \p p. - rvalue operator()(const line_graph_psite<P>& p) const; - - /// Read-write access of pixel value at point site \p p. - lvalue operator()(const line_graph_psite<P>& p); - - /// Accessors. - /// \{ - /// Return the domain of psites od the image. - const p_line_graph<P>& domain() const; - - /// Return the array of values associated to the edges. - const std::vector<V>& edge_values() const; - /// Return the array of values associated to the vertices. - const std::vector<V>& vertex_values() const; - /// \} - - /* FIXME: Do we want to provide these two methods? (at least, in - the interface of the class? */ - - /// Return the point of the first vertex adjacent to the edge with - /// id \a e. - const P& vertex1(const util::edge_id& e) const; - /// Return the point of the second vertex adjacent to the edge with - /// id \a e. - const P& vertex2(const util::edge_id& e) const; - }; - - // Fwd decl. - template <typename P, typename V, typename W> - void init_(tag::image_t, - line_graph_image<P, V>& target, - const line_graph_image<P, W>& model); - - -# ifndef MLN_INCLUDE_ONLY - - /*-----------------. - | Initialization. | - `-----------------*/ - - template <typename P, typename V, typename W> - inline - void init_(tag::image_t, - line_graph_image<P, V>& target, - const line_graph_image<P, W>& model) - { - target.init_(model.domain(), - std::vector<V>(model.vertex_values().size()), - std::vector<V>(model.edge_values().size())); - } - - /*-------. - | Data. | - `-------*/ - - namespace internal - { - template <typename P, typename V> - inline - data< line_graph_image<P, V> >::data(const p_line_graph<P>& plg, - const std::vector<V>& vertex_val, - const std::vector<V>& edge_val) - : vertex_val_(vertex_val), - edge_val_(edge_val), - plg_(plg) - { - mln_precondition(plg.nvertices() == vertex_val.size()); - mln_precondition(plg.nedges() == edge_val.size()); - } - - } // end of namespace mln::internal - - /*---------------. - | Construction. | - `---------------*/ - - template <typename P, typename V> - inline - line_graph_image<P, V>::line_graph_image() - { - } - - template <typename P, typename V> - inline - line_graph_image<P, V>::line_graph_image(const p_line_graph<P>& plg) - { - init_(plg, std::vector<V>(plg.nvertices()), std::vector<V>(plg.nedges())); - } - - template <typename P, typename V> - inline - line_graph_image<P, V>::line_graph_image(const p_line_graph<P>& plg, - const std::vector<V>& vertex_val, - const std::vector<V>& edge_val) - { - init_(plg, vertex_val, edge_val); - } - - template <typename P, typename V> - inline - void - line_graph_image<P, V>::init_(const p_line_graph<P>& plg, - const std::vector<V>& vertex_val, - const std::vector<V>& edge_val) - { - mln_precondition(! this->is_valid()); - this->data_ = - new internal::data< line_graph_image<P, V> >(plg, vertex_val, edge_val); - } - - /*---------------. - | Manipulation. | - `---------------*/ - - template <typename P, typename V> - inline - typename line_graph_image<P, V>::rvalue - line_graph_image<P, V>::operator()(const line_graph_psite<P>& p) const - { - mln_precondition(p.is_valid()); - mln_precondition(p.site_set() == this->data_->plg_); - return this->data_->edge_val_[p.edge_id()]; - } - - template <typename P, typename V> - inline - typename line_graph_image<P, V>::lvalue - line_graph_image<P, V>::operator()(const line_graph_psite<P>& p) - { - mln_precondition(p.is_valid()); - mln_precondition(p.site_set() == this->data_->plg_); - return this->data_->edge_val_[p.edge_id()]; - } - - template <typename P, typename V> - inline - const std::vector<V>& - line_graph_image<P, V>::edge_values() const - { - return this->data_->edge_val_; - } - - template <typename P, typename V> - inline - const std::vector<V>& - line_graph_image<P, V>::vertex_values() const - { - return this->data_->vertex_val_; - } - - template <typename P, typename V> - inline - const p_line_graph<P>& - line_graph_image<P, V>::domain() const - { - mln_precondition(this->is_valid()); - return this->data_->plg_; - } - - template <typename P, typename V> - inline - const P& - line_graph_image<P, V>::vertex1(const util::edge_id& e) const - { - // FIXME: Improve the interface of graph to avoid these low-level - // manipulations. - util::vertex_id v1 = this->domain().gr_.edge(e).v1(); - return this->domain().gr_.vertex_data(v1); - } - - template <typename P, typename V> - inline - const P& - line_graph_image<P, V>::vertex2(const util::edge_id& e) const - { - // FIXME: Improve the interface of graph to avoid these low-level - // manipulations. - util::vertex_id v2 = this->domain().gr_.edge(e).v2(); - return this->domain().gr_.vertex_data(v2); - } - -# endif // ! MLN_INCLUDE_ONLY - -} // end of namespace mln - - -#endif // ! MLN_CORE_IMAGE_LINE_GRAPH_IMAGE_HH diff --git a/milena/trash/mono_obased_rle_encode.hh b/milena/trash/mono_obased_rle_encode.hh deleted file mode 100644 index e3ccdc1..0000000 --- a/milena/trash/mono_obased_rle_encode.hh +++ /dev/null @@ -1,120 +0,0 @@ -// Copyright (C) 2007 EPITA Research and Development Laboratory -// -// 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_CORE_IMAGE_MONO_OBASED_RLE_ENCODE_HH -# define MLN_CORE_IMAGE_MONO_OBASED_RLE_ENCODE_HH - -/*! \file mln/core/image/mono_obased_rle_encode.hh - * - * \brief Definintion of function which encodes an image in mono_obased_rle_image. - */ - -# include <mln/core/image/mono_obased_rle_image.hh> - -namespace mln -{ - - /*! - ** Encode an image class to a mono_obased_rle_image. - ** - ** @param input has to respect the Image concept - ** @param ignore_zero says if zero has to be considered as a valid value - ** - ** @return mono_obased_rle_image. - */ - template <typename I> - mono_obased_rle_image<mln_psite(I), mln_value(I)> - mono_obased_rle_encode(const Image<I>& input, bool ignore_zero = true); - -# ifndef MLN_INCLUDE_ONLY - /*! - ** test if Point p1 and p2 are on the same line - */ - template <typename P> - inline - bool - on_the_same_line(const P& p1, const P& p2) - { - const unsigned dim = P::dim; - bool same_line = true; - - for (unsigned n = 0; same_line && n < dim - 1; ++n) - same_line = (p1[n] == p2[n]); - return same_line; - } - - template <typename I> - inline - mono_obased_rle_image<mln_psite(I), mln_value(I)> - mono_obased_rle_encode(const Image<I>& input, bool ignore_zero) - { - typedef mln_psite(I) P; - - const I& ima = exact(input); - mln_piter(I) p (exact(input).domain()); - unsigned len = 0; - mln_psite(I) rstart; - mln_value(I) rvalue; - std::set< mln_value(I) > sv; - - for_all(p) - { - if (!ignore_zero || ima(p) != literal::zero) - sv.insert(ima(p)); - } - - mono_obased_rle_image<mln_psite(I), mln_value(I)> output(sv); - for_all(p) - if (!ignore_zero || ima(p) != literal::zero || len) - { - if (len == 0) - { - ++len; - rstart = p; - rvalue = ima(p); - } - else - if (rvalue == ima(p) - && on_the_same_line(rstart, mln_psite(I)(p))) - ++len; - else - { - output.insert(p_run<P>(rstart, len), rvalue); - if ((len = (!ignore_zero || ima(p) != literal::zero))) - { - rstart = p; - rvalue = ima(p); - } - } - } - output.finalize(); - return output; - } - -#endif // ! MLN_INCLUDE_ONLY - -} - -#endif // ! MLN_CORE_IMAGE_MONO_OBASED_RLE_ENCODE_HH diff --git a/milena/trash/mono_obased_rle_image.cc b/milena/trash/mono_obased_rle_image.cc deleted file mode 100644 index 5d13156..0000000 --- a/milena/trash/mono_obased_rle_image.cc +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright (C) 2007, 2008 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. - -/*! \file tests/core/image/mono_obased_rle_image.cc - * - * \brief Test on mln::mono_obased_rle_image.hh. - */ - -#include <mln/core/image/image2d.hh> -#include <mln/value/int_u8.hh> -#include <mln/io/pgm/load.hh> -#include <mln/pw/all.hh> -#include <mln/core/alias/neighb2d.hh> - -#include <mln/labeling/blobs.hh> -#include <mln/data/transform.hh> -#include <mln/data/paste.hh> -#include <mln/data/compare.hh> -#include <mln/io/pgm/save.hh> - -#include <mln/core/image/mono_obased_rle_encode.hh> - -#include "tests/data.hh" - - -struct fold_t : public mln::Function_v2v< fold_t > -{ - typedef mln::value::int_u8 result; - result operator()(unsigned i) const { return i == 0 ? 0 : (i - 1) % 255 + 1; } -}; - - -int main() -{ - using namespace mln; - using value::int_u8; - - image2d<int_u8> lena; - io::pgm::load(lena, MLN_IMG_DIR "/small.pgm"); - image2d<int_u8> cmp(lena.domain()); - - unsigned n; - image2d<unsigned> labels = - labeling::blobs((pw::value(lena) > pw::cst(172u)) | lena.domain(), - c4(), n); - - mono_obased_rle_image<point2d, int_u8> rle = - mono_obased_rle_encode(data::transform(labels, fold_t())); - - std::cout << n << ", compression ratio: " << rle.compression() << std::endl; - - data::fill(cmp, literal::zero); - data::paste(rle, cmp); - - mln_assertion(cmp == data::transform(labels, fold_t())); -} diff --git a/milena/trash/mono_obased_rle_image.hh b/milena/trash/mono_obased_rle_image.hh deleted file mode 100644 index 393f9ae..0000000 --- a/milena/trash/mono_obased_rle_image.hh +++ /dev/null @@ -1,266 +0,0 @@ -// Copyright (C) 2007.2008 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_CORE_IMAGE_MONO_OBASED_RLE_IMAGE_HH -# define MLN_CORE_IMAGE_MONO_OBASED_RLE_IMAGE_HH - -/// \file mln/core/image/mono_obased_rle_image.hh -/// -/// Definition of an image with rle encoding. - -# include <mln/core/internal/run_image.hh> -# include <mln/core/site_set/p_run.hh> -# include <mln/core/site_set/p_set_of.hh> -# include <mln/core/site_set/box.hh> -# include <mln/value/set.hh> -# include <mln/core/image/mono_rle_image.hh> -# include <vector> - -namespace mln -{ - - // Forward declaration. - template <typename P, typename T> struct mono_obased_rle_image; - - - namespace internal - { - - /// Data structure for \c mln::mono_obased_rle_image<P,T>. - template <typename P, typename T> - struct data< mono_obased_rle_image<P,T> > - { - data(const std::set<T>& values); - - /// Objects. - std::vector< mono_rle_image<P, T> > ima_; - - /// Image value. - std::vector<T> values_; - - /// domain of the image - p_set_of< p_run<P> > domain_; - - /// Return the size of the data in memory. - unsigned memory_size() const; - - /// Finalize the domain (internal use). - void finalize(); - - }; - - } // end of namespace mln::internal - - - namespace trait - { - - template <typename P, typename T> - struct image_< mono_obased_rle_image<P,T> > : default_image_< T, mono_obased_rle_image<P,T> > - { - typedef trait::image::category::primary category; - - // FIXME: update with new properties. -// typedef trait::image::access::browsing access; - // FIXME: Put the right dimension. -// typedef trait::image::space::two_d space; -// typedef trait::image::size::regular size; -// typedef trait::image::support::aligned support; -// -// typedef trait::image::border::none border; -// typedef trait::image::data::linear data; -// typedef trait::image::io::read_only io; -// typedef trait::image::speed::slow speed; - }; - - } // end of namespace mln::trait - - - /*! RLE image with objects based on mln::mono_rle_image. - * - * - * Parameter \c P is the type of the image points. - * Parameter \c T is the type of the pixel values. - * This image is not point wise accessible. - */ - template <typename P, typename T> - class mono_obased_rle_image : public internal::run_image_< T, P, mono_obased_rle_image<P, T> > - { - public: - typedef T value; - typedef T& lvalue; - typedef const T rvalue; - typedef p_set_of< p_run<P> > pset; - typedef mln_psite(pset) psite; - - - /// Skeleton. - typedef mono_obased_rle_image< tag::psite_<P>, tag::value_<T> > skeleton; - - /// Constructor. - mono_obased_rle_image(const std::set<T>& values); - - /// Initialize an empty image. - void init_(const std::set<T>& values); - - /// Add a new range to the image. - void insert(const p_run<P>& pr, T value); - - /// Read-only access to the image value located at point \p p. - const T operator()(const mln_psite(pset)& site) const; - - /// Read-write access to the image value located at point \p p. - T& operator()(const mln_psite(pset)& site); - - /// Test if this image has been initialized. - bool is_valid() const; - - /// Give the definition domain. - const pset& domain() const; - - /// Give the index vector of the i-th object. - const mono_rle_image<P, T>& object(unsigned i) const; - - }; - - -# ifndef MLN_INCLUDE_ONLY - - namespace internal - { - - // internal::data< mono_obased_rle_image<P,T> > - - template <typename P, typename T> - inline - data< mono_obased_rle_image<P,T> >::data(const std::set<T>& values) - : ima_(values.begin(), values.end()) - { - } - - template <typename P, typename T> - inline - unsigned - data< mono_obased_rle_image<P,T> >::memory_size() const - { - return domain_.memory_size() * 2 + sizeof(T) * (values_.size() + ima_.size()); - } - - template <typename P, typename T> - inline - void - data< mono_obased_rle_image<P,T> >::finalize() - { - domain_.finalize(); - for (typename std::vector< mono_rle_image<P, T> >::iterator it = ima_.begin(); - it != ima_.end(); ++it) - it->finalize(); - } - - } // end of namespace mln::internal - - template <typename P, typename T> - inline - mono_obased_rle_image<P, T>::mono_obased_rle_image(const std::set<T>& values) - { - init_(values); - } - - template <typename P, typename T> - inline - void - mono_obased_rle_image<P, T>::init_(const std::set<T>& values) - { - this->data_ = new internal::data< mono_obased_rle_image<P,T> >(values); - } - - template <typename P, typename T> - inline - bool - mono_obased_rle_image<P, T>::is_valid() const - { - return this->data_->ima_.size() != 0; - } - - template <typename P, typename T> - inline - void - mono_obased_rle_image<P, T>::insert(const p_run<P>& pr, T value) - { - mln_assertion(this->data_->values_.size() == 0 || this->data_->domain_.nsites() == 0 || - pr[0] > this->data_->domain_[this->data_->domain_.nsites() - 1].start()); - this->data_->domain_.insert(pr); - this->data_->values_.push_back(value); - unsigned i; - for (i = 0; i < this->data_->ima_.size() - && this->data_->ima_[i].get_value() != value; ++i) - ; - mln_assertion(i != this->data_->ima_.size()); - this->data_->ima_[i].insert(pr); - } - - template <typename P, typename T> - inline - const T - mono_obased_rle_image<P, T>::operator() (const mln_psite(pset)& site) const - { - mln_precondition(this->has(site)); - return this->data_->values_[site.index()]; - } - - template <typename P, typename T> - inline - T& - mono_obased_rle_image<P, T>::operator() (const mln_psite(pset)& site) - { - mln_precondition(this->has(site)); - return this->data_->values_[site.index()]; - } - - template <typename P, typename T> - inline - const typename mono_obased_rle_image<P, T>::pset& - mono_obased_rle_image<P, T>::domain() const - { - return this->data_->domain_; - } - - template <typename P, typename T> - inline - const mono_rle_image<P, T>& - mono_obased_rle_image<P, T>::object(unsigned i) const - { - mln_assertion(i < this->data_->ima_.size()); - return this->data_->ima_[i]; - } - -# endif // ! MLN_INCLUDE_ONLY - - -} // end of namespace mln - - -#endif // ! MLN_CORE_IMAGE_MONO_OBASED_RLE_IMAGE_HH diff --git a/milena/trash/mono_rle_encode.hh b/milena/trash/mono_rle_encode.hh deleted file mode 100644 index 950064c..0000000 --- a/milena/trash/mono_rle_encode.hh +++ /dev/null @@ -1,108 +0,0 @@ -// Copyright (C) 2007 EPITA Research and Development Laboratory -// -// 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_CORE_IMAGE_MONO_RLE_ENCODE_HH -# define MLN_CORE_IMAGE_MONO_RLE_ENCODE_HH - -/*! \file mln/core/image/mono_rle_encode.hh - * - * \brief Definintion of function which encodes an image in mono_rle_image. - */ - -# include <mln/core/image/mono_rle_image.hh> - -namespace mln -{ - - /*! - ** encode an image class to a mono_rle_image - ** - ** @param input has to respect the Image concept - ** @param val specify the value which has to be considered - ** - ** @return mono_rle_image - */ - template <typename I> - mono_rle_image<mln_psite(I), mln_value(I)> - mono_rle_encode(const Image<I>& input, mln_value(I) val); - -# ifndef MLN_INCLUDE_ONLY - /*! - ** test if Point p1 and p2 are on the same line - */ - template <typename P> - inline - bool - on_the_same_line(const P& p1, const P& p2) - { - const unsigned dim = P::dim; - bool same_line = true; - - for (unsigned n = 0; same_line && n < dim - 1; ++n) - same_line = (p1[n] == p2[n]); - return same_line; - } - - template <typename I> - inline - mono_rle_image<mln_psite(I), mln_value(I)> - mono_rle_encode(const Image<I>& input, mln_value(I) val) - { - typedef mln_psite(I) P; - - mono_rle_image<mln_psite(I), mln_value(I)> output(val); - const I& ima = exact(input); - mln_piter(I) p (exact(input).domain()); - unsigned len = 0; - mln_psite(I) rstart; - - for_all(p) - if (ima(p) == val || len) - { - if (len == 0) - { - ++len; - rstart = p; - } - else - if (val == ima(p) - && on_the_same_line(rstart, mln_psite(I)(p))) - ++len; - else - { - output.insert(p_run<P>(rstart, len)); - if ((len = (ima(p) == val))) - rstart = p; - } - } - output.finalize(); - return output; - } - -#endif // ! MLN_INCLUDE_ONLY - -} - -#endif // ! MLN_CORE_IMAGE_MONO_RLE_ENCODE_HH diff --git a/milena/trash/mono_rle_image.cc b/milena/trash/mono_rle_image.cc deleted file mode 100644 index 0ad907d..0000000 --- a/milena/trash/mono_rle_image.cc +++ /dev/null @@ -1,84 +0,0 @@ -// Copyright (C) 2007, 2008 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. - -/*! \file tests/core/image/mono_rle_image.cc - * - * \brief Test on mln::labeling::blobs. - */ - -#include <mln/core/image/image2d.hh> -#include <mln/value/int_u8.hh> -#include <mln/io/pgm/load.hh> -#include <mln/pw/all.hh> -#include <mln/core/alias/neighb2d.hh> - -#include <mln/labeling/blobs.hh> -#include <mln/data/transform.hh> -#include <mln/data/paste.hh> -#include <mln/data/compare.hh> -#include <mln/io/pgm/save.hh> - -#include <mln/core/image/mono_rle_encode.hh> - -#include "tests/data.hh" - - -struct fold_t : public mln::Function_v2v< fold_t > -{ - typedef mln::value::int_u8 result; - result operator()(unsigned i) const { return i == 0 ? 0 : (i - 1) % 255 + 1; } -}; - -struct only_two_t : public mln::Function_v2v< only_two_t > -{ - typedef mln::value::int_u8 result; - result operator()(unsigned i) const { return i == 2 ? 2 : 0; } -}; - - -int main() -{ - using namespace mln; - using value::int_u8; - - image2d<int_u8> lena; - io::pgm::load(lena, MLN_IMG_DIR "/small.pgm"); - image2d<int_u8> cmp(lena.domain()); - - unsigned n; - image2d<unsigned> labels = - labeling::blobs((pw::value(lena) > pw::cst(172u)) | lena.domain(), - c4(), n); - - mono_rle_image<point2d, int_u8> rle = - mono_rle_encode(data::transform(labels, fold_t()), 2); - - std::cout << n << ", compression ratio: " << rle.compression() << std::endl; - - data::fill(cmp, literal::zero); - data::paste(rle, cmp); - - mln_assertion(cmp == data::transform(labels, only_two_t())); -} diff --git a/milena/trash/mono_rle_image.hh b/milena/trash/mono_rle_image.hh deleted file mode 100644 index 2bc1aed..0000000 --- a/milena/trash/mono_rle_image.hh +++ /dev/null @@ -1,254 +0,0 @@ -// Copyright (C) 2007,2008 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_CORE_IMAGE_MONO_RLE_IMAGE_HH -# define MLN_CORE_IMAGE_MONO_RLE_IMAGE_HH - -/// \file mln/core/image/mono_rle_image.hh -/// -/// Definition of an image with rle encoding. - -# include <mln/core/internal/run_image.hh> -# include <mln/core/site_set/p_run.hh> -# include <mln/core/site_set/p_set_of.hh> -# include <mln/value/set.hh> -# include <vector> - -namespace mln -{ - - // Fwd decl. - template <typename P, typename T> struct mono_rle_image; - - - namespace internal - { - - /// Data structure for \c mln::mono_rle_image<P,T>. - template <typename P, typename T> - struct data< mono_rle_image<P,T> > - { - data(const T& val); - - /// Image value. - T value_; - - /// domain of the image - p_set_of< p_run<P> > domain_; - - /// Return the size of the data in memory. - unsigned memory_size() const; - - /// Finalize the domain (internal use). - void finalize(); - - }; - - } // end of namespace mln::internal - - - namespace trait - { - - template <typename P, typename T> - struct image_< mono_rle_image<P,T> > : default_image_< T, mono_rle_image<P,T> > - { - typedef trait::image::category::primary category; - - // FIXME: Update with new properties! - -// typedef trait::image::access::browsing access; - // FIXME: Put the right dimension. -// typedef trait::image::space::two_d space; -// typedef trait::image::size::regular size; -// typedef trait::image::support::aligned support; -// -// typedef trait::image::border::none border; -// typedef trait::image::data::linear data; -// typedef trait::image::io::read_only io; -// typedef trait::image::speed::slow speed; - - }; - - } // end of namespace mln::trait - - - /*! Monochrome RLE image. - * - * RLE image with only one colour. - * - * Parameter \c P is the type of the image points. - * Parameter \c T is the type of the pixel values. - * This image is not point wise accessible. - */ - template <typename P, typename T> - class mono_rle_image : public internal::run_image_< T, P, mono_rle_image<P, T> > - { - public: - typedef T value; - typedef T& lvalue; - typedef const T rvalue; - typedef p_set_of< p_run<P> > pset; - typedef mln_psite(pset) psite; - - - /// Skeleton. - typedef mono_rle_image< tag::psite_<P>, tag::value_<T> > skeleton; - - - /// Constructor - mono_rle_image(const T& val); - - /// Initialize an empty image. - void init_(const T& val); - - /// Add a new range to the image. - void insert(const p_run<P>& pr); - - /// Read-only access to the image value located at point \p p. - rvalue operator() (const mln_psite(pset)& site) const; - - /// Read-write access to the image value located at point \p p. - lvalue operator() (const mln_psite(pset)& site); - - /// Test if this image has been initialized. - bool is_valid() const; - - /// Give the uniq value of the image. - rvalue get_value() const; - - /// Give the definition domain. - const pset& domain() const; - - }; - - -# ifndef MLN_INCLUDE_ONLY - - namespace internal - { - - // internal::data< mono_rle_image<I,S> > - - template <typename P, typename T> - inline - data< mono_rle_image<P,T> >::data(const T& val) - : value_(val) - { - } - - template <typename P, typename T> - inline - unsigned - data< mono_rle_image<P,T> >::memory_size() const - { - return sizeof(T) + domain_.memory_size(); - } - - template <typename P, typename T> - inline - void - data< mono_rle_image<P,T> >::finalize() - { - domain_.finalize(); - } - - } // end of namespace mln::internal - - template <typename P, typename T> - inline - mono_rle_image<P, T>::mono_rle_image(const T& val) - { - init_(val); - } - - template <typename P, typename T> - inline - void - mono_rle_image<P, T>::init_(const T& val) - { - this->data_ = new internal::data< mono_rle_image<P,T> >(val); - } - - template <typename P, typename T> - inline - bool - mono_rle_image<P, T>::is_valid() const - { - return true; - } - - template <typename P, typename T> - inline - void - mono_rle_image<P, T>::insert(const p_run<P>& pr) - { - if (this->data_->domain_.nsites() != 0) - mln_assertion(pr[0] > this->data_->domain_[this->data_->domain_.nsites() - 1].start()); - this->data_->domain_.insert(pr); - } - - template <typename P, typename T> - inline - typename mono_rle_image<P, T>::rvalue - mono_rle_image<P, T>::operator() (const mln_psite(pset)& site) const - { - mln_precondition(this->has(site)); - return this->data_->value_; - } - - template <typename P, typename T> - inline - typename mono_rle_image<P, T>::lvalue - mono_rle_image<P, T>::operator() (const mln_psite(pset)& site) - { - mln_precondition(this->has(site)); - return this->data_->value_; - } - - template <typename P, typename T> - inline - typename mono_rle_image<P, T>::rvalue - mono_rle_image<P, T>::get_value() const - { - return this->data_->value_; - } - - template <typename P, typename T> - inline - const typename mono_rle_image<P, T>::pset& - mono_rle_image<P, T>::domain() const - { - return this->data_->domain_; - } - -# endif // ! MLN_INCLUDE_ONLY - - -} // end of namespace mln - - -#endif // ! MLN_CORE_IMAGE_MONO_RLE_IMAGE_HH diff --git a/milena/trash/neighb_get.hh b/milena/trash/neighb_get.hh deleted file mode 100644 index 25ae909..0000000 --- a/milena/trash/neighb_get.hh +++ /dev/null @@ -1,190 +0,0 @@ -// Copyright (C) 2008, 2013 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_NEIGHB_GET_HH -# define MLN_NEIGHB_GET_HH - -/// \file mln/neighb/get.hh -/// \brief Define function that returns the neighborhood assocoatied -/// to an image. - -# include <mln/trait/images.hh> -# include <mln/neighb/image.hh> - - -/// Shortcuts to access the neighborhood type associated to I. -/// \{ -# define mln_neighb(T) typename mln::neighb::get_helper<I>::type -# define mln_neighb_(T) mln::neighb::get_helper<I>::type -/// \} - - -namespace mln -{ - - namespace neighb - { - - // Fwd decl. - template <typename I> - struct get_helper; - - template <typename I> - typename get_helper<I>::type - get(const Image<I>& ima); - - - /// FIXME: Move this to mln/trait/neighb.hh? And split - /// neighborhood type deduction from neighborhood access (fun)? - - /// Get the (possible) neighborhood type associated to an image - /// type \c I. - template <typename I> - struct get_helper - { - /// Select the neighborhood from the presence of the - /// neighborhood and the category of the image. - /// { - - // FIXME: Rename select_from_traits. - - template <typename image_neighb, typename image_category, typename I_> - struct select_from_traits; - - /// Case where the image has a neighborhood and is a primary - /// image. - template <typename I_> - struct select_from_traits<trait::image::neighb::some, - trait::image::category::primary, - I_> - { - typedef typename I_::neighb type; - - static const type& - run(const I_& ima) { return ima.neighborhood(); } - }; - - /// Special case: neighb::image<I_, N_>. - template <typename I_, typename N_> - struct select_from_traits<trait::image::neighb::some, - trait::image::category::morpher, - mln::neighb::image<I_, N_> > - { - typedef typename neighb::image<I_, N_>::neighb type; - - static const type& - run(const neighb::image<I_, N_>& ima) { return ima.neighborhood(); } - }; - - /// Case where the image has a neighborhood and is a morpher. - template <typename I_> - struct select_from_traits<trait::image::neighb::some, - trait::image::category::morpher, - I_> - { - typedef typename get_helper<typename I_::delegatee>::type type; - - static const type& - run(const I_& ima) { return neighb::get( *ima.delegatee_() ); } - }; - - /// Case where the image has a neighborhood and is a identity morpher. - template <typename I_> - struct select_from_traits<trait::image::neighb::some, - trait::image::category::identity_morpher, - I_> - { - typedef typename get_helper<typename I_::delegatee>::type type; - - static const type& - run(const I_& ima) { return neighb::get( *ima.delegatee_() ); } - }; - - /// Case where the image has a neighborhood and is a value morpher. - template <typename I_> - struct select_from_traits<trait::image::neighb::some, - trait::image::category::value_morpher, - I_> - { - typedef typename get_helper<typename I_::delegatee>::type type; - - static const type& - run(const I_& ima) { return neighb::get( *ima.delegatee_() ); } - }; - - /// \brief Default case: error. - /// - /// Causes: - /// \li the image has no neighborhood; - /// \li the image category is of an invalid morpher type (e.g., - /// a domain morpher); - /// \li the trait for the neighborhood of the image is not - /// defined or ill-defined; - /// \li the trait for the image category is not defined or - /// ill-defined. - template <typename image_neighb, typename image_category, typename I_> - struct select_from_traits - { - /// Nothing. - }; - - /// \} - - typedef select_from_traits< mln_trait_image_neighb(I), - mln_trait_image_category(I), - I > selection_; - - typedef typename selection_::type type; - - static const type& run(const I& ima) { return selection_::run(ima); } - }; - - - -# ifndef MLN_INCLUDE_ONLY - - // Facade. - - template <typename I> - inline - typename get_helper<I>::type - get(const Image<I>& ima) - { - mln_trace("neighb::get"); - - mln_precondition(exact(ima).is_valid()); - typename neighb::get_helper<I>::type res = - neighb::get_helper<I>::run(exact(ima)); - return res; - } - -# endif // ! MLN_INCLUDE_ONLY - - } // end of namespace mln::neighb - -} // end of namespace mln - - -#endif // ! MLN_NEIGHB_GET_HH diff --git a/milena/trash/neighb_image.cc b/milena/trash/neighb_image.cc deleted file mode 100644 index 03969a3..0000000 --- a/milena/trash/neighb_image.cc +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright (C) 2008 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. - -/*! \file tests/neighb/image.cc - * - * \brief Tests on mln::neighb::image. - */ - -#include <mln/neighb/image.hh> -#include <mln/core/image/image2d.hh> -#include <mln/core/alias/neighb2d.hh> -#include <mln/metal/has_neighborhood.hh> - - -int main() -{ - using namespace mln; - - typedef image2d<int> ima_t; - typedef neighb2d nbh_t; - - typedef neighb::image<ima_t, nbh_t> ima_with_nbh_t; - - metal::has_neighborhood<ima_with_nbh_t>::check(); - - ima_t ima (make::box2d(5, 5)); - - // Explicit construction. - ima_with_nbh_t ima1 (ima, c4()); - neighb::get(ima1); - - // Construction using operator+. - ima_with_nbh_t ima2 = ima + c4(); - neighb::get(ima2); -} diff --git a/milena/trash/neighb_image.hh b/milena/trash/neighb_image.hh deleted file mode 100644 index 604e6b8..0000000 --- a/milena/trash/neighb_image.hh +++ /dev/null @@ -1,255 +0,0 @@ -// Copyright (C) 2008 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_NEIGHB_IMAGE_HH -# define MLN_NEIGHB_IMAGE_HH - -/// \file mln/neighb/image.hh -/// \brief An image morpher adding a neighborhood to an image. - -# include <mln/core/internal/image_identity.hh> -# include <mln/core/concept/neighborhood.hh> - -// FIXME: Handle the constness of the underlying image. - -namespace mln -{ - - // Fwd decl. - namespace neighb { template <typename I, typename N> struct image; } - - /// Create an image with a neighborhood from an image and a - /// neighborhood. - template <typename I, typename N> - neighb::image<I, N> - operator+ (Image<I>& ima, const Neighborhood<N>& nbh); - - - namespace internal - { - - /// Data structure for mln::neighb::image - template <typename I, typename N> - struct data< mln::neighb::image<I, N> > - { - data(I& ima, const N& nbh); - - I ima_; - N nbh_; - }; - - } // end of namespace mln::internal - - - - namespace trait - { - - template <typename I, typename N> - struct image_< neighb::image<I, N> > - : public default_image_morpher< I, mln_value(I), neighb::image<I, N> > - - { - typedef trait::image::category::morpher category; - - typedef trait::image::neighb::some neighb; - }; - - } // end of namespace mln::trait - - - namespace neighb - { - /// \brief A class that embodies an image with an attached - /// neighborhood. - /// - /// Parameter \c I is the actual type of the image, and \c N is - /// the one of the neighborhood. - /// - /// \pre The domains of \c I and \c N must be compatible. - template <typename I, typename N> - struct image - : public internal::image_identity < I, mln_pset(I), image <I, N> > - { - /// Point_Site associated type. - typedef mln_psite(I) psite; - - /// Site_Set associated type. - typedef mln_pset(I) pset; - - /// Neighborhood associated type. - typedef N neighb; - - /// Skeleton. - typedef image< tag::image_<I>, tag::neighb_<N> > skeleton; - - /// Constructors. - /// \{ - image(); - image(Image<I>& ima, const Neighborhood<N>& nbh); - /// \} - - /// Test if this image has been initialized. - bool is_valid() const; - - /// Accessors. - /// \{ - /// Return the underlying image, read-only. - const I& ima() const; - /// Return the underlying image, read-write. - I& ima(); - // FIXME: Rename to nbh(). - /// Return the neighborhood associated to this image. - const neighb& neighborhood() const; - /// \} - - /// Initialize an empty image. - void init_(Image<I>& ima, const Neighborhood<N>& nbh); - }; - - } // end of namespace mln::neighb - - - // Fwd decl. - template <typename I, typename J, typename N> - void init_(tag::image_t, - neighb::image<I, N>& target, const neighb::image<J, N>& model); - - - -# ifndef MLN_INCLUDE_ONLY - - /*-----------------. - | Initialization. | - `-----------------*/ - - template <typename I, typename J, typename N> - void init_(tag::image_t, - neighb::image<I, N>& target, const neighb::image<J, N>& model) - { - I ima; - initialize(ima, model.ima()); - target.init_(ima, model.neighborhood()); - } - - /*------------. - | operator+. | - `------------*/ - - template <typename I, typename N> - neighb::image<I, N> - operator+ (Image<I>& ima, const Neighborhood<N>& nbh) - { - neighb::image<I, N> tmp(ima, nbh); - return tmp; - } - - /*-----------------------------------------. - | internal::data< neighb::image_<T,I> >. | - `-----------------------------------------*/ - - namespace internal - { - template <typename I, typename N> - inline - data< mln::neighb::image<I, N> >::data(I& ima, const N& nbh) - : ima_(ima), - nbh_(nbh) - { - } - } - - /*----------------------. - | neighb::image<I, N>. | - `----------------------*/ - - namespace neighb - { - - template <typename I, typename N> - inline - image<I, N>::image() - { - } - - template <typename I, typename N> - inline - image<I, N>::image(Image<I>& ima, const Neighborhood<N>& nbh) - { - init_(ima, nbh); - } - - template <typename I, typename N> - inline - void - image<I, N>::init_(Image<I>& ima, const Neighborhood<N>& nbh) - { - mln_precondition(! this->is_valid()); - this->data_ = - new mln::internal::data< mln::neighb::image<I, N> >(exact(ima), - exact(nbh)); - } - - template <typename I, typename N> - inline - bool - image<I, N>::is_valid() const - { - return this->delegatee_() && this->delegatee_()->is_valid(); - } - - template <typename I, typename N> - inline - I& - image<I, N>::ima() - { - return this->data_->ima_; - } - - template <typename I, typename N> - inline - const I& - image<I, N>::ima() const - { - return this->data_->ima_; - } - - template <typename I, typename N> - inline - const N& - image<I, N>::neighborhood() const - { - return this->data_->nbh_; - } - - } // end of namespace mln::neighb - -# endif // ! MLN_INCLUDE_ONLY - -} // end of namespace mln - -#include <mln/neighb/get.hh> - -#endif // ! MLN_NEIGHB_IMAGE_HH diff --git a/milena/trash/obased_rle_encode.hh b/milena/trash/obased_rle_encode.hh deleted file mode 100644 index f8b2f83..0000000 --- a/milena/trash/obased_rle_encode.hh +++ /dev/null @@ -1,120 +0,0 @@ -// Copyright (C) 2007 EPITA Research and Development Laboratory -// -// 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_CORE_IMAGE_OBASED_RLE_ENCODE_HH -# define MLN_CORE_IMAGE_OBASED_RLE_ENCODE_HH - -/*! \file mln/core/image/obased_rle_encode.hh - * - * \brief Definintion of function which encodes an image in obased_rle_image. - */ - -# include <mln/core/image/obased_rle_image.hh> - -namespace mln -{ - - /*! - ** encode an image class to a obased_rle_image - ** - ** @param input has to respect the Image concept - ** @param ignore_zero says if zero has to be considered as a valid value - ** - ** @return obased_rle_image - */ - template <typename I> - obased_rle_image<mln_psite(I), mln_value(I)> - obased_rle_encode(const Image<I>& input, bool ignore_zero = true); - -# ifndef MLN_INCLUDE_ONLY - /*! - ** test if Point p1 and p2 are on the same line - */ - template <typename P> - inline - bool - on_the_same_line(const P& p1, const P& p2) - { - const unsigned dim = P::dim; - bool same_line = true; - - for (unsigned n = 0; same_line && n < dim - 1; ++n) - same_line = (p1[n] == p2[n]); - return same_line; - } - - template <typename I> - inline - obased_rle_image<mln_psite(I), mln_value(I)> - obased_rle_encode(const Image<I>& input, bool ignore_zero) - { - typedef mln_psite(I) P; - - const I& ima = exact(input); - mln_piter(I) p (exact(input).domain()); - unsigned len = 0; - mln_psite(I) rstart; - mln_value(I) rvalue; - std::set< mln_value(I) > sv; - - for_all(p) - { - if (!ignore_zero || ima(p) != literal::zero) - sv.insert(ima(p)); - } - - obased_rle_image<mln_psite(I), mln_value(I)> output(sv); - for_all(p) - if (!ignore_zero || ima(p) != literal::zero || len) - { - if (len == 0) - { - ++len; - rstart = p; - rvalue = ima(p); - } - else - if (rvalue == ima(p) - && on_the_same_line(rstart, mln_psite(I)(p))) - ++len; - else - { - output.insert(p_run<P>(rstart, len), rvalue); - if ((len = (!ignore_zero || ima(p) != literal::zero))) - { - rstart = p; - rvalue = ima(p); - } - } - } - output.finalize(); - return output; - } - -#endif // ! MLN_INCLUDE_ONLY - -} - -#endif // ! MLN_CORE_IMAGE_OBASED_RLE_ENCODE_HH diff --git a/milena/trash/obased_rle_image.cc b/milena/trash/obased_rle_image.cc deleted file mode 100644 index 43a668d..0000000 --- a/milena/trash/obased_rle_image.cc +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright (C) 2007, 2008 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. - -/*! \file tests/core/image/obased_rle_image.cc - * - * \brief Test on mln::obased_rle_image.hh. - */ - -#include <mln/core/image/image2d.hh> -#include <mln/value/int_u8.hh> -#include <mln/io/pgm/load.hh> -#include <mln/pw/all.hh> -#include <mln/core/alias/neighb2d.hh> - -#include <mln/labeling/blobs.hh> -#include <mln/data/transform.hh> -#include <mln/data/paste.hh> -#include <mln/data/compare.hh> -#include <mln/io/pgm/save.hh> - -#include <mln/core/image/obased_rle_encode.hh> - -#include "tests/data.hh" - - -struct fold_t : public mln::Function_v2v< fold_t > -{ - typedef mln::value::int_u8 result; - result operator()(unsigned i) const { return i == 0 ? 0 : (i - 1) % 255 + 1; } -}; - - -int main() -{ - using namespace mln; - using value::int_u8; - - image2d<int_u8> lena; - io::pgm::load(lena, MLN_IMG_DIR "/small.pgm"); - image2d<int_u8> cmp(lena.domain()); - - unsigned n; - image2d<unsigned> labels = - labeling::blobs((pw::value(lena) > pw::cst(172u)) | lena.domain(), - c4(), n); - - obased_rle_image<point2d, int_u8> rle = - obased_rle_encode(data::transform(labels, fold_t())); - - std::cout << n << ", compression ratio: " << rle.compression() << std::endl; - - data::fill(cmp, literal::zero); - data::paste(rle, cmp); - - mln_assertion(cmp == data::transform(labels, fold_t())); -} diff --git a/milena/trash/obased_rle_image.hh b/milena/trash/obased_rle_image.hh deleted file mode 100644 index 0375c2b..0000000 --- a/milena/trash/obased_rle_image.hh +++ /dev/null @@ -1,289 +0,0 @@ -// Copyright (C) 2007, 2008 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_CORE_IMAGE_OBASED_RLE_IMAGE_HH -# define MLN_CORE_IMAGE_OBASED_RLE_IMAGE_HH - -/// \file mln/core/image/obased_rle_image.hh -/// -/// Definition of an image with rle encoding. - - -# include <mln/core/internal/run_image.hh> -# include <mln/core/site_set/p_run.hh> -# include <mln/core/site_set/p_set_of.hh> -# include <mln/core/site_set/box.hh> -# include <mln/value/set.hh> -# include <vector> - -namespace mln -{ - - // Fwd decl. - template <typename P, typename T> struct obased_rle_image; - - - namespace internal - { - - /// Data structure for \c mln::obased_rle_image<P,T>. - template <typename P, typename T> - struct data< obased_rle_image<P,T> > - { - data(const std::set<T>& values); - - /// Objects. - std::vector< std::vector<unsigned> > obj_; - - /// Bounding boxes of the objects. - std::vector< accu::shape::bbox<P> > bbox_; - - /// Value of Objects. - std::vector<T> v_obj_; - - /// Image values. - std::vector<T> values_; - - /// domain of the image - p_set_of< p_run<P> > domain_; - - /// Return the size of the data in memory. - unsigned memory_size() const; - - /// Finalize the domain (internal use). - void finalize(); - }; - - } // end of namespace mln::internal - - - namespace trait - { - - template <typename P, typename T> - struct image_< obased_rle_image<P,T> > : default_image_< T, obased_rle_image<P,T> > - { - typedef trait::image::category::primary category; - - /// FIXME: Update with new properties! -/* typedef trait::image::access::browsing access; - // FIXME: Put the right dimension. - typedef trait::image::space::two_d space; - typedef trait::image::size::regular size; - typedef trait::image::support::aligned support; - - typedef trait::image::border::none border; - typedef trait::image::data::linear data; - typedef trait::image::io::read_only io; - typedef trait::image::speed::slow speed;*/ - }; - - } // end of namespace mln::trait - - - /*! RLE image with objects. - * - * - * Parameter \c P is the type of the image points. - * Parameter \c T is the type of the pixel values. - * This image is not point wise accessible. - */ - template <typename P, typename T> - class obased_rle_image : public internal::run_image_< T, P, obased_rle_image<P, T> > - { - public: - typedef T value; - typedef T& lvalue; - typedef const T rvalue; - typedef p_set_of< p_run<P> > pset; - typedef mln_psite(pset) psite; - - - /// Skeleton. - typedef obased_rle_image< tag::psite_<P>, tag::value_<T> > skeleton; - - /// Constructor - obased_rle_image(const std::set<T>& values); - - /// Initialize an empty image - void init_(const std::set<T>& values); - - /// Add a new range to the image. - void insert(const p_run<P>& pr, T value); - - /// Read-only access to the image value located at point \p p. - rvalue operator() (const mln_psite(pset)& site) const; - - /// Read-write access to the image value located at point \p p. - lvalue operator() (const mln_psite(pset)& site); - - /// Test if this image has been initialized. - bool is_valid() const; - - /// Give the definition domain. - const pset& domain() const; - - /// Give the index vector of the i-th object. - const std::vector<unsigned>& object(unsigned i) const; - - /// Give the bounding box of the i-th object. - const box<P>& bbox_of_run(unsigned i) const; - - }; - - -# ifndef MLN_INCLUDE_ONLY - - namespace internal - { - - // internal::data< obased_rle_image<P,T> > - - template <typename P, typename T> - inline - data< obased_rle_image<P,T> >::data(const std::set<T>& values) - : obj_(values.size()), - bbox_(values.size()) - { - std::copy(values.begin(), values.end(), - std::back_inserter(this->v_obj_)); - } - - template <typename P, typename T> - inline - unsigned - data< obased_rle_image<P,T> >::memory_size() const - { - return domain_.memory_size() + bbox_.size() - * (sizeof(T) + sizeof(box<P>) + sizeof(std::vector<unsigned>)) - + (sizeof(unsigned) + sizeof(T)) * domain_.nsites(); - } - - template <typename P, typename T> - inline - void - data< obased_rle_image<P,T> >::finalize() - { - domain_.finalize(); - } - - } // end of namespace mln::internal - - template <typename P, typename T> - inline - obased_rle_image<P, T>::obased_rle_image(const std::set<T>& values) - { - init_(values); - } - - template <typename P, typename T> - inline - void - obased_rle_image<P, T>::init_(const std::set<T>& values) - { - this->data_ = new internal::data< obased_rle_image<P,T> >(values); - } - - template <typename P, typename T> - inline - bool - obased_rle_image<P, T>::is_valid() const - { - return this->data_->values_.size() != 0; - } - - template <typename P, typename T> - inline - void - obased_rle_image<P, T>::insert(const p_run<P>& pr, T value) - { - mln_assertion(this->data_->v_obj_.size() == 0 || this->data_->domain_.nsites() == 0 || - pr[0] > this->data_->domain_[this->data_->domain_.nsites() - 1].start()); - this->data_->domain_.insert(pr); - this->data_->values_.push_back(value); - unsigned i; - for (i = 0; i < this->data_->v_obj_.size() - && this->data_->v_obj_[i] != value; ++i) - ; - mln_assertion(i != this->data_->v_obj_.size()); - this->data_->obj_[i].push_back(this->data_->domain_.nsites() - 1); - this->data_->bbox_[i].take(pr.bbox().pmin()); - this->data_->bbox_[i].take(pr.bbox().pmax()); - } - - template <typename P, typename T> - inline - typename obased_rle_image<P, T>::rvalue - obased_rle_image<P, T>::operator() (const mln_psite(pset)& site) - const - { - mln_precondition(this->has(site)); - return this->data_->values_[site.index()]; - } - - template <typename P, typename T> - inline - typename obased_rle_image<P, T>::lvalue - obased_rle_image<P, T>::operator() (const mln_psite(pset)& site) - { - mln_precondition(this->has(site)); - return this->data_->values_[site.index()]; - } - - template <typename P, typename T> - inline - const typename obased_rle_image<P, T>::pset& - obased_rle_image<P, T>::domain() const - { - return this->data_->domain_; - } - - template <typename P, typename T> - inline - const std::vector<unsigned>& - obased_rle_image<P, T>::object(unsigned i) const - { - mln_assertion(i < this->data_->obj_.size()); - return this->data_->obj_[i]; - } - - template <typename P, typename T> - inline - const box<P>& - obased_rle_image<P, T>::bbox_of_run(unsigned i) const - { - mln_assertion(i < this->data_->bbox_.size()); - return this->data_->bbox_[i]; - } - - -# endif // ! MLN_INCLUDE_ONLY - - -} // end of namespace mln - - -#endif // ! MLN_CORE_IMAGE_OBASED_RLE_IMAGE_HH diff --git a/milena/trash/p_bgraph.cc b/milena/trash/p_bgraph.cc deleted file mode 100644 index 18cefa8..0000000 --- a/milena/trash/p_bgraph.cc +++ /dev/null @@ -1,85 +0,0 @@ -// Copyright (C) 2007, 2008 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. - -/// \file tests/core/site_set/p_bgraph.cc -/// \brief Tests on mln::p_bgraph (the psite based on boost-graph). - -#include <mln/core/site_set/p_bgraph.hh> -#include <mln/core/alias/point2d.hh> -#include <mln/util/internal/boost_graph.hh> -#include <boost/typeof/std/utility.hpp> - -struct empty {}; - -int main() -{ - /*--------------. - | boost_graph. | - `--------------*/ - - using namespace mln; - typedef util::internal::boost_graph<point2d, util::empty> Graph; - - // Make convenient labels for the vertices - const int num_vertices = 5; - - // writing out the edges in the graph - typedef std::pair<int, int> Edge; - Edge edge_array[] = { - Edge(0, 1), Edge(0, 3), Edge(2, 0), Edge(3, 2), - Edge(2, 4), Edge(1, 3), Edge(3, 4) - }; - - const int num_edges = sizeof(edge_array)/sizeof(edge_array[0]); - // declare a graph object - Graph g(num_vertices); - - // add the edges to the graph object - for (int i = 0; i < num_edges; ++i) - boost::add_edge(edge_array[i].first, edge_array[i].second, g); - - g[0] = point2d(0, 0); - g[1] = point2d(0, 1); - g[2] = point2d(1, 0); - g[3] = point2d(1, 1); - g[4] = point2d(0, 2); - - /*-----------. - | p_bgraph. | - `-----------*/ - - /// Creation - p_bgraph<point2d> pset(&g); - - /// Iterator - p_bgraph_piter_<point2d> p(pset); - - for (p.start(); p.is_valid(); p.next()) - std::cout << p << std::endl; - - - - return 0; -} diff --git a/milena/trash/p_bgraph.hh b/milena/trash/p_bgraph.hh deleted file mode 100644 index 0bb9c03..0000000 --- a/milena/trash/p_bgraph.hh +++ /dev/null @@ -1,220 +0,0 @@ -// Copyright (C) 2007, 2008 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_CORE_BGRAPH_P_HH -# define MLN_CORE_BGRAPH_P_HH - -# include <utility> - -# include <mln/core/concept/point_site.hh> -# include <mln/core/internal/site_set_base.hh> -# include <mln/accu/shape/bbox.hh> -# include <mln/util/internal/boost_graph.hh> -# include <mln/core/image/bgraph_psite.hh> -# include <mln/core/site_set/p_bgraph_piter.hh> - - - -/// \file mln/core/site_set/p_bgraph.hh -/// -/// Definition of a point set based on a boost graph. - -namespace mln -{ - - template<typename P> class p_bgraph_piter_; - - template<typename P> - struct p_bgraph - : public internal::site_set_base_< bgraph_psite<P>, p_bgraph<P> > - { - typedef util::internal::boost_graph<P, util::empty> graph; - - /// Point_Site associated type. - typedef bgraph_psite<P> psite; - - /// Forward Site_Iterator associated type. - typedef p_bgraph_piter_<P> fwd_piter; - - /// Backward Site_Iterator associated type. - typedef p_bgraph_piter_<P> bkd_piter; - - /// Graph vertex/edge identifier - typedef typename graph::vertex_descriptor node_id; - typedef typename graph::edge_descriptor edge_id; - - /// Graph vertex/edge iterator - typedef typename graph::vertex_iterator node_iterator; - typedef typename graph::edge_iterator edge_iterator; - typedef std::pair<node_iterator, node_iterator> node_iterators; - - - /// Construct a graph psite set from a graph of points. - /// \p gr is a pointer on a boost graph. - /// This boost graph must have been allocated dynamically. - p_bgraph (graph* gr); - - /// Return The number of points (i.e., nodes) in the graph. - unsigned nsites() const; - - /// Return The number of lines (i.e., edges) in the graph. - unsigned nlines() const; - - /// Give the exact bounding box. - const box<P>& bbox() const; - - bool has(const psite& p) const; - - /// Return the graph point (FIXME site?) from an index - const P& point_from_id(const node_id& id) const; - P& point_from_id(const node_id& id); - - /// Return the point contained in the first node adjacent - // to the edge id \a e. - const P& node1(const edge_id& e) const; - /// Return the point contained in the second node adjacent - /// to the edge id \a e. - const P& node2(const edge_id& e) const; - - /// Return the graph associated to the p_bgraph domain: - const graph& to_graph() const; - graph& to_graph(); - - - private: - graph* gr_; - box<P> bb_; - }; - -# ifndef MLN_INCLUDE_ONLY - - template<typename P> - inline - p_bgraph<P>::p_bgraph (graph* gr) - : gr_ (gr) - { - mln_precondition(gr != 0); - // FIXME: Warning: if the underlying graph is updated later, this - // won't be taken into account by this p_bgraph! - accu::shape::bbox<P> a; - - for (node_iterators iter = boost::vertices(*gr_); - iter.first != iter.second; - ++iter.first) - a.take((*gr_)[*iter.first]); - bb_ = a.to_result(); - } - - template<typename P> - inline - unsigned - p_bgraph<P>::nsites() const - { - return boost::num_vertices(*gr_); - } - - template<typename P> - inline - unsigned - p_bgraph<P>::nlines() const - { - return boost::num_edges(gr_->nedges()); - } - - template<typename P> - inline - const box<P>& - p_bgraph<P>::bbox() const - { - return bb_; - } - - template<typename P> - inline - bool - p_bgraph<P>::has(const psite& p) const - { - return - // Check whether P is compatible with this psite set. - (&p.pg() == this) && - // Check that the node id of P belongs to the range of valid node ids. - (p.id() < this->nsites()); - } - - - template <typename P> - const P& - p_bgraph<P>::point_from_id(const node_id& id) const - { - return this->gr_->operator[](id); - } - - template <typename P> - P& - p_bgraph<P>::point_from_id(const node_id& id) - { - return this->gr_->operator[](id); - } - - - /// FIXME: Compare to p_bgraph, here we are loosing the vertex ordering - /// information. Is it bad?? - template <typename P> - const P& - p_bgraph<P>::node1(const edge_id& e) const - { - return this->point_from_id(source(e, *this->gr_)); - } - - /// FIXME: same as node1... - template <typename P> - const P& - p_bgraph<P>::node2(const edge_id& e) const - { - return this->point_from_id(target(e, *this->gr_)); - } - - template <typename P> - const typename p_bgraph<P>::graph& - p_bgraph<P>::to_graph() const - { - return *this->gr_; - } - - template <typename P> - typename p_bgraph<P>::graph& - p_bgraph<P>::to_graph() - { - return *this->gr_; - } - - -# endif // ! MLN_INCLUDE_ONLY - -} // end of mln - - -#endif // MLN_CORE_BGRAPH_P_HH diff --git a/milena/trash/p_bgraph_piter.hh b/milena/trash/p_bgraph_piter.hh deleted file mode 100644 index 09162e3..0000000 --- a/milena/trash/p_bgraph_piter.hh +++ /dev/null @@ -1,245 +0,0 @@ -// Copyright (C) 2007, 2008 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_CORE_SITE_SET_P_BGRAPH_PITER_HH -# define MLN_CORE_SITE_SET_P_BGRAPH_PITER_HH - -# include <utility> - -# include <mln/core/internal/site_iterator_base.hh> -# include <mln/core/site_set/p_bgraph.hh> -# include <mln/core/image/bgraph_psite.hh> - -/*! \file mln/core/site_set/p_bgraph_piter.hh - * - * \brief Definition of point iterator on boost-graph-based point set. - */ - -namespace mln -{ - // Fwd decls. - template<typename P> class p_bgraph; - template<typename P> class bgraph_psite; - - - // FIXME: check the constraint due to the boost iterators - template<typename P> - class p_bgraph_piter_ - : public internal::site_iterator_base< P, p_bgraph_piter_<P> > - { - typedef p_bgraph_piter_<P> self_; - typedef internal::site_iterator_base< P, self_ > super_; - typedef std::pair<typename p_bgraph<P>::node_iterator, - typename p_bgraph<P>::node_iterator> iterators_type_; - - public: - - // Make definitions from super class available. - enum { dim = super_::dim }; - typedef bgraph_psite<P> psite; - typedef P point; - - p_bgraph_piter_(const p_bgraph<P>& pg); - - /// Read-only access to the \p i-th coordinate. - mln_coord(P) operator[](unsigned i) const; - - /// Test if the iterator is valid. - bool is_valid() const; - - /// Invalidate the iterator. - void invalidate(); - - /// Start an iteration. - void start(); - - /// Go to the next point. - void next_(); - - /// Update the internal data of the iterator. - void update_(); - - /// Reference to the corresponding point. - const point& to_point () const; - - /// Reference to the corresponding point site. - const psite& to_psite () const; - - /// Convert the iterator into a point. - operator point() const; - - /// Convert the iterator into a graph psite. - operator psite() const; - - protected: - /// The p_graph this point site belongs to. - const p_bgraph<P>& pg_; - - /// The psite corresponding to this iterator. - psite psite_; - /// The point corresponding to this iterator. - point p_; - - private: - iterators_type_ iterators_; - typename p_bgraph<P>::node_iterator cur_; - }; - - - -# ifndef MLN_INCLUDE_ONLY - - template<typename P> - inline - p_bgraph_piter_<P>::p_bgraph_piter_(const p_bgraph<P>& pg) - : pg_(pg), - // Initialize psite_ to a dummy value. - psite_(pg, pg_.nsites()), - p_() - { - iterators_ = boost::vertices(pg_.to_graph()); - // Invalidate id_. - invalidate(); - } - - template<typename P> - inline - mln_coord(P) - p_bgraph_piter_<P>::operator[](unsigned i) const - { - return p_[i]; - } - - template<typename P> - inline - bool - p_bgraph_piter_<P>::is_valid() const - { - return cur_ != iterators_.second; - } - - template<typename P> - inline - void - p_bgraph_piter_<P>::invalidate() - { - cur_ = iterators_.second; // Past the end iterator. - } - - template<typename P> - inline - void - p_bgraph_piter_<P>::start() - { - cur_ = iterators_.first; - /// FIXME: Hide implementation details? - if (is_valid()) - update_(); - } - - template<typename P> - inline - void - p_bgraph_piter_<P>::next_() - { - ++cur_; - if (is_valid()) - update_(); - } - - template<typename P> - inline - void - p_bgraph_piter_<P>::update_() - { - // Update psite_. - psite_ = bgraph_psite<P>(pg_, *cur_); - // Update p_. - p_ = pg_.point_from_id(*cur_); - } - - template<typename P> - inline - const P& - p_bgraph_piter_<P>::to_point() const - { - /* We don't check whether the iterator is valid before returning - the value using - - mln_precondition(is_valid()); - - since this method may be called *before* the iterator is - actually initialized. This is the case for instance when this - point iterator (say, P) is used to initialize another iterator - on window or neighborhood (say, Q); most of the time, for_all() - is responsible for the initialization of P, but it takes place - *after* the creation of Q. */ - return p_; - } - - template<typename P> - inline - const bgraph_psite<P>& - p_bgraph_piter_<P>::to_psite() const - { - /* We don't check whether the iterator is valid before returning - the value using - - mln_precondition(is_valid()); - - since this method may be called *before* the iterator is - actually initialized. This is the case for instance when this - point iterator (say, P) is used to initialize another iterator - on window or neighborhood (say, Q); most of the time, for_all() - is responsible for the initialization of P, but it takes place - *after* the creation of Q. */ - - return psite_; - } - - template<typename P> - inline - p_bgraph_piter_<P>::operator point() const - { - mln_precondition(is_valid()); - return p_; - } - - template<typename P> - inline - p_bgraph_piter_<P>::operator psite() const - { - mln_precondition(is_valid()); - bgraph_psite<P> tmp(pg_, *cur_); - return tmp; // psite_; - } - -# endif // ! MLN_INCLUDE_ONLY - -} // end of mln - - -#endif // MLN_P_BGRAPH_PITER_HH diff --git a/milena/trash/rle_encode.hh b/milena/trash/rle_encode.hh deleted file mode 100644 index aeb4435..0000000 --- a/milena/trash/rle_encode.hh +++ /dev/null @@ -1,113 +0,0 @@ -// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory -// -// 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_CORE_IMAGE_RLE_ENCODE_HH -# define MLN_CORE_IMAGE_RLE_ENCODE_HH - -/*! \file mln/core/image/rle_encode.hh - * - * \brief Definintion of function which encodes an image in rle_image. - */ - -# include <mln/core/image/rle_image.hh> - -namespace mln -{ - - /*! - ** encode an image class to a rle_image - ** - ** @param input has to respect the Image concept - ** @param ignore_zero says if zero has to be considered as a valid value - ** - ** @return rle_image - */ - template <typename I> - rle_image<mln_psite(I), mln_value(I)> - rle_encode(const Image<I>& input, bool ignore_zero = true); - -# ifndef MLN_INCLUDE_ONLY - /*! - ** test if Point p1 and p2 are on the same line - */ - template <typename P> - inline - bool - on_the_same_line(const P& p1, const P& p2) - { - const unsigned dim = P::dim; - bool same_line = true; - - for (unsigned n = 0; same_line && n < dim - 1; ++n) - same_line = (p1[n] == p2[n]); - return same_line; - } - - template <typename I> - inline - rle_image<mln_psite(I), mln_value(I)> - rle_encode(const Image<I>& input, bool ignore_zero) - { - typedef mln_psite(I) P; - - rle_image<mln_psite(I), mln_value(I)> output; - const I& ima = exact(input); - mln_piter(I) p (exact(input).domain()); - unsigned len = 0; - mln_psite(I) rstart; - mln_value(I) rvalue; - - for_all(p) - if (!ignore_zero || ima(p) != literal::zero || len) - { - if (len == 0) - { - ++len; - rstart = p; - rvalue = ima(p); - } - else - if (rvalue == ima(p) - && on_the_same_line(rstart, mln_psite(I)(p))) - ++len; - else - { - output.insert(p_run<P>(rstart, len), rvalue); - if ((len = (!ignore_zero || ima(p) != literal::zero))) - { - rstart = p; - rvalue = ima(p); - } - } - } - output.finalize(); - return output; - } - -#endif // ! MLN_INCLUDE_ONLY - -} - -#endif // ! MLN_CORE_IMAGE_RLE_ENCODE_HH diff --git a/milena/trash/rle_image.cc b/milena/trash/rle_image.cc deleted file mode 100644 index 5b5154f..0000000 --- a/milena/trash/rle_image.cc +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright (C) 2007, 2008 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. - -/*! \file tests/core/image/rle_image.cc - * - * \brief Test on mln::rle_image.hh. - */ - -#include <mln/core/image/image2d.hh> -#include <mln/value/int_u8.hh> -#include <mln/io/pgm/load.hh> -#include <mln/pw/all.hh> -#include <mln/core/alias/neighb2d.hh> - -#include <mln/labeling/blobs.hh> -#include <mln/data/transform.hh> -#include <mln/data/paste.hh> -#include <mln/data/compare.hh> -#include <mln/io/pgm/save.hh> - -#include <mln/core/image/rle_encode.hh> - -#include "tests/data.hh" - - -struct fold_t : public mln::Function_v2v< fold_t > -{ - typedef mln::value::int_u8 result; - result operator()(unsigned i) const { return i == 0 ? 0 : (i - 1) % 255 + 1; } -}; - - -int main() -{ - using namespace mln; - using value::int_u8; - - image2d<int_u8> lena; - io::pgm::load(lena, MLN_IMG_DIR "/small.pgm"); - image2d<int_u8> cmp(lena.domain()); - - unsigned n; - image2d<unsigned> labels = - labeling::blobs((pw::value(lena) > pw::cst(172u)) | lena.domain(), - c4(), n); - - rle_image<point2d, int_u8> rle = - rle_encode(data::transform(labels, fold_t())); - - std::cout << n << ", compression ratio: " << rle.compression() << std::endl; - - data::fill(cmp, literal::zero); - data::paste(rle, cmp); - - mln_assertion(cmp == data::transform(labels, fold_t())); -} diff --git a/milena/trash/rle_image.hh b/milena/trash/rle_image.hh deleted file mode 100644 index a6c6c2f..0000000 --- a/milena/trash/rle_image.hh +++ /dev/null @@ -1,230 +0,0 @@ -// Copyright (C) 2007, 2008 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_CORE_IMAGE_RLE_IMAGE_HH -# define MLN_CORE_IMAGE_RLE_IMAGE_HH - -/// \file mln/core/image/rle_image.hh -/// -/// Definition of an image with rle encoding. - -# include <mln/core/internal/run_image.hh> -# include <mln/core/site_set/p_set_of.hh> -# include <mln/core/site_set/p_run.hh> -# include <mln/value/set.hh> -# include <vector> - -namespace mln -{ - - // Forward declaration - template <typename P, typename T> struct rle_image; - - - namespace internal - { - - /// Data structure for \c mln::rle_image<P,T>. - template <typename P, typename T> - struct data< rle_image<P,T> > - { - data(); - - /// Image values. - std::vector<T> values_; - - /// domain of the image - p_set_of< p_run<P> > domain_; - - /// Return the size of the data in memory. - unsigned memory_size() const; - - /// Finalize the domain (internal use). - void finalize(); - }; - - } // end of namespace mln::internal - - - namespace trait - { - - template <typename P, typename T> - struct image_< rle_image<P,T> > : default_image_< T, rle_image<P,T> > - { - typedef trait::image::category::primary category; - - // FIXME: update with new properties. -// typedef trait::image::access::browsing access; - // FIXME: Put the right dimension. -// typedef trait::image::space::two_d space; -// typedef trait::image::size::regular size; -// typedef trait::image::support::aligned support; -// -// typedef trait::image::border::none border; -// typedef trait::image::data::linear data; -// typedef trait::image::io::read_only io; -// typedef trait::image::speed::slow speed; - }; - - } // end of namespace mln::trait - - - /*! RLE image. - * - * - * Parameter \c P is the type of the image points. - * Parameter \c T is the type of the pixel values. - * This image is not point wise accessible. - */ - template <typename P, typename T> - class rle_image : public internal::run_image_< T, P, rle_image<P, T> > - { - public: - typedef T value; - typedef T& lvalue; - typedef const T rvalue; - typedef p_set_of< p_run<P> > pset; - typedef mln_psite(pset) psite; - - - /// Skeleton. - typedef rle_image< tag::psite_<P>, tag::value_<T> > skeleton; - - /// Constructor. - rle_image(); - - /// Add a new range to the image. - void insert(const p_run<P>& pr, T value); - - /// Read-only access to the image value located at point \p p. - rvalue operator() (const mln_psite(pset)& site) const; - - /// Read-write access to the image value located at point \p p. - lvalue operator() (const mln_psite(pset)& site); - - /// Test if this image has been initialized. - bool is_valid() const; - - /// Give the definition domain. - const pset& domain() const; - - }; - - -# ifndef MLN_INCLUDE_ONLY - - namespace internal - { - - // internal::data< rle_image<I,S> > - - template <typename P, typename T> - inline - data< rle_image<P,T> >::data() - { - } - - template <typename P, typename T> - inline - unsigned - data< rle_image<P,T> >::memory_size() const - { - return sizeof(T) * values_.size() + domain_.memory_size(); - } - - template <typename P, typename T> - inline - void - data< rle_image<P,T> >::finalize() - { - domain_.finalize(); - } - - } // end of namespace mln::internal - - template <typename P, typename T> - inline - rle_image<P, T>::rle_image() - { - this->data_ = new internal::data< rle_image<P,T> >(); - } - - template <typename P, typename T> - inline - bool - rle_image<P, T>::is_valid() const - { - return this->data_->values_.size() != 0; - } - - template <typename P, typename T> - inline - void - rle_image<P, T>::insert(const p_run<P>& pr, T value) - { - if (!this->is_valid()) - this->data_ = new internal::data< rle_image<P,T> >(); - mln_assertion(this->data_->values_.size() == 0 || - pr[0] > this->data_->domain_[this->data_->domain_.nsites() - 1].start()); - this->data_->domain_.insert(pr); - this->data_->values_.push_back(value); - } - - template <typename P, typename T> - inline - typename rle_image<P, T>::rvalue - rle_image<P, T>::operator() (const mln_psite(pset)& site) - const - { - mln_precondition(this->has(site)); - return this->data_->values_[site.index()]; - } - - template <typename P, typename T> - inline - typename rle_image<P, T>::lvalue - rle_image<P, T>::operator() (const mln_psite(pset)& site) - { - mln_precondition(this->has(site)); - return this->data_->values_[site.index()]; - } - - template <typename P, typename T> - inline - const typename rle_image<P, T>::pset& - rle_image<P, T>::domain() const - { - return this->data_->domain_; - } - -# endif // ! MLN_INCLUDE_ONLY - - -} // end of namespace mln - - -#endif // ! MLN_CORE_IMAGE_RLE_IMAGE_HH diff --git a/milena/trash/save_and_show.cc b/milena/trash/save_and_show.cc deleted file mode 100644 index 06f6f60..0000000 --- a/milena/trash/save_and_show.cc +++ /dev/null @@ -1,79 +0,0 @@ -// Copyright (C) 2007, 2008 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. - -/*! \file tests/display/save_and_show.cc - * - * \brief Tests on mln::display::save_and_show. - */ - -#include <mln/core/image/image2d.hh> -#include <mln/io/pbm/load.hh> -#include <mln/make/win_chamfer.hh> -#include <mln/geom/chamfer.hh> -#include <mln/value/rgb8.hh> -#include <mln/core/image/sub_image.hh> -#include <mln/core/image_if_value.hh> - -#include <mln/core/alias/w_window2d_int.hh> -#include <mln/display/show.hh> -#include <mln/io/ppm/save.hh> -#include <mln/display/save_and_show.hh> -#include <mln/data/fill.hh> - -#include "tests/data.hh" - - -int main() -{ - using namespace mln; - - unsigned max = 51; - - image2d<bool> input = io::pbm::load(MLN_IMG_DIR "/toto.pbm"); - - // Create a weighted windows : - // 0 2 0 - // 2 p 2 - // 0 2 0 - const w_window2d_int& w_win = make::mk_chamfer_3x3_int<2, 0> (); - - // Call chamfer for a distance image. - image2d<unsigned> tmp = geom::chamfer(input, w_win, max); - - // Call color_pretty for sub_image. - for (unsigned i = 2; i < 6; i += 2) - { - image_if_value<image2d<unsigned> > t = tmp | i; - display::save_and_show (t, "display", 1); - } - - /// Test with color image. - { - image2d<value::rgb8> ima (100, 100); - data::fill(ima, value::rgb8 (0, 0, 255)); - display::save_and_show (ima, "display", 1); - } - -} diff --git a/milena/trash/sparse_encode.hh b/milena/trash/sparse_encode.hh deleted file mode 100644 index 7064cf6..0000000 --- a/milena/trash/sparse_encode.hh +++ /dev/null @@ -1,118 +0,0 @@ -// Copyright (C) 2007 EPITA Research and Development Laboratory -// -// 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_CORE_IMAGE_SPARSE_ENCODE_HH -# define MLN_CORE_IMAGE_SPARSE_ENCODE_HH - -/*! \file mln/core/image/sparse_encode.hh - * - * \brief Definintion of function which encodes an image in sparse_image. - */ - -# include <mln/core/image/sparse_image.hh> - -namespace mln -{ - - /*! - ** encode an image class to a sparse_image - ** - ** @param input has to respect the Image concept - ** @param ignore_zero says if zero has to be considered as a valid value - ** - ** @return sparse_image - */ - template <typename I> - sparse_image<mln_psite(I), mln_value(I)> - sparse_encode(const Image<I>& input, bool ignore_zero = true); - -# ifndef MLN_INCLUDE_ONLY - /*! - ** test if Point p1 and p2 are on the same line - */ - template <typename P> - inline - bool - on_the_same_line(const P& p1, const P& p2, int len) - { - const unsigned dim = P::dim; - bool same_line = true; - - for (unsigned n = 0; same_line && n < dim - 1; ++n) - same_line = (p1[n] == p2[n]); - return same_line && p1[dim - 1] + len == p2[dim - 1]; - } - - template <typename I> - inline - sparse_image<mln_psite(I), mln_value(I)> - sparse_encode(const Image<I>& input, bool ignore_zero) - { - typedef mln_psite(I) P; - - sparse_image<mln_psite(I), mln_value(I)> output; - const I& ima = exact(input); - mln_piter(I) p (exact(input).domain()); - unsigned len = 0; - mln_psite(I) rstart; - std::vector< mln_value(I) > rvalue; - rvalue.clear(); - - for_all(p) - if (!ignore_zero || ima(p) != literal::zero || len) - { - if (len == 0) - { - ++len; - rstart = p; - rvalue.push_back(ima(p)); - } - else - if ((!ignore_zero || ima(p) != literal::zero) && - on_the_same_line(rstart, mln_psite(I)(p), len)) - { - ++len; - rvalue.push_back(ima(p)); - } - else - { - output.insert(p_run<P>(rstart, len), rvalue); - rvalue.clear(); - if ((len = (!ignore_zero || ima(p) != literal::zero))) - { - rstart = p; - rvalue.push_back(ima(p)); - } - } - } - output.finalize(); - return output; - } - -#endif // ! MLN_INCLUDE_ONLY - -} - -#endif // ! MLN_CORE_IMAGE_SPARSE_ENCODE_HH diff --git a/milena/trash/sparse_image.cc b/milena/trash/sparse_image.cc deleted file mode 100644 index 2a5343b..0000000 --- a/milena/trash/sparse_image.cc +++ /dev/null @@ -1,79 +0,0 @@ -// Copyright (C) 2007, 2008 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. - -/*! \file tests/core/image/sparse_image.cc - * - * \brief Test on mln::sparse_image.hh. - */ - -#include <mln/core/image/image2d.hh> -#include <mln/value/int_u8.hh> -#include <mln/io/pgm/load.hh> -#include <mln/pw/all.hh> -#include <mln/core/alias/neighb2d.hh> - -#include <mln/labeling/blobs.hh> -#include <mln/data/transform.hh> -#include <mln/data/paste.hh> -#include <mln/data/compare.hh> -#include <mln/io/pgm/save.hh> - -#include <mln/core/image/sparse_encode.hh> - -#include "tests/data.hh" - - -struct fold_t : public mln::Function_v2v< fold_t > -{ - typedef mln::value::int_u8 result; - result operator()(unsigned i) const { return i == 0 ? 0 : (i - 1) % 255 + 1; } -}; - - -int main() -{ - using namespace mln; - using value::int_u8; - - image2d<int_u8> lena; - io::pgm::load(lena, MLN_IMG_DIR "/small.pgm"); - image2d<int_u8> cmp(lena.domain()); - - unsigned n; - image2d<unsigned> labels = - labeling::blobs((pw::value(lena) > pw::cst(172u)) | lena.domain(), - c4(), n); - - sparse_image<point2d, int_u8> sparse = - sparse_encode(data::transform(labels, fold_t())); - - std::cout << n << ", compression ratio: " << sparse.compression() - << std::endl; - - data::fill(cmp, literal::zero); - data::paste(sparse, cmp); - - mln_assertion(cmp == data::transform(labels, fold_t())); -} diff --git a/milena/trash/sparse_image.hh b/milena/trash/sparse_image.hh deleted file mode 100644 index f13b69e..0000000 --- a/milena/trash/sparse_image.hh +++ /dev/null @@ -1,261 +0,0 @@ -// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory -// -// 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_CORE_IMAGE_SPARSE_IMAGE_HH -# define MLN_CORE_IMAGE_SPARSE_IMAGE_HH - -/*! \file mln/core/image/sparse_image.hh - * - * \brief Definition of an image with sparse encoding. - */ - -# include <vector> -# include <mln/core/internal/image_primary.hh> -# include <mln/core/site_set/p_set_of.hh> -# include <mln/core/site_set/p_run.hh> -# include <mln/value/set.hh> - - -namespace mln -{ - - // Fwd decl. - template <typename P, typename T> struct sparse_image; - - - namespace internal - { - - /// Data structure for \c mln::sparse_image<P,T>. - template <typename P, typename T> - struct data< sparse_image<P,T> > - { - data(); - data(const p_set_of< p_run<P> >& s); - - /// Domain. - p_set_of< p_run<P> > domain_; - - /// Image. - std::vector< std::vector<T> > values_; - }; - - } // end of namespace mln::internal - - - namespace trait - { - - template <typename P, typename T> - struct image_< sparse_image<P,T> > : default_image_< T, sparse_image<P,T> > - { - // misc - typedef trait::image::category::primary category; - typedef trait::image::speed::fast speed; - typedef trait::image::size::regular size; - - // value - typedef trait::image::value_access::direct value_access; - typedef trait::image::value_storage::piecewise value_storage; - typedef trait::image::value_browsing::value_wise value_browsing; - typedef trait::image::value_io::read_write value_io; - - // site / domain - typedef trait::image::localization::basic_grid localization; - typedef trait::image::dimension::two_d dimension; // FIXME - - // extended domain - typedef trait::image::ext_domain::none ext_domain; - typedef trait::image::ext_value::irrelevant ext_value; - typedef trait::image::ext_io::irrelevant ext_io; - }; - - } // end of namespace mln::trait - - - - /*! \brief RLE image with different value in runs. - * - * - * Parameter \c P is the type of the image points. - * Parameter \c T is the type of the pixel values. - * This image is not point wise accessible. - */ - template <typename P, typename T> - class sparse_image - : public internal::image_primary< P, p_set_of< p_run<P> >, - sparse_image<P,T> > - { - typedef sparse_image<P,T> self_; - typedef internal::image_primary<P, p_set_of< p_run<P> >, self_> super_; - public: - - /// Value associated type. - typedef T value; - - /// Return type of read-only access. - typedef const T& rvalue; - - /// Return type of read-write access. - typedef T& lvalue; - - /// Skeleton. - typedef sparse_image< tag::psite_<P>, tag::value_<T> > skeleton; - - - /// Constructor without argument. - sparse_image(); - - /// Constructor from a set of runs. - sparse_image(const p_set_of< p_run<P> >& s); - - /// Initialize an empty image. - void init_(const p_set_of< p_run<P> >& s); - - /// Add a new range to the image. - void insert(const p_run<P>& r, const std::vector<T>& vals); - - - typedef typename super_::psite psite; - - /// Test if \p p is valid. - bool has(const psite& p) const; - - /// Read-only access to the image value located at point \p p. - rvalue operator()(const psite& p) const; - - /// Read-write access to the image value located at point \p p. - lvalue operator()(const psite& p); - - /// Give the definition domain. - const p_set_of< p_run<P> >& domain() const; - }; - - - -# ifndef MLN_INCLUDE_ONLY - - namespace internal - { - - // internal::data< sparse_image<I,S> > - template <typename P, typename T> - inline - data< sparse_image<P,T> >::data() - { - } - - template <typename P, typename T> - inline - data< sparse_image<P,T> >::data(const p_set_of< p_run<P> >& s) - { - mln_precondition(s.is_valid()); - this->domain_ = s; - const unsigned nr = s.nelements(); - this->values_.resize(nr); - for (unsigned r = 0; r < nr; ++r) - this->values_[r].resize(s[r].nsites()); - } - - } // end of namespace mln::internal - - - template <typename P, typename T> - inline - sparse_image<P,T>::sparse_image() - { - } - - template <typename P, typename T> - inline - sparse_image<P,T>::sparse_image(const p_set_of< p_run<P> >& s) - { - this->data_ = new internal::data< sparse_image<P,T> >(s); - } - - template <typename P, typename T> - inline - void - sparse_image<P,T>::init_(const p_set_of< p_run<P> >& s) - { - this->data_ = new internal::data< sparse_image<P,T> >(s); - } - - - template <typename P, typename T> - inline - void - sparse_image<P,T>::insert(const p_run<P>& r, const std::vector<T>& vals) - { - mln_precondition(r.nsites() == vals.size()); - if (! this->is_valid()) - this->data_ = new internal::data< sparse_image<P,T> >(); - this->data_->domain_.insert(r); - this->data_->values_.push_back(vals); - } - - template <typename P, typename T> - inline - bool - sparse_image<P,T>::has(const psite& p) const - { - mln_precondition(this->is_valid()); - return this->data_->domain_.has(p); - } - - template <typename P, typename T> - inline - const T& - sparse_image<P,T>::operator()(const psite& p) const - { - mln_precondition(this->has(p)); - return this->data_->values_[p.index()][p.p().index()]; - } - - template <typename P, typename T> - inline - T& - sparse_image<P,T>::operator()(const psite& p) - { - mln_precondition(this->has(p)); - return this->data_->values_[p.index()][p.p().index()]; - } - - template <typename P, typename T> - inline - const p_set_of< p_run<P> >& - sparse_image<P,T>::domain() const - { - mln_precondition(this->is_valid()); - return this->data_->domain_; - } - -# endif // ! MLN_INCLUDE_ONLY - - -} // end of namespace mln - - -#endif // ! MLN_CORE_IMAGE_SPARSE_IMAGE_HH diff --git a/milena/trash/t_image.cc b/milena/trash/t_image.cc deleted file mode 100644 index 6892744..0000000 --- a/milena/trash/t_image.cc +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright (C) 2007, 2009 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. - -/// \file tests/core/image/morph/t_image.cc -/// -/// Tests on mln::t_image. - - -#include <mln/core/image/image2d.hh> -#include <mln/core/image/morph/t_image.hh> - -#include <mln/debug/iota.hh> -#include <mln/debug/println.hh> - -int main() -{ - using namespace mln; - - typedef image2d<int> I; - - I ima(2, 3); - debug::iota(ima); - debug::println(ima); - - t_image<I> t_ima(ima, 0, 1); - debug::println(t_ima); - - // FIXME: Enrich this test (exercise more features and write - // assertions). -} diff --git a/milena/trash/t_image.hh b/milena/trash/t_image.hh deleted file mode 100644 index e9b5288..0000000 --- a/milena/trash/t_image.hh +++ /dev/null @@ -1,304 +0,0 @@ -// Copyright (C) 2007, 2008, 2009 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_CORE_IMAGE_MORPH_T_IMAGE_HH -# define MLN_CORE_IMAGE_MORPH_T_IMAGE_HH - -/// \file mln/core/image/morph/t_image.hh -/// -/// Definition of the "transposed" image class mln::t_image. - -# include <mln/core/internal/image_morpher.hh> -# include <mln/core/site_set/box.hh> -# include <mln/value/set.hh> - -namespace mln -{ - - // Fwd decl. - template <typename I> struct t_image; - - namespace internal - { - - /// Data structure for \c mln::t_image<I>. - template <typename I> - struct data< t_image<I> > - { - /// \brief Build the data object held by a t_image. - /// - /// \param ima The underlying image. - /// \param dim1 The first dimension to be swapped. - /// \param dim2 The second dimension to be swapped. - /// \param box The bounding box (domain) of the morphed image. - data(I& ima, unsigned dim1, unsigned dim2, - mln::box<mln_psite(I)>& box); - - /// Underlying image. - I ima_; - /// The swapped dimensions. - /// \{ - unsigned dim1_; - unsigned dim2_; - /// \} - /// The bounding box of the morphed image. - mln::box<mln_psite(I)> box_; - }; - - } // end of namespace mln::internal - - - /// Transposed image. - /// - /// Swap a couple of coordinates. - /// - /// \warning This class only works on images whose domain is a box. - /// - /// \ingroup modimagemorpher - // - template <typename I> - class t_image - : public internal::image_morpher<I, mln_value(I), mln_domain(I), t_image<I> > - { - public: - /// Super type. - typedef internal::image_morpher< I, mln_value(I), mln_domain(I), - t_image<I> > super_; - - /// Point_Site associated type. - typedef mln_psite(I) psite; - - /// Value associated type. - typedef mln_value(I) value; - - /// Type returned by the read-write pixel value operator. - typedef mln_morpher_lvalue(I) lvalue; - - /// Return type of read-only access. - typedef mln_rvalue(I) rvalue; - - /// Skeleton. - typedef t_image< tag::image_<I> > skeleton; - - public: - /// \brief Build the generalized transpose of an image. - /// - /// In the 2-dimension case, \a dim1 and \a dim2 must be resp. 1 and 2 - /// (or 2 and 1), and t_image is a transpose of a matrix with the - /// usual meaning. - /// - /// In dimensions greater than 2, mln::t_image represents a view - /// of the underlying image where two dimensions (i.e., two - /// components of each point) have been exchanged. - /// - /// \param ima The underlying image. - /// \param dim1 The first dimension to be swapped. - /// \param dim2 The second dimension to be swapped. - t_image(I& ima, unsigned dim1, unsigned dim2); - - - /// Initialize an empty image. - void init_(I& ima, unsigned dim1, unsigned dim2); - - - /// Test if this image has been initialized. - bool is_valid() const; - - /// Test if a pixel value is accessible at \p p. - bool has(const mln_psite(I)& p) const; - - /// Give the definition domain. - const box<mln_psite(I)>& domain() const; - - /// Read-only access of pixel value at point site \p p. - mln_rvalue(I) operator()(const mln_psite(I)& p) const; - - /// Read-write access of pixel value at point site \p p. - mln_morpher_lvalue(I) operator()(const mln_psite(I)& p); - - - protected: - /// Exchange components \a dim1_ and \a dim2_ of point \a p. - mln_psite(I) transpose_(const mln_psite(I)& p) const; - /// Exchange components \a dim1 and \a dim2 of point \a p. - mln_psite(I) exchange_coords_(const mln_psite(I)& p, - unsigned dim1, unsigned dim2) const; - }; - - - /* FIXME: Shouldn't we move these elsewhere? I (Roland) think mixing - data structure and routines is confusing, even if they are - closely related. What about mln/geom/swap_coords.hh? */ - template <typename I> - t_image<I> - swap_coords(Image<I>& ima, unsigned dim1, unsigned dim2); - - template <typename I> - t_image<const I> - swap_coords(const Image<I>& ima, unsigned dim1, unsigned dim2); - - - -# ifndef MLN_INCLUDE_ONLY - - namespace internal - { - - // internal::data< t_image<I,S> > - - template <typename I> - inline - data< t_image<I> >::data(I& ima, - unsigned dim1, unsigned dim2, - mln::box<mln_psite(I)>& box) - : ima_(ima), - dim1_(dim1), dim2_(dim2), - box_(box) - { - } - - } // end of namespace mln::internal - - - template <typename I> - inline - t_image<I>::t_image(I& ima, unsigned dim1, unsigned dim2) - { - init_(ima, dim1, dim2); - } - - template <typename I> - inline - void - t_image<I>::init_(I& ima, unsigned dim1, unsigned dim2) - { - mln_precondition(ima.is_valid()); - /* FIXME: Add a precondition on the fact that the domain of ima is - a box. */ - // We don't use mln::t_image::transpose here, since one its - // prerequisite is that data_ is initialized, which is not done - // yet at this point. - box<mln_psite(I)> box(exchange_coords_(ima.bbox().pmin(), dim1, dim2), - exchange_coords_(ima.bbox().pmax(), dim1, dim2)); - this->data_ = new internal::data< t_image<I> >(ima, dim1, dim2, box); - } - - - template <typename I> - inline - bool t_image<I>::is_valid() const - { - mln_invariant(this->delegatee_()->is_valid()); - return true; - } - - template <typename I> - inline - bool - t_image<I>::has(const mln_psite(I)& p) const - { - mln_precondition(this->is_valid()); - return this->delegatee_()->has(transpose_(p)); - } - - template <typename I> - inline - mln_psite(I) - t_image<I>::transpose_(const mln_psite(I)& p) const - { - mln_precondition(this->is_valid()); - return exchange_coords_(p, this->data_->dim1_, this->data_->dim2_); - } - - template <typename I> - inline - mln_psite(I) - t_image<I>::exchange_coords_(const mln_psite(I)& p, - unsigned dim1, unsigned dim2) const - { - mln_psite(I) tmp(p); - tmp[dim1] = p[dim2]; - tmp[dim2] = p[dim1]; - return tmp; - } - - template <typename I> - inline - const box<mln_psite(I)>& - t_image<I>::domain() const - { - mln_precondition(this->is_valid()); - return this->data_->box_; - } - - template <typename I> - inline - mln_rvalue(I) - t_image<I>::operator()(const mln_psite(I)& p) const - { - mln_precondition(this->has(p)); - return (*this->delegatee_())(transpose_(p)); - } - - template <typename I> - inline - mln_morpher_lvalue(I) - t_image<I>::operator()(const mln_psite(I)& p) - { - mln_precondition(this->has(p)); - return (*this->delegatee_())(transpose_(p)); - } - - template <typename I> - inline - t_image<I> - swap_coords(Image<I>& ima, unsigned dim1, unsigned dim2) - { - typedef mln_psite(I) P; - mln_precondition(dim1 != dim2); - mln_precondition(dim1 <= P::dim && dim2 <= P::dim); - t_image<I> tmp(exact(ima), dim1, dim2); - return tmp; - } - - template <typename I> - inline - t_image<const I> - swap_coords(const Image<I>& ima, unsigned dim1, unsigned dim2) - { - typedef mln_psite(I) P; - mln_precondition(dim1 != dim2); - mln_precondition(dim1 <= P::dim && dim2 <= P::dim); - t_image<const I> tmp(exact(ima), dim1, dim2); - return tmp; - } - -# endif // ! MLN_INCLUDE_ONLY - -} // end of namespace mln - - -#endif // ! MLN_CORE_IMAGE_MORPH_T_IMAGE_HH diff --git a/milena/trash/to_tiles.cc b/milena/trash/to_tiles.cc deleted file mode 100644 index 4a66f1b..0000000 --- a/milena/trash/to_tiles.cc +++ /dev/null @@ -1,88 +0,0 @@ -// Copyright (C) 2007 EPITA Research and Development Laboratory -// -// 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. - -/*! \file tests/convert/to_tiles.cc - * - * \brief Tests on mln::convert::to_tiles. - */ - -#include <mln/core/image/image2d.hh> -#include <mln/value/int_u8.hh> -#include <mln/debug/iota.hh> -#include <mln/data/fill.hh> -#include <mln/data/paste.hh> -#include <mln/border/fill.hh> -#include <mln/debug/println_with_border.hh> -#include <mln/debug/println.hh> -#include <mln/core/image/translate_image.hh> -#include <mln/convert/to_tiles.hh> - -int main () -{ - using namespace mln; - - typedef image2d<value::int_u8> I; - std::vector<I> vec; - - I ima1 (4, 2, 1); - data::fill(ima1, 1); - vec.push_back(ima1); - - I ima2 (4, 2, 1); - data::fill(ima2, 2); - vec.push_back(ima2); - - I ima3 (4, 2, 1); - data::fill(ima3, 3); - vec.push_back(ima3); - - I ima4 (4, 2, 1); - data::fill(ima4, 4); - vec.push_back(ima4); - - I ima5 (4, 2, 1); - data::fill(ima5, 5); - vec.push_back(ima5); - - I ima6 (4, 2, 1); - data::fill(ima6, 6); - vec.push_back(ima6); - - I ima7 (4, 2, 1); - data::fill(ima7, 7); - vec.push_back(ima7); - - I ima8 (4, 2, 1); - data::fill(ima8, 8); - vec.push_back(ima8); - - I ima9 (4, 2, 1); - data::fill(ima9, 9); - vec.push_back(ima9); - - I output = convert::to_tiles(vec, 1.33333f); - - debug::println (output); -} diff --git a/milena/trash/to_tiles.hh b/milena/trash/to_tiles.hh deleted file mode 100644 index c401e40..0000000 --- a/milena/trash/to_tiles.hh +++ /dev/null @@ -1,98 +0,0 @@ -// Copyright (C) 2007 EPITA Research and Development Laboratory -// -// 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_CONVERT_TO_TILES_HH -# define MLN_CONVERT_TO_TILES_HH - -/*! \file mln/convert/to_tiles.hh - * - * \brief Conversion of a vector of image2d into a tiled image with ratio. - */ - -# include <mln/core/image/translate_image.hh> -# include <mln/data/paste.hh> -# include <mln/geom/nrows.hh> -# include <mln/geom/ncols.hh> - -# include <vector> - -namespace mln -{ - - namespace convert - { - - /// FIXME : Run only for image2d - /// Convert a vector of image2d into a tiled image with ratio. - template <typename I> - I to_tiles(std::vector<I>& v_ima, float ratio); - -# ifndef MLN_INCLUDE_ONLY - - template <typename I> - inline - I - to_tiles(std::vector<I>& v_ima, float ratio) - { - // Test if v_ima is not empty. - mln_precondition(! v_ima.empty()); - - unsigned size = v_ima.size(); - unsigned nrows = geom::nrows(v_ima[0]); - unsigned ncols = geom::ncols(v_ima[0]); - - // Compute output size. - int size_c = (int) ceil(sqrt(size * ratio)); - int size_r = (int) ceil(sqrt(size / ratio)); - - I output(size_r * nrows, size_c * ncols); - - for (unsigned i = 0; i < size; ++i) - { - /// Check if current image has good dimension. - mln_precondition(geom::nrows(v_ima[i]) == nrows); - mln_precondition(geom::ncols(v_ima[i]) == ncols); - - /// Compute the delta point of translation. - dpoint2d dp = dpoint2d(i / size_c * nrows, i % size_c * ncols); - - /// Convert current image in translate image with its delta point. - translate_image<I> tr_ima(v_ima[i], dp); - - /// Paste translated image into output. - data::paste(tr_ima, output); - } - - return output; - } - -# endif // ! MLN_INCLUDE_ONLY - - } // end of namespace mln::convert - -} // end of namespace mln - - -#endif // ! MLN_CONVERT_TO_TILES_HH diff --git a/milena/trash/translate_image.cc b/milena/trash/translate_image.cc deleted file mode 100644 index 399983a..0000000 --- a/milena/trash/translate_image.cc +++ /dev/null @@ -1,74 +0,0 @@ -// Copyright (C) 2007 EPITA Research and Development Laboratory -// -// 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. - -/*! \file tests/core/image/translate_image.cc - * - * \brief Tests on mln::core::translate_image.hh. - */ - -#include <mln/core/image/image2d.hh> -#include <mln/value/int_u8.hh> -#include <mln/debug/iota.hh> -#include <mln/data/fill.hh> -#include <mln/data/paste.hh> -#include <mln/border/fill.hh> -#include <mln/debug/println_with_border.hh> -#include <mln/debug/println.hh> -#include <mln/core/image/translate_image.hh> - - -int main () -{ - using namespace mln; - - typedef image2d<value::int_u8> I; - - I ima (4, 2, 1); - debug::iota (ima); - translate_image<I> tmp (ima, dpoint2d (0,2)); - std::cout << "orginal image domain : " - << ima.domain () - << std::endl - << "translated image domain : " - << tmp.domain () - << std::endl; - - std::cout << "original image :" - << std::endl; - debug::println (ima); - std::cout << std::endl; - std::cout << "translated image :" - << std::endl; - debug::println (tmp); - - std::cout << std::endl; - I out (4,4); - data::paste(ima, out); - data::paste(tmp, out); - std::cout << "pasted image :" - << std::endl; - debug::println (out); - std::cout << std::endl; -} diff --git a/milena/trash/translate_image.hh b/milena/trash/translate_image.hh deleted file mode 100644 index 9c07f1e..0000000 --- a/milena/trash/translate_image.hh +++ /dev/null @@ -1,209 +0,0 @@ -// Copyright (C) 2007, 2008 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_CORE_IMAGE_TRANSLATE_IMAGE_HH -# define MLN_CORE_IMAGE_TRANSLATE_IMAGE_HH - -/// \file mln/core/image/translate_image.hh -/// -/// Definition of an image which be translated by a delta point. - -# include <cmath> - -# include <mln/core/internal/image_identity.hh> -# include <mln/core/alias/box2d.hh> - -//FIXME: Fix this image morpher. - -namespace mln -{ - - // Fwd decl. - template <typename I> struct translate_image; - - namespace internal - { - - /// Data structure for \c mln::translate_image<I>. - template <typename I> - struct data< translate_image<I> > - { - data(I& ima, const mln_site(I)::dpsite dp); - - I ima_; - - /// Real domain. - box2d bb_; - - /// Delta point of translation. - const mln_site(I)::dpsite dp_; - }; - - } // end of namespace mln::internal - - - - namespace trait - { - - template <typename I> - struct image_< translate_image<I> > : default_image_morpher< I, mln_value(I), - translate_image<I> > - { - typedef trait::image::category::domain_morpher category; - - typedef mln_trait_image_value_access(I) value_access; - typedef mln_trait_image_localization(I) localization; - typedef mln_trait_image_size(I) size; - //typedef mln_trait_image_io_from_(I) io; - //typedef mln_trait_image_data_from_(I) data; - }; - - } // end of namespace mln::trait - - - - /// \brief Translate image class. - /// - /// The parameter \c I is the type of image. This image class - /// makes a translation of a delta point. - /// - template <typename I> - struct translate_image : public mln::internal::image_identity< I, mln_pset(I), translate_image<I> > - { - - typedef mln::internal::image_identity< I, mln_pset(I), translate_image<I> > super_; - - /// Return type of read-write access. - typedef mln_morpher_lvalue(I) lvalue; - - /// Skeleton. - typedef translate_image< tag::image_<I> > skeleton; - - /// Test if a pixel value is accessible at \p p. - using super_::is_valid; - - /// Constructors. - translate_image(I& ima, const mln_site(I)::dpsite dp); - translate_image(); - - /// Return domain of translated_image. - const box2d& domain() const; - - /// Test if a pixel value is accessible at \p p. - bool has(const mln_psite(I)& ) const; - - /// Read-only access of pixel value at point site \p p. - mln_rvalue(I) operator()(const mln_psite(I)& p) const; - - /// Read and "write if possible" access of pixel value at point site \p p. - mln_morpher_lvalue(I) operator()(const mln_psite(I)& p); - }; - - - -# ifndef MLN_INCLUDE_ONLY - - namespace internal - { - - // internal::data< translate_image<I,S> > - - template <typename I> - inline - data< translate_image<I> >::data(I& ima, const mln_site(I)::dpsite dp) - : ima_ (ima), - dp_ (dp) - { - point2d start = ima.bbox ().pmin () + dp; - point2d end = ima.bbox ().pmax () + dp; - int x1 = start[0]; - int y1 = start[1]; - int x2 = end[0]; - int y2 = end[1]; - - bb_ = make::box2d (x1, y1, x2, y2); - } - - } // end of namespace mln::internal - - template <typename I> - inline - translate_image<I>::translate_image(I& ima, const mln_site(I)::dpsite dp) - { - mln_precondition(ima.is_valid()); - this->data_ = new internal::data< translate_image<I> >(ima, dp); - } - - template <typename I> - inline - translate_image<I>::translate_image() - { - } - - template <typename I> - inline - bool translate_image<I>::has(const mln_psite(I)& p) const - { - mln_psite(I) np = p - this->data_->dp_; - return this->data_->ima_.has(np); - } - - template <typename I> - inline - mln_rvalue(I) - translate_image<I>::operator()(const mln_psite(I)& p) const - { - mln_assertion(this->has(p)); - mln_psite(I) np = p - this->data_->dp_; - return this->data_->ima_(np); - } - - - template <typename I> - inline - mln_morpher_lvalue(I) - translate_image<I>::operator()(const mln_psite(I)& p) - { - mln_assertion(this->has(p)); - mln_psite(I) np = p - this->data_->dp_; - return this->data_->ima_(np); - } - - template <typename I> - inline - const box2d& - translate_image<I>::domain() const - { - return this->data_->bb_; - } - -# endif // ! MLN_INCLUDE_ONLY - -} // end of namespace mln - - -#endif // ! MLN_CORE_IMAGE_TRANSLATE_IMAGE_HH diff --git a/milena/trash/value_enc_image.cc b/milena/trash/value_enc_image.cc deleted file mode 100644 index 1fdb00b..0000000 --- a/milena/trash/value_enc_image.cc +++ /dev/null @@ -1,155 +0,0 @@ -// Copyright (C) 2007, 2008 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. - -/*! \file tests/core/image/rle_image.cc - * - * \brief Test on mln::core::value_enc_image.hh. - */ - -#include <mln/core/image/image2d.hh> -#include <mln/core/image/value_enc_image.hh> - -#include <mln/value/int_u8.hh> -#include <mln/io/pgm/load.hh> -#include <mln/pw/all.hh> -#include <mln/core/alias/neighb2d.hh> - -#include <mln/labeling/blobs.hh> -#include <mln/data/transform.hh> -#include <mln/data/paste.hh> -#include <mln/data/compare.hh> -#include <mln/io/pgm/save.hh> -#include <mln/core/alias/p_runs2d.hh> - -#include "tests/data.hh" - -#include <mln/core/image/value_encode.hh> - -struct fold_t : public mln::Function_v2v< fold_t > -{ - - typedef mln::value::int_u8 result; - result operator()(unsigned i) const - { - return i == 0 ? 0 : (i - 1) % 255 + 1; - } - -}; - -int main() -{ - using namespace mln; - - /// Basic test - { - typedef value_enc_image<point2d, int> ima_type; - - p_runs2d pruns0; - p_runs2d pruns1; - p_runs2d pruns2; - - pruns0.insert(p_run<point2d>(point2d(0, 0), 2)); - - pruns1.insert(p_run<point2d>(point2d(2, 4), 7)); - pruns1.insert(p_run<point2d>(point2d(18, 42), 5)); - pruns1.insert(p_run<point2d>(point2d(50, 76), 2)); - pruns1.insert(p_run<point2d>(point2d(17,40), 6)); - - pruns2.insert(p_run<point2d>(point2d(10,10), 5)); - - ima_type ima; - ima.insert(pruns0, 0); - ima.insert(pruns2, 2); - ima.insert(pruns1, 1); - - mln_piter_(ima_type) piter (ima.domain()); - int i = 0; - int nb = 0; - for_all(piter) - { - assert(ima(piter) == i); - - ++nb; - if (nb == 2) - i = 2; - if (nb == 7) - i = 1; - } - } - - /// Basic test two - { - typedef value_enc_image<point2d, int> ima_type; - ima_type ima; - - ima.insert(p_run<point2d>(point2d(0, 0), 2), 0); - ima.insert(p_run<point2d>(point2d(10,10), 5), 2); - - ima.insert(p_run<point2d>(point2d(2, 4), 7), 1); - ima.insert(p_run<point2d>(point2d(18, 42), 5), 1); - ima.insert(p_run<point2d>(point2d(50, 76), 2), 1); - ima.insert(p_run<point2d>(point2d(17,40), 6), 1); - - - mln_piter_(ima_type) piter (ima.domain()); - int i = 0; - int nb = 0; - for_all(piter) - { - assert(ima(piter) == i); - - ++nb; - if (nb == 2) - i = 2; - if (nb == 7) - i = 1; - } - } - - /// A third test - { - using value::int_u8; - - image2d<int_u8> lena; - io::pgm::load(lena, MLN_IMG_DIR "/lena.pgm"); - image2d<int_u8> cmp(lena.domain()); - - unsigned n; - image2d<unsigned> labels = - labeling::blobs((pw::value(lena) > pw::cst(172u)) | lena.domain(), - c4(), n); - - value_enc_image<point2d, int_u8> val_enc = - value_encode(data::transform(labels, fold_t())); - - data::fill(cmp, literal::zero); - data::paste(val_enc, cmp); - std::cout << val_enc.values().size() << std::endl; - - mln_assertion(cmp == data::transform(labels, fold_t())); - //io::pgm::save(cmp, "output.pgm"); - //io::pgm::save(data::transform(labels, fold_t()), "output2.pgm"); - } -} diff --git a/milena/trash/value_enc_image.hh b/milena/trash/value_enc_image.hh deleted file mode 100644 index 29653af..0000000 --- a/milena/trash/value_enc_image.hh +++ /dev/null @@ -1,254 +0,0 @@ -// Copyright (C) 2007, 2008 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_CORE_VALUE_ENC_IMAGE_CC_ -# define MLN_CORE_VALUE_ENC_IMAGE_CC_ - -/// \file mln/core/image/value_enc_image.hh -/// -/// Define the class value_enc_image. - -# include <mln/core/internal/image_primary.hh> - -# include <mln/core/site_set/p_array.hh> -# include <mln/core/site_set/p_run.hh> -# include <mln/core/site_set/p_set_of.hh> - -# include <vector> -# include <mln/util/tracked_ptr.hh> - -namespace mln -{ - - // Forward declaration - template <typename P, typename T> struct value_enc_image; - - - namespace internal - { - - /// Data structure for \c mln::value_enc_image<P,T>. - template <typename P, typename T> - struct data< value_enc_image<P, T> > - { - data(); - - /// Image values. - std::vector<T> values_; - - /// domain of the image - p_array< p_set_of< p_run<P> > > domain_; - }; - - } // end of namespace mln::internal - - - namespace trait - { - - template <typename P, typename T> - struct image_< value_enc_image<P,T> > : - default_image_< T, value_enc_image<P,T> > - { - typedef trait::image::category::primary category; - -// FIXME: update with new properties. -// typedef trait::image::access::browsing access; -// -// // FIXME: Put the right dimension. -// typedef trait::image::space::two_d space; -// -// typedef trait::image::size::regular size; -// typedef trait::image::support::aligned support; -// -// typedef trait::image::border::none border; -// typedef trait::image::data::linear data; -// typedef trait::image::io::read_only io; -// typedef trait::image::speed::slow speed; - }; - - } // end of namespace mln::trait - - - /// Value encoded image. - /// Associate a value to set of runs. - template <typename P, typename T> - class value_enc_image : - public internal::image_primary< P, p_array< p_set_of< p_run<P> > >, - value_enc_image<P, T> > - { - public: - - /// Value related typedefs - typedef T value; - typedef T& lvalue; - typedef const T rvalue; - - /// Domain related typedefs - typedef p_array< p_set_of< p_run<P> > > pset; - typedef mln_psite(pset) psite; - - /// Skeleton. - typedef value_enc_image< tag::psite_<P>, tag::value_<T> > skeleton; - - value_enc_image(); - - /// Add a new set of ranges to the image. - void insert(const p_set_of< p_run<P> >& ps, T value); - - /// Add a new range to the image - void insert(const p_run<P>& pr, T value); - - /// Tell if the image has the given point site. - bool has(const psite& ps) const; - - /// Read-only access to the image value located at the site \p site. - rvalue operator() (const psite& site) const; - - /// Read-write access to the image value located at the site \p site. - lvalue operator() (const psite& site); - - /// Test if this image has been initialized. - bool is_valid() const; - - /// Give the definition domain. - const pset& domain() const; - }; - - -# ifndef MLN_INCLUDE_ONLY - - namespace internal - { - - // internal::data< value_enc_image<P, T> > - - template <typename P, typename T> - inline - data< value_enc_image<P,T> >::data() - { - } - - } // end of namespace mln::internal - - - template <typename P, typename T> - inline - value_enc_image<P, T>::value_enc_image() - { - this->data_ = new internal::data< value_enc_image<P,T> >(); - } - - template <typename P, typename T> - inline - bool - value_enc_image<P, T>::is_valid() const - { - return this->data_->values_.size() != 0; - } - - template <typename P, typename T> - inline - void - value_enc_image<P, T>::insert(const p_set_of<p_run<P> >& ps, T value) - { - if (!this->is_valid()) - this->data_ = new internal::data< value_enc_image<P,T> >(); - - this->data_->domain_.insert(ps); - this->data_->values_.push_back(value); - } - - template <typename P, typename T> - inline - void - value_enc_image<P, T>::insert(const p_run<P>& pr, T value) - { - unsigned i = 0; - typename std::vector<T>::iterator it; - - for (it = this->data_->values_.begin(); - it != this->data_->values_.end() && *it != value; - ++it) - ++i; - - if (it != this->data_->values_.end()) - this->data_->domain_[i].insert(pr); - else - { - p_set_of< p_run<P> > ps = p_set_of< p_run<P> >(); - ps.insert(pr); - this->data_->domain_.insert(ps); - this->data_->values_.push_back(value); - } - } - - template <typename P, typename T> - inline - bool - value_enc_image<P, T>::has(const psite& site) - const - { - return this->data_->domain_.has(site); - } - - template <typename P, typename T> - inline - typename value_enc_image<P, T>::rvalue - value_enc_image<P, T>::operator() (const psite& site) - const - { - mln_precondition(this->has(site)); - - return this->data_->values_[site.index()]; - } - - template <typename P, typename T> - inline - typename value_enc_image<P, T>::lvalue - value_enc_image<P, T>::operator() (const psite& site) - { - mln_precondition(this->has(site)); - - return this->data_->values_[site.to_index()]; - } - - template <typename P, typename T> - inline - const typename value_enc_image<P, T>::pset& - value_enc_image<P, T>::domain() const - { - return this->data_->domain_; - } - -# endif // ! MLN_INCLUDE_ONLY - - -} // end of namespace mln - - -#endif // ! MLN_CORE_VALUE_ENC_IMAGE_CC_ - diff --git a/milena/trash/value_encode.hh b/milena/trash/value_encode.hh deleted file mode 100644 index 99e729b..0000000 --- a/milena/trash/value_encode.hh +++ /dev/null @@ -1,113 +0,0 @@ -// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory -// -// 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_CORE_IMAGE_VALUE_ENCODE_HH_ -# define MLN_CORE_IMAGE_VALUE_ENCODE_HH_ - -/*! \file mln/core/image/value_encode.hh - * - * \brief Definition of function which encodes an image in value_enc_image. - */ - -# include <mln/core/image/value_enc_image.hh> - -namespace mln -{ - - /*! - ** encode an image class to a value_enc_image - ** - ** @param input has to respect the Image concept. - ** The input image must be based on a regular grid. - ** @param ignore_zero says if zero has to be considered as a valid value - ** - ** @return value_enc_image - */ - template <typename I> - value_enc_image<mln_psite(I), mln_value(I)> - value_encode(const Image<I>& input, bool ignore_zero = true); - -# ifndef MLN_INCLUDE_ONLY - /*! - ** test if Point p1 and p2 are on the same line - */ - template <typename P> - inline - bool - on_the_same_line(const P& p1, const P& p2) - { - const unsigned dim = P::dim; - bool same_line = true; - - for (unsigned n = 0; same_line && n < dim - 1; ++n) - same_line = (p1[n] == p2[n]); - return same_line; - } - - template <typename I> - inline - value_enc_image<mln_psite(I), mln_value(I)> - value_encode(const Image<I>& input, bool ignore_zero) - { - value_enc_image<mln_psite(I), mln_value(I)> output; - const I& ima = exact(input); - mln_piter(I) p (exact(input).domain()); - - unsigned len = 0; - mln_psite(I) rstart; - mln_value(I) rvalue; - - for_all(p) - if (!ignore_zero || ima(p) != literal::zero || len) - { - if (len == 0) - { - ++len; - rstart = p; - rvalue = ima(p); - } - else - if (rvalue == ima(p) - && on_the_same_line(rstart, mln_psite(I)(p))) - ++len; - else - { - //FIXME is it right?? - output.insert(p_run<mln_psite(I)>(rstart, len), rvalue); - if ((len = (!ignore_zero || ima(p) != literal::zero))) - { - rstart = p; - rvalue = ima(p); - } - } - } - return output; - } - -#endif // ! MLN_INCLUDE_ONLY - -} - -#endif // ! MLN_CORE_IMAGE_VALUE_ENCODE_HH_ -- 1.7.10.4
participants (1)
-
Roland Levillain