* src/Makefile.am: Update target name.
* src/text_in_picture_neg.cc: Rename as...
* src/text_in_picture_dual.cc: ... this. Use option parser.
---
scribo/ChangeLog | 9 +
scribo/src/Makefile.am | 14 +-
...{text_in_picture.cc => text_in_picture_dual.cc} | 52 ++++--
scribo/src/text_in_picture_neg.cc | 197 --------------------
4 files changed, 56 insertions(+), 216 deletions(-)
copy scribo/src/{text_in_picture.cc => text_in_picture_dual.cc} (73%)
delete mode 100644 scribo/src/text_in_picture_neg.cc
diff --git a/scribo/ChangeLog b/scribo/ChangeLog
index 3dbe7db..28de74b 100644
--- a/scribo/ChangeLog
+++ b/scribo/ChangeLog
@@ -1,3 +1,12 @@
+2012-04-05 Guillaume Lazzara <z(a)lrde.epita.fr>
+
+ Cleanup text_in_picture_dual.
+
+ * src/Makefile.am: Update target name.
+
+ * src/text_in_picture_neg.cc: Rename as...
+ * src/text_in_picture_dual.cc: ... this. Use option parser.
+
2012-04-02 Guillaume Lazzara <z(a)lrde.epita.fr>
Make unskew an option in content_in_doc.
diff --git a/scribo/src/Makefile.am b/scribo/src/Makefile.am
index 08dc3ce..f0b1298 100644
--- a/scribo/src/Makefile.am
+++ b/scribo/src/Makefile.am
@@ -73,13 +73,13 @@ endif HAVE_TESSERACT
$(MAGICKXX_LDFLAGS)
- utilexec_PROGRAMS += text_in_picture_neg
- text_in_picture_neg_SOURCES = text_in_picture_neg.cc
- text_in_picture_neg_CPPFLAGS = $(AM_CPPFLAGS) \
- $(MAGICKXX_CPPFLAGS)
- text_in_picture_neg_LDFLAGS = $(AM_LDFLAGS) \
- -lpthread \
- $(MAGICKXX_LDFLAGS)
+ utilexec_PROGRAMS += text_in_picture_dual
+ text_in_picture_dual_SOURCES = text_in_picture_dual.cc
+ text_in_picture_dual_CPPFLAGS = $(AM_CPPFLAGS) \
+ $(MAGICKXX_CPPFLAGS)
+ text_in_picture_dual_LDFLAGS = $(AM_LDFLAGS) \
+ -lpthread \
+ $(MAGICKXX_LDFLAGS)
if HAVE_TESSERACT
diff --git a/scribo/src/text_in_picture.cc b/scribo/src/text_in_picture_dual.cc
similarity index 73%
copy from scribo/src/text_in_picture.cc
copy to scribo/src/text_in_picture_dual.cc
index d38d756..3eb9433 100644
--- a/scribo/src/text_in_picture.cc
+++ b/scribo/src/text_in_picture_dual.cc
@@ -1,5 +1,5 @@
-// Copyright (C) 2009, 2010, 2011 EPITA Research and Development
-// Laboratory (LRDE)
+// Copyright (C) 2010, 2011 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of Olena.
//
@@ -33,6 +33,8 @@
#include <scribo/debug/option_parser.hh>
#include <scribo/debug/logger.hh>
+#include <mln/world/rgb/invert.hh>
+#include <scribo/primitive/merge/components.hh>
static const scribo::debug::arg_data arg_desc[] =
{
@@ -65,10 +67,10 @@ static const scribo::debug::opt_data opt_desc[] =
};
-
int main(int argc, char* argv[])
{
using namespace scribo;
+ using namespace scribo::primitive;
using namespace mln;
scribo::debug::option_parser options(arg_desc, toggle_desc, opt_desc);
@@ -82,12 +84,13 @@ int main(int argc, char* argv[])
scribo::debug::logger().set_level(scribo::debug::All);
}
+
trace::entering("main");
Magick::InitializeMagick(*argv);
image2d<value::rgb8> input_rgb;
- io::magick::load(input_rgb, options.arg("input.*"));
+ io::magick::load(input_rgb, argv[1]);
bool verbose = options.is_set("verbose");
unsigned max_dim_size = atoi(options.opt_value("max-dim-size").c_str());
@@ -101,18 +104,43 @@ int main(int argc, char* argv[])
<< " - multi_scale_bin = " << multi_scale_bin
<< " - lambda = " << lambda << std::endl;
- component_set<image2d<scribo::def::lbl_type> >
- comps = toolchain::text_in_picture(input_rgb,
- fg_extraction, multi_scale_bin,
+
+ typedef image2d<scribo::def::lbl_type> L;
+ component_set<L>
+ comps = toolchain::text_in_picture(input_rgb, fg_extraction, multi_scale_bin,
max_dim_size, lambda, verbose);
+ typedef image2d<scribo::def::lbl_type> L;
+ component_set<L>
+ comps_neg = toolchain::text_in_picture(world::rgb::invert(input_rgb),
+ fg_extraction, multi_scale_bin,
+ max_dim_size, lambda, verbose);
+
+
+ component_set<L> merged_comps = primitive::merge::components(comps, comps_neg);
+
+
io::ppm::save(mln::labeling::colorize(value::rgb8(),
- comps.labeled_image(),
- comps.nelements()),
+ merged_comps.labeled_image(),
+ merged_comps.nelements()),
options.arg("output.ppm"));
-
- trace::exiting("main");
- return comps.nelements() != 0;
+# ifndef SCRIBO_NDEBUG
+ if (scribo::debug::logger().is_enabled())
+ {
+ scribo::debug::logger().log_image(scribo::debug::Results,
+ scribo::debug::highlight_text_area(input_rgb,
+ merged_comps),
+ "input_with_bboxes.ppm");
+ scribo::debug::logger().log_image(scribo::debug::Results,
+ scribo::debug::text_areas_image(input_rgb,
+ merged_comps),
+ "out_text.ppm");
+ }
+# endif // ! SCRIBO_NDEBUG
+
+ std::cout << "# objects = " << merged_comps.nelements() <<
std::endl;
+
+ return merged_comps.nelements() != 0;
}
diff --git a/scribo/src/text_in_picture_neg.cc b/scribo/src/text_in_picture_neg.cc
deleted file mode 100644
index dcd6857..0000000
--- a/scribo/src/text_in_picture_neg.cc
+++ /dev/null
@@ -1,197 +0,0 @@
-// Copyright (C) 2010, 2011 EPITA Research and Development Laboratory
-// (LRDE)
-//
-// This file is part of Olena.
-//
-// Olena is free software: you can redistribute it and/or modify it under
-// the terms of the GNU General Public License as published by the Free
-// Software Foundation, version 2 of the License.
-//
-// Olena is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with Olena. If not, see <http://www.gnu.org/licenses/>.
-//
-// As a special exception, you may use this file as part of a free
-// software project without restriction. Specifically, if other files
-// instantiate templates or use macros or inline functions from this
-// file, or you compile this file and link it with other files to produce
-// an executable, this file does not by itself cause the resulting
-// executable to be covered by the GNU General Public License. This
-// exception does not however invalidate any other reasons why the
-// executable file might be covered by the GNU General Public License.
-
-#include <libgen.h>
-#include <iostream>
-
-#include <mln/core/image/image2d.hh>
-#include <mln/core/image/imorph/tr_image.hh>
-#include <mln/core/alias/neighb2d.hh>
-
-#include <mln/labeling/colorize.hh>
-
-#include <mln/data/stretch.hh>
-
-#include <mln/io/pbm/all.hh>
-#include <mln/io/ppm/save.hh>
-#include <mln/io/magick/all.hh>
-
-#include <mln/arith/revert.hh>
-
-#include <mln/math/min.hh>
-
-#include <mln/logical/not.hh>
-
-#include <mln/literal/colors.hh>
-#include <mln/value/rgb8.hh>
-
-#include <mln/data/wrap.hh>
-
-#include <mln/draw/box.hh>
-
-#include <mln/geom/translate.hh>
-
-#include <mln/subsampling/antialiased.hh>
-
-#include <mln/world/rgb/invert.hh>
-
-#include <scribo/draw/bounding_boxes.hh>
-#include <scribo/draw/groups_bboxes.hh>
-
-#include <scribo/binarization/sauvola_ms.hh>
-#include <scribo/binarization/sauvola.hh>
-
-#include <scribo/primitive/extract/components.hh>
-
-#include <scribo/primitive/link/merge_double_link.hh>
-#include <scribo/primitive/link/with_single_left_link.hh>
-#include <scribo/primitive/link/with_single_right_link.hh>
-
-#include <scribo/primitive/group/apply.hh>
-#include <scribo/primitive/group/from_double_link.hh>
-#include <scribo/primitive/group/from_single_link.hh>
-
-#include <scribo/primitive/regroup/from_single_left_link.hh>
-// #include <scribo/primitive/regroup/from_single_left_link_wrt_h_ratio.hh>
-
-#include <scribo/filter/object_groups_with_holes.hh>
-
-#include <scribo/filter/object_links_bbox_h_ratio.hh>
-#include <scribo/filter/object_links_bbox_overlap.hh>
-
-#include <scribo/filter/common/objects_photo.hh>
-
-#include <scribo/filter/object_groups_small.hh>
-
-#include <scribo/debug/highlight_text_area.hh>
-#include <scribo/debug/text_areas_image.hh>
-
-#include <scribo/debug/decision_image.hh>
-
-#include <scribo/debug/usage.hh>
-
-#include <scribo/preprocessing/split_bg_fg.hh>
-
-#include <scribo/make/debug_filename.hh>
-
-#include <scribo/toolchain/text_in_picture.hh>
-
-#include <scribo/primitive/merge/components.hh>
-
-#include <mln/util/timer.hh>
-#include <mln/core/var.hh>
-
-const char *args_desc[][2] =
-{
- { "input.*", "A color image." },
- { "ouput.ppm", "A color image where the text is highlighted." },
- { "debug_output_dir", "Directory were debug images will be saved"
},
- { "lambda", "Lambda value used for foreground extraction" },
- {0, 0}
-};
-
-
-
-int main(int argc, char* argv[])
-{
- using namespace scribo;
- using namespace scribo::primitive;
- using namespace mln;
-
- if (argc < 3 || argc > 8)
- return scribo::debug::usage(argv,
- "Find text in a photo.\n\n"
- "Common usage: ./text_in_photo_fast input.*"
- " output.ppm 1 1",
- "input.ppm output.ppm <bg/fg enabled>"
- " <sauvola_ms enabled> "
- "[debug_output_dir] [max_dim_size] [lambda]",
- args_desc);
-
- char *out_base_dir = 0;
- if (argc > 5)
- out_base_dir = argv[5];
-
- trace::entering("main");
-
- Magick::InitializeMagick(*argv);
-
- image2d<value::rgb8> input_rgb;
- io::magick::load(input_rgb, argv[1]);
-
- unsigned max_dim_size = 0;
- if (argc >= 7)
- max_dim_size = atoi(argv[6]);
-
-
- unsigned lambda = 0;
- if (argc == 8)
- lambda = atoi(argv[7]);
-
- bool bg_removal = false;
- if (argc > 3 && atoi(argv[3]) != 0)
- bg_removal = true;
-
- bool multi_scale_bin = false;
- if (argc > 4 && atoi(argv[4]) != 0)
- multi_scale_bin = true;
-
-
- typedef image2d<scribo::def::lbl_type> L;
- component_set<L>
- comps = toolchain::text_in_picture(input_rgb, bg_removal, multi_scale_bin,
- max_dim_size, lambda, out_base_dir);
-
-
- typedef image2d<scribo::def::lbl_type> L;
- component_set<L>
- comps_neg = toolchain::text_in_picture(world::rgb::invert(input_rgb),
- bg_removal,
- multi_scale_bin,
- max_dim_size, lambda, out_base_dir);
-
-
- component_set<L> merged_comps = primitive::merge::components(comps, comps_neg);
-
-
-
- io::ppm::save(mln::labeling::colorize(value::rgb8(),
- merged_comps.labeled_image(),
- merged_comps.nelements()),
- argv[2]);
-
- if (out_base_dir)
- {
- io::ppm::save(scribo::debug::highlight_text_area(input_rgb, merged_comps),
- std::string(out_base_dir) + "_input_with_bboxes.ppm");
- io::ppm::save(scribo::debug::text_areas_image(input_rgb, merged_comps),
- std::string(out_base_dir) + "_out_text.ppm");
- }
-
- std::cout << "# objects = " << merged_comps.nelements() <<
std::endl;
-
- return merged_comps.nelements() != 0;
-}
--
1.7.2.5