cleanup-2008 2899: Fix the code that computes connexity numbers.

https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena/sandbox Index: ChangeLog from Thierry Geraud <thierry.geraud@lrde.epita.fr> Fix the code that computes connexity numbers. * garrigues/ocr/compute_local_configurations.cc: Fix. compute_local_configurations.cc | 65 +++++++++++++++++++--------------------- 1 file changed, 31 insertions(+), 34 deletions(-) Index: garrigues/ocr/compute_local_configurations.cc --- garrigues/ocr/compute_local_configurations.cc (revision 2898) +++ garrigues/ocr/compute_local_configurations.cc (working copy) @@ -6,23 +6,27 @@ #include <mln/debug/println.hh> #include <iomanip> + int main() { using namespace mln; - using namespace mln::value; + using value::int_u8; typedef image2d<bool> I; - image2d<bool> ima(3,3); - point2d p(1,1); - std::cout << "----- Object in C8 ------" << std::endl; + box2d b = make::box2d(-1,-1, 1,1); + image2d<bool> ima(b, 0); + point2d p(0, 0); + + std::vector<int_u8> x8(256), x4(256); + for (unsigned i = 0; i < 256; i++) { level::fill(ima, false); - int_u8 tmp = i; - mln_niter_(neighb2d) n(c8() , p); + int_u8 tmp = i; + mln_fwd_niter_(neighb2d) n(c8(), p); for_all(n) { if (tmp % 2) @@ -30,16 +34,28 @@ tmp = tmp >> 1; } + labeling::blobs(ima, c8(), x8[i]); - unsigned x; - labeling::blobs(ima, c8(), x); + { + int_u8 nl; + image2d<int_u8> lab = labeling::blobs(ima, c4(), nl); + std::set<int_u8> s; + mln_fwd_niter_(neighb2d) n(c4(), p); + for_all(n) + if (lab(n) != 0) + s.insert(lab(n)); + x4[i] = s.size(); + } + } -// 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 << ", "; + // Now printing! + + std::cout << "----- Object in C8 ------" << std::endl; + + for (unsigned i = 0; i < 256; i++) + { + std::cout << std::setw(2) << x8[i] << ", "; if (! ((i + 1) % 4)) std::cout << " "; if (! ((i + 1) % 16)) std::cout << std::endl; if (! ((i + 1) % 64)) std::cout << std::endl; @@ -49,29 +65,10 @@ 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 << ", "; + std::cout << std::setw(2) << x4[i] << ", "; if (! ((i + 1) % 4)) std::cout << " "; if (! ((i + 1) % 16)) std::cout << std::endl; if (! ((i + 1) % 64)) std::cout << std::endl; } + }
participants (1)
-
Thierry Geraud