r3728: Debugging fixed segmentation

URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena/sandbox ChangeLog: 2009-04-29 Fabien Freling <fabien.freling@lrde.epita.fr> Debugging fixed segmentation. * fabien/igr/seg_fixed.cc: Debugging, crash at runtime. --- seg_fixed.cc | 39 +++++++++++++++++++++++++++++++++------ 1 file changed, 33 insertions(+), 6 deletions(-) Index: trunk/milena/sandbox/fabien/igr/seg_fixed.cc =================================================================== --- trunk/milena/sandbox/fabien/igr/seg_fixed.cc (revision 3727) +++ trunk/milena/sandbox/fabien/igr/seg_fixed.cc (revision 3728) @@ -8,7 +8,9 @@ #include <mln/core/routine/duplicate.hh> #include <mln/io/dump/all.hh> +#include <mln/io/pgm/save.hh> +#include <mln/value/int_u8.hh> #include <mln/value/int_u12.hh> #include <mln/accu/sum.hh> @@ -16,10 +18,14 @@ #include <mln/debug/quiet.hh> #include <mln/convert/from_to.hh> #include <mln/level/compute.hh> +#include <mln/level/stretch.hh> #include <mln/util/array.hh> +#include <mln/world/inter_pixel/display_edge.hh> + using namespace mln; +using value::int_u8; using value::int_u12; @@ -56,13 +62,20 @@ { float res = 0.f; - if (!ima_sum.bbox().has(n)) - return res; - + std::cout << "computing..." << std::endl; + std::cout << "ima_arr.bbox(): " << ima_arr.bbox() << std::endl; + std::cout << "ima_arr(p).nelements(): " << ima_arr(p).nelements() << std::endl; + std::cout << "ima_arr(n).nelements(): " << ima_arr(n).nelements() << std::endl; for (unsigned i = 0; i < ima_arr(p).nelements(); ++i) res += std::min(ima_arr(p)[i], ima_arr(n)[i]); + + float max = std::max(ima_sum(p), ima_sum(n)); + if (max) res /= std::max(ima_sum(p), ima_sum(n)); + else + res = 0.f; + //std::cout << "\t" << res << std::endl; return res; } @@ -88,6 +101,7 @@ box2d b = ima_arr.bbox(); image2d<float> edges(make::box2d(2 * b.pmin()[0], 2 * b.pmin()[1], 2 * b.pmax()[0], 2 * b.pmax()[1])); + box2d edge_b = edges.bbox(); data::fill(edges, -1.f); image2d<float> ima_sum; initialize(ima_sum, ima_arr); @@ -100,9 +114,17 @@ for_all(n) { point2d location = get_edge_location(p, n); - //std::cout << "p: " << p << " | n: " << n << " | e: " << location << std::endl; - if (edges(location) == -1.f) - edges(location) = compute_dist(ima_arr, ima_sum, p, n); + if (b.has(n) && edge_b.has(location) && edges(location) == -1.f) + { + std::cout << "p: " << p << " | n: " << n << " | e: " << location << std::endl; + std::cout << "will compute..." << std::endl; + float res = compute_dist(ima_arr, ima_sum, p, n); + std::cout << "has computed" << std::endl << std::endl; + std::cout << "\t" << res << std::endl; + edges(location) = res; + } + else + std::cout << "." << std::endl; } } @@ -124,6 +146,7 @@ if (argc != 2) return usage(argv[0]); + // Initialization. image3d<int_u12> input; io::dump::load(input, argv[1]); image2d<util::array<int_u12> > ima_arr; @@ -136,7 +159,11 @@ ima_arr(p).append(tmp_slice(p)); } + // Edges computation. image2d<float> edges = dist_on_edges(ima_arr); + // Display. + io::pgm::save(level::stretch(int_u8(), world::inter_pixel::display_edge(edges, 0.0, 3)), "edges.pgm"); + return 0; }
participants (1)
-
Fabien Freling