
* apps/graph-morpho/io.hh (println): Take an extra argument to print a (leading) message. * apps/graph-morpho/complex1d.cc: Adjust and simplify. --- milena/ChangeLog | 8 +++ milena/apps/graph-morpho/complex1d.cc | 83 ++++++++------------------------ milena/apps/graph-morpho/io.hh | 4 +- 3 files changed, 32 insertions(+), 63 deletions(-) diff --git a/milena/ChangeLog b/milena/ChangeLog index c48cbd0..d40aae2 100644 --- a/milena/ChangeLog +++ b/milena/ChangeLog @@ -1,5 +1,13 @@ 2009-09-10 Roland Levillain <roland@lrde.epita.fr> + Simplify apps/graph-morpho/complex1d.cc. + + * apps/graph-morpho/io.hh (println): Take an extra argument to + print a (leading) message. + * apps/graph-morpho/complex1d.cc: Adjust and simplify. + +2009-09-10 Roland Levillain <roland@lrde.epita.fr> + Make apps/graph-morpho/complex1d.cc more modular. * apps/graph-morpho/complex1d.cc: Move I/O-related functions... diff --git a/milena/apps/graph-morpho/complex1d.cc b/milena/apps/graph-morpho/complex1d.cc index 9cf23b4..d3650a3 100644 --- a/milena/apps/graph-morpho/complex1d.cc +++ b/milena/apps/graph-morpho/complex1d.cc @@ -56,87 +56,46 @@ int main() // Dilations and erosions. // // ------------------------ // - /* Set the values so that X corresponds to the graph X of the ISMM - 2009 paper from Jean Cousty et al. */ + /* Create an image corresponding to the graph X of the ISMM 2009 + paper from Jean Cousty et al. */ image2d<bool> x_pbm = io::pbm::load(MLN_APPS_DIR "/graph-morpho/x.pbm"); ima_t x = make_regular_complex1d_image(x_pbm); box2d x_box(x_pbm.nrows() / 2 + 1, x_pbm.ncols() / 2 + 1); - std::cout << "x:" << std::endl; - println(x, x_box); + println("x:", x, x_box); - ima_t dil_e2v_ima = dilation_e2v(x); - std::cout << "dil_e2v_ima:" << std::endl; - println(dil_e2v_ima, x_box); + println("dilation_e2v(x):", dilation_e2v(x), x_box); + println("erosion_v2e(x):", erosion_v2e(x), x_box); - ima_t ero_v2e_ima = erosion_v2e(x); - std::cout << "ero_v2e_ima:" << std::endl; - println(ero_v2e_ima, x_box); + println("erosion_e2v(x):", erosion_e2v(x), x_box); + println("dilation_v2e(x):", dilation_v2e(x), x_box); + println("dilation_graph(x):", dilation_graph(x), x_box); + println("erosion_graph(x):", erosion_graph(x), x_box); - ima_t ero_e2v_ima = erosion_e2v(x); - std::cout << "ero_e2v_ima:" << std::endl; - println(ero_e2v_ima, x_box); - - ima_t dil_v2e_ima = dilation_v2e(x); - std::cout << "dil_v2e_ima:" << std::endl; - println(dil_v2e_ima, x_box); - - - ima_t dil_ima = dilation_graph(x); - std::cout << "dil_ima:" << std::endl; - println(dil_ima, x_box); - - ima_t ero_ima = erosion_graph(x); - std::cout << "ero_ima:" << std::endl; - println(ero_ima, x_box); - - - ima_t alpha3_ima = alpha3(x); - std::cout << "alpha3_ima:" << std::endl; - println(alpha3_ima, x_box); - - ima_t beta3_ima = beta3(x); - std::cout << "beta3_ima:" << std::endl; - println(beta3_ima, x_box); + println("alpha3(x):", alpha3(x), x_box); + println("beta3(x):", beta3(x), x_box); // --------- // // Filters. // // --------- // + // Create an image corresponding to the graph Y. image2d<bool> y_pbm = io::pbm::load(MLN_APPS_DIR "/graph-morpho/y.pbm"); ima_t y = make_regular_complex1d_image(y_pbm); box2d y_box(y_pbm.nrows() / 2 + 1, y_pbm.ncols() / 2 + 1); - std::cout << "y:" << std::endl; - println(y, y_box); - - ima_t ope_ima = opening_graph(y); - std::cout << "ope_ima:" << std::endl; - println(ope_ima, y_box); - - ima_t half_ope_ima = half_opening_graph(y); - std::cout << "half_ope_ima:" << std::endl; - println(half_ope_ima, y_box); - - ima_t beta3_o_alpha3_ima = beta3(alpha3(y)); - std::cout << "beta3_o_alpha3_ima:" << std::endl; - println(beta3_o_alpha3_ima, y_box); + println("y:", y, y_box); + println("opening_graph(y):", opening_graph(y), y_box); + println("half_opening_graph(y):", half_opening_graph(y), y_box); + println("beta3(alpha3(y)):", beta3(alpha3(y)), y_box); + // Create an image corresponding to the graph Z. image2d<bool> z_pbm = io::pbm::load(MLN_APPS_DIR "/graph-morpho/z.pbm"); ima_t z = make_regular_complex1d_image(z_pbm); box2d z_box(z_pbm.nrows() / 2 + 1, z_pbm.ncols() / 2 + 1); - std::cout << "z:" << std::endl; - println(z, z_box); - - ima_t clo_ima = closing_graph(z); - std::cout << "clo_ima:" << std::endl; - println(clo_ima, z_box); - - ima_t half_clo_ima = half_closing_graph(z); - std::cout << "half_clo_ima:" << std::endl; - println(half_clo_ima, z_box); + println("z:", z, z_box); - ima_t alpha3_o_beta3_ima = alpha3(beta3(z)); - std::cout << "alpha3_o_beta3_ima:" << std::endl; - println(alpha3_o_beta3_ima, z_box); + println("closing_graph(z):", closing_graph(z), z_box); + println("half_closing_graph(z):", half_closing_graph(z), z_box); + println("alpha3(beta3(z)):", alpha3(beta3(z)), z_box); } diff --git a/milena/apps/graph-morpho/io.hh b/milena/apps/graph-morpho/io.hh index 5b7a809..f2dfa9a 100644 --- a/milena/apps/graph-morpho/io.hh +++ b/milena/apps/graph-morpho/io.hh @@ -155,7 +155,8 @@ make_regular_complex1d_image(const mln::Image<I>& input_) inline void -println(const mln::bin_1complex_image2d& ima, const mln::box2d& support) +println(const std::string& message, const mln::bin_1complex_image2d& ima, + const mln::box2d& support) { using namespace mln; @@ -205,6 +206,7 @@ println(const mln::bin_1complex_image2d& ima, const mln::box2d& support) } } + std::cout << message << std::endl; for (int row = vertices.domain().pmin().row(); row <= vertices.domain().pmax().row(); ++row) { -- 1.6.4.2