Commit 4a195987 authored by Guillaume Lazzara's avatar Guillaume Lazzara
Browse files

Small fixes in Scribo.

	* binarization/sauvola_ms.hh: Fix compilation issues on MacOS X.

	* core/component_set.hh: Add labeled_image_() member.

	* debug/save_bboxes_image.hh: Add a missing include.

	* preprocessing/split_bg_fg.hh,
	* primitive/extract/components.hh: Fix namespace ambiguities.

	* src/text_in_article.cc: Rename as...
	* src/text_in_article_pbm.cc: ... this.

	* src/Makefile.am: Update source file names.
parent c5e55142
2010-03-19 Guillaume Lazzara <z@lrde.epita.fr>
Small fixes in Scribo.
* binarization/sauvola_ms.hh: Fix compilation issues on MacOS X.
* core/component_set.hh: Add labeled_image_() member.
* debug/save_bboxes_image.hh: Add a missing include.
* preprocessing/split_bg_fg.hh,
* primitive/extract/components.hh: Fix namespace ambiguities.
* src/text_in_article.cc: Rename as...
* src/text_in_article_pbm.cc: ... this.
* src/Makefile.am: Update source file names.
2010-03-18 Guillaume Lazzara <z@lrde.epita.fr>
Cleanup binarization tools.
......
......@@ -125,7 +125,8 @@ namespace scribo
typedef image2d<int_u8> I;
typedef point2d P;
unsigned ratio = std::pow(q, i - 2); // Ratio in comparison to e_2
// Cast to float is needed on MacOS X.
unsigned ratio = std::pow(float(q), float(i - 2u)); // Ratio in comparison to e_2
unsigned
w_local = w * ratio,
......@@ -832,7 +833,8 @@ namespace scribo
// Highest scale -> no maximum component size.
{
int i = sub_ima.size() - 1;
unsigned ratio = std::pow(q, i - 2); // Ratio compared to e_2
// Cast to float is needed on MacOS X.
unsigned ratio = std::pow(float(q), float(i - 2)); // Ratio compared to e_2
t_ima[i] = internal::compute_t_n_and_e_2(sub_ima[i], e_2,
lambda_min_2 / ratio,
mln_max(unsigned),
......@@ -845,7 +847,8 @@ namespace scribo
{
for (int i = sub_ima.size() - 2; i > 2; --i)
{
unsigned ratio = std::pow(q, i - 2); // Ratio compared to e_2
// Cast to float is needed on MacOS X.
unsigned ratio = std::pow(float(q), float(i - 2)); // Ratio compared to e_2
t_ima[i] = internal::compute_t_n_and_e_2(sub_ima[i], e_2,
lambda_min_2 / ratio,
lambda_max_2 / ratio,
......
......@@ -191,6 +191,13 @@ namespace scribo
/// Unique set Id.
unsigned id_() const;
/// Read/Write access to the underlying labeled image.
/// Careful! Write in this image at your own risks! It may lead to
/// non-synchronised related data.
//
L& labeled_image_();
/// @}
private:
......@@ -477,6 +484,15 @@ namespace scribo
}
template <typename L>
inline
L&
component_set<L>::labeled_image_()
{
return this->data_->ima_;
}
template <typename L>
inline
bool
......
......@@ -36,6 +36,7 @@
# include <mln/util/array.hh>
# include <mln/io/ppm/save.hh>
# include <scribo/core/line_set.hh>
# include <scribo/draw/bounding_boxes.hh>
......
......@@ -326,7 +326,7 @@ namespace scribo
image2d<value::rgb8> fg = internal::inverted_diff_abs(input, bg);
trace::exiting("scribo::preprocessing::split_bg_fg");
return make::couple(bg, fg);
return mln::make::couple(bg, fg);
}
......
......@@ -42,6 +42,7 @@
# include <mln/labeling/compute.hh>
# include <mln/util/array.hh>
# include <mln/util/couple.hh>
# include <mln/extension/fill.hh>
......@@ -120,9 +121,9 @@ namespace scribo
// Setting extension value.
extension::fill(input, 0);
util::couple<L,
util::couple<util::array<mln_result(pair_accu_t)>,
util::array<pair_accu_t> > >
mln::util::couple<L,
mln::util::couple<mln::util::array<mln_result(pair_accu_t)>,
mln::util::array<pair_accu_t> > >
results = labeling::blobs_and_compute(input, nbh, ncomponents,
pair_accu_t());
......
......@@ -72,16 +72,16 @@ if HAVE_TIFF
-lpthread -lhpdf
bin_PROGRAMS += text_in_article
text_in_article_CPPFLAGS = $(AM_CPPFLAGS) \
bin_PROGRAMS += text_in_article_pbm
text_in_article_pbm_CPPFLAGS = $(AM_CPPFLAGS) \
$(TESSERACT_CPPFLAGS) \
$(TIFF_CPPFLAGS)
text_in_article_LDFLAGS = $(AM_LDFLAGS) \
text_in_article_pbm_LDFLAGS = $(AM_LDFLAGS) \
$(TESSERACT_LDFLAGS) \
$(TIFF_LDFLAGS) \
-lpthread
# -lhpdf
text_in_article_SOURCES = text_in_article.cc
text_in_article_pbm_SOURCES = text_in_article_pbm.cc
text_in_photo_ppm_fast_CPPFLAGS = $(AM_CPPFLAGS) \
......
......@@ -80,6 +80,7 @@ const char *args_desc[][2] =
{
{ "input.pbm", "A binary image. 'False' for object, 'True'\
for the background." },
{ "denoise", "1 enables denoising, 0 disables it. (enabled by default)" },
{ "debug_dir", "Output directory for debug image" },
{0, 0}
};
......@@ -90,15 +91,15 @@ int main(int argc, char* argv[])
using namespace scribo;
using namespace mln;
if (argc != 3 && argc != 4)
if (argc != 3 && argc != 4 && argc != 5)
return scribo::debug::usage(argv,
"Find text lines using left/right validation and display x-height in a binarized article.",
"input.pbm out.ppm <debug_dir>",
"input.pbm out.txt <denoise: 0|1> <debug_dir>",
args_desc,
"A color image. The following colors are used : dark blue for object bboxes, orange for single object bboxes, purple for group bboxes and light blue for x-height.");
"Text output.");
if (argc == 4)
scribo::make::internal::debug_filename_prefix = argv[3];
if (argc == 5)
scribo::make::internal::debug_filename_prefix = argv[4];
trace::entering("main");
......@@ -131,8 +132,11 @@ int main(int argc, char* argv[])
// mln::io::pbm::save(input_cleaned, "input_no_separators.pbm");
// Denoise
std::cout << "Denoise..." << std::endl;
input_cleaned = preprocessing::denoise_fg(input_cleaned, c8(), 3);
if (argc > 3 && atoi(argv[3]) != 0)
{
std::cout << "Denoise..." << std::endl;
input_cleaned = preprocessing::denoise_fg(input_cleaned, c8(), 3);
}
// mln::io::pbm::save(input_cleaned, "input_denoised.pbm");
......@@ -273,13 +277,14 @@ int main(int argc, char* argv[])
scribo::make::debug_filename("step2_looks_like_a_text_line.ppm"));
// Bboxes image.
scribo::debug::save_bboxes_image(input, lines, argv[2]);
scribo::debug::save_bboxes_image(input, lines,
scribo::make::debug_filename("step2_bboxes.ppm"));
//===== END OF DEBUG =====
scribo::text::recognition(lines, "fra", "out.txt");
scribo::text::recognition(lines, "fra", argv[2]);
// // Display median character space.
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment