https://svn.lrde.epita.fr/svn/oln/trunk/milena/sandbox Index: ChangeLog from Thierry Geraud <thierry.geraud@lrde.epita.fr> Add some exec files. * exec/filetype.hh: New. * exec/histo_save.cc: New. * theo/exec/closing_height.cc: New. exec/histo_save.cc | 46 +++++++++++++++++++++++++++++++++ theo/exec/closing_height.cc | 60 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 106 insertions(+) Property changes on: exec/filetype.hh ___________________________________________________________________ Added: svn:mergeinfo Index: exec/histo_save.cc --- exec/histo_save.cc (revision 0) +++ exec/histo_save.cc (revision 0) @@ -0,0 +1,46 @@ +#include "filetype.hh" + +#include <mln/histo/compute.hh> +#include <mln/debug/histo.hh> + +#include <mln/core/image/image_if.hh> +#include <mln/pw/all.hh> + + + +void usage(char* argv[]) +{ + std::cerr << "usage: " << argv[0] << " input.pgm [mask.pbm] output.txt" << std::endl + << " Compute an histogram." << std::endl + << " Input images are 2D." << std::endl; + std::abort(); +} + + + +int main(int argc, char* argv[]) +{ + using namespace mln; + using value::int_u8; + + if (argc != 3 && argc != 4) + usage(argv); + + trace::entering("main"); + + image2d<int_u8> input; + io::pgm::load(input, argv[1]); + + histo::array<int_u8> h; + if (argc == 3) + h = histo::compute(input); + else + { + image2d<bool> mask; + io::pbm::load(mask, argv[2]); + h = histo::compute(input | pw::value(mask)); + } + debug::histo(h, argv[argc - 1]); + + trace::exiting("main"); +} Index: theo/exec/closing_height.cc --- theo/exec/closing_height.cc (revision 0) +++ theo/exec/closing_height.cc (revision 0) @@ -0,0 +1,60 @@ +#include "filetype.hh" +#include <mln/morpho/closing/height.hh> + + + +void usage(char* argv[]) +{ + std::cerr << "usage: " << argv[0] << " input.xxx lambda output.xxx" << std::endl + << " Height closing." << std::endl + << " xxx in { pgm, dump }" << std::endl; + std::abort(); +} + + + +int main(int argc, char* argv[]) +{ + using namespace mln; + using value::int_u8; + + if (argc != 4) + usage(argv); + + trace::entering("main"); + + std::string filename = argv[1]; + unsigned lambda = atoi(argv[2]); + + switch (get_filetype(argv[1])) + { + case filetype::pgm: + { + image2d<int_u8> ima, clo; + io::pgm::load(ima, argv[1]); + clo = morpho::closing::height(ima, c4(), lambda); + io::pgm::save(clo, argv[3]); + } + break; + + case filetype::dump: + { + image3d<int_u8> ima, clo; + io::dump::load(ima, argv[1]); + clo = morpho::closing::height(ima, c6(), lambda); + io::dump::save(clo, argv[3]); + } + break; + + case filetype::unknown: + std::cerr << "unknown filename extension!" << std::endl; + usage(argv); + break; + + default: + std::cerr << "file type not handled!" << std::endl; + usage(argv); + } + + trace::exiting("main"); +}