* src/Makefile.am: Add ImageMagick CPPFLAGS and LDFLAGS.
* src/text_in_photo_ppm_fast.cc: Rename as...
* src/text_in_photo_fast.cc: ... this. Use ImageMagick to load images.
---
scribo/ChangeLog | 9 ++++
scribo/src/Makefile.am | 18 ++++----
..._in_photo_ppm_fast.cc => text_in_photo_fast.cc} | 42 ++++++++++++++++---
3 files changed, 53 insertions(+), 16 deletions(-)
rename scribo/src/{text_in_photo_ppm_fast.cc => text_in_photo_fast.cc} (94%)
diff --git a/scribo/ChangeLog b/scribo/ChangeLog
index bc1c87a..50f9d86 100644
--- a/scribo/ChangeLog
+++ b/scribo/ChangeLog
@@ -1,3 +1,12 @@
+2010-03-29 Guillaume Lazzara <z(a)lrde.epita.fr>
+
+ Add support for various image types in text_in_photo_fast.
+
+ * src/Makefile.am: Add ImageMagick CPPFLAGS and LDFLAGS.
+
+ * src/text_in_photo_ppm_fast.cc: Rename as...
+ * src/text_in_photo_fast.cc: ... this. Use ImageMagick to load images.
+
2010-03-19 Guillaume Lazzara <z(a)lrde.epita.fr>
Improve dematerialization wizard.
diff --git a/scribo/src/Makefile.am b/scribo/src/Makefile.am
index e254689..80dc782 100644
--- a/scribo/src/Makefile.am
+++ b/scribo/src/Makefile.am
@@ -34,7 +34,6 @@ bin_PROGRAMS = \
pbm_lines_in_doc \
text_in_photo \
text_in_photo_ppm \
- text_in_photo_ppm_fast \
text_in_photo_pbm_fast \
text_in_photo_invert
@@ -42,7 +41,6 @@ bin_PROGRAMS = \
pbm_lines_in_doc_SOURCES = pbm_lines_in_doc.cc
text_in_photo_SOURCES = text_in_photo.cc
text_in_photo_ppm_SOURCES = text_in_photo_ppm.cc
-text_in_photo_ppm_fast_SOURCES = text_in_photo_ppm_fast.cc
text_in_photo_pbm_fast_SOURCES = text_in_photo_pbm_fast.cc
text_in_photo_invert_SOURCES = text_in_photo_invert.cc
@@ -84,13 +82,15 @@ if HAVE_TIFF
text_in_article_pbm_SOURCES = text_in_article_pbm.cc
- text_in_photo_ppm_fast_CPPFLAGS = $(AM_CPPFLAGS) \
- $(TESSERACT_CPPFLAGS) \
- $(TIFF_CPPFLAGS)
- text_in_photo_ppm_fast_LDFLAGS = $(AM_LDFLAGS) \
- $(TESSERACT_LDFLAGS) \
- $(TIFF_LDFLAGS) \
- -lpthread
+ bin_PROGRAMS += text_in_photo_fast
+ text_in_photo_fast_SOURCES = text_in_photo_fast.cc
+ text_in_photo_fast_CPPFLAGS = $(AM_CPPFLAGS) \
+ $(TESSERACT_CPPFLAGS) \
+ `Magick++-config --cppflags`
+
+ text_in_photo_fast_LDFLAGS = $(AM_LDFLAGS) \
+ $(TESSERACT_LDFLAGS) \
+ -lpthread `Magick++-config --libs`
endif HAVE_TIFF
endif HAVE_TESSERACT
diff --git a/scribo/src/text_in_photo_ppm_fast.cc b/scribo/src/text_in_photo_fast.cc
similarity index 94%
rename from scribo/src/text_in_photo_ppm_fast.cc
rename to scribo/src/text_in_photo_fast.cc
index d534161..68b2014 100644
--- a/scribo/src/text_in_photo_ppm_fast.cc
+++ b/scribo/src/text_in_photo_fast.cc
@@ -37,6 +37,7 @@
#include <mln/io/pbm/all.hh>
#include <mln/io/ppm/save.hh>
+#include <mln/io/magick/all.hh>
#include <mln/math/min.hh>
@@ -54,6 +55,10 @@
#include <mln/geom/translate.hh>
+#include <mln/subsampling/antialiased.hh>
+
+#include <mln/subsampling/antialiased_rgb.hh>
+
#include <scribo/draw/bounding_boxes.hh>
#include <scribo/draw/groups_bboxes.hh>
@@ -101,8 +106,8 @@
#include <scribo/src/afp/link.hh>
#include <scribo/src/afp/regroup.hh>
-#include <scribo/core/line_set.hh>
-#include <scribo/text/recognition.hh>
+// #include <scribo/core/line_set.hh>
+// #include <scribo/text/recognition.hh>
const char *args_desc[][2] =
{
@@ -210,6 +215,19 @@ namespace mln
return output;
}
+
+ template <typename I>
+ unsigned get_factor(const I& ima)
+ {
+ unsigned
+ nrows = ima.nrows(),
+ ncols = ima.ncols(),
+ max_dim = std::max(nrows, ncols),
+ factor = max_dim / 512;
+
+ return factor ? factor : 1;
+ }
+
} // end of namespace mln
@@ -238,8 +256,17 @@ Common usage: ./ppm_text_in_photo input.ppm output.ppm 1 1 1 1
1",
trace::entering("main");
image2d<value::rgb8> input_rgb;
- io::ppm::load(input_rgb, argv[1]);
+ io::magick::load(input_rgb, argv[1]);
+
+ unsigned factor = get_factor(input_rgb);
+
+ std::cout << "Reduction Factor : " << factor << std::endl;
+
+ std::cout << "Original domain: " << input_rgb.domain() <<
std::endl;
+
+ input_rgb = mln::subsampling::impl::antialiased_2d_rgb(input_rgb, factor);
+ std::cout << "Resized domain: " << input_rgb.domain() <<
std::endl;
unsigned lambda;
if (argc == 10)
@@ -291,7 +318,7 @@ Common usage: ./ppm_text_in_photo input.ppm output.ppm 1 1 1 1
1",
unsigned w = std::min(intensity_ima.nrows() / 3, intensity_ima.ncols() / 3);
if (! w % 2)
++w;
- w = std::min(w, 101u);
+ w = std::min(w, 51u);
if (argc > 4 && atoi(argv[4]) != 0)
{
std::cout << "** Using sauvola_ms with w_1 = " << w <<
std::endl;
@@ -311,6 +338,7 @@ Common usage: ./ppm_text_in_photo input.ppm output.ppm 1 1 1 1
1",
#endif // !NOUT
+ logical::not_inplace(input);
// if (debug)
// io::pbm::save(input, "input.pbm");
@@ -626,9 +654,9 @@ Common usage: ./ppm_text_in_photo input.ppm output.ppm 1 1 1 1
1",
- scribo::line_set<L>
- lines = scribo::make::line_set(groups);
- text::recognition(lines, "fra", "out.txt");
+// scribo::line_set<L>
+// lines = scribo::make::line_set(groups);
+// text::recognition(lines, "fra", "out.txt");
trace::exiting("main");
return comps.nelements() != 0;
--
1.5.6.5