3644: Update ICDAR-HSC code.

https://svn.lrde.epita.fr/svn/oln/trunk/milena/sandbox Index: ChangeLog from Thierry Geraud <thierry.geraud@lrde.epita.fr> Update ICDAR-HSC code. * icdar/2009/hsc/input_to_lines_dat.cc: Move code to... * icdar/2009/hsc/input_to_lines.hh: ...this new file. * icdar/2009/hsc/input_to_lines_dat.cc (main): Use the 'input_to_lines' routine. input_to_lines.hh | 79 +++++++++++--------------------------------------- input_to_lines_dat.cc | 46 +++-------------------------- 2 files changed, 24 insertions(+), 101 deletions(-) Index: icdar/2009/hsc/input_to_lines.hh --- icdar/2009/hsc/input_to_lines.hh (revision 3642) +++ icdar/2009/hsc/input_to_lines.hh (working copy) @@ -1,87 +1,44 @@ #include <sandbox/icdar/2009/hsc/clean_input.hh> #include <sandbox/icdar/2009/hsc/input_to_ws.hh> #include <sandbox/icdar/2009/hsc/ws_to_wsl.hh> -#include <sandbox/icdar/2009/hsc/io/icdar/save.hh> +#include <sandbox/icdar/2009/hsc/clean_lines.hh> #include <mln/world/binary_2d/subsample.hh> - #include <mln/value/int_u8.hh> #include <mln/value/label.hh> -#include <mln/value/rgb8.hh> -#include <mln/debug/colorize.hh> #include <mln/labeling/relabel.hh> - -#include <mln/level/transform.hh> -#include <mln/fun/v2v/enc.hh> - -#include <mln/io/pbm/load.hh> -#include <mln/io/pgm/save.hh> -#include <mln/io/ppm/save.hh> - #include <mln/core/image/violent_cast_image.hh> - - - -void usage(char* argv[]) +namespace mln { - std::cerr << "usage: " << argv[0] << " input.pbm output.dat [output.ppm]" << std::endl - << " HSC @ ICDAR'2009" << std::endl - << " input.pbm: input 2D binary image (text is black; background is white)" << std::endl - << " output.dat: line buffer (int; 0 is bg)." << std::endl; - std::abort(); -} - - -int main(int argc, char* argv[]) + template <typename L> + image2d<L> + input_to_lines(const image2d<bool>& raw_input, L& n_lines) { - using namespace mln; - using value::int_u8; - - if (argc != 3 && argc != 4) - usage(argv); - - - trace::entering("main"); - - - image2d<bool> input; - io::pbm::load(input, argv[1]); - - // First clean. - input = clean_input(input); - + image2d<bool> input = clean_input(raw_input); // Sub-sample. - image2d<int_u8> small = world::binary_2d::subsample(input, 4); + image2d<value::int_u8> small = world::binary_2d::subsample(input, 4); - typedef value::int_u<12> L; + typedef value::int_u<12> L_reg; + L_reg n_reg; + image2d<L_reg> ws, wsl; - L n_lines; - image2d<L> // Get text regions. - ws = input_to_ws(input, small, n_lines), - // Merge regions. - wsl = ws_to_wslines(input, small, ws, n_lines); + ws = input_to_ws(input, small, n_reg); - typedef value::label<12> L_; - L_ n_lines_; - image2d<L_> wsl_ = labeling::relabel(violent_cast_image_<L_>(wsl), - n_lines_); + // Merge regions. + wsl = ws_to_wslines(input, small, ws, n_reg); - io::icdar::save(wsl_, argv[2]); + // Clean lines + wsl = clean_lines(input, wsl, 0.7f); - if (argc == 4) - { - io::ppm::save(debug::colorize(value::rgb8(), - wsl_, - n_lines_), - argv[3]); + return labeling::relabel(violent_cast_image_<L>(wsl), + n_lines); } - trace::exiting("main"); -} +} // mln Property changes on: icdar/2009/hsc/input_to_lines.hh ___________________________________________________________________ Added: svn:mergeinfo Index: icdar/2009/hsc/input_to_lines_dat.cc --- icdar/2009/hsc/input_to_lines_dat.cc (revision 3643) +++ icdar/2009/hsc/input_to_lines_dat.cc (working copy) @@ -1,27 +1,13 @@ -#include <sandbox/icdar/2009/hsc/clean_input.hh> -#include <sandbox/icdar/2009/hsc/input_to_ws.hh> -#include <sandbox/icdar/2009/hsc/ws_to_wsl.hh> +#include <sandbox/icdar/2009/hsc/input_to_lines.hh> #include <sandbox/icdar/2009/hsc/io/icdar/save.hh> -#include <mln/world/binary_2d/subsample.hh> - -#include <mln/value/int_u8.hh> -#include <mln/value/label.hh> #include <mln/value/rgb8.hh> #include <mln/debug/colorize.hh> -#include <mln/labeling/relabel.hh> - -#include <mln/level/transform.hh> -#include <mln/fun/v2v/enc.hh> #include <mln/io/pbm/load.hh> #include <mln/io/pgm/save.hh> #include <mln/io/ppm/save.hh> -#include <mln/core/image/violent_cast_image.hh> - - - @@ -44,42 +30,22 @@ if (argc != 3 && argc != 4) usage(argv); - trace::entering("main"); - image2d<bool> input; io::pbm::load(input, argv[1]); - - // First clean. - input = clean_input(input); - - - // Sub-sample. - image2d<int_u8> small = world::binary_2d::subsample(input, 4); - - typedef value::int_u<12> L; - + typedef value::label<12> L; L n_lines; - image2d<L> - // Get text regions. - ws = input_to_ws(input, small, n_lines), - // Merge regions. - wsl = ws_to_wslines(input, small, ws, n_lines); - - typedef value::label<12> L_; - L_ n_lines_; - image2d<L_> wsl_ = labeling::relabel(violent_cast_image_<L_>(wsl), - n_lines_); + image2d<L> output = input_to_lines(input, n_lines); - io::icdar::save(wsl_, argv[2]); + io::icdar::save(output, argv[2]); if (argc == 4) { io::ppm::save(debug::colorize(value::rgb8(), - wsl_, - n_lines_), + output, + n_lines), argv[3]); }
participants (1)
-
Thierry Geraud