Commit cf9b21ec authored by Guillaume Lazzara's avatar Guillaume Lazzara
Browse files

Cleanup IGR's code.

	* lazzara/igr/irm/irm_seg_with_mm_and_rag.cc: rename as...
	* lazzara/igr/irm/grad_clo: ... this.

	* lazzara/igr/irm/wst_rag.cc,
	* lazzara/igr/registration_3d.cc: make it compile.

git-svn-id: https://svn.lrde.epita.fr/svn/oln/trunk@3474 4aad255d-cdde-0310-9447-f3009e2ae8c0
parent 923a18d9
2009-03-04 Guillaume Lazzara <z@lrde.epita.fr>
Cleanup IGR's code.
* lazzara/igr/irm/irm_seg_with_mm_and_rag.cc: rename as...
* lazzara/igr/irm/grad_clo: ... this.
* lazzara/igr/irm/wst_rag.cc,
* lazzara/igr/registration_3d.cc: make it compile.
2009-03-03 Fabien Freling <fabien.freling@lrde.epita.fr>
Create small tools for IGR.
......
......@@ -22,7 +22,7 @@
#include <mln/convert/to_fun.hh>
#include <mln/morpho/gradient.hh>
#include <mln/morpho/closing_area.hh>
#include <mln/morpho/closing/area.hh>
#include <mln/morpho/meyer_wst.hh>
#include <mln/fun/l2l/wrap.hh>
......@@ -64,11 +64,11 @@ int main(int argc, char *argv[])
image2d<int_u8> grad = morpho::gradient(irm, win_c4p());
io::pgm::save(grad, "tmp_grad_c4p.pgm");
// image2d<int_u8> clo = morpho::closing_area(grad, c4(), atoi(argv[3]));
// io::pgm::save(clo, "tmp_clo_a100.pgm");
image2d<int_u8> clo = morpho::closing::area(grad, c4(), atoi(argv[3]));
io::pgm::save(clo, "tmp_clo_a100.pgm");
label_16 nbasins;
image2d<label_16> wshed = morpho::meyer_wst(grad, c4(), nbasins);
image2d<label_16> wshed = morpho::meyer_wst(clo, c4(), nbasins);
std::cout << "nbasins = " << nbasins << std::endl;
io::pgm::save(level::transform(wshed, fun::l2l::wrap<int_u8>()),
......
......@@ -12,7 +12,6 @@
#include <mln/core/alias/dpoint2d.hh>
#include <mln/draw/box.hh>
#include <mln/level/stretch.hh>
#include <mln/canvas/morpho/algebraic_union_find.hh>
#include <mln/fun/v2v/id.hh>
#include <mln/core/image/line_graph_elt_neighborhood.hh>
#include <mln/morpho/elementary/dilation.hh>
......@@ -20,6 +19,7 @@
#include <mln/extension/adjust_fill.hh>
#include <mln/extract/all.hh>
#include <mln/make/region_adjacency_graph.hh>
#include <mln/make/graph.hh>
// Given a color image and a wshed image, computes the component graph.
// Vertex values are computed thanks to a RGB image.
......@@ -223,20 +223,20 @@ int main(int argc, char *argv[])
I input;
io::ppm::load(input, argv[1]);
// image2d<rgb16> input = level::convert(rgb16(), input_);
J vol;
io::dump::load(vol, argv[2]);
J wsd;
io::dump::load(wsd, argv[2]);
label_16 nbasins = atoi(argv[3]);
std::cout << "nbasins = " << nbasins << std::endl;
util::graph g = make::graph(vol, c4(), nbasins);
// Compute value distances with a RGB image.
mln_VAR(ima_v, make_vertex_graph_image(g, input, vol, nbasins));
/// Build graph
util::graph g = make::graph(wsd, c4(), nbasins);
// Build graph images and compute distance values with a RGB image.
mln_VAR(ima_v, make_vertex_graph_image(g, input, wsd, nbasins));
mln_VAR(ima_e, make_edge_graph_image(ima_v, g));
//DEBUG
io::ppm::save(make_debug_graph_image(input, ima_v, ima_e, box_size, literal::white),
"wst_rag_graph_image_white.ppm");
......@@ -244,6 +244,7 @@ int main(int argc, char *argv[])
"wst_rag_graph_image_black.ppm");
/// Try to merge vertices.
mln_piter_(ima_e_t) e(ima_e.domain());
util::array<label_16> parent(g.v_nmax());
for (unsigned i = 0; i < parent.nelements(); ++i)
......@@ -272,21 +273,23 @@ int main(int argc, char *argv[])
mln_invariant(f(0) == 0u);
--nbasins2; //nbasins2 does not count the basin with label 0.
std::cout << "nbasins2 = " << nbasins2 << std::endl;
J wsd2 = level::transform(wsd, f);
J vol2 = level::transform(vol, f);
util::graph g2 = make::graph(vol2, c4(), nbasins2);
// Compute value distances with a RGB image.
mln_VAR(ima_v2, make_vertex_graph_image(g2, input, vol2, nbasins2));
/// Reconstruct a graph from the simplified image.
util::graph g2 = make::graph(wsd2, c4(), nbasins2);
// Compute distance values with a RGB image.
mln_VAR(ima_v2, make_vertex_graph_image(g2, input, wsd2, nbasins2));
mln_VAR(ima_e2, make_edge_graph_image(ima_v2, g2));
mln_VAR(vol2_,
morpho::elementary::dilation(extend(vol2 | (pw::value(vol2) == 0u),
vol2),
mln_VAR(wsd2_,
morpho::elementary::dilation(extend(wsd2 | (pw::value(wsd2) == 0u),
wsd2),
c8()));
data::fill((vol2 | (pw::value(vol2) == 0u)).rw(), vol2_);
data::fill((wsd2 | (pw::value(wsd2) == 0u)).rw(), wsd2_);
io::ppm::save(labeling::mean_values(input, vol2, nbasins2),
io::ppm::save(labeling::mean_values(input, wsd2, nbasins2),
"wst_rag_mean_colors.ppm");
io::ppm::save(make_debug_graph_image(input, ima_v2, ima_e2, box_size, literal::white),
"wst_rag_graph_image2_white.ppm");
......
......@@ -16,33 +16,43 @@ int main(int, char *argv[])
arr_t ref;
io::cloud::load(ref, argv[2]);
box3d bbox = geom::bbox(ref);
bbox.enlarge(1, bbox.nrows() / 2);
bbox.enlarge(2, bbox.ncols() / 2);
bbox.enlarge(0, bbox.nslis() / 2);
// Starting registration.
util::timer t;
t.start();
typedef fun::x2x::rotation<3u,float> rot_t;
typedef fun::x2x::translation<3u,float> trans_t;
fun::x2x::composed<trans_t,rot_t> qk = registration::registration3(in, ref);
fun::x2x::composed<trans_t,rot_t> qk = registration::registration2(bbox, in, ref);
std::cout << "igr.cc - Registration - " << t << "s" << std::endl;
box3d bbox = geom::bbox(ref);
bbox.enlarge(1, 50);
bbox.enlarge(2, 50);
image3d<value::rgb8> ima_in(bbox);
data::fill(ima_in, literal::black);
data::fill((ima_in | in).rw(), literal::green);
mln_VAR(ext_ima, extended_with(ima_in, pw::cst(value::rgb8(literal::black))));
mln_VAR(ext_ima, extend(ima_in, pw::cst(value::rgb8(literal::black))));
mln_VAR(trima, transposed_image(bbox, ext_ima, qk));
p_array<point3d> arr;
mln_VAR(tmp, (ima_in | in));
mln_piter_(tmp_t) p(tmp.domain());
for_all(p)
arr.insert(qk(p));
std::cout << arr.nsites() << std::endl;
io::cloud::save(arr, "registered.txt");
image3d<value::rgb8> ima_ref(geom::bbox(ref));
mln_VAR(ext_ima_ref, extended_with(ima_ref, pw::cst(value::rgb8(literal::black))));
mln_VAR(ext_ima_ref, extend(ima_ref, pw::cst(value::rgb8(literal::black))));
data::fill(ext_ima_ref, literal::black);
data::fill((ext_ima_ref | ref).rw(), literal::white);
data::fill((ext_ima_ref | pw::value(trima) == pw::cst(literal::green)).rw(), literal::green);
// io::cloud::save(res, "registered.txt");
// io::cloud::save(trima, "registered.txt");
io::ppm::save(debug::slices_2d(ima_ref, 5, 3, literal::black), "registration_3d.ppm");
// io::ppm::save(debug::slices_2d(ima_ref, 5, 3, literal::black), "registration_3d.ppm");
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment