Milena (Olena)
User documentation 2.0a Id
|
00001 # include <mln/io/pbm/load.hh> 00002 # include <mln/core/image/image2d.hh> 00003 # include <mln/core/alias/p_run2d.hh> 00004 # include <mln/core/p_set_of.hh> 00005 # include <mln/convert/from_to.hh> 00006 # include <mln/util/timer.hh> 00007 00008 # include <sandbox/geraud/p_runs__with_dedicated_piter.hh> 00009 00010 00011 const unsigned n_times = 32; 00012 00013 00014 template <typename I> 00015 float browse_ima(const I& ima, unsigned& c) 00016 { 00017 mln::util::timer t; 00018 t.start(); 00019 for (unsigned i = 0; i < n_times; ++i) 00020 { 00021 c = 0; 00022 mln_piter(I) p(ima.domain()); 00023 for_all(p) 00024 if (ima(p)) 00025 ++c; 00026 } 00027 return t.read(); 00028 } 00029 00030 template <typename R> 00031 float browse_runs(const R& runs, unsigned& c) 00032 { 00033 mln::util::timer t; 00034 t.start(); 00035 for (unsigned i = 0; i < n_times; ++i) 00036 { 00037 c = 0; 00038 mln_fwd_piter(R) p(runs); 00039 for_all(p) 00040 ++c; 00041 } 00042 return t.read(); 00043 } 00044 00045 00046 int main() 00047 { 00048 using namespace mln; 00049 image2d<bool> ima; 00050 io::pbm::load(ima, "../../img/lena.pbm"); 00051 00052 unsigned c; 00053 std::cout << "ref: " << browse_ima(ima, c) << std::endl; 00054 00055 { 00056 util::timer t; 00057 t.start(); 00058 00059 // Conversion. 00060 p_set_of<p_run2d> rs; 00061 convert::from_to(ima, rs); 00062 std::cout << "enc: " << t.read() << std::endl; 00063 // FIXME: mln_assertion(rs.zratio() < 1); 00064 00065 // Browsing. 00066 unsigned cr; 00067 std::cout << "brs: " << browse_runs(rs, cr) << std::endl; 00068 mln_assertion(cr == c); 00069 } 00070 00071 { 00072 util::timer t; 00073 t.start(); 00074 00075 // Conversion. 00076 p_runs<point2d> rs; 00077 convert::from_to(ima, rs); 00078 std::cout << "enc: " << t.read() << std::endl; 00079 // FIXME: mln_assertion(rs.zratio() < 1); 00080 00081 // Browsing. 00082 unsigned cr; 00083 std::cout << "brs: " << browse_runs(rs, cr) << std::endl; 00084 mln_assertion(cr == c); 00085 } 00086 00087 }