
URL: https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena/sandbox ChangeLog: 2008-10-29 Matthieu Garrigues <garrigues@lrde.epita.fr> * garrigues/ocr/compute_local_configurations.cc: New, A program to compute the number of connected component in a local configuration. --- compute_local_configurations.cc | 77 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) Index: branches/cleanup-2008/milena/sandbox/garrigues/ocr/compute_local_configurations.cc =================================================================== --- branches/cleanup-2008/milena/sandbox/garrigues/ocr/compute_local_configurations.cc (revision 0) +++ branches/cleanup-2008/milena/sandbox/garrigues/ocr/compute_local_configurations.cc (revision 2729) @@ -0,0 +1,77 @@ +#include <mln/core/image/image2d.hh> +#include <mln/core/alias/neighb2d.hh> + +#include <mln/labeling/blobs.hh> +#include <mln/level/fill.hh> +#include <mln/debug/println.hh> +#include <iomanip> + +int main() +{ + using namespace mln; + using namespace mln::value; + + typedef image2d<bool> I; + image2d<bool> ima(3,3); + point2d p(1,1); + + std::cout << "----- Object in C8 ------" << std::endl; + + for (unsigned i = 0; i < 256; i++) + { + level::fill(ima, false); + int_u8 tmp = i; + + mln_niter_(neighb2d) n(c8() , p); + for_all(n) + { + if (tmp % 2) + ima(n) = true; + tmp = tmp >> 1; + } + + + unsigned x; + labeling::blobs(ima, c8(), x); + +// std::cout << "----- conf no " << i << "------" << std::endl; +// debug::println(ima); +// std::cout << "----- " << x << " cc------" << std::endl; +// std::cout << "-----------" << std::endl; + + std::cout << std::setw(2) << x << ", "; + if (! ((i + 1) % 4)) std::cout << " "; + if (! ((i + 1) % 16)) std::cout << std::endl; + if (! ((i + 1) % 64)) std::cout << std::endl; + } + + std::cout << "----- Object in C4 ------" << std::endl; + + for (unsigned i = 0; i < 256; i++) + { + level::fill(ima, false); + int_u8 tmp = i; + + mln_niter_(neighb2d) n(c8() , p); + for_all(n) + { + if (tmp % 2) + ima(n) = true; + tmp = tmp >> 1; + } + + + unsigned x; + labeling::blobs(ima, c4(), x); + +// std::cout << "----- conf no " << i << "------" << std::endl; +// debug::println(ima); +// std::cout << "----- " << x << " cc------" << std::endl; +// std::cout << "-----------" << std::endl; + + std::cout << std::setw(2) << x << ", "; + if (! ((i + 1) % 4)) std::cout << " "; + if (! ((i + 1) % 16)) std::cout << std::endl; + if (! ((i + 1) % 64)) std::cout << std::endl; + } +}