Olena-patches
Threads by month
- ----- 2025 -----
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- 9625 discussions

last-svn-commit-20-gd8a9be8 Experiment variation on regional maxima labeling.
by Guillaume Lazzara 15 Nov '10
by Guillaume Lazzara 15 Nov '10
15 Nov '10
* green/demo/labeling/regional_maxima/regional_maxima.cc
(demo_17_12_2009): New function that describes the experimentation.
---
milena/sandbox/ChangeLog | 7 +
.../labeling/regional_maxima/regional_maxima.cc | 702 ++++++++++----------
2 files changed, 367 insertions(+), 342 deletions(-)
diff --git a/milena/sandbox/ChangeLog b/milena/sandbox/ChangeLog
index 3a7ffb7..8a92218 100644
--- a/milena/sandbox/ChangeLog
+++ b/milena/sandbox/ChangeLog
@@ -1,3 +1,10 @@
+2009-12-23 Yann Jacquelet <jacquelet(a)lrde.epita.fr>
+
+ Experiment variation on regional maxima labeling.
+
+ * green/demo/labeling/regional_maxima/regional_maxima.cc
+ (demo_17_12_2009): New function that describes the experimentation.
+
2009-12-18 Yann Jacquelet<jacquelet(a)lrde.epita.fr>
Fix the right behaviour of the regmax software.
diff --git a/milena/sandbox/green/demo/labeling/regional_maxima/regional_maxima.cc b/milena/sandbox/green/demo/labeling/regional_maxima/regional_maxima.cc
index 65b6608..566c698 100644
--- a/milena/sandbox/green/demo/labeling/regional_maxima/regional_maxima.cc
+++ b/milena/sandbox/green/demo/labeling/regional_maxima/regional_maxima.cc
@@ -2,6 +2,7 @@
#include <iostream>
#include <sstream>
+#include <fstream>
#include <boost/format.hpp>
#include <mln/img_path.hh>
@@ -144,182 +145,6 @@ unsigned unquant(const float& value)
return result;
}
-template <unsigned n>
-void print_count2(const mln::image2d<mln::value::rgb<n> >& input_rgbn,
- const mln::image3d<unsigned>& histo,
- const mln::image3d<mln::value::label_8>& label,
- const unsigned n_labels)
-{
- typedef mln::value::label_8 t_lbl8;
- typedef mln::value::rgb<n> t_rgbn;
- typedef mln::value::int_u<n> t_int_un;
- typedef mln::algebra::vec<3,float> t_vec3f;
- typedef mln::accu::math::sum<unsigned,unsigned> t_sum;
- typedef mln::accu::stat::mean<t_vec3f,t_vec3f,t_vec3f> t_mean;
- typedef mln::accu::math::sum<t_vec3f,t_vec3f> t_diff;
- typedef mln::accu::stat::variance<float,float,float> t_var;
- typedef mln::image2d<t_lbl8> t_image2d_lbl8;
- typedef mln::image2d<t_rgbn> t_image2d_rgbn;
- typedef mln::image2d<t_int_un> t_image2d_int_un;
-
- mln::util::array<t_mean> mean((unsigned)(n_labels)+1);
-// mln::util::array<t_diff> diff((unsigned)(n_labels)+1);
- mln::util::array<t_var> var_red((unsigned)(n_labels)+1);
- mln::util::array<t_var> var_green((unsigned)(n_labels)+1);
- mln::util::array<t_var> var_blue((unsigned)(n_labels)+1);
- mln::util::array<t_sum> count((unsigned)(n_labels)+1);
- mln::util::array<float> abs((unsigned)(n_labels)+1);
- mln::util::array<float> rel((unsigned)(n_labels)+1);
- unsigned nb = 0;
-
- for (unsigned i = 0; i <= n_labels; ++i)
- {
- count(i).init();
- mean(i).init();
-// diff(i).init();
- var_red(i).init();
- var_green(i).init();
- var_blue(i).init();
- abs[i] = 0.0;
- rel[i] = 0.0;
- }
-
- mln::labeling::compute(count, histo, label, n_labels);
-
- for (unsigned i = 0; i <= n_labels; ++i)
- {
- unsigned c = count[i];
- nb += c;
- }
-
- for (unsigned i = 0; i <= n_labels; ++i)
- if (0 < count[i])
- {
- abs[i] = ((float)count[i] / nb)*100.0;
- rel[i] = ((float)count[i] / (nb - count[0]))*100.0;
- }
-
- t_image2d_lbl8 label_img = mln::data::transform(input_rgbn,
- t_labeling_rgbn<n>(label));
-
- mln::labeling::compute(mean, input_rgbn, label_img, n_labels);
-
-
-// t_image2d_rgbn mean_rgbn = mln::labeling::mean_values(input_rgbn,
-// label_img,
-// n_labels);
-
-// t_image2d_int_un mean_red =mln::data::transform(mean_rgbn,t_channel<n>());
-// t_image2d_int_un mean_green=mln::data::transform(mean_rgbn,t_channel<n>());
-// t_image2d_int_un mean_blue =mln::data::transform(mean_rgbn,t_channel<n>());
-
- t_image2d_int_un input_red =mln::data::transform(input_rgbn,
- t_channel<n,0>());
- t_image2d_int_un input_green=mln::data::transform(input_rgbn,
- t_channel<n,1>());
- t_image2d_int_un input_blue =mln::data::transform(input_rgbn,
- t_channel<n,2>());
-
-// FIXME VARIANCE NEGATIVE DANS LES RESULTATS !!
-
-// mln::labeling::compute(var_red, input_rgbn, label_img, n_labels);
-// mln::labeling::compute(var_green, input_rgbn, label_img, n_labels);
-// mln::labeling::compute(var_blue, input_rgbn, label_img, n_labels);
-
-// t_image2d_rgbn diff_rgbn = mln::arith::diff_abs(input_rgbn, mean_rgbn);
-
- std::cout << mln::labeling::compute(var_red, input_red, label_img, n_labels)(29) << std::endl;
-// mln::labeling::compute(t_var(), input_red, label_img, n_labels);
- mln::labeling::compute(var_green, input_green, label_img, n_labels);
- mln::labeling::compute(var_blue, input_blue, label_img, n_labels);
-
- for (unsigned i = 0; i <= n_labels; ++i)
- {
- if (5.0 < abs[i] && 10.0 < rel[i])
- {
- const t_vec3f& mean_v = mean[i];
-// const t_vec3f& diff_v = diff[i];
-
- std::cout << i << " :[" << unquant<n>(mean_v[0])
-// << "(" << diff_v[0]
- << "(" << var_red[i]
- << ")," << unquant<n>(mean_v[1])
-// << "(" << diff_v[1]
- << "(" << var_green[i]
- << ")," << unquant<n>(mean_v[2])
-// << "(" << diff_v[2]
- << "(" << var_blue[i]
- << ")]- " << count[i]
- << " - " << abs[i]
- << " - " << rel[i]
- << std::endl;
- }
- }
-}
-
-
-void print_count(const mln::image3d<unsigned>& histo,
- const mln::image3d<mln::value::label_8>& label,
- const unsigned n_labels)
-{
- unsigned count[255];
- unsigned red[255];
- unsigned green[255];
- unsigned blue[255];
- unsigned nb = 0;
- unsigned tmp = 0;
-
- for (unsigned i = 0; i <= n_labels; ++i)
- {
- count[i] = 0;
- red[i] = 0;
- green[i] = 0;
- blue[i] = 0;
- }
-
- mln_piter_(mln::image3d<unsigned>) p(histo.domain());
-
- for_all(p)
- {
- count[label(p)] += histo(p);
- red[label(p)] += histo(p) * p.row();
- green[label(p)] += histo(p) * p.col();
- blue[label(p)] += histo(p) * p.sli();
- nb += histo(p);
- ++tmp;
- }
-
- std::cout << std::endl;
-
- std::cout << "nb : " << nb << std::endl;
- std::cout << "tmp : " << tmp << std::endl;
-
- std::cout << std::endl;
-
- for (unsigned i = 0; i <= n_labels; ++i)
- if (0 < count[i])
- {
- float percentage_abs = ((float)count[i] / nb)*100.0;
- float percentage_rel = ((float)count[i] / (nb - count[0]))*100.0;
-
- red[i] = red[i] / count[i];
- green[i] = green[i] / count[i];
- blue[i] = blue[i] / count[i];
-
- std::cout << "count[" << i << "]("
- << red[i] << ", " << green[i] << ", "
- << blue[i] << ") = " << count[i] << "("
- << percentage_abs << "%)";
-
- if (0 < i)
- std::cout << "[" << percentage_rel << "%]";
-
- std::cout << std::endl;
- }
-
- std::cout << std::endl;
-}
-
// Version optimisée de merge
template <unsigned n>
@@ -354,111 +179,98 @@ struct t_merge_lbl8_with_rgbn : mln::Function_v2v< t_merge_lbl8_with_rgbn<n> >
}
};
-// version non optimisée de merge
-template <unsigned n>
-mln::image2d< mln::value::rgb<n> >
-merge(const mln::image2d< mln::value::rgb<n> >& input,
- const mln::image3d< mln::value::label_8 >& label)
-{
- mln::image2d<mln::value::rgb<n> > output;
- mln::initialize(output, input);
- // mln::data::fill(output, mln::literal::green);
+void compute_stats(const mln::image2d<mln::value::rgb8>& i_input_rgb8,
+ const mln::image2d<mln::value::label_8>& l_input_lbl8,
+ const mln::image3d<unsigned>& h_histo_rgbn,
+ const mln::image3d<mln::value::label_8>& l_histo_lbl8,
+ const mln::value::label_8& n_labels,
+ const std::string& log)
+{
+ typedef mln::algebra::vec<3,float> t_vec3f;
+ typedef mln::accu::math::sum<unsigned,unsigned> t_sum;
+ typedef mln::accu::stat::mean<t_vec3f,t_vec3f,t_vec3f> t_mean;
+ typedef mln::util::array<unsigned> t_count_array;
+ typedef mln::util::array<t_vec3f> t_mean_array;
- mln_piter(mln::image2d< mln::value::rgb<n> >) pi(input.domain());
- mln_piter(mln::image2d< mln::value::rgb<n> >) po(output.domain());
+ mln::util::array<float> abs((unsigned)(n_labels)+1);
+ mln::util::array<float> rel((unsigned)(n_labels)+1);
+ unsigned nb = 0;
- for_all_2(pi, po)
+ for (unsigned i = 0; i <= n_labels; ++i)
{
- const mln::value::rgb<n>& vi = input(pi);
- mln::value::rgb<n>& vo = output(po);
-
- if (0 < mln::opt::at(label,vi.blue(),vi.red(),vi.green()))
- {
- vo.red() = vi.red();
- vo.green() = vi.green();
- vo.blue() = vi.blue();
- }
- else
- vo = mln::literal::black;
+ abs[i] = 0.0;
+ rel[i] = 0.0;
}
- return output;
-}
-
-
-//
-// Theo regional maxima image processing chain.
-//
-
-// FIXME C'est la dilatation qui fait apparaître des classes < min_volume.
-// Une couleur se dilate au détriment du fond et des autres couleurs.
-
-int main2()
-{
- const unsigned min_volume = 1000;
- //const std::string& image = OLENA_IMG_PATH"/fly.ppm";
- const std::string& image = SCRIBO_PPM_IMG_PATH"/mp00082c_50p.ppm";
- //const std::string& image = OLENA_IMG_PATH"/tiny.ppm";
-
- typedef mln::value::label_8 t_lbl8;
- typedef mln::value::rgb8 t_rgb8;
- typedef mln::value::rgb<5> t_rgb5;
- typedef mln::image2d<t_rgb8> t_image2d_rgb8;
- typedef mln::image2d<t_rgb5> t_image2d_rgb5;
- typedef mln::image3d<t_lbl8> t_image3d_lbl8;
- typedef mln::image3d<unsigned> t_image3d_unsigned;
- typedef mln::fun::v2v::rgb8_to_rgbn<5> t_rgb8_to_rgb5;
- typedef mln::accu::meta::stat::histo3d_rgb t_histo3d_fun;
- typedef mln::accu::math::sum<unsigned,unsigned> t_sum;
-
- mln::util::timer timer;
-
- // START IMAGE PROCESSING CHAIN
- timer.start();
-
- t_image2d_rgb8 input_rgb8;
- t_image2d_rgb5 input_rgb5;
- t_image3d_unsigned histo;
- t_image3d_unsigned opened;
- t_image3d_lbl8 label;
- t_image3d_lbl8 dilated;
- t_lbl8 n_labels;
-
-
- mln::io::ppm::load(input_rgb8, image.c_str());
- input_rgb5 = mln::data::transform(input_rgb8, t_rgb8_to_rgb5());
- histo = mln::data::compute(t_histo3d_fun(), input_rgb5);
- opened = mln::morpho::opening::volume(histo, mln::c6(), min_volume);
- label = mln::labeling::regional_maxima(opened, mln::c6(), n_labels);
- dilated = mln::morpho::elementary::dilation(label, mln::c26());
+ // COMPUTE THE SUM
+ t_count_array count = mln::labeling::compute(t_sum(),
+ h_histo_rgbn,
+ l_histo_lbl8,
+ n_labels);
- mln::util::array<t_sum> length((unsigned)(n_labels)+1);
+ // COMPUTE THE TOTAL
+ for (unsigned i = 0; i <= n_labels; ++i)
+ {
+ unsigned c = count[i];
+ nb += c;
+ }
+ // COMPUTE THE PERCENTAGES
for (unsigned i = 0; i <= n_labels; ++i)
- length(i).init();
+ if (0 < count[i])
+ {
+ abs[i] = ((float)count[i] / nb)*100.0;
+ rel[i] = ((float)count[i] / (nb - count[0]))*100.0;
+ }
- mln::labeling::compute(length, histo, dilated, n_labels);
+ // COMPUTE THE MEAN
+
+ t_mean_array mean = mln::labeling::compute(t_mean(),
+ i_input_rgb8,
+ l_input_lbl8,
+ n_labels);
- timer.stop();
- // STOP IMAGE PROCESSING CHAIN
+ // CORRECT 0 LABEL STATS
+ rel[0] = 0;
+ mean[0][0] = 255.0;
+ mean[0][1] = 255.0;
+ mean[0][2] = 0.0;
- std::cout << "Done in " << timer.read() << " ms" << std::endl;
- std::cout << "n_labels : " << n_labels << std::endl;
+ // PRINT STATS
+ std::ofstream log_stream(log.c_str());
for (unsigned i = 0; i <= n_labels; ++i)
{
- std::cout << "count[" << i << "] = " << length[i] << std::endl;
- }
-
- print_count(histo,label,n_labels);
+ const t_vec3f& mean_v = mean[i];
- //mln::io::plot::save_image_sh(histo, "histo.sh");
- //mln::io::plot::save_image_sh(histo, "opened.sh");
- //mln::io::plot::save_image_sh(label, "label.sh");
+ log_stream << boost::format("%2i|"
+ "r = %6.2f, g = %6.2f, b = %6.2f |"
+ "c = %7i, %%i = %5.2f, %%c = %5.2f")
+ % i
+ % mean_v[0]
+ % mean_v[1]
+ % mean_v[2]
+ % count[i]
+ % abs[i]
+ % rel[i]
+ << std::endl;
+ /*
+ std::cout << i << "|("
+ << "r = " << unquant<n>(mean_v[0]) << ", "
+ << "g = " << unquant<n>(mean_v[1]) << ", "
+ << "b = " << unquant<n>(mean_v[2]) << ")|("
+ << "c = " << count[i] << ", "
+ << "%i= " << abs[i] << "%, "
+ << "%c= " << rel[i] << "%)"
+ << std::endl;
+ */
+ }
- return 0;
+ log_stream << std::endl << std::endl;
+ log_stream.flush();
+ log_stream.close();
}
void compute_stats(const mln::image2d<mln::value::rgb8>& i_input_rgb8,
@@ -546,7 +358,6 @@ void compute_stats(const mln::image2d<mln::value::rgb8>& i_input_rgb8,
}
std::cout << std::endl << std::endl;
-
}
void save_histo(const mln::image2d<mln::value::rgb8>& input_rgb8,
@@ -565,7 +376,7 @@ void save_histo(const mln::image2d<mln::value::rgb8>& input_rgb8,
// n < 8, n is the degree of quantification
template <unsigned n>
-void demo(const std::string& image, const unsigned min_vol)
+void demo_17_12_2009(const std::string& image, const unsigned min_vol)
{
typedef mln::value::label_8 t_lbl8;
typedef mln::value::int_u8 t_int_u8;
@@ -622,8 +433,6 @@ void demo(const std::string& image, const unsigned min_vol)
// END OF IMAGE PROCESSING CHAIN
-// i2_mean = mln::data::transform(l0_input,t_mean_lbl8_with_rgb8(mean_array));
-
// BEGIN DUMPING
save_histo(i0_input, "h0_input.pgm");
@@ -683,69 +492,235 @@ void demo(const std::string& image, const unsigned min_vol)
save_histo(i5_mean, "h5_mean.pgm");
save_histo(i5_merge, "h5_merge.pgm");
// END DUMPING
+}
-/*
- std::ostringstream name;
- std::ostringstream name2;
- std::ostringstream name3;
-
- name << "input_rgb" << n << ".ppm";
- name2 << "output_rgb" << n << ".ppm";
- name3 << "label_img" << n << ".pgm";
-
- std::cout << "Labels : " << n_labels << std::endl;
- std::cout << "Name : " << name.str() << std::endl;
-
-// mln::io::ppm::save(input_rgbn, name.str());
-
- std::cout << "timer2 : " << timer2.read() << std::endl;
- output_rgbn = mln::data::transform(input_rgbn,
- t_merge_lbl8_with_rgbn<n>(label));
- // output_rgbn = merge<n>(input_rgbn, dilated);
- mln::io::ppm::save(output_rgbn, name2.str());
-
- label_img = mln::data::transform(input_rgbn,
- t_labeling_rgbn<n>(label));
- // label_img = label_image<n>(input_rgbn, dilated);
- mln::io::pgm::save(label_img, name3.str());
-*/
-
- // localiser les couleurs sur l'image (fond en black, le reste)
-
- // La dilatation englobe beaucoup plus de couleur, mais celles-ci ne
- // sont pas forcément présentes dans l'image. Du coup, les classes ne
- // bougent pas démeusurément.
-
-// mln::io::ppm::save(input_rgb5, "input_rgb5.ppm");
-// mln::io::plot::save_image_sh(input_rgb8, "input_rgb8.sh");
-// mln::io::plot::save_image_sh(input_rgb5, "input_rgb5.sh");
-// projected = mln::display::display_histo3d_unsigned(histo);
-// mln::io::pgm::save(projected, "histo.pgm");
-// mln::io::plot::save_image_sh(histo, "histo.sh");
-// mln::io::plot::save_image_sh(opened, "opened.sh");
-// filtered = mln::display::display_histo3d_unsigned(opened);
-// mln::io::pgm::save(filtered, "filtered.pgm");
-// mln::io::plot::save_image_sh(label, "label.sh");
- // mln::io::plot::save_image_sh(dilated, "dilated.sh");
-
- /*
- // OUTPUT PHASE
- std::cout << "Output phase ..." << std::endl;
- output_rgb5 = merge(input_rgb5, dilated);
- //mln::io::ppm::save(output_rgb5, "output_rgb5.ppm");
- mln::io::plot::save_image_sh(output_rgb5, "output_rgb5.sh");
-
-
- // LABELING IMG OUTPUT
- std::cout << "Labeling img output phase ..." << std::endl;
- label_img = label_image(input_rgb5, dilated);
- mln::io::pgm::save(label_img, "label_img.pgm");
-
- // BUILDING MEAN VALUES
- std::cout << "Building mean values phase ..." << std::endl;
- mean_rgb5 = mln::labeling::mean_values(input_rgb5, label_img, n_labels);
- mln::io::ppm::save(mean_rgb5, "mean.ppm");
- */
+// n < 8, n is the degree of quantification
+template <unsigned n>
+void demo_21_12_2009(const std::string& image, const unsigned min_vol)
+{
+ typedef mln::value::label_8 t_lbl8;
+ typedef mln::value::int_u8 t_int_u8;
+ typedef mln::value::rgb8 t_rgb8;
+ typedef mln::value::rgb<n> t_rgbn;
+ typedef mln::image3d<t_lbl8> t_image3d_lbl8;
+ typedef mln::image2d<t_lbl8> t_image2d_lbl8;
+ typedef mln::image2d<t_rgb8> t_image2d_rgb8;
+ typedef mln::image2d<t_rgbn> t_image2d_rgbn;
+ typedef mln::image2d<t_int_u8> t_image2d_int_u8;
+ typedef mln::image3d<unsigned> t_histo3d;
+ typedef mln::image2d<unsigned> t_histo2d;
+ typedef mln::fun::v2v::rgb8_to_rgbn<n> t_rgb8_to_rgbn;
+ typedef mln::accu::meta::stat::histo3d_rgb t_histo3d_fun;
+
+ // START OF IMAGE PROCESSING CHAIN
+ t_image2d_rgb8 i0_input; // input rgb8
+ t_histo3d h0_input; // histo input
+
+ t_image2d_rgbn i1_input; // input rgbn
+ t_histo3d h1_input; // histo input
+
+ t_histo3d h2_input; // histo opened
+ t_image3d_lbl8 l2_histo; // label histo
+ t_image2d_lbl8 l2_input; // label image
+ t_image2d_rgb8 i2_merge; // merge label
+ t_image2d_rgb8 i2_mean; // mean label
+
+ t_image3d_lbl8 l5_histo; // label iz 2
+ t_image2d_lbl8 l5_input; // label image
+ t_image2d_rgb8 i5_merge; // merge label
+ t_image2d_rgb8 i5_mean; // mean label
+
+ t_lbl8 n_lbl; // nb class
+
+ mln::io::ppm::load(i0_input, image.c_str());
+ i1_input = mln::data::transform(i0_input, t_rgb8_to_rgbn());
+ h1_input = mln::data::compute(t_histo3d_fun(), i1_input);
+ h2_input = mln::morpho::opening::volume(h1_input, mln::c6(), min_vol);
+ l2_histo = mln::labeling::regional_maxima(h2_input, mln::c6(), n_lbl);
+ l5_histo = mln::transform::influence_zone_geodesic(l2_histo, mln::c26(), 2);
+ // END OF IMAGE PROCESSING CHAIN
+
+ // BEGIN DUMPING
+ save_histo(i0_input, "h0_input.pgm");
+
+ // without nothing
+ l2_input = mln::data::transform(i1_input, t_labeling_rgbn<n>(l2_histo));
+ i2_mean = mln::labeling::mean_values(i0_input, l2_input, n_lbl);
+ i2_merge = mln::data::transform(i0_input,t_merge_lbl8_with_rgbn<n>(l2_histo));
+
+ compute_stats(i0_input, l2_input, h1_input, l2_histo, n_lbl);
+
+ mln::io::pgm::save(l2_input, "l2_input.pgm");
+ mln::io::ppm::save(i2_mean, "i2_mean.ppm");
+ mln::io::ppm::save(i2_merge, "i2_merge.ppm");
+
+ save_histo(i2_mean, "h2_mean.pgm");
+ save_histo(i2_merge, "h2_merge.pgm");
+
+ // with restricted geodesic influence
+ l5_input = mln::data::transform(i1_input, t_labeling_rgbn<n>(l5_histo));
+ i5_mean = mln::labeling::mean_values(i0_input, l5_input, n_lbl);
+ i5_merge = mln::data::transform(i0_input,t_merge_lbl8_with_rgbn<n>(l5_histo));
+
+ compute_stats(i0_input, l5_input, h1_input, l5_histo, n_lbl);
+
+ mln::io::pgm::save(l5_input, "l5_input.pgm");
+ mln::io::ppm::save(i5_mean, "i5_mean.ppm");
+ mln::io::ppm::save(i5_merge, "i5_merge.ppm");
+
+ save_histo(i5_mean, "h5_mean.pgm");
+ save_histo(i5_merge, "h5_merge.pgm");
+ // END DUMPING
+}
+
+
+// EXE THEO
+// a.out input.ppm q v output.ppm [log.txt]
+// input.ppm ==> l'image 8 bits couleur format ppm
+// q ==> la quantification [2,3,4,5,6,7,8]
+// v ==> l'effectif minimal de chaque classe [0 = pas de filtrage]
+// output.ppm ==> l'image où l'étiquette est remplacée par la couleur moyenne
+// log.txt ==> le fichier de statistiques [optionnel]
+
+// n < 8, n is the degree of quantification
+template <unsigned n>
+void exe_theo_22_12_2009(const std::string& input,
+ const unsigned min_vol,
+ const std::string& output,
+ const std::string& log)
+{
+ typedef mln::value::label_8 t_lbl8;
+ typedef mln::value::int_u8 t_int_u8;
+ typedef mln::value::rgb8 t_rgb8;
+ typedef mln::value::rgb<n> t_rgbn;
+ typedef mln::image3d<t_lbl8> t_image3d_lbl8;
+ typedef mln::image2d<t_lbl8> t_image2d_lbl8;
+ typedef mln::image2d<t_rgb8> t_image2d_rgb8;
+ typedef mln::image2d<t_rgbn> t_image2d_rgbn;
+ typedef mln::image2d<t_int_u8> t_image2d_int_u8;
+ typedef mln::image3d<unsigned> t_histo3d;
+ typedef mln::image2d<unsigned> t_histo2d;
+ typedef mln::fun::v2v::rgb8_to_rgbn<n> t_rgb8_to_rgbn;
+ typedef mln::accu::meta::stat::histo3d_rgb t_histo3d_fun;
+
+ // START OF IMAGE PROCESSING CHAIN
+ t_image2d_rgb8 i0_input; // input rgb8
+ t_histo3d h0_input; // histo input
+
+ t_image2d_rgbn i1_input; // input rgbn
+ t_histo3d h1_input; // histo input
+
+ t_histo3d h2_input; // histo opened
+ t_image3d_lbl8 l2_histo; // label histo
+
+ t_image3d_lbl8 l4_histo; // label iz
+ t_image2d_lbl8 l4_input; // label image
+ t_image2d_rgb8 i4_merge; // merge label
+ t_image2d_rgb8 i4_mean; // mean label
+
+ t_lbl8 n_lbl; // nb class
+
+ mln::io::ppm::load(i0_input, input.c_str());
+ i1_input = mln::data::transform(i0_input, t_rgb8_to_rgbn());
+ h1_input = mln::data::compute(t_histo3d_fun(), i1_input);
+
+ if (0 < min_vol)
+ h2_input = mln::morpho::opening::volume(h1_input, mln::c6(), min_vol);
+ else
+ h2_input = h1_input; // no filtering
+
+ l2_histo = mln::labeling::regional_maxima(h2_input, mln::c6(), n_lbl);
+ l4_histo = mln::transform::influence_zone_geodesic(l2_histo, mln::c26());
+ // END OF IMAGE PROCESSING CHAIN
+
+ // BEGIN DUMPING
+ l4_input = mln::data::transform(i1_input, t_labeling_rgbn<n>(l4_histo));
+ i4_mean = mln::labeling::mean_values(i0_input, l4_input, n_lbl);
+
+ if (0 < log.size())
+ compute_stats(i0_input, l4_input, h1_input, l4_histo, n_lbl, log);
+
+ mln::io::ppm::save(i4_mean, output.c_str());
+ // END DUMPING
+}
+
+// n < 8, n is the degree of quantification
+template <unsigned n>
+void demo_22_12_2009(const std::string& image, const unsigned min_vol)
+{
+ typedef mln::value::label_8 t_lbl8;
+ typedef mln::value::int_u8 t_int_u8;
+ typedef mln::value::rgb8 t_rgb8;
+ typedef mln::value::rgb<n> t_rgbn;
+ typedef mln::image3d<t_lbl8> t_image3d_lbl8;
+ typedef mln::image2d<t_lbl8> t_image2d_lbl8;
+ typedef mln::image2d<t_rgb8> t_image2d_rgb8;
+ typedef mln::image2d<t_rgbn> t_image2d_rgbn;
+ typedef mln::image2d<t_int_u8> t_image2d_int_u8;
+ typedef mln::image3d<unsigned> t_histo3d;
+ typedef mln::image2d<unsigned> t_histo2d;
+ typedef mln::fun::v2v::rgb8_to_rgbn<n> t_rgb8_to_rgbn;
+ typedef mln::accu::meta::stat::histo3d_rgb t_histo3d_fun;
+
+ // START OF IMAGE PROCESSING CHAIN
+ t_image2d_rgb8 i0_input; // input rgb8
+ t_histo3d h0_input; // histo input
+
+ t_image2d_rgbn i1_input; // input rgbn
+ t_histo3d h1_input; // histo input
+
+ t_histo3d h2_input; // histo opened
+ t_image3d_lbl8 l2_histo; // label histo
+ t_image2d_lbl8 l2_input; // label image
+ t_image2d_rgb8 i2_merge; // merge label
+ t_image2d_rgb8 i2_mean; // mean label
+
+ t_image3d_lbl8 l5_histo; // label iz 2
+ t_image2d_lbl8 l5_input; // label image
+ t_image2d_rgb8 i5_merge; // merge label
+ t_image2d_rgb8 i5_mean; // mean label
+
+ t_lbl8 n_lbl; // nb class
+
+ mln::io::ppm::load(i0_input, image.c_str());
+ i1_input = mln::data::transform(i0_input, t_rgb8_to_rgbn());
+ h1_input = mln::data::compute(t_histo3d_fun(), i1_input);
+ h2_input = mln::morpho::opening::volume(h1_input, mln::c6(), min_vol);
+ l2_histo = mln::labeling::regional_maxima(h2_input, mln::c6(), n_lbl);
+ l5_histo = mln::transform::influence_zone_geodesic(l2_histo, mln::c26(), 2);
+ // END OF IMAGE PROCESSING CHAIN
+
+ // BEGIN DUMPING
+ save_histo(i0_input, "h0_input.pgm");
+
+ // without nothing
+ l2_input = mln::data::transform(i1_input, t_labeling_rgbn<n>(l2_histo));
+ i2_mean = mln::labeling::mean_values(i0_input, l2_input, n_lbl);
+ i2_merge = mln::data::transform(i0_input,t_merge_lbl8_with_rgbn<n>(l2_histo));
+
+ compute_stats(i0_input, l2_input, h1_input, l2_histo, n_lbl);
+
+ mln::io::pgm::save(l2_input, "l2_input.pgm");
+ mln::io::ppm::save(i2_mean, "i2_mean.ppm");
+ mln::io::ppm::save(i2_merge, "i2_merge.ppm");
+
+ save_histo(i2_mean, "h2_mean.pgm");
+ save_histo(i2_merge, "h2_merge.pgm");
+
+ // with restricted geodesic influence
+ l5_input = mln::data::transform(i1_input, t_labeling_rgbn<n>(l5_histo));
+ i5_mean = mln::labeling::mean_values(i0_input, l5_input, n_lbl);
+ i5_merge = mln::data::transform(i0_input,t_merge_lbl8_with_rgbn<n>(l5_histo));
+
+ compute_stats(i0_input, l5_input, h1_input, l5_histo, n_lbl);
+
+ mln::io::pgm::save(l5_input, "l5_input.pgm");
+ mln::io::ppm::save(i5_mean, "i5_mean.ppm");
+ mln::io::ppm::save(i5_merge, "i5_merge.ppm");
+
+ save_histo(i5_mean, "h5_mean.pgm");
+ save_histo(i5_merge, "h5_merge.pgm");
+ // END DUMPING
}
@@ -774,30 +749,73 @@ void usage()
// *
}
-int main(int argc, char* args[])
+void usage_exe_theo_22_12_2009()
{
- if (argc != 3)
+ std::cout << std::endl;
+ std::cout << "a.out input.ppm q v [log.txt]" << std::endl;
+ std::cout << "where" << std::endl;
+ std::cout << "input.ppm is the 8 bits color ppm image" << std::endl;
+ std::cout << "q is the degree of quanification {2,3,4,5,6,7,8}" << std::endl;
+ std::cout << "v is the minimal size for the histogram classes" << std::endl;
+ std::cout << "log.txt is the statistical file for classes" << std::endl;
+ std::cout << std::endl;
+}
+
+int main_21_12_2009(int argc, char* args[])
+{
+ if (argc == 2)
{
// const std::string& image = OLENA_IMG_PATH"/fly.ppm";
const std::string& image = SCRIBO_PPM_IMG_PATH"/mp00082c_50p.ppm";
// const std::string& image = OLENA_IMG_PATH"/tiny.ppm";
// const std::string image = OLENA_IMG_PATH"/tiny.ppm";
- const unsigned min_volume = 1000;
- // const unsigned min_volume = atoi(args[2]);
+ // const unsigned min_volume = 1000;
+ const unsigned min_volume = atoi(args[1]);
- switch(args[2][0])
+// switch(args[1][0])
+ switch(5)
{
- case '2': demo<2>(image, min_volume); break;
- case '3': demo<3>(image, min_volume); break;
- case '4': demo<4>(image, min_volume); break;
- case '5': demo<5>(image, min_volume); break;
- case '6': demo<6>(image, min_volume); break;
- case '7': demo<7>(image, min_volume); break;
- case '8': demo<8>(image, min_volume); break;
- default: demo<5>(image, min_volume); break;
+ case '2': demo_21_12_2009<2>(image, min_volume); break;
+ case '3': demo_21_12_2009<3>(image, min_volume); break;
+ case '4': demo_21_12_2009<4>(image, min_volume); break;
+ case '5': demo_21_12_2009<5>(image, min_volume); break;
+ case '6': demo_21_12_2009<6>(image, min_volume); break;
+ case '7': demo_21_12_2009<7>(image, min_volume); break;
+ case '8': demo_21_12_2009<8>(image, min_volume); break;
+ default: demo_21_12_2009<5>(image, min_volume); break;
// default: usage(); break;
}
}
else
usage();
+
+ return 0;
+}
+
+int main(int argc, char* args[])
+{
+ if (5 == argc || 6 == argc)
+ {
+ const std::string input(args[1]);
+ const char q = args[2][0];
+ const unsigned v = atoi(args[3]);
+ const std::string output(args[4]);
+ const std::string log(6 == argc? args[5] : "");
+
+ switch(q)
+ {
+ case '2': exe_theo_22_12_2009<2>(input, v, output, log); break;
+ case '3': exe_theo_22_12_2009<3>(input, v, output, log); break;
+ case '4': exe_theo_22_12_2009<4>(input, v, output, log); break;
+ case '5': exe_theo_22_12_2009<5>(input, v, output, log); break;
+ case '6': exe_theo_22_12_2009<6>(input, v, output, log); break;
+ case '7': exe_theo_22_12_2009<7>(input, v, output, log); break;
+ case '8': exe_theo_22_12_2009<8>(input, v, output, log); break;
+ default: usage_exe_theo_22_12_2009(); break;
+ }
+ }
+ else
+ usage_exe_theo_22_12_2009();
+
+ return 0;
}
--
1.5.6.5
1
0

15 Nov '10
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Olena, a generic and efficient image processing platform".
The branch embed-libiberty has been updated
discards 03b9cbf2a4bcbc88cc07e3b1b2eef6adb8b800c2 (commit)
discards f921a73388e0145472fd2ef1a788940865a398ba (commit)
discards 6a4c5949ce3038a7b6d3fcc68e4b4a3e457cfc68 (commit)
discards 2a6d9c0fbd5f548a25dcfbcddaecc60fb8c69344 (commit)
discards d919f5832bc0ea4e69815721e90150be45da8670 (commit)
discards 39fc68ecfd97fc03fdb79a0b04bda05bc4fef28d (commit)
discards 8091ab545d88dbb9f32d8e43d701590aee789ed7 (commit)
discards da8a0abae64574c16a28000821e987d29dd1918c (commit)
discards 7db887d6e192dcf9c9835d85530bc1a7c96b0072 (commit)
discards 489eda8c8e46fe33c2cf92bda565a1db86d7747b (commit)
discards 72885505b3647af5a1412a5fb7cbe4a4640cb167 (commit)
discards 057eb205c8f1dadc40851f48395a5e3118df50a7 (commit)
discards dad02b15ec254743b1671cbdb31e634e6d3336db (commit)
discards 8629f8ff3e604e540fe0349dd0ce2a420b968633 (commit)
discards d175073d628a36f2aa9789220f3f4cb463647c82 (commit)
discards fc1f455d294243bcb7dcefd4cd2ad14691413e31 (commit)
discards 7d199c04616894eb113abb07594c5388ed11cff0 (commit)
discards eb3778a94c8aa0211ee47e532e539dbf832abbfc (commit)
via c23c47928224c69eeadc539f85400749495706a0 (commit)
via d3cd1aa0a318cd998d6da9a2c13e9c5831116ed6 (commit)
via 45f7112e908c9e32cf6a0f33ead120ff0c53b63f (commit)
via de87f38439ee6a1d61806244caf726a5c8e9d368 (commit)
via cf101e3de813d028e91b9224fc275d97bd6d73d7 (commit)
via c1521eb5c4e1e5d92a5ddeab2c1960a0a9bc5626 (commit)
via 85c3c299100259475187ef55822cbed60ec48ddf (commit)
via 3c6ea49295e43bbb51829774fa7528552ccf49c5 (commit)
via a534a0c2055445d4e9a5de82a3844f4019eff29d (commit)
via 39035156ae679b8fb412b3239846359623dd4581 (commit)
via ecf4b207cfe6a69cd2f951df7a0fa388623fc6ed (commit)
via 3dc3c53940a3b5635815b29fa65a3a77d1466d57 (commit)
via 9c195f901dd07a27e2cb4f2fb180e323e66a00e2 (commit)
via 5daaf29cc5e5cafdefc65b1f2fa1cc796c1efa62 (commit)
via a695fd417f604281ef94e5403030079035d9d76a (commit)
via 9fd487f8e7db3287d5d483dd1e834e7748f29c75 (commit)
via dce5b55bdcaa1e09232d5931884d6e69f0feb7b7 (commit)
via 5545f9c9a4e977c3b55f50f0bec8b7d5eea11aa0 (commit)
via 4d7c62bba7e1bc8e11fc4d05f502575eeac314b2 (commit)
This update added new revisions after undoing existing revisions. That is
to say, the old revision is not a strict subset of the new revision. This
situation occurs when you --force push a change and generate a repository
containing something like this:
* -- * -- B -- O -- O -- O (03b9cbf2a4bcbc88cc07e3b1b2eef6adb8b800c2)
\
N -- N -- N (c23c47928224c69eeadc539f85400749495706a0)
When this happens we assume that you've already had alert emails for all
of the O revisions, and so we here report only the revisions in the N
branch from the common base, B.
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
c23c479 Mention Libiberty in Extatica's AUTHORS, NEWS and README.
d3cd1aa Work around a defect in Libiberty's `configure.ac' (in Olena).
45f7112 Work around a defect in Libiberty's `configure.ac' (in Extatica).
de87f38 Fix the distribution of Libiberty.
cf101e3 Fix cleaning rules in Libiberty.
c1521eb Make Libiberty compatible with Automake.
85c3c29 Have Extatica use the embedded GNU Libiberty.
3c6ea49 Add extatica/libiberty/.gitignore.
a534a0c Tailor GNU Libiberty for Extatica.
3903515 Add GNU Libiberty files from CVS GNU Binutils.
-----------------------------------------------------------------------
Summary of changes:
extatica/ChangeLog | 20 +++++++++++++++-----
1 files changed, 15 insertions(+), 5 deletions(-)
hooks/post-receive
--
Olena, a generic and efficient image processing platform
1
0
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Olena, a generic and efficient image processing platform".
The branch extatica has been updated
discards 72885505b3647af5a1412a5fb7cbe4a4640cb167 (commit)
discards 057eb205c8f1dadc40851f48395a5e3118df50a7 (commit)
discards dad02b15ec254743b1671cbdb31e634e6d3336db (commit)
discards 8629f8ff3e604e540fe0349dd0ce2a420b968633 (commit)
discards d175073d628a36f2aa9789220f3f4cb463647c82 (commit)
discards fc1f455d294243bcb7dcefd4cd2ad14691413e31 (commit)
discards 7d199c04616894eb113abb07594c5388ed11cff0 (commit)
discards eb3778a94c8aa0211ee47e532e539dbf832abbfc (commit)
via ecf4b207cfe6a69cd2f951df7a0fa388623fc6ed (commit)
via 3dc3c53940a3b5635815b29fa65a3a77d1466d57 (commit)
via 9c195f901dd07a27e2cb4f2fb180e323e66a00e2 (commit)
via 5daaf29cc5e5cafdefc65b1f2fa1cc796c1efa62 (commit)
via a695fd417f604281ef94e5403030079035d9d76a (commit)
via 9fd487f8e7db3287d5d483dd1e834e7748f29c75 (commit)
via dce5b55bdcaa1e09232d5931884d6e69f0feb7b7 (commit)
via 5545f9c9a4e977c3b55f50f0bec8b7d5eea11aa0 (commit)
via 4d7c62bba7e1bc8e11fc4d05f502575eeac314b2 (commit)
This update added new revisions after undoing existing revisions. That is
to say, the old revision is not a strict subset of the new revision. This
situation occurs when you --force push a change and generate a repository
containing something like this:
* -- * -- B -- O -- O -- O (72885505b3647af5a1412a5fb7cbe4a4640cb167)
\
N -- N -- N (ecf4b207cfe6a69cd2f951df7a0fa388623fc6ed)
When this happens we assume that you've already had alert emails for all
of the O revisions, and so we here report only the revisions in the N
branch from the common base, B.
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
ecf4b20 Update and augment Extatica's AUTHORS, NEWS and README.
3dc3c53 Replace shared Autoconf macros by symlinks in Extatica.
9c195f9 Bundle Extatica with Olena.
5daaf29 Prepare Extatica to be bundled with Olena.
a695fd4 Properly configure xtc-config.
9fd487f Cleanup and aesthetic changes.
dce5b55 Rename Dyn as Extatica within the project.
5545f9c Add support for configuration option `--with-milena' in Extatica.
4d7c62b Fix the distribution of Extatica.
-----------------------------------------------------------------------
Summary of changes:
extatica/AUTHORS | 17 ++-
extatica/ChangeLog | 9 +-
extatica/NEWS | 16 ++-
extatica/README | 345 ++++++++++++++++++++++++++++++++++++++++---
extatica/config/Makefile.am | 3 -
5 files changed, 359 insertions(+), 31 deletions(-)
hooks/post-receive
--
Olena, a generic and efficient image processing platform
1
0

last-svn-commit-555-gecf4b20 Update and augment Extatica's AUTHORS, NEWS and README.
by Roland Levillain 15 Nov '10
by Roland Levillain 15 Nov '10
15 Nov '10
* AUTHORS: Add details.
* NEWS: Update.
* README: Update and add instructions and information.
---
extatica/AUTHORS | 17 +++-
extatica/ChangeLog | 8 ++
extatica/NEWS | 16 ++-
extatica/README | 345 ++++++++++++++++++++++++++++++++++++++++++++++++----
4 files changed, 359 insertions(+), 27 deletions(-)
diff --git a/extatica/AUTHORS b/extatica/AUTHORS
index 98ed64d..cbae6fe 100644
--- a/extatica/AUTHORS
+++ b/extatica/AUTHORS
@@ -4,21 +4,36 @@ This package was written by and with the assistance of
Active LRDE Staff.
==================
+* Thierry Géraud theo(a)lrde.epita.fr
+ - Original idea and implementation.
+
* Roland Levillain roland(a)lrde.epita.fr
+ - Project maintainer.
+ - Revival of the `dynamic-use-of-static-c++' prototype.
+ - Integration of a third-party C++ implementation of the MD5 algorithm.
+ - Progressive conversion of Ruby parts into C++ code.
+ - Addition of a few wrappers around Milena.
+ - First experiments with SWIG and Python.
+ - Modernization of the package and renaming as ``Extatica''.
================================
Past contributors of LRDE Staff.
================================
* Alexandre Duret-Lutz adl(a)lrde.epita.fr
-* Thierry Géraud theo(a)lrde.epita.fr
+ - Original idea and implementation.
=========
Students.
=========
* Nicolas Pouillard
+ - Initial work on the `dynamic-use-of-static-c++' prototype
+ (dynamic-static bridge).
+
* Damien Thivolle
+ - Initial work on the `dynamic-use-of-static-c++' prototype
+ (dynamic-static bridge).
.. Local Variables:
diff --git a/extatica/ChangeLog b/extatica/ChangeLog
index 141c0b6..8a3a34e 100644
--- a/extatica/ChangeLog
+++ b/extatica/ChangeLog
@@ -1,3 +1,11 @@
+2010-11-09 Roland Levillain <roland(a)lrde.epita.fr>
+
+ Update and augment Extatica's AUTHORS, NEWS and README.
+
+ * AUTHORS: Add details.
+ * NEWS: Update.
+ * README: Update and add instructions and information.
+
2010-11-10 Roland Levillain <roland(a)lrde.epita.fr>
Prepare Extatica to be bundled with Olena.
diff --git a/extatica/NEWS b/extatica/NEWS
index 8eebf76..4066a0f 100644
--- a/extatica/NEWS
+++ b/extatica/NEWS
@@ -1,6 +1,18 @@
* Extatica 0.1a MONTH DAY, YEAR
- * Initial public release.
+ * First public release.
+
+ * Revival of the `dynamic-use-of-static-c++' prototype,
+ modernization of the infrastructure, and renaming as
+ ``Extatica''.
+
+ * Better handling of extra dependencies of the package: many
+ Ruby parts have been turned into C++ code; dependencies (MD5)
+ have been integrated into the project.
+
+ * First experiments with Milena: addition of a few wrappers
+ around Milena routines; first ``dynamic'' Python wrappers
+ over Milena using SWIG and Extatica.
Local Variables:
@@ -10,7 +22,7 @@ End:
----
-Copyright (C) 2010 EPITA Research and Development Laboratory (LRDE)
+Copyright (C) 2010 EPITA Research and Development Laboratory (LRDE).
This file is part of Olena.
diff --git a/extatica/README b/extatica/README
index 78ef1eb..34d76f2 100644
--- a/extatica/README
+++ b/extatica/README
@@ -1,31 +1,328 @@
-HOW TO USE THIS PROJECT
+Copyright (C) 2005, 2009, 2010 EPITA Research and Development
+Laboratory (LRDE).
- Note: These instructions have been updated since this project has
- been re-integrated into the Olena repository (October 2009).
- However, they will probably evolve again, since the project should
- eventually become a part of the Olena distribution. The biggest
- change will probably be to run things from the parent directory
- (Olena's) and enable a configure flag to activate this module.
+This file is part of Olena.
-From the repository:
+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.
- # Initialize the build system.
- ./bootstrap
+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.
- # Make a build dir.
- mkdir _build && cd _build
+You should have received a copy of the GNU General Public License
+along with Olena. If not, see <http://www.gnu.org/licenses/>.
- # Configure the build for your system.
- ../configure
+The complete GNU General Public License Notice can also be found in
+the 'COPYING' file in the root directory.
- # You can also use the file `config.site' shipped with the
- # distribution, though it is a bit old. `config.site' tries to use
- # more efficient tools (g++-4.0 and ccache). It also enables
- # configure's caching mechanism. With `--prefix' you can set the
- # destination (here, `../_install').
- CONFIG_SITE=`pwd`/../config.site ../configure --prefix=`pwd`/../_install
- # You may want to add the `bin/' directory to your path, but it is
- # no longer mandatory (`xtc-config' from `bin/' used to be required
- # by programs compiled with our system).
- export PATH=$PATH:`pwd`/bin
+========================
+Introduction to Extatica
+========================
+
+Extatica is a part of Olena_, a generic and efficient platform
+dedicated to image processing.
+
+.. _Olena: http://olena.lrde.epita.fr
+
+Extatica is a dynamic-static C++ bridge, enabling users to generate,
+compile and link C++ functions and methods at run time. Extatica
+features a simple yet powerful C++ Just-In-Time (JIT) compiling
+engine. A common use case is the execution of C++ template routines
+that are not already compiled.
+
+The name of project comes from the phrase ``ex static'' (from the
+static [world]); add the canonical `-a' suffix to make it Olena-ish,
+and you get Extatica.
+
+Extatica can be used to provide dynamic services over the C++
+front-end directly, or indirectly (e.g., through a SWIG-based
+wrapper). This way, other languages or environment can benefit from
+the power of C++ JIT compiling.
+
+Extatica is currently distributed as a standalone package, but like
+other Olena sub-projects, it will eventually come in two flavors: as a
+standalone package and as a component of the Olena meta-package.
+
+
+=====================
+Detailed Instructions
+=====================
+
+-----------------
+Required Software
+-----------------
+
+Here is a non-exhaustive list of required software required to build
+Extatica successfully.
+
+ * to compile the user examples:
+
+ - a POSIX shell, like Bash
+
+ - a decent C++ compiler, like GNU C++
+
+ - a `make' utility, like GNU `make'
+
+ - Ruby 1.8.6 or greater.
+
+ * if you want to build the SWIG Python bindings, you will also need:
+
+ - the Simplified Wrapper and Interface Generator (SWIG_).
+
+ - Python_
+
+.. _SWIG: http://www.swig.org
+
+.. _Python: http://www.python.org
+
+You also need a working Milena_ install (Milena is shipped with
+Olena).
+
+.. _Milena: http://olena.lrde.epita.fr
+
+
+-------------
+Configuration
+-------------
+
+In order to prepare the build process, you need to configure the source
+tree.
+
+ Assuming your Extatica distribution is uncompressed in directory
+`extatica-1.1', follow these steps:
+
+ % cd extatica-1.1
+ % mkdir _build
+ % cd _build
+ % ../configure
+
+ The build process can be altered by a number of options you can pass
+to the `configure' script. The following sections describe them.
+
+
+Milena path
+===========
+
+Extatica requires the Milena library. If Extatica's `configure' is
+unable to find your installation of Milena, or if you want to use a
+specific installation, you must help `configure' find it using the
+`--with-milena' flag. For instance, if you have installed Milena in
+`$HOME/local', replace the call to `configure' from the previous
+section by this command:
+
+ % ../configure --with-milena=$HOME/local
+
+GNU Libiberty
+=============
+
+Extatica depends on GNU Libiberty, which is part of GNU Binutils (and
+GCC). If `configure' cannot find Libiberty, you can pass the path to
+the library (usually named `libiberty.a') through `LDFLAGS', e.g.
+
+ % ../configure LDFLAGS="-L/opt/local/lib"
+
+Installation Path
+=================
+
+By default, Extatica is installed in the standard "local" directory of
+your system. This is usually `/usr/local' under Unix.
+
+ You can change this path with the following flag:
+
+ --prefix=<installation prefix>
+
+
+Compiler Selection and Compilation Flags
+========================================
+
+By default, `configure' will try to use the first C++ compiler it
+encounters on your system. If `CXX' is not set, it will look, in order,
+for:
+
+ - the value of the `CXX' environment variable,
+
+ - the GNU C++ compiler (`g++'),
+
+ - the `c++' or `gpp' commands on your system,
+
+ - `aCC', the HP-UX standard C++ compiler,
+
+ - the `CC', `cxx', `cc++' or `cl' commands on your system,
+
+ - KAI's C++ compiler (`KCC'),
+
+ - `RCC', `xlC_r' or `xlC'.
+
+ You can override the detection system by passing your favorite
+compiler name to `configure', as follows:
+
+ % ../configure CXX=<your-favorite-C++-compiler>
+
+ As an alternative, you can also set the environment variable `CXX'.
+
+
+ For some compilers (GNU g++ and Intel's icpc to some extent) ,
+`configure' will use default CXXFLAGS. You can override the default
+C++ flags by giving `configure' your selection of flags:
+
+ % ../configure CXXFLAGS="<your-favorite-C++-flags>"
+
+
+ Extatica uses some C components: likewise, you can set set the C
+compiler and the C compilation flags by setting `CC' and `CFLAGS'
+respectively:
+
+ % ../configure CC=<your-favorite-C-compiler>
+
+ % ../configure CFLAGS="<your-favorite-C-flags>"
+
+You can of course use all of these all together:
+
+ % ../configure CC="<C-compiler>" CFLAGS="<C-flags>" \
+ CXX="<C++-compiler>" CXXFLAGS="<C++-flags>"
+
+
+--------
+Building
+--------
+
+Once your build directory is `configure'd, you can run
+
+ % make
+
+to build Extatica.
+
+
+ Additionally, you can build and run the test suite with:
+
+ % make check
+
+However, this process is time- and memory- consuming, and you probably
+do not need it except if you are developing/debugging Extatica.
+
+
+----------
+Installing
+----------
+
+To install Extatica on your system, run:
+
+ % make install
+
+from the build directory.
+
+ If not overridden with `--prefix', this will install:
+
+ * the `xtc-config' script in `/usr/local/bin',
+
+ * Extatica headers in `/usr/local/include',
+
+ * Extatica libraries in `/usr/local/lib',
+
+ * Python bindings in `/usr/local/lib/python2.x/site-packages'.
+
+ * Extatica boilerplate code in `/usr/local/share/extatica'.
+
+
+ You can later remove Extatica from your system by running
+
+ % make uninstall
+
+from the build directory (if you have kept it). We recommend the use
+of GNU Stow (or any similar program) during the installation of Extatica,
+to make the uninstallation of Extatica easier.
+
+
+=====================
+Layout of the Tarball
+=====================
+
+The Extatica project directory layout is as follows:
+
+_config
+ Auxiliary tools used by the GNU Build System during ``configure``
+ and ``make`` stages.
+
+bin
+ Scripts used by the build system or Extatica.
+
+config
+ Extra Autoconf macros and generators.
+
+data
+ Extatica template used to generate wrappers.
+
+libltdl
+ Third-party library used to load dynamic modules.
+
+libmd5
+ Third-party library providing a C++ implementation of the MD5 algorithm.
+
+src
+ Code of libextatica.
+
+ wrappers
+ Code to generate wrappers around libraries (currently, Milena).
+
+swig
+
+ python
+ SWIG Python bindings.
+
+test
+ Extatica's test suite.
+
+
+===================
+Supported Platforms
+===================
+
+Extatica has been tested on the following configurations:
+
+=========================== =============================================
+System Compiler
+=========================== =============================================
+GNU/Linux on IA-32 g++ (GNU GCC) 4.4
+Mac OS X (10.6) on IA-32 g++ (GNU GCC) 4.2.1
+=========================== =============================================
+
+
+See Also
+========
+
+There are other sources of interest in the distribution.
+
+- Headline news about the project can be found in the file ``NEWS`` at
+ the root of the source tree.
+
+
+License
+=======
+
+Extatica is released under the GNU General Public License. See the file
+``COPYING`` (at the root of the source tree) for details.
+
+
+Contacts
+========
+
+The team can be reached by mail at olena(a)lrde.epita.fr. The snail
+mail address follows.
+
+* Olena - LRDE
+
+ | Laboratoire de Recherche et Développement de l'EPITA (LRDE)
+ | 14-16 rue Voltaire
+ | FR-94276 Le Kremlin-Bicêtre CEDEX
+ | France
+
+
+
+.. Local Variables:
+.. mode: rst
+.. ispell-local-dictionary: "american"
+.. End:
--
1.5.6.5
1
0

last-svn-commit-652-ga37cf92 src/content_in_doc.cc: New example extracting document content.
by Guillaume Lazzara 15 Nov '10
by Guillaume Lazzara 15 Nov '10
15 Nov '10
---
scribo/ChangeLog | 4 ++
scribo/src/Makefile.am | 15 +++++
.../src/{pbm_text_in_doc.cc => content_in_doc.cc} | 56 +++++++++++++-------
3 files changed, 56 insertions(+), 19 deletions(-)
copy scribo/src/{pbm_text_in_doc.cc => content_in_doc.cc} (74%)
diff --git a/scribo/ChangeLog b/scribo/ChangeLog
index 9400016..5ed918f 100644
--- a/scribo/ChangeLog
+++ b/scribo/ChangeLog
@@ -1,5 +1,9 @@
2010-11-15 Guillaume Lazzara <z(a)lrde.epita.fr>
+ * src/content_in_doc.cc: New example extracting document content.
+
+2010-11-15 Guillaume Lazzara <z(a)lrde.epita.fr>
+
* scribo/toolchain/text_in_doc.hh: Make use of non visible
separators information.
diff --git a/scribo/src/Makefile.am b/scribo/src/Makefile.am
index a2c72b2..cd7618c 100644
--- a/scribo/src/Makefile.am
+++ b/scribo/src/Makefile.am
@@ -85,6 +85,21 @@ if HAVE_TESSERACT
$(TIFF_LDFLAGS) \
$(MAGICKXX_LDFLAGS)
+
+ utilexec_PROGRAMS += content_in_doc
+ content_in_doc_SOURCES = content_in_doc.cc
+ content_in_doc_CPPFLAGS = $(AM_CPPFLAGS) \
+ -I/home/lazzara/git/oln/scribo/sandbox/green/ \
+ -I/home/lazzara/git/oln/scribo/sandbox/z/ \
+ $(TESSERACT_CPPFLAGS) \
+ $(TIFF_CPPFLAGS) \
+ $(MAGICKXX_CPPFLAGS)
+ content_in_doc_LDFLAGS = $(AM_LDFLAGS) \
+ $(TESSERACT_LDFLAGS) \
+ $(TIFF_LDFLAGS) \
+ $(MAGICKXX_LDFLAGS) \
+ -lpthread
+
endif HAVE_TESSERACT
endif HAVE_MAGICKXX
diff --git a/scribo/src/pbm_text_in_doc.cc b/scribo/src/content_in_doc.cc
similarity index 74%
copy from scribo/src/pbm_text_in_doc.cc
copy to scribo/src/content_in_doc.cc
index 23ed9e7..fe3eacf 100644
--- a/scribo/src/pbm_text_in_doc.cc
+++ b/scribo/src/content_in_doc.cc
@@ -1,5 +1,4 @@
-// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory
-// (LRDE)
+// Copyright (C) 2010 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -24,9 +23,6 @@
// exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
#include <libgen.h>
#include <fstream>
@@ -35,30 +31,42 @@
#include <mln/core/image/image2d.hh>
#include <mln/core/alias/neighb2d.hh>
-#include <mln/io/pbm/all.hh>
+#include <mln/io/pbm/save.hh>
+#include <mln/io/magick/load.hh>
+
+#include <mln/value/label_8.hh>
+
+#include <mln/core/var.hh>
+
+#include <mln/accu/count_value.hh>
+
+#include <mln/draw/box_plain.hh>
#include <scribo/toolchain/text_in_doc.hh>
+#include <scribo/toolchain/text_in_doc_preprocess.hh>
+#include <scribo/core/document.hh>
#include <scribo/core/line_set.hh>
#include <scribo/debug/usage.hh>
#include <scribo/make/debug_filename.hh>
+#include <scribo/primitive/extract/elements.hh>
+
#include <scribo/preprocessing/crop_without_localization.hh>
+#include <scribo/preprocessing/crop.hh>
#include <scribo/io/xml/save.hh>
#include <scribo/io/text_boxes/save.hh>
-
const char *args_desc[][2] =
{
- { "input.pbm", "A binary image. 'False' for object, 'True'\
-for the background." },
- { "out.txt", "Text output" },
+ { "input.*", "An image." },
+ { "out.xml", "Result of the document analysis." },
{ "denoise_enabled", "1 enables denoising, 0 disables it. (enabled by default)" },
{ "pmin_row", "Row index of the top left corner of the Region of interest." },
{ "pmin_col", "Col index of the top left corner of the Region of interest." },
@@ -69,6 +77,7 @@ for the background." },
};
+
int main(int argc, char* argv[])
{
using namespace scribo;
@@ -76,8 +85,8 @@ int main(int argc, char* argv[])
if (argc != 3 && argc != 4 && argc != 5 && argc != 8 && argc != 9)
return scribo::debug::usage(argv,
- "Find text lines using left/right validation and display x-height in a binarized article.",
- "input.pbm out.txt <denoise_enabled> [<pmin_row> <pmin_col> <pmax_row> <pmax_col>] <debug_dir>",
+ "Find text lines and elements in a document",
+ "input.* out.xml <denoise_enabled> [<pmin_row> <pmin_col> <pmax_row> <pmax_col>] <debug_dir>",
args_desc);
bool debug = false;
@@ -91,9 +100,12 @@ int main(int argc, char* argv[])
trace::entering("main");
+ typedef image2d<scribo::def::lbl_type> L;
+ scribo::document<L> doc(argv[1]);
- image2d<bool> input;
- mln::io::pbm::load(input, argv[1]);
+ // Preprocess document
+ image2d<bool>
+ input = toolchain::text_in_doc_preprocess(doc.image(), false);
// Optional Cropping
@@ -119,15 +131,21 @@ int main(int argc, char* argv[])
// Run document toolchain.
- typedef image2d<scribo::def::lbl_type> L;
+
+ // Text
+ std::cout << "Extracting text" << std::endl;
line_set<L>
lines = scribo::toolchain::text_in_doc(input, denoise, debug);
+ doc.set_text(lines);
+
+ // Elements
+ std::cout << "Extracting Elements" << std::endl;
+ component_set<L> elements = scribo::primitive::extract::elements(doc, input);
+ doc.set_elements(elements);
- // Saving results
- scribo::io::xml::save(argv[1], lines, "out.xml", true);
- // Specify shift due to potential previous crop.
- scribo::io::text_boxes::save(lines, argv[2], crop_shift);
+ // Saving results
+ scribo::io::xml::save(doc, argv[2], true);
trace::exiting("main");
}
--
1.5.6.5
1
0

last-svn-commit-651-g667167f src/content_in_doc.cc: New example extracting document content.
by Guillaume Lazzara 15 Nov '10
by Guillaume Lazzara 15 Nov '10
15 Nov '10
---
scribo/ChangeLog | 4 ++
scribo/src/Makefile.am | 15 +++++
.../src/{pbm_text_in_doc.cc => content_in_doc.cc} | 56 +++++++++++++-------
3 files changed, 56 insertions(+), 19 deletions(-)
copy scribo/src/{pbm_text_in_doc.cc => content_in_doc.cc} (74%)
diff --git a/scribo/ChangeLog b/scribo/ChangeLog
index 07d166b..9eddce6 100644
--- a/scribo/ChangeLog
+++ b/scribo/ChangeLog
@@ -1,5 +1,9 @@
2010-11-15 Guillaume Lazzara <z(a)lrde.epita.fr>
+ * src/content_in_doc.cc: New example extracting document content.
+
+2010-11-15 Guillaume Lazzara <z(a)lrde.epita.fr>
+
* scribo/toolchain/text_in_doc.hh: Make use of non visible
separators information.
diff --git a/scribo/src/Makefile.am b/scribo/src/Makefile.am
index a2c72b2..cd7618c 100644
--- a/scribo/src/Makefile.am
+++ b/scribo/src/Makefile.am
@@ -85,6 +85,21 @@ if HAVE_TESSERACT
$(TIFF_LDFLAGS) \
$(MAGICKXX_LDFLAGS)
+
+ utilexec_PROGRAMS += content_in_doc
+ content_in_doc_SOURCES = content_in_doc.cc
+ content_in_doc_CPPFLAGS = $(AM_CPPFLAGS) \
+ -I/home/lazzara/git/oln/scribo/sandbox/green/ \
+ -I/home/lazzara/git/oln/scribo/sandbox/z/ \
+ $(TESSERACT_CPPFLAGS) \
+ $(TIFF_CPPFLAGS) \
+ $(MAGICKXX_CPPFLAGS)
+ content_in_doc_LDFLAGS = $(AM_LDFLAGS) \
+ $(TESSERACT_LDFLAGS) \
+ $(TIFF_LDFLAGS) \
+ $(MAGICKXX_LDFLAGS) \
+ -lpthread
+
endif HAVE_TESSERACT
endif HAVE_MAGICKXX
diff --git a/scribo/src/pbm_text_in_doc.cc b/scribo/src/content_in_doc.cc
similarity index 74%
copy from scribo/src/pbm_text_in_doc.cc
copy to scribo/src/content_in_doc.cc
index 23ed9e7..fe3eacf 100644
--- a/scribo/src/pbm_text_in_doc.cc
+++ b/scribo/src/content_in_doc.cc
@@ -1,5 +1,4 @@
-// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory
-// (LRDE)
+// Copyright (C) 2010 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -24,9 +23,6 @@
// exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
#include <libgen.h>
#include <fstream>
@@ -35,30 +31,42 @@
#include <mln/core/image/image2d.hh>
#include <mln/core/alias/neighb2d.hh>
-#include <mln/io/pbm/all.hh>
+#include <mln/io/pbm/save.hh>
+#include <mln/io/magick/load.hh>
+
+#include <mln/value/label_8.hh>
+
+#include <mln/core/var.hh>
+
+#include <mln/accu/count_value.hh>
+
+#include <mln/draw/box_plain.hh>
#include <scribo/toolchain/text_in_doc.hh>
+#include <scribo/toolchain/text_in_doc_preprocess.hh>
+#include <scribo/core/document.hh>
#include <scribo/core/line_set.hh>
#include <scribo/debug/usage.hh>
#include <scribo/make/debug_filename.hh>
+#include <scribo/primitive/extract/elements.hh>
+
#include <scribo/preprocessing/crop_without_localization.hh>
+#include <scribo/preprocessing/crop.hh>
#include <scribo/io/xml/save.hh>
#include <scribo/io/text_boxes/save.hh>
-
const char *args_desc[][2] =
{
- { "input.pbm", "A binary image. 'False' for object, 'True'\
-for the background." },
- { "out.txt", "Text output" },
+ { "input.*", "An image." },
+ { "out.xml", "Result of the document analysis." },
{ "denoise_enabled", "1 enables denoising, 0 disables it. (enabled by default)" },
{ "pmin_row", "Row index of the top left corner of the Region of interest." },
{ "pmin_col", "Col index of the top left corner of the Region of interest." },
@@ -69,6 +77,7 @@ for the background." },
};
+
int main(int argc, char* argv[])
{
using namespace scribo;
@@ -76,8 +85,8 @@ int main(int argc, char* argv[])
if (argc != 3 && argc != 4 && argc != 5 && argc != 8 && argc != 9)
return scribo::debug::usage(argv,
- "Find text lines using left/right validation and display x-height in a binarized article.",
- "input.pbm out.txt <denoise_enabled> [<pmin_row> <pmin_col> <pmax_row> <pmax_col>] <debug_dir>",
+ "Find text lines and elements in a document",
+ "input.* out.xml <denoise_enabled> [<pmin_row> <pmin_col> <pmax_row> <pmax_col>] <debug_dir>",
args_desc);
bool debug = false;
@@ -91,9 +100,12 @@ int main(int argc, char* argv[])
trace::entering("main");
+ typedef image2d<scribo::def::lbl_type> L;
+ scribo::document<L> doc(argv[1]);
- image2d<bool> input;
- mln::io::pbm::load(input, argv[1]);
+ // Preprocess document
+ image2d<bool>
+ input = toolchain::text_in_doc_preprocess(doc.image(), false);
// Optional Cropping
@@ -119,15 +131,21 @@ int main(int argc, char* argv[])
// Run document toolchain.
- typedef image2d<scribo::def::lbl_type> L;
+
+ // Text
+ std::cout << "Extracting text" << std::endl;
line_set<L>
lines = scribo::toolchain::text_in_doc(input, denoise, debug);
+ doc.set_text(lines);
+
+ // Elements
+ std::cout << "Extracting Elements" << std::endl;
+ component_set<L> elements = scribo::primitive::extract::elements(doc, input);
+ doc.set_elements(elements);
- // Saving results
- scribo::io::xml::save(argv[1], lines, "out.xml", true);
- // Specify shift due to potential previous crop.
- scribo::io::text_boxes::save(lines, argv[2], crop_shift);
+ // Saving results
+ scribo::io::xml::save(doc, argv[2], true);
trace::exiting("main");
}
--
1.5.6.5
1
0

last-svn-commit-651-g4e3b22c scribo/toolchain/text_in_doc.hh: Make use of non visible separators information.
by Guillaume Lazzara 15 Nov '10
by Guillaume Lazzara 15 Nov '10
15 Nov '10
---
scribo/ChangeLog | 5 +++++
scribo/scribo/toolchain/text_in_doc.hh | 31 +++++++++++++++++++++----------
2 files changed, 26 insertions(+), 10 deletions(-)
diff --git a/scribo/ChangeLog b/scribo/ChangeLog
index b14e5bf..9400016 100644
--- a/scribo/ChangeLog
+++ b/scribo/ChangeLog
@@ -1,5 +1,10 @@
2010-11-15 Guillaume Lazzara <z(a)lrde.epita.fr>
+ * scribo/toolchain/text_in_doc.hh: Make use of non visible
+ separators information.
+
+2010-11-15 Guillaume Lazzara <z(a)lrde.epita.fr>
+
* scribo/io/xml/save.hh: Make use of document structure.
2010-11-15 Guillaume Lazzara <z(a)lrde.epita.fr>
diff --git a/scribo/scribo/toolchain/text_in_doc.hh b/scribo/scribo/toolchain/text_in_doc.hh
index 50db26a..279ac13 100644
--- a/scribo/scribo/toolchain/text_in_doc.hh
+++ b/scribo/scribo/toolchain/text_in_doc.hh
@@ -37,6 +37,7 @@
# include <scribo/primitive/extract/components.hh>
# include <scribo/primitive/extract/vertical_separators.hh>
+# include <scribo/primitive/extract/separators_nonvisible.hh>
# include <scribo/primitive/remove/separators.hh>
@@ -63,13 +64,15 @@
# include <scribo/debug/looks_like_a_text_line_image.hh>
-
namespace scribo
{
namespace toolchain
{
+ using namespace mln;
+
+
template <typename I>
line_set<mln_ch_value(I, def::lbl_type)>
text_in_doc(const Image<I>& input, bool denoise, bool debug = false);
@@ -77,6 +80,7 @@ namespace scribo
# ifndef MLN_INCLUDE_ONLY
+
template <typename I>
line_set<mln_ch_value(I, def::lbl_type)>
text_in_doc(const Image<I>& input, bool denoise, bool debug = false)
@@ -84,15 +88,11 @@ namespace scribo
typedef value::label<30> V;
typedef image2d<V> L;
- // Add whitespace separators.
- // win::rectangle2d win = win::rectangle2d(151, 41);
- // image2d<bool> whitespaces = morpho::closing::structural(input, win);
- // logical::not_inplace(whitespaces);
-
// Remove separators
if (debug)
std::cout << "Find vertical separators..." << std::endl;
+ // Vertical separators
image2d<bool>
separators = primitive::extract::vertical_separators(input, 81);
@@ -102,15 +102,23 @@ namespace scribo
image2d<bool> input_cleaned = primitive::remove::separators(input,
separators);
-// whitespaces += separators;
+ // Whitespace separators
+ if (debug)
+ std::cout << "Find whitespace separators..." << std::endl;
+
+ image2d<bool>
+ whitespaces = primitive::extract::separators_nonvisible(input);
if (debug)
{
+ mln::io::pbm::save(whitespaces,
+ scribo::make::debug_filename("whitespaces.pbm"));
+
mln::io::pbm::save(separators,
scribo::make::debug_filename("vseparators.pbm"));
-// mln::io::pbm::save(whitespaces, "separators.pbm");
- mln::io::pbm::save(input_cleaned, scribo::make::debug_filename("input_wo_vseparators.pbm"));
+ mln::io::pbm::save(input_cleaned,
+ scribo::make::debug_filename("input_wo_vseparators.pbm"));
}
// Denoise
@@ -137,10 +145,13 @@ namespace scribo
/// Set separator components.
components.add_separators(separators);
-// components.add_separators(whitespaces);
+ components.add_separators(whitespaces);
components = scribo::filter::components_small(components, 3);
+ if (debug)
+ mln::io::pbm::save(components.separators(),
+ scribo::make::debug_filename("all_separators.pbm"));
/// Linking potential objects
if (debug)
--
1.5.6.5
1
0

last-svn-commit-650-gf148998 scribo/toolchain/text_in_doc.hh: Make use of non visible separators information.
by Guillaume Lazzara 15 Nov '10
by Guillaume Lazzara 15 Nov '10
15 Nov '10
---
scribo/ChangeLog | 5 +++++
scribo/scribo/toolchain/text_in_doc.hh | 31 +++++++++++++++++++++----------
2 files changed, 26 insertions(+), 10 deletions(-)
diff --git a/scribo/ChangeLog b/scribo/ChangeLog
index 000bf1a..07d166b 100644
--- a/scribo/ChangeLog
+++ b/scribo/ChangeLog
@@ -1,5 +1,10 @@
2010-11-15 Guillaume Lazzara <z(a)lrde.epita.fr>
+ * scribo/toolchain/text_in_doc.hh: Make use of non visible
+ separators information.
+
+2010-11-15 Guillaume Lazzara <z(a)lrde.epita.fr>
+
* scribo/io/xml/save.hh: Make use of document structure.
2010-11-15 Guillaume Lazzara <z(a)lrde.epita.fr>
diff --git a/scribo/scribo/toolchain/text_in_doc.hh b/scribo/scribo/toolchain/text_in_doc.hh
index 50db26a..279ac13 100644
--- a/scribo/scribo/toolchain/text_in_doc.hh
+++ b/scribo/scribo/toolchain/text_in_doc.hh
@@ -37,6 +37,7 @@
# include <scribo/primitive/extract/components.hh>
# include <scribo/primitive/extract/vertical_separators.hh>
+# include <scribo/primitive/extract/separators_nonvisible.hh>
# include <scribo/primitive/remove/separators.hh>
@@ -63,13 +64,15 @@
# include <scribo/debug/looks_like_a_text_line_image.hh>
-
namespace scribo
{
namespace toolchain
{
+ using namespace mln;
+
+
template <typename I>
line_set<mln_ch_value(I, def::lbl_type)>
text_in_doc(const Image<I>& input, bool denoise, bool debug = false);
@@ -77,6 +80,7 @@ namespace scribo
# ifndef MLN_INCLUDE_ONLY
+
template <typename I>
line_set<mln_ch_value(I, def::lbl_type)>
text_in_doc(const Image<I>& input, bool denoise, bool debug = false)
@@ -84,15 +88,11 @@ namespace scribo
typedef value::label<30> V;
typedef image2d<V> L;
- // Add whitespace separators.
- // win::rectangle2d win = win::rectangle2d(151, 41);
- // image2d<bool> whitespaces = morpho::closing::structural(input, win);
- // logical::not_inplace(whitespaces);
-
// Remove separators
if (debug)
std::cout << "Find vertical separators..." << std::endl;
+ // Vertical separators
image2d<bool>
separators = primitive::extract::vertical_separators(input, 81);
@@ -102,15 +102,23 @@ namespace scribo
image2d<bool> input_cleaned = primitive::remove::separators(input,
separators);
-// whitespaces += separators;
+ // Whitespace separators
+ if (debug)
+ std::cout << "Find whitespace separators..." << std::endl;
+
+ image2d<bool>
+ whitespaces = primitive::extract::separators_nonvisible(input);
if (debug)
{
+ mln::io::pbm::save(whitespaces,
+ scribo::make::debug_filename("whitespaces.pbm"));
+
mln::io::pbm::save(separators,
scribo::make::debug_filename("vseparators.pbm"));
-// mln::io::pbm::save(whitespaces, "separators.pbm");
- mln::io::pbm::save(input_cleaned, scribo::make::debug_filename("input_wo_vseparators.pbm"));
+ mln::io::pbm::save(input_cleaned,
+ scribo::make::debug_filename("input_wo_vseparators.pbm"));
}
// Denoise
@@ -137,10 +145,13 @@ namespace scribo
/// Set separator components.
components.add_separators(separators);
-// components.add_separators(whitespaces);
+ components.add_separators(whitespaces);
components = scribo::filter::components_small(components, 3);
+ if (debug)
+ mln::io::pbm::save(components.separators(),
+ scribo::make::debug_filename("all_separators.pbm"));
/// Linking potential objects
if (debug)
--
1.5.6.5
1
0

last-svn-commit-650-gc2ce47f scribo/io/xml/save.hh: Make use of document structure.
by Guillaume Lazzara 15 Nov '10
by Guillaume Lazzara 15 Nov '10
15 Nov '10
---
scribo/ChangeLog | 4 +
scribo/scribo/io/xml/save.hh | 214 +++++++++++++++++++++---------------------
2 files changed, 111 insertions(+), 107 deletions(-)
diff --git a/scribo/ChangeLog b/scribo/ChangeLog
index e738a8a..b14e5bf 100644
--- a/scribo/ChangeLog
+++ b/scribo/ChangeLog
@@ -1,5 +1,9 @@
2010-11-15 Guillaume Lazzara <z(a)lrde.epita.fr>
+ * scribo/io/xml/save.hh: Make use of document structure.
+
+2010-11-15 Guillaume Lazzara <z(a)lrde.epita.fr>
+
* scribo/primitive/extract/elements.hh: New routine.
2010-11-15 Guillaume Lazzara <z(a)lrde.epita.fr>
diff --git a/scribo/scribo/io/xml/save.hh b/scribo/scribo/io/xml/save.hh
index f13396f..c6b416d 100644
--- a/scribo/scribo/io/xml/save.hh
+++ b/scribo/scribo/io/xml/save.hh
@@ -28,7 +28,7 @@
/// \file
///
-/// \brief Save text line information as XML.
+/// \brief Save document information as XML.
# include <fstream>
# include <sstream>
@@ -46,7 +46,7 @@ namespace scribo
namespace xml
{
- /*! \brief Save text line information as XML.
+ /*! \brief Save document information as XML.
We use a XML Schema part of the PAGE (Page Analysis and Ground
truth Elements) image representation framework.
@@ -60,8 +60,7 @@ namespace scribo
*/
template <typename L>
void
- save(const std::string& input_name,
- const line_set<L>& lines,
+ save(const document<L>& doc,
const std::string& output_name,
bool extended_format);
@@ -86,12 +85,34 @@ namespace scribo
return input;
}
+
+ void print_box_coords(std::ofstream& ostr, const box2d& b,
+ const char *space)
+ {
+ std::string sc = space;
+ std::string sp = sc + " ";
+ ostr << sc << "<coords>" << std::endl
+ << sp << "<point x=\"" << b.pmin().col()
+ << "\" y=\"" << b.pmin().row() << "\"/>"
+ << std::endl
+ << sp << "<point x=\"" << b.pmax().col()
+ << "\" y=\"" << b.pmin().row() << "\"/>"
+ << std::endl
+ << sp << "<point x=\"" << b.pmax().col()
+ << "\" y=\"" << b.pmax().row() << "\"/>"
+ << std::endl
+ << sp << "<point x=\"" << b.pmin().col()
+ << "\" y=\"" << b.pmax().row() << "\"/>"
+ << std::endl
+ << sc << "</coords>" << std::endl;
+
+ }
+
} // end of namespace scribo::io::xml::internal
template <typename L>
void
- save(const std::string& input_name,
- const line_set<L>& lines,
+ save(const document<L>& doc,
const std::string& output_name,
bool extended_format)
{
@@ -100,9 +121,12 @@ namespace scribo
std::ofstream file(output_name.c_str());
if (! file)
{
- std::cerr << "error: cannot open file '" << input_name << "'!";
+ std::cerr << "error: cannot open file '" << doc.filename() << "'!";
abort();
}
+
+ const line_set<L>& lines = doc.text();
+
std::map<char, std::string> html_map;
html_map['\"'] = """;
html_map['<'] = "<";
@@ -111,13 +135,13 @@ namespace scribo
file << "<?xml version=\"1.0\"?>" << std::endl;
if (extended_format)
- {
- file << "<pcGts>" << std::endl;
- }
+ {
+ file << "<pcGts>" << std::endl;
+ }
else
- {
- file << "<pcGts xmlns=\"http://schema.primaresearch.org/PAGE/gts/pagecontent/2009-03-16\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://schema.primaresearch.org/PAGE/gts/pagecontent/2009-03-16 http://schema.primaresearch.org/PAGE/gts/pagecontent/2009-03-16/pagecontent…" pcGtsId=\"" << input_name << "\">" << std::endl;
- }
+ {
+ file << "<pcGts xmlns=\"http://schema.primaresearch.org/PAGE/gts/pagecontent/2009-03-16\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://schema.primaresearch.org/PAGE/gts/pagecontent/2009-03-16 http://schema.primaresearch.org/PAGE/gts/pagecontent/2009-03-16/pagecontent…" pcGtsId=\"" << doc.filename() << "\">" << std::endl;
+ }
file << " <PcMetadata>" << std::endl;
file << " <PcCreator>LRDE</PcCreator>" << std::endl;
@@ -126,110 +150,86 @@ namespace scribo
file << " <PcComments>Generated by Scribo from Olena.</PcComments>" << std::endl;
file << " </PcMetadata>" << std::endl;
- file << " <page image_filename=\"" << input_name
+ file << " <page image_filename=\"" << doc.filename()
<< "\" image_width=\"" << lines.components().labeled_image().ncols()
<< "\" image_height=\"" << lines.components().labeled_image().nrows()
<< "\">" << std::endl;
for_all_lines(l, lines)
+ {
+ if (! lines(l).is_valid()
+ || lines(l).tag() != line::None
+ || lines(l).type() != line::Text) // Is NOT a text line.
+ continue;
{
- if (! lines(l).is_valid()
- || lines(l).tag() != line::None
- || lines(l).type() != line::Text) // Is NOT a text line.
- continue;
+ file << " <text_region id=\"" << lines(l).id()
+ << "\" txt_orientation=\"" << lines(l).orientation()
+ << "\" txt_reading_orientation=\"" << lines(l).reading_orientation()
+ << "\" txt_reading_direction=\"" << lines(l).reading_direction()
+ << "\" txt_text_type=\"" << lines(l).type()
+ << "\" txt_reverse_video=\"" << (lines(l).reverse_video() ? "true" : "false")
+ << "\" txt_indented=\"" << (lines(l).indented() ? "true" : "false")
+ << "\" kerning=\"" << lines(l).char_space();
+
+ // EXTENSIONS - Not officially supported
+ if (extended_format)
{
- file << " <text_region id=\"" << lines(l).id()
- << "\" txt_orientation=\"" << lines(l).orientation()
- << "\" txt_reading_orientation=\"" << lines(l).reading_orientation()
- << "\" txt_reading_direction=\"" << lines(l).reading_direction()
- << "\" txt_text_type=\"" << lines(l).type()
- << "\" txt_reverse_video=\"" << (lines(l).reverse_video() ? "true" : "false")
- << "\" txt_indented=\"" << (lines(l).indented() ? "true" : "false")
- << "\" kerning=\"" << lines(l).char_space();
-
- // EXTENSIONS - Not officially supported
- if (extended_format)
- {
- file << "\" baseline=\"" << lines(l).baseline()
- << "\" meanline=\"" << lines(l).meanline()
- << "\" x_height=\"" << lines(l).x_height()
- << "\" d_height=\"" << lines(l).d_height()
- << "\" a_height=\"" << lines(l).a_height()
- << "\" char_width=\"" << lines(l).char_width();
- }
- // End of EXTENSIONS
- file << "\">"
- << std::endl;
+ file << "\" baseline=\"" << lines(l).baseline()
+ << "\" meanline=\"" << lines(l).meanline()
+ << "\" x_height=\"" << lines(l).x_height()
+ << "\" d_height=\"" << lines(l).d_height()
+ << "\" a_height=\"" << lines(l).a_height()
+ << "\" char_width=\"" << lines(l).char_width();
+ }
+ // End of EXTENSIONS
+ file << "\">"
+ << std::endl;
- if (extended_format)
- {
- file << " <coords>" << std::endl
- << " <point x=\"" << lines(l).bbox().pmin().col()
- << "\" y=\"" << lines(l).bbox().pmin().row() << "\"/>"
- << std::endl
- << " <point x=\"" << lines(l).bbox().pmax().col()
- << "\" y=\"" << lines(l).bbox().pmin().row() << "\"/>"
- << std::endl
- << " <point x=\"" << lines(l).bbox().pmax().col()
- << "\" y=\"" << lines(l).bbox().pmax().row() << "\"/>"
- << std::endl
- << " <point x=\"" << lines(l).bbox().pmin().col()
- << "\" y=\"" << lines(l).bbox().pmax().row() << "\"/>"
- << std::endl
- << " </coords>" << std::endl;
-
-
- file << " <paragraph>" << std::endl;
-
- file << " <coords>" << std::endl
- << " <point x=\"" << lines(l).bbox().pmin().col()
- << "\" y=\"" << lines(l).bbox().pmin().row() << "\"/>"
- << std::endl
- << " <point x=\"" << lines(l).bbox().pmax().col()
- << "\" y=\"" << lines(l).bbox().pmin().row() << "\"/>"
- << std::endl
- << " <point x=\"" << lines(l).bbox().pmax().col()
- << "\" y=\"" << lines(l).bbox().pmax().row() << "\"/>"
- << std::endl
- << " <point x=\"" << lines(l).bbox().pmin().col()
- << "\" y=\"" << lines(l).bbox().pmax().row() << "\"/>"
- << std::endl
- << " </coords>" << std::endl;
-
- if (lines(l).has_text())
- {
- std::string tmp = lines(l).text();
- tmp = internal::html_markups_replace(tmp, html_map);
-
- file << " <line text=\""
- << tmp
- << "\">" << std::endl;
- }
- else
- file << " <line>" << std::endl;
-
- file << " <coords>" << std::endl
- << " <point x=\"" << lines(l).bbox().pmin().col()
- << "\" y=\"" << lines(l).bbox().pmin().row() << "\"/>"
- << std::endl
- << " <point x=\"" << lines(l).bbox().pmax().col()
- << "\" y=\"" << lines(l).bbox().pmin().row() << "\"/>"
- << std::endl
- << " <point x=\"" << lines(l).bbox().pmax().col()
- << "\" y=\"" << lines(l).bbox().pmax().row() << "\"/>"
- << std::endl
- << " <point x=\"" << lines(l).bbox().pmin().col()
- << "\" y=\"" << lines(l).bbox().pmax().row() << "\"/>"
- << std::endl
- << " </coords>" << std::endl;
-
- file << " </line>" << std::endl;
-
- file << " </paragraph>" << std::endl;
- }
+ internal::print_box_coords(file, lines(l).bbox(), " ");
+
+ if (extended_format)
+ {
+ file << " <paragraph>" << std::endl;
+
+ internal::print_box_coords(file, lines(l).bbox(), " ");
+
+ if (lines(l).has_text())
+ {
+ std::string tmp = lines(l).text();
+ tmp = internal::html_markups_replace(tmp, html_map);
+
+ file << " <line text=\""
+ << tmp
+ << "\">" << std::endl;
+ }
+ else
+ file << " <line>" << std::endl;
+
+ internal::print_box_coords(file, lines(l).bbox(), " ");
- file << " </text_region>" << std::endl;
+ file << " </line>" << std::endl;
+
+ file << " </paragraph>" << std::endl;
}
+
+ file << " </text_region>" << std::endl;
+ }
+ }
+
+
+ const component_set<L>& elts = doc.elements();
+ for_all_comps(e, elts)
+ if (elts(e).is_valid())
+ {
+ file << " <image_region id=\"ir" << elts(e).id()
+ << "\" img_colour_type=\"24_Bit_Colour\""
+ << " img_orientation=\"0.000000\" "
+ << " img_emb_text=\"No\" "
+ << " img_bgcolour=\"White\">" << std::endl;
+
+ internal::print_box_coords(file, elts(e).bbox(), " ");
+
+ file << " </image_region>" << std::endl;
}
file << " </page>" << std::endl;
--
1.5.6.5
1
0

last-svn-commit-649-gf502432 scribo/io/xml/save.hh: Make use of document structure.
by Guillaume Lazzara 15 Nov '10
by Guillaume Lazzara 15 Nov '10
15 Nov '10
---
scribo/ChangeLog | 4 +
scribo/scribo/io/xml/save.hh | 214 +++++++++++++++++++++---------------------
2 files changed, 111 insertions(+), 107 deletions(-)
diff --git a/scribo/ChangeLog b/scribo/ChangeLog
index 828f9b8..000bf1a 100644
--- a/scribo/ChangeLog
+++ b/scribo/ChangeLog
@@ -1,5 +1,9 @@
2010-11-15 Guillaume Lazzara <z(a)lrde.epita.fr>
+ * scribo/io/xml/save.hh: Make use of document structure.
+
+2010-11-15 Guillaume Lazzara <z(a)lrde.epita.fr>
+
* scribo/primitive/extract/elements.hh: New routine.
2010-11-15 Guillaume Lazzara <z(a)lrde.epita.fr>
diff --git a/scribo/scribo/io/xml/save.hh b/scribo/scribo/io/xml/save.hh
index f13396f..c6b416d 100644
--- a/scribo/scribo/io/xml/save.hh
+++ b/scribo/scribo/io/xml/save.hh
@@ -28,7 +28,7 @@
/// \file
///
-/// \brief Save text line information as XML.
+/// \brief Save document information as XML.
# include <fstream>
# include <sstream>
@@ -46,7 +46,7 @@ namespace scribo
namespace xml
{
- /*! \brief Save text line information as XML.
+ /*! \brief Save document information as XML.
We use a XML Schema part of the PAGE (Page Analysis and Ground
truth Elements) image representation framework.
@@ -60,8 +60,7 @@ namespace scribo
*/
template <typename L>
void
- save(const std::string& input_name,
- const line_set<L>& lines,
+ save(const document<L>& doc,
const std::string& output_name,
bool extended_format);
@@ -86,12 +85,34 @@ namespace scribo
return input;
}
+
+ void print_box_coords(std::ofstream& ostr, const box2d& b,
+ const char *space)
+ {
+ std::string sc = space;
+ std::string sp = sc + " ";
+ ostr << sc << "<coords>" << std::endl
+ << sp << "<point x=\"" << b.pmin().col()
+ << "\" y=\"" << b.pmin().row() << "\"/>"
+ << std::endl
+ << sp << "<point x=\"" << b.pmax().col()
+ << "\" y=\"" << b.pmin().row() << "\"/>"
+ << std::endl
+ << sp << "<point x=\"" << b.pmax().col()
+ << "\" y=\"" << b.pmax().row() << "\"/>"
+ << std::endl
+ << sp << "<point x=\"" << b.pmin().col()
+ << "\" y=\"" << b.pmax().row() << "\"/>"
+ << std::endl
+ << sc << "</coords>" << std::endl;
+
+ }
+
} // end of namespace scribo::io::xml::internal
template <typename L>
void
- save(const std::string& input_name,
- const line_set<L>& lines,
+ save(const document<L>& doc,
const std::string& output_name,
bool extended_format)
{
@@ -100,9 +121,12 @@ namespace scribo
std::ofstream file(output_name.c_str());
if (! file)
{
- std::cerr << "error: cannot open file '" << input_name << "'!";
+ std::cerr << "error: cannot open file '" << doc.filename() << "'!";
abort();
}
+
+ const line_set<L>& lines = doc.text();
+
std::map<char, std::string> html_map;
html_map['\"'] = """;
html_map['<'] = "<";
@@ -111,13 +135,13 @@ namespace scribo
file << "<?xml version=\"1.0\"?>" << std::endl;
if (extended_format)
- {
- file << "<pcGts>" << std::endl;
- }
+ {
+ file << "<pcGts>" << std::endl;
+ }
else
- {
- file << "<pcGts xmlns=\"http://schema.primaresearch.org/PAGE/gts/pagecontent/2009-03-16\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://schema.primaresearch.org/PAGE/gts/pagecontent/2009-03-16 http://schema.primaresearch.org/PAGE/gts/pagecontent/2009-03-16/pagecontent…" pcGtsId=\"" << input_name << "\">" << std::endl;
- }
+ {
+ file << "<pcGts xmlns=\"http://schema.primaresearch.org/PAGE/gts/pagecontent/2009-03-16\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://schema.primaresearch.org/PAGE/gts/pagecontent/2009-03-16 http://schema.primaresearch.org/PAGE/gts/pagecontent/2009-03-16/pagecontent…" pcGtsId=\"" << doc.filename() << "\">" << std::endl;
+ }
file << " <PcMetadata>" << std::endl;
file << " <PcCreator>LRDE</PcCreator>" << std::endl;
@@ -126,110 +150,86 @@ namespace scribo
file << " <PcComments>Generated by Scribo from Olena.</PcComments>" << std::endl;
file << " </PcMetadata>" << std::endl;
- file << " <page image_filename=\"" << input_name
+ file << " <page image_filename=\"" << doc.filename()
<< "\" image_width=\"" << lines.components().labeled_image().ncols()
<< "\" image_height=\"" << lines.components().labeled_image().nrows()
<< "\">" << std::endl;
for_all_lines(l, lines)
+ {
+ if (! lines(l).is_valid()
+ || lines(l).tag() != line::None
+ || lines(l).type() != line::Text) // Is NOT a text line.
+ continue;
{
- if (! lines(l).is_valid()
- || lines(l).tag() != line::None
- || lines(l).type() != line::Text) // Is NOT a text line.
- continue;
+ file << " <text_region id=\"" << lines(l).id()
+ << "\" txt_orientation=\"" << lines(l).orientation()
+ << "\" txt_reading_orientation=\"" << lines(l).reading_orientation()
+ << "\" txt_reading_direction=\"" << lines(l).reading_direction()
+ << "\" txt_text_type=\"" << lines(l).type()
+ << "\" txt_reverse_video=\"" << (lines(l).reverse_video() ? "true" : "false")
+ << "\" txt_indented=\"" << (lines(l).indented() ? "true" : "false")
+ << "\" kerning=\"" << lines(l).char_space();
+
+ // EXTENSIONS - Not officially supported
+ if (extended_format)
{
- file << " <text_region id=\"" << lines(l).id()
- << "\" txt_orientation=\"" << lines(l).orientation()
- << "\" txt_reading_orientation=\"" << lines(l).reading_orientation()
- << "\" txt_reading_direction=\"" << lines(l).reading_direction()
- << "\" txt_text_type=\"" << lines(l).type()
- << "\" txt_reverse_video=\"" << (lines(l).reverse_video() ? "true" : "false")
- << "\" txt_indented=\"" << (lines(l).indented() ? "true" : "false")
- << "\" kerning=\"" << lines(l).char_space();
-
- // EXTENSIONS - Not officially supported
- if (extended_format)
- {
- file << "\" baseline=\"" << lines(l).baseline()
- << "\" meanline=\"" << lines(l).meanline()
- << "\" x_height=\"" << lines(l).x_height()
- << "\" d_height=\"" << lines(l).d_height()
- << "\" a_height=\"" << lines(l).a_height()
- << "\" char_width=\"" << lines(l).char_width();
- }
- // End of EXTENSIONS
- file << "\">"
- << std::endl;
+ file << "\" baseline=\"" << lines(l).baseline()
+ << "\" meanline=\"" << lines(l).meanline()
+ << "\" x_height=\"" << lines(l).x_height()
+ << "\" d_height=\"" << lines(l).d_height()
+ << "\" a_height=\"" << lines(l).a_height()
+ << "\" char_width=\"" << lines(l).char_width();
+ }
+ // End of EXTENSIONS
+ file << "\">"
+ << std::endl;
- if (extended_format)
- {
- file << " <coords>" << std::endl
- << " <point x=\"" << lines(l).bbox().pmin().col()
- << "\" y=\"" << lines(l).bbox().pmin().row() << "\"/>"
- << std::endl
- << " <point x=\"" << lines(l).bbox().pmax().col()
- << "\" y=\"" << lines(l).bbox().pmin().row() << "\"/>"
- << std::endl
- << " <point x=\"" << lines(l).bbox().pmax().col()
- << "\" y=\"" << lines(l).bbox().pmax().row() << "\"/>"
- << std::endl
- << " <point x=\"" << lines(l).bbox().pmin().col()
- << "\" y=\"" << lines(l).bbox().pmax().row() << "\"/>"
- << std::endl
- << " </coords>" << std::endl;
-
-
- file << " <paragraph>" << std::endl;
-
- file << " <coords>" << std::endl
- << " <point x=\"" << lines(l).bbox().pmin().col()
- << "\" y=\"" << lines(l).bbox().pmin().row() << "\"/>"
- << std::endl
- << " <point x=\"" << lines(l).bbox().pmax().col()
- << "\" y=\"" << lines(l).bbox().pmin().row() << "\"/>"
- << std::endl
- << " <point x=\"" << lines(l).bbox().pmax().col()
- << "\" y=\"" << lines(l).bbox().pmax().row() << "\"/>"
- << std::endl
- << " <point x=\"" << lines(l).bbox().pmin().col()
- << "\" y=\"" << lines(l).bbox().pmax().row() << "\"/>"
- << std::endl
- << " </coords>" << std::endl;
-
- if (lines(l).has_text())
- {
- std::string tmp = lines(l).text();
- tmp = internal::html_markups_replace(tmp, html_map);
-
- file << " <line text=\""
- << tmp
- << "\">" << std::endl;
- }
- else
- file << " <line>" << std::endl;
-
- file << " <coords>" << std::endl
- << " <point x=\"" << lines(l).bbox().pmin().col()
- << "\" y=\"" << lines(l).bbox().pmin().row() << "\"/>"
- << std::endl
- << " <point x=\"" << lines(l).bbox().pmax().col()
- << "\" y=\"" << lines(l).bbox().pmin().row() << "\"/>"
- << std::endl
- << " <point x=\"" << lines(l).bbox().pmax().col()
- << "\" y=\"" << lines(l).bbox().pmax().row() << "\"/>"
- << std::endl
- << " <point x=\"" << lines(l).bbox().pmin().col()
- << "\" y=\"" << lines(l).bbox().pmax().row() << "\"/>"
- << std::endl
- << " </coords>" << std::endl;
-
- file << " </line>" << std::endl;
-
- file << " </paragraph>" << std::endl;
- }
+ internal::print_box_coords(file, lines(l).bbox(), " ");
+
+ if (extended_format)
+ {
+ file << " <paragraph>" << std::endl;
+
+ internal::print_box_coords(file, lines(l).bbox(), " ");
+
+ if (lines(l).has_text())
+ {
+ std::string tmp = lines(l).text();
+ tmp = internal::html_markups_replace(tmp, html_map);
+
+ file << " <line text=\""
+ << tmp
+ << "\">" << std::endl;
+ }
+ else
+ file << " <line>" << std::endl;
+
+ internal::print_box_coords(file, lines(l).bbox(), " ");
- file << " </text_region>" << std::endl;
+ file << " </line>" << std::endl;
+
+ file << " </paragraph>" << std::endl;
}
+
+ file << " </text_region>" << std::endl;
+ }
+ }
+
+
+ const component_set<L>& elts = doc.elements();
+ for_all_comps(e, elts)
+ if (elts(e).is_valid())
+ {
+ file << " <image_region id=\"ir" << elts(e).id()
+ << "\" img_colour_type=\"24_Bit_Colour\""
+ << " img_orientation=\"0.000000\" "
+ << " img_emb_text=\"No\" "
+ << " img_bgcolour=\"White\">" << std::endl;
+
+ internal::print_box_coords(file, elts(e).bbox(), " ");
+
+ file << " </image_region>" << std::endl;
}
file << " </page>" << std::endl;
--
1.5.6.5
1
0