last-svn-commit-143-ge8373a0 Add a fast rotation tool.

* scribo/src/preprocessing/Makefile.am, * scribo/src/preprocessing/rotate_90.cc: New. --- scribo/ChangeLog | 7 ++++ scribo/src/preprocessing/Makefile.am | 10 ++++++ scribo/src/preprocessing/rotate_90.cc | 51 +++++++++++++++++++++++++++++++++ 3 files changed, 68 insertions(+), 0 deletions(-) create mode 100644 scribo/src/preprocessing/rotate_90.cc diff --git a/scribo/ChangeLog b/scribo/ChangeLog index 355b467..95fa4d2 100644 --- a/scribo/ChangeLog +++ b/scribo/ChangeLog @@ -1,5 +1,12 @@ 2010-06-15 Guillaume Lazzara <z@lrde.epita.fr> + Add a fast rotation tool. + + * scribo/src/preprocessing/Makefile.am, + * scribo/src/preprocessing/rotate_90.cc: New. + +2010-06-15 Guillaume Lazzara <z@lrde.epita.fr> + Add a new routine to highlight text areas in an image. * debug/highlight_text_area.hh: New. diff --git a/scribo/src/preprocessing/Makefile.am b/scribo/src/preprocessing/Makefile.am index d080c96..6096d8f 100644 --- a/scribo/src/preprocessing/Makefile.am +++ b/scribo/src/preprocessing/Makefile.am @@ -37,6 +37,16 @@ unskew_SOURCES = unskew.cc if HAVE_MAGICKXX + bin_PROGRAMS += rotate_90 + rotate_90_SOURCES = rotate_90.cc + rotate_90_CPPFLAGS = $(AM_CPPFLAGS) \ + $(TESSERACT_CPPFLAGS) \ + `Magick++-config --cppflags` + + rotate_90_LDFLAGS = $(AM_LDFLAGS) \ + $(TESSERACT_LDFLAGS) \ + -lpthread `Magick++-config --libs` + bin_PROGRAMS += to_pgm to_pgm_SOURCES = to_pgm.cc to_pgm_CPPFLAGS = $(AM_CPPFLAGS) \ diff --git a/scribo/src/preprocessing/rotate_90.cc b/scribo/src/preprocessing/rotate_90.cc new file mode 100644 index 0000000..3c4e84f --- /dev/null +++ b/scribo/src/preprocessing/rotate_90.cc @@ -0,0 +1,51 @@ +#include <mln/core/image/image2d.hh> +#include <mln/value/rgb8.hh> +#include <mln/io/magick/load.hh> +#include <mln/io/ppm/save.hh> + +#include <mln/util/timer.hh> + +#include <scribo/debug/usage.hh> +#include <scribo/preprocessing/rotate_90.hh> + + +const char *args_desc[][2] = +{ + { "input.*", "An image." }, + { "output.ppm", "A rotated image." }, + { "positive", "if set to 1, performs a +90 rotation; -90 otherwise. (default: 0)" }, + {0, 0} +}; + + + +int main(int argc, char *argv[]) +{ + using namespace mln; + + if (argc != 3 && argc != 4) + return scribo::debug::usage(argv, + "Fast +90/-90 rotation", + "input.* output.ppm", + args_desc); + + + typedef image2d<value::rgb8> I; + I ima; + io::magick::load(ima, argv[1]); + + bool positive = false; + + if (argc >= 4) + positive = (atoi(argv[3]) != 0); + + + mln::util::timer t; + t.start(); + image2d<value::rgb8> out = scribo::preprocessing::rotate_90(ima, positive); + t.stop(); + + std::cout << t << std::endl; + + io::ppm::save(out, argv[2]); +} -- 1.5.6.5
participants (1)
-
Guillaume Lazzara