---
scribo/sandbox/raphael/code/#test.cc# | 179 ++++++++
scribo/sandbox/raphael/code/makefile | 13 +
scribo/sandbox/raphael/code/my/debug/all.hh | 2 +
scribo/sandbox/raphael/code/my/debug/bbox.hh | 46 ++
scribo/sandbox/raphael/code/my/debug/pict.hh | 119 ++++++
.../sandbox/raphael/code/my/document/bloc.hh | 0
scribo/sandbox/raphael/code/my/document/clean.hh | 92 ++++
.../sandbox/raphael/code/my/document/document.hh | 446 ++++++++++++++++++++
.../sandbox/raphael/code/my/document/image.hh | 0
scribo/sandbox/raphael/code/my/document/lettre.hh | 17 +
.../sandbox/raphael/code/my/document/title.hh | 0
.../sandbox/raphael/code/my/math/sqrt.hh | 0
scribo/sandbox/raphael/code/my/util/graph.hh | 8 +
scribo/sandbox/raphael/code/my/util/vec2.hh | 23 +
scribo/sandbox/raphael/code/my/util/vector_bbox.hh | 97 +++++
.../raphael/code/my/util/vector_bbox_group.hh | 67 +++
scribo/sandbox/raphael/code/test.cc | 180 ++++++++
scribo/sandbox/raphael/test | 1 -
18 files changed, 1289 insertions(+), 1 deletions(-)
create mode 100644 scribo/sandbox/raphael/code/#test.cc#
create mode 100644 scribo/sandbox/raphael/code/makefile
create mode 100644 scribo/sandbox/raphael/code/my/debug/all.hh
create mode 100644 scribo/sandbox/raphael/code/my/debug/bbox.hh
create mode 100644 scribo/sandbox/raphael/code/my/debug/pict.hh
copy milena/doc/outputs/accu-right-instantiation.txt =>
scribo/sandbox/raphael/code/my/document/bloc.hh (100%)
create mode 100644 scribo/sandbox/raphael/code/my/document/clean.hh
create mode 100644 scribo/sandbox/raphael/code/my/document/document.hh
copy milena/doc/outputs/accu-right-instantiation.txt =>
scribo/sandbox/raphael/code/my/document/image.hh (100%)
create mode 100644 scribo/sandbox/raphael/code/my/document/lettre.hh
copy milena/doc/outputs/accu-right-instantiation.txt =>
scribo/sandbox/raphael/code/my/document/title.hh (100%)
copy milena/doc/outputs/accu-right-instantiation.txt =>
scribo/sandbox/raphael/code/my/math/sqrt.hh (100%)
create mode 100644 scribo/sandbox/raphael/code/my/util/graph.hh
create mode 100644 scribo/sandbox/raphael/code/my/util/vec2.hh
create mode 100644 scribo/sandbox/raphael/code/my/util/vector_bbox.hh
create mode 100644 scribo/sandbox/raphael/code/my/util/vector_bbox_group.hh
create mode 100644 scribo/sandbox/raphael/code/test.cc
delete mode 120000 scribo/sandbox/raphael/test
diff --git a/scribo/sandbox/raphael/code/#test.cc#
b/scribo/sandbox/raphael/code/#test.cc#
new file mode 100644
index 0000000..ea36241
--- /dev/null
+++ b/scribo/sandbox/raphael/code/#test.cc#
@@ -0,0 +1,179 @@
+
+#include <vector>
+#include <mln/io/all.hh>
+
+#include <mln/core/site_set/p_vertices.hh>
+#include <mln/core/image/graph_elt_window.hh>
+#include <mln/core/image/vertex_image.hh>
+#include <mln/core/image/graph_elt_neighborhood.hh>
+#include <mln/core/concept/function.hh>
+#include <mln/core/neighb.hh>
+#include <mln/core/image/graph_elt_neighborhood_if.hh>
+#include <mln/core/var.hh>
+#include <mln/accu/shape/bbox.hh>
+#include <mln/fun/i2v/array.hh>
+#include <mln/util/graph.hh>
+#include <mln/util/timer.hh>
+#include <mln/debug/draw_graph.hh>
+#include <mln/debug/println.hh>
+#include <mln/transform/all.hh>
+#include <mln/make/image2d.hh>
+#include <mln/core/alias/neighb2d.hh>
+#include <mln/make/influence_zone_adjacency_graph.hh>
+#include <mln/make/w_window2d.hh>
+#include <mln/labeling/all.hh>
+#include <mln/make/image.hh>
+#include <mln/value/rgb8.hh>
+#include <mln/value/int_u8.hh>
+#include <mln/value/int_u.hh>
+#include <mln/data/all.hh>
+#include <mln/core/alias/neighb2d.hh>
+#include <mln/algebra/all.hh>
+#include <mln/core/image/graph_elt_neighborhood.hh>
+#include <mln/literal/all.hh>
+#include <mln/graph/compute.hh>
+
+#include <mln/draw/plot.hh>
+
+#include <my/util/vector_bbox.hh>
+#include <my/util/vector_bbox_group.hh>
+#include <my/document/document.hh>
+#include <my/debug/pict.hh>
+#include <my/debug/bbox.hh>
+#include <my/document/clean.hh>
+using namespace mln;
+using namespace std;
+void Process(std::string File)
+{
+
+ std::cout << "Processing : " << File << endl;
+ /* CREATE GRAPH */
+ typedef value::int_u<16> uint16;
+ image2d<bool> ima;
+
+ mln::util::timer timer;
+ timer.start();
+ io::pbm::load(ima, File);
+ std::cout << "LOADING FILE : " << timer.stop() << endl;
+ timer.restart();
+
+
+
+ uint16 areas_detected;
+ image2d<uint16> ima_blob = labeling::blobs(ima, c4(), areas_detected);
+ image2d<uint16> ima_influ = transform::influence_zone_geodesic(ima_blob,
c8());
+ util::graph grph = make::influence_zone_adjacency_graph(ima_influ, c4(),
areas_detected);
+
+
+ std::cout << "CREATE GRAPH : " << timer.stop() << endl;
+
+
+ /* COMPUTE GRAPH POINT POSITION */
+ timer.restart();
+ typedef p_vertices<util::graph, fun::i2v::array<mln::point2d> >
g_vertices_p;
+ typedef graph_elt_neighborhood<util::graph, g_vertices_p> g_nbh;
+ mymln::util::vector_bbox_group<2, short, uint16>
vect_bbox_group(areas_detected);
+ mln_fwd_piter_(image2d<uint16>) pi(ima_blob.domain());
+ for_all(pi)
+ {
+ uint16 lpi = ima_blob(pi);
+ if (lpi == 0)
+ continue;
+
+ vect_bbox_group.add(0,pi[0], lpi - 1);
+ vect_bbox_group.add(1,pi[1], lpi - 1);
+ }
+ fun::i2v::array<point2d> graph_points(areas_detected + 1);
+ graph_points(0) = point2d(0,0);
+ for(unsigned int N = 0; N < areas_detected; N++)
+ {
+ graph_points(N + 1) =
+ point2d(
+ (vect_bbox_group.start(0, N) + vect_bbox_group.end(0, N)) / 2,
+ (vect_bbox_group.start(1, N) + vect_bbox_group.end(1, N)) / 2);
+ }
+ g_vertices_p area_grph(grph, graph_points);
+
+ std::cout << "COMPUTE GRAPH POINT POSITION : " << timer.stop()
<< endl;
+
+ /* WORK ON GRAPH */
+ timer.restart();
+
+ mymln::document::document<uint16,float,short> doc(ima_blob,vect_bbox_group,
area_grph, areas_detected);
+ doc.vertical_separator_ratio_range(0.0f, 0.1f);
+ doc.horizontal_separator_ratio_range(6.0f, 1000.0f);
+ doc.container_volume_range(100, 100);
+ for (uint16 N = 1; N < areas_detected + 1; N++)
+ {
+
+ g_nbh grph_nbh;
+ mln_psite_(g_vertices_p) plist(area_grph, N);
+ mln_fwd_niter_(g_nbh) fq(grph_nbh, plist);
+ unsigned link = 0;
+ for_all((fq))
+ {
+ link++;
+ }
+ doc.add(N, (uint16)link);
+
+ }
+
+ // mymln::document::clean_containers_items(doc);
+ doc.stat();
+ //io::ppm::save(ima_influ, "separator.ppm");
+ //io::pbm::save(doc.image_mask_separators(),"separators");
+ io::pbm::save(doc.image_mask_letters(),"letters_" + File);
+ io::pbm::save(doc.image_mask_separators(),"separators_" + File);
+ io::pbm::save(doc.image_mask_containers(),"containers_" + File);
+ io::pbm::save(doc.image_mask_noise(),"noise_" + File);
+ /* typedef vertex_image<point2d,bool> v_ima_g;
+ v_ima_g mask = doc.fun_mask_letters();
+*/
+ /*image2d<bool> out(3500,3500);
+
+
+
+
+ mln_piter_(v_ima_g) v(mask.domain());
+ typedef graph_elt_neighborhood_if<util::graph, g_vertices_p, v_ima_g> nbh_t;
+ nbh_t nbh(mask);
+ mln_niter_(nbh_t) q(nbh, v);
+
+ unsigned int fnds = 0;
+ for_all(v)
+ {
+ unsigned int nds = 0;
+ for_all(q)
+ {
+ nds++;
+
+ draw::line(out, q,v, true);
+ }
+ if(nds > 0)
+ {
+ std::cout << v << endl;
+ fnds++;
+ }
+
+
+ }*/
+ //mymln::debug::draw_graph(out, mask);
+ //io::pbm::save(out, "maskltt.dgb");
+ //std::cout << "NODES:" << fnds << endl;
+ // mymln::debug::save_graph_image(area_grph, ima, "graph_" + File);
+ // mymln::debug::save_graph_image(doc.fun_mask_separators(), ima,
"separator_graph_" + File);
+ // mymln::debug::save_graph_image(doc.fun_mask_containers(),
doc.image_mask_letters(), "container_graph_" + File);
+ std::cout << "WORK ON GRAPH : " << timer.stop() << endl;
+}
+
+
+int main( int argc, char** argv)
+{
+ if(argc <= 1){Process("ima.pbm");}
+ else
+ {
+ for(int N = 1 ; N < argc; N++)
+ {Process(argv[N]);}
+ }
+
+}
diff --git a/scribo/sandbox/raphael/code/makefile b/scribo/sandbox/raphael/code/makefile
new file mode 100644
index 0000000..5588f9b
--- /dev/null
+++ b/scribo/sandbox/raphael/code/makefile
@@ -0,0 +1,13 @@
+speed:
+ g++ test.cc -o ~/Bureau/test/bin/test.elf -I . -I ./../../../../milena -O3
-fwhole-program
+ ~/Bureau/test/bin/test.elf
+std:
+
+ g++ test.cc -o ~/Bureau/test/bin/test.elf -I . -I ./../../../../milena
+ ~/Bureau/test/bin/test.elf
+release:
+ g++ test.cc -o ~/Bureau/test/bin/test.elf -I . -I ./../../../../milena -DNDEBUG -O2
+ ~/Bureau/test/bin/test.elf
+clean:
+ rm -r -f ../bin/*
+
diff --git a/scribo/sandbox/raphael/code/my/debug/all.hh
b/scribo/sandbox/raphael/code/my/debug/all.hh
new file mode 100644
index 0000000..cd2c28e
--- /dev/null
+++ b/scribo/sandbox/raphael/code/my/debug/all.hh
@@ -0,0 +1,2 @@
+#include <pict.hh>
+#include <bbox.hh>
\ No newline at end of file
diff --git a/scribo/sandbox/raphael/code/my/debug/bbox.hh
b/scribo/sandbox/raphael/code/my/debug/bbox.hh
new file mode 100644
index 0000000..debba99
--- /dev/null
+++ b/scribo/sandbox/raphael/code/my/debug/bbox.hh
@@ -0,0 +1,46 @@
+#ifndef INC_DEBUG_BBOX
+#define INC_DEBUG_BBOX
+#include<my/util/vector_bbox_group.hh>
+#include<my/util/vector_bbox.hh>
+#include<iostream>
+namespace mymln
+{
+ namespace debug
+ {
+ template <unsigned int D, typename C>
+ inline
+ void printdb(util::vector_bbox<D,C> bbox);
+
+ template <unsigned int D, typename C>
+ inline
+ void printdb(mln::algebra::vec<D,C> vector);
+
+ template<unsigned int D, typename C> inline void
printdb(mln::algebra::vec<D,C> vector)
+ {
+ std::cout << std::endl;
+ std::cout << "Vector " << D << " : " <<
std::endl;
+ for(unsigned int N = 0;N < D; N++)
+ {
+ std::cout << " " << vector[N] << std::endl;
+ }
+ }
+
+ template<unsigned int D, typename C> inline void
printdb(util::vector_bbox<D,C> bbox)
+ {
+ std::cout << std::endl;
+ std::cout << "Vector Bounding Box " << D << " :
" << std::endl;
+ std::cout << " Start: " << std::endl;
+ for(unsigned int N = 0;N < D; N++)
+ {
+ std::cout << " " << bbox.start(N) << std::endl;
+ }
+
+ std::cout << " End: " << std::endl;
+ for(unsigned int N = 0;N < D; N++)
+ {
+ std::cout << " " << bbox.end(N) << std::endl;
+ }
+ }
+ }
+}
+#endif
\ No newline at end of file
diff --git a/scribo/sandbox/raphael/code/my/debug/pict.hh
b/scribo/sandbox/raphael/code/my/debug/pict.hh
new file mode 100644
index 0000000..1597d53
--- /dev/null
+++ b/scribo/sandbox/raphael/code/my/debug/pict.hh
@@ -0,0 +1,119 @@
+#ifndef INC_DEBUG_PICT
+#define INC_DEBUG_PICT
+#include <mln/util/graph.hh>
+
+#include <mln/debug/superpose.hh>
+using namespace mln;
+using namespace std;
+namespace mymln
+{
+ namespace debug
+ {
+ template<typename I> inline void save_label_image(I ima, std::string file)
+ {
+ image2d<value::rgb8> ima_color = labeling::colorize(value::rgb8(), ima);
+ io::ppm::save(ima_color, file);
+ }
+ template<typename I1, typename I2> inline void
save_label_image(image2d<I1> ima, mln::util::array<I2> trans, std::string
file)
+ {
+ mln_piter(image2d<I1>) p(ima.domain());
+ p.start();
+ while(p.is_valid())
+ {
+ ima(p) = trans(ima(p));
+ p.next();
+ }
+ image2d<value::rgb8> ima_color = labeling::colorize(value::rgb8(), ima);
+ io::ppm::save(ima_color, file);
+ }
+ template<typename p_v> inline void save_graph_image(p_v& pv, unsigned int
SizeX, unsigned int SizeY, std::string file)
+ {
+ image2d<value::rgb8> ima_graph(SizeY, SizeX);
+ data::fill(ima_graph, literal::black);
+ mln::debug::draw_graph(ima_graph, pv, mln::literal::magenta, mln::literal::magenta);
+ io::ppm::save(ima_graph, file);
+ }
+ template<typename p_v,typename I> inline void save_graph_image(p_v& pv, I
source, std::string file)
+ {
+ image2d<value::rgb8> ima_graph;
+ mln::initialize(ima_graph, source);
+ data::fill(ima_graph, literal::black);
+ mln::debug::draw_graph(ima_graph, pv, mln::literal::magenta, mln::literal::magenta);
+
+ io::ppm::save(mln::debug::superpose(ima_graph,source, literal::white) , file);
+ }
+ typedef fun::i2v::array<point2d> graph_fun_points2d;
+ template<typename point> inline void save_graph_image(mln::util::graph&
graph, fun::i2v::array<point>& points, unsigned int SizeX, unsigned int SizeY,
std::string file)
+ {
+ typedef p_vertices<mln::util::graph, fun::i2v::array<mln::point2d> >
g_vertices_p;
+ g_vertices_p pv(graph, points);
+ image2d<value::rgb8> ima_graph(SizeY, SizeX);
+ data::fill(ima_graph, literal::black);
+ mln::debug::draw_graph(ima_graph, pv, mln::literal::magenta, mln::literal::magenta);
+ io::ppm::save(ima_graph, file);
+ }
+ template<typename I> inline void
save_boxes_image(mln::util::array<box2d> boxes, I source, std::string file)
+ {
+ image2d<bool> out(source.domain());
+ data::fill(out, false);
+ for(unsigned int N = 0 ; N < boxes.size(); N++)
+ {
+ data::fill((out | (boxes[N])).rw(), true);
+ }
+ io::pbm::save(out , file);
+ }
+ template<typename I> inline void
save_graph_image(vertex_image<point2d,bool> mask, I source, std::string file)
+ {
+ typedef p_vertices<mln::util::graph, fun::i2v::array<mln::point2d> >
g_vertices_p;
+ typedef vertex_image<point2d,bool> v_ima_g;
+ typedef graph_elt_neighborhood_if<mln::util::graph, g_vertices_p, v_ima_g> nbh_t;
+
+ image2d<value::rgb8> out;
+ mln::initialize(out, source);
+
+ mln_piter_(v_ima_g) v(mask.domain());
+
+ nbh_t nbh(mask);
+ mln_niter_(nbh_t) q(nbh, v);
+
+ unsigned int fnds = 0;
+ for_all(v)
+ {
+ unsigned int nds = 0;
+ for_all(q) {
+
+ draw::line(out, q,v, mln::literal::magenta);
+ }
+ }
+ io::ppm::save(mln::debug::superpose(out,source, literal::white) , file);
+ }
+
+ template<typename I> inline void
save_graph_image(vertex_image<point2d,bool> graphsource,
vertex_image<point2d,bool> mask, I source, std::string file)
+ {
+ typedef p_vertices<mln::util::graph, fun::i2v::array<mln::point2d> >
g_vertices_p;
+ typedef vertex_image<point2d,bool> v_ima_g;
+ typedef graph_elt_neighborhood_if<mln::util::graph, g_vertices_p, v_ima_g> nbh_t;
+
+ image2d<value::rgb8> out;
+ mln::initialize(out, source);
+
+ mln_piter_(v_ima_g) v(graphsource.domain());
+
+ nbh_t nbh(mask);
+ mln_niter_(nbh_t) q(nbh, v);
+
+ unsigned int fnds = 0;
+ for_all(v)
+ {
+ unsigned int nds = 0;
+ for_all(q) {
+
+ draw::line(out, q,v, mln::literal::magenta);
+ }
+ }
+ io::ppm::save(mln::debug::superpose(out,source, literal::white) , file);
+ }
+
+ }
+}
+#endif
\ No newline at end of file
diff --git a/milena/doc/outputs/accu-right-instantiation.txt
b/scribo/sandbox/raphael/code/my/document/bloc.hh
similarity index 100%
copy from milena/doc/outputs/accu-right-instantiation.txt
copy to scribo/sandbox/raphael/code/my/document/bloc.hh
diff --git a/scribo/sandbox/raphael/code/my/document/clean.hh
b/scribo/sandbox/raphael/code/my/document/clean.hh
new file mode 100644
index 0000000..a421439
--- /dev/null
+++ b/scribo/sandbox/raphael/code/my/document/clean.hh
@@ -0,0 +1,92 @@
+#ifndef INC_CLEAN_DOC
+#define INC_CLEAN_DOC
+#include<my/document/document.hh>
+#include <mln/core/image/graph_elt_neighborhood.hh>
+#include <mln/core/image/vertex_image.hh>
+using namespace mln;
+
+namespace mymln
+{
+ namespace document
+ {
+ template<typename L, typename F, typename D>
+ void clean_containers_items(mymln::document::document<L,F,D>& doc)
+ {
+ typedef vertex_image<point2d,bool> v_ima_g;
+ typedef p_vertices<mln::util::graph, fun::i2v::array<mln::point2d> >
g_vertices_p;
+ v_ima_g mask = doc.fun_mask_containers();
+ mln_piter_(v_ima_g) v(mask.domain());
+ typedef graph_elt_neighborhood_if<mln::util::graph, g_vertices_p, v_ima_g>
nbh_t;
+ nbh_t nbh(mask);
+ mln_niter_(nbh_t) q(nbh, v);
+ for_all(v)
+ {
+
+ for_all(q)
+ {
+ if(!doc.contain_container(v) && doc.get_bbox(q).has(v))
+ doc.add_noise(v);
+ }
+ }
+
+ }
+ template<typename L, typename F, typename D>
+ void clean_letters_items(mymln::document::document<L,F,D>& doc)
+ {
+ typedef vertex_image<point2d,bool> v_ima_g;
+ typedef p_vertices<mln::util::graph, fun::i2v::array<mln::point2d> >
g_vertices_p;
+ v_ima_g mask = doc.fun_mask_letters();
+ mln_piter_(v_ima_g) v(mask.domain());
+ typedef graph_elt_neighborhood_if<mln::util::graph, g_vertices_p, v_ima_g>
nbh_t;
+ nbh_t nbh(mask);
+ mln_niter_(nbh_t) q(nbh, v);
+ for_all(v)
+ {
+ if(doc.contain_letter(v))
+ {
+ unsigned int count = 0;
+ for_all(q)
+ {
+ if(doc.contain_letter(q))
+ count++;
+ }
+ if(count < 1)
+ { doc.add_noise(v); }
+ }
+ }
+
+ }
+
+ template<typename L, typename F, typename D>
+ void clean_get_lines(mymln::document::document<L,F,D>& doc)
+ {
+ typedef vertex_image<point2d,bool> v_ima_g;
+ typedef p_vertices<mln::util::graph, fun::i2v::array<mln::point2d> >
g_vertices_p;
+ v_ima_g mask = doc.fun_mask_letters();
+ mln_piter_(v_ima_g) v(mask.domain());
+ typedef graph_elt_neighborhood_if<mln::util::graph, g_vertices_p, v_ima_g>
nbh_t;
+ nbh_t nbh(mask);
+ mln_niter_(nbh_t) q(nbh, v);
+ for_all(v)
+ {
+ if(doc.contain_letter(v))
+ {
+ doc.jump_to_line(v);
+ doc.add_to_line(v);
+ for_all(q)
+ {
+ if((!doc.contain_line(q)))
+ {
+ if((doc.allign_V(q,v)))
+ {
+ doc.add_to_line(q);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+#endif
\ No newline at end of file
diff --git a/scribo/sandbox/raphael/code/my/document/document.hh
b/scribo/sandbox/raphael/code/my/document/document.hh
new file mode 100644
index 0000000..5a18723
--- /dev/null
+++ b/scribo/sandbox/raphael/code/my/document/document.hh
@@ -0,0 +1,446 @@
+#ifndef INC_DOCUMENT_DOC
+#define INC_DOCUMENT_DOC
+#include<my/util/vector_bbox_group.hh>
+#include <mln/util/graph.hh>
+using namespace mln;
+namespace mymln
+{
+ namespace document
+ {
+
+ template<typename Label, typename Float, typename Data>
+ class document
+ {
+ typedef
+ mln::p_graph_piter<
+ mln::p_vertices<
+ mln::util::graph,
+ fun::i2v::array<point2d>
+ >,
+ mln::internal::vertex_fwd_iterator<mln::util::graph>
+ >
+ graph_itt;
+
+ typedef p_vertices<mln::util::graph, fun::i2v::array<mln::point2d> >
g_vertices_p;
+
+ public:
+ // Create a document
+ // A document enable the user to work on several elements like
+ // separatororletter
+ // to work correctly a document need a labelized image that represent
+ // the structure of the document.( - usualy created with labeling::blobs - )
+
+ // NOTE : The type Float is used toperform floating point operation on data
+ // with type Label. So a conversion betweem Data and Float must exist.
+
+ document(image2d<Label>& ima, image2d<Label>&
ima_influ,mln::util::array<box2d>& bboxgp, g_vertices_p& area_graph, Label
Areas)
+ {
+ img = ima;
+ _bboxgp = bboxgp;
+ _area_graph = area_graph;
+ separators_mask = fun::i2v::array<bool>(Areas + 1);
+ containers_mask = fun::i2v::array<bool>(Areas + 1);
+ letters_mask = fun::i2v::array<bool>(Areas + 1);
+ Hseparator_mask = fun::i2v::array<bool>(Areas + 1);
+ Vseparator_mask = fun::i2v::array<bool>(Areas + 1);
+ noise_mask = fun::i2v::array<bool>(Areas + 1);
+
+ lines_mark = mln::util::array<unsigned int>(Areas + 1);
+ lines_mark.fill(0);
+ img_influ = ima_influ;
+ CSep = 0;
+ CSepH = 0;
+ CSepV = 0;
+ CLet = 0;
+ CLine = 1;
+ NLine = 2;
+
+ }
+ /* OPERATION ON LINES */
+ inline void add_to_line(const point2d& point)
+ { add_to_line(img_influ(point)); }
+
+ inline void add_new_line(const point2d& point)
+ { add_new_line(img_influ(point)); }
+
+ inline void jump_to_line(const point2d& point)
+ { jump_to_line(img_influ(point)); }
+
+ inline bool contain_line(const point2d& point)
+ { return contain_line(img_influ(point)); }
+
+ inline void add_to_line(const Label lbl)
+ { lines_mark[lbl] = CLine; std::cout << "add : " << CLine; }
+
+ inline void add_new_line(const Label lbl)
+ { CLine = NLine; NLine++; }
+
+ inline void jump_to_line(const Label lbl)
+ {
+ if(lines_mark[lbl] != 0)
+ CLine = lines_mark[lbl];
+ else
+ add_new_line(lbl);
+ }
+
+ inline bool contain_line(const Label lbl)
+ { return lines_mark[lbl] != 0;}
+
+ /* LABELS MUST ALLWAYS BE SORTED */
+ inline void add_noise(const point2d& point)
+ {add_noise(img_influ(point));}
+
+
+
+ void add_noise(Label lbl)
+ {
+ separators_mask(lbl) = false;
+ letters_mask(lbl) = false;
+ containers_mask(lbl) = false;
+ Hseparator_mask(lbl) = false;
+ Vseparator_mask(lbl) = false;
+
+ noise_mask(lbl) = true;
+ }
+ void inline add(Label lbl, int link)
+ {
+ if (link == 0){add_noise(lbl);}
+ else if (link > 40){ add_separator(lbl);}
+ else { add_letter(lbl);}
+ }
+ void inline invalid_letter(const point2d& point)
+ {invalid_letter(img_influ(point));}
+ void invalid_letter(Label lbl)
+ {letters_mask(lbl) = true;}
+ void inline invalid_separator(const point2d& point)
+ {invalid_separator(img_influ(point));}
+ void invalid_separator(Label lbl)
+ {
+ separators_mask(lbl) = false;
+ Vseparator_mask(lbl) = false;
+ Hseparator_mask(lbl) = false;
+ }
+ void inline invalid_container(const point2d& point)
+ {invalid_container(img_influ(point));}
+ void invalid_container(const Label lbl)
+ {containers_mask(lbl) = false;}
+ void inline add_letter(const point2d& point)
+ {add_letter(img_influ(point)); }
+ void add_letter(const Label lbl)
+ {
+ CLet++;
+ if(label_valid_size_Min_(lbl, 2))
+ {
+ letters_mask(lbl) = true;
+ separators_mask(lbl) = false;
+ containers_mask(lbl) = false;
+ Vseparator_mask(lbl) = false;
+ Hseparator_mask(lbl) = false;
+
+ noise_mask(lbl) = false;
+ }
+ else
+ add_noise(lbl);
+ }
+ void inline add_container(const point2d& point)
+ {add_container(img_influ(point)); }
+ void add_container(const Label lbl)
+ {
+ if(label_valid_size_Min_(lbl, 2))
+ {
+ CSep++;
+ containers_mask(lbl) = true;
+ Vseparator_mask(lbl) = false;
+ Hseparator_mask(lbl) = false;
+ letters_mask(lbl) = false;
+ separators_mask(lbl) = false;
+ noise_mask(lbl) = false;
+ }
+ else
+ add_noise(lbl);
+ }
+ void add_Hseparator(const Label lbl)
+ {
+ CSep++;
+ containers_mask(lbl) = false;
+ Vseparator_mask(lbl) = false;
+ Hseparator_mask(lbl) = true;
+ letters_mask(lbl) = false;
+ separators_mask(lbl) = true;
+
+ noise_mask(lbl) = false;
+ }
+ void add_Vseparator(const Label lbl)
+ {
+ CSep++;
+ containers_mask(lbl) = false;
+ Vseparator_mask(lbl) = true;
+ Hseparator_mask(lbl) = false;
+ letters_mask(lbl) = false;
+ separators_mask(lbl) = true;
+
+ noise_mask(lbl) = false;
+ }
+ void inline add_separator(const point2d& point)
+ {add_letter(img_influ(point)); }
+ void add_separator(const Label lbl)
+ {
+ if(label_valid_ratio_(lbl, _VSepRatio_Min,_VSepRatio_Max))
+ add_Vseparator(lbl);
+ else if(label_valid_ratio_(lbl, _HSepRatio_Min,_HSepRatio_Max))
+ add_Hseparator(lbl);
+ else
+ add_container(lbl);
+ }
+
+ bool inline contain_separator(const Label lbl)
+ {return contain_(lbl, separators_mask);}
+
+ bool inline contain_letter(const Label lbl)
+ {return contain_(lbl, letters_mask);}
+
+ bool inline contain_container(const Label lbl)
+ {return contain_(lbl, containers_mask);}
+
+ bool inline contain_separator(const point2d& point)
+ {return contain_separator(img_influ(point));}
+
+ bool inline contain_letter(const point2d& point)
+ {return contain_letter(img_influ(point));}
+
+ bool inline contain_container(const point2d& point)
+ {return contain_container(img_influ(point));}
+
+ box2d inline get_bbox(const point2d& point)
+ {return _bboxgp(img_influ(point));}
+
+ box2d inline get_bbox(const Label lbl)
+ {return _bboxgp(lbl);}
+
+ inline void vertical_separator_ratio_range(Float min, Float max)
+ {_VSepRatio_Min = min; _VSepRatio_Max = max;}
+
+ inline void horizontal_separator_ratio_range(Float min, Float max)
+ {_HSepRatio_Min = min; _HSepRatio_Max = max;}
+
+ inline void letter_volume_range(Data min, Data max)
+ {_LeterVolume_Min = min; _LeterVolume_Max = max;}
+
+ inline void container_volume_range(Data min, Data max)
+ {_ContainerVolume_Min = min; _ContainerVolume_Max = max;}
+
+ /* ALLIGN FUNCTION */
+
+ inline bool allign_H( const point2d& Left, const point2d& Right)
+ {return allign_H(img_influ(Left), img_influ(Right));}
+
+ inline bool allign_H( const Label Left, const Label Right)
+ {
+ return label_allign_(1, Left, Right) < label_size_(1 ,Left);
+ }
+ inline bool allign_V( const point2d& Left, const point2d& Right)
+ {return allign_V(img_influ(Left), img_influ(Right));}
+
+ inline bool allign_V( const Label Left, const Label Right)
+ {
+ short int allignV = label_allign_(0, Left, Right) * 4;
+ return allignV < label_size_(0, Left) && allignV < label_size_(0,
Right);
+ }
+ inline bool allign_Space_Factor(const point2d& Left, const point2d& Right)
+ {return allign_Space_Factor(img_influ(Left), img_influ(Right));}
+
+ inline bool allign_Space_Factor( const Label Left, const Label Right)
+ {
+ Float AFactor = label_allign_(1, Left, Right);
+ return AFactor < label_size_(1,Left);
+ }
+
+
+ void stat()
+ {
+ std::cout << "document :" << std::endl;
+ std::cout << " letter(s) : " << CLet << std::endl;
+ std::cout << " separator(s) : " << CSep << std::endl;
+ std::cout << " vertical separator(s) : " << CSepV
<< std::endl;
+ std::cout << " horizontal separator(s) : " << CSepH
<< std::endl;
+ std::cout << " lines(s) : " << CLine << std::endl;
+ mymln::debug::save_label_image(img, lines_mark , "outfileline.pbm");
+ }
+
+ vertex_image<point2d,bool> fun_mask_separators()
+ { return fun_mask_(separators_mask); }
+ vertex_image<point2d,bool> fun_mask_containers()
+ { return fun_mask_(containers_mask); }
+ vertex_image<point2d,bool> fun_mask_all()
+ {
+ typedef vertex_image<point2d,bool> v_ima_g;
+ v_ima_g result(_area_graph);
+ return result;
+ }
+ vertex_image<point2d,bool> fun_mask_letters()
+ { return fun_mask_(letters_mask); }
+ image2d<bool> image_mask_containers()
+ { return image_mask_(containers_mask); }
+ image2d<bool> image_mask_separators()
+ { return image_mask_(separators_mask); }
+ image2d<bool> image_mask_letters()
+ { return image_mask_(letters_mask); }
+ image2d<bool> image_mask_noise()
+ { return image_mask_(noise_mask); }
+
+ mln::util::array<box2d> bbox_mask_containers()
+ { return bbox_mask_(containers_mask); }
+ mln::util::array<box2d> bbox_mask_separators()
+ { return bbox_mask_(separators_mask); }
+ mln::util::array<box2d> bbox_mask_letters()
+ { return bbox_mask_(letters_mask); }
+ mln::util::array<box2d> bbox_mask_noise()
+ { return bbox_mask_(noise_mask); }
+
+ mln::util::array<box2d> bbox_enlarge_mask_containers(short int x, short int
y)
+ { return bbox_mask_enlarge_(containers_mask, x, y); }
+ mln::util::array<box2d> bbox_enlarge_mask_separators(short int x, short int y)
+ { return bbox_mask_enlarge_(separators_mask, x, y); }
+ mln::util::array<box2d> bbox_enlarge_mask_letters(short int x, short int y)
+ { return bbox_mask_enlarge_(letters_mask, x, y); }
+ mln::util::array<box2d> bbox_enlarge_mask_noise(short int x, short int y)
+ { return bbox_mask_enlarge_(noise_mask, x, y); }
+
+
+
+ /*image_if<image2d<Label> masked_image_letters()
+ {return masked_image_(letters_mask); }
+ image_if<image2d<Label> masked_image_separator()
+ {return masked_image_(letters_mask); }*/
+
+ private:
+ // GENERIC CONTAIN TEST
+ inline bool contain_(const Label& lbl, const fun::i2v::array<bool>&
array)
+ {
+ return array(lbl);
+ }
+ // VECTOR MUST BE VECTOR 2 OTHERWISE THE RATION WILL BE Z / X
+ // THIS CAN BE A PROBLEM FOR GENERICITY
+ inline Float label_ratio_(Label label)
+ {
+ return ((Float)_bboxgp[label].len(0)) / ((Float)_bboxgp[label].len(1));
+ }
+ inline short int label_allign_(const unsigned int N, const Label l1, const Label l2)
+ {
+ short int AFactor = _bboxgp[l1].pcenter()[N] - _bboxgp[l2].pcenter()[N];
+ return AFactor < 0 ? -AFactor : AFactor;
+ }
+ inline Data label_size_(const unsigned int N, const Label label)
+ {
+ return _bboxgp[label].len(N);
+ }
+ inline bool label_valid_size_(Label label, Data Min, Data Max)
+ {
+ Data SX = label_size_(0, label);
+ Data SY = label_size_(1, label);
+ return !(SX < Min|| SX > Max || SY < Min || SX > Max);
+ }
+ inline bool label_valid_size_Min_(Label label, Data Min)
+ {
+ Data SX = label_size_(0, label);
+ Data SY = label_size_(1, label);
+ return SX >= Min && SY >= Min;
+ }
+ inline bool label_valid_ratio_(Label label, Float Min, Float Max)
+ {
+ Float Ratio = label_ratio_(label);
+ return !(Ratio < Min || Ratio > Max);
+ }
+
+
+ // MASK & ITER
+ inline image_if<image2d<Label>, fun::i2v::array<bool> >
masked_image_(const fun::i2v::array<bool>& fun)
+ {
+ return (img | fun).rw();
+ }
+ inline image2d<bool> image_mask_(const fun::i2v::array<bool>& fun)
+ {
+ typedef image2d<Label> I;
+ image2d<bool> mask;
+ mln::initialize(mask, img);
+ mln_piter(I) p(img.domain());
+ p.start();
+ while(p.is_valid())
+ {
+ mask(p) = contain_(img(p), fun);
+ p.next();
+ }
+ return mask;
+ }
+ vertex_image<point2d,bool> fun_mask_(const fun::i2v::array<bool>&
mask)
+ {
+ typedef vertex_image<point2d,bool> v_ima_g;
+ v_ima_g result(_area_graph, mask);
+ return result;
+ }
+ mln::util::array<box2d> bbox_mask_(fun::i2v::array<bool>& mask)
+ {
+ mln::util::array<box2d> bbox_mask;
+ bbox_mask.reserve(_bboxgp.size());
+
+ for(unsigned int u = 0; u < _bboxgp.size(); u++)
+ {
+ if(mask(u))
+ bbox_mask.append(_bboxgp[u]);
+ }
+ return bbox_mask;
+ }
+ mln::util::array<box2d> bbox_mask_enlarge_(fun::i2v::array<bool>&
mask, short int x, short int y)
+ {
+ mln::util::array<box2d> bbox_mask;
+ bbox_mask.reserve(_bboxgp.size());
+ for(unsigned int u = 0; u < _bboxgp.size(); u++)
+ {
+ if(mask(u))
+ {
+ box2d box = _bboxgp[u];
+ box.enlarge(1, x);box.enlarge(0, y);
+ bbox_mask.append(box);
+ }
+ }
+ return bbox_mask;
+ }
+
+ fun::i2v::array<bool> Hseparator_mask;
+ fun::i2v::array<bool> Vseparator_mask;
+ fun::i2v::array<bool> separators_mask;
+ fun::i2v::array<bool> letters_mask;
+ fun::i2v::array<bool> containers_mask;
+ fun::i2v::array<bool> noise_mask;
+ unsigned int CLine;
+ unsigned int NLine;
+ mln::util::array<unsigned int> lines_mark;
+ unsigned int CLet ;
+ unsigned int CSep ;
+ unsigned int CSepH ;
+ unsigned int CSepV ;
+
+ /* RANGE DATA */
+ Float _VSepRatio_Min; // The ratio is computed with the bounding box
+ Float _VSepRatio_Max;
+ Float _HSepRatio_Min;
+ Float _HSepRatio_Max;
+ Float _LeterRatio_Min;
+ Float _LeterRatio_Max;
+ Data _LeterVolume_Min;
+ Data _LeterVolume_Max;
+
+ Data _ContainerVolume_Min;
+ Data _ContainerVolume_Max;
+
+
+ mln::util::array<box2d> _bboxgp;
+
+ /* DOCUMENT DATA */
+ g_vertices_p _area_graph;
+ mln::image2d<Label> img;
+ mln::image2d<Label> img_influ;
+ };
+ }
+}
+#endif
\ No newline at end of file
diff --git a/milena/doc/outputs/accu-right-instantiation.txt
b/scribo/sandbox/raphael/code/my/document/image.hh
similarity index 100%
copy from milena/doc/outputs/accu-right-instantiation.txt
copy to scribo/sandbox/raphael/code/my/document/image.hh
diff --git a/scribo/sandbox/raphael/code/my/document/lettre.hh
b/scribo/sandbox/raphael/code/my/document/lettre.hh
new file mode 100644
index 0000000..98a1725
--- /dev/null
+++ b/scribo/sandbox/raphael/code/my/document/lettre.hh
@@ -0,0 +1,17 @@
+class line
+{
+ public:
+ line(){}
+ void add(lettre& ltr)
+ {lettres.append(ltr);}
+ private:
+ mln::util::array<vbbox> lettres;
+ std::string name;}
+class lettre
+{
+ public:
+ letter(){}
+ private:
+ std::string name;
+
+}
\ No newline at end of file
diff --git a/milena/doc/outputs/accu-right-instantiation.txt
b/scribo/sandbox/raphael/code/my/document/title.hh
similarity index 100%
copy from milena/doc/outputs/accu-right-instantiation.txt
copy to scribo/sandbox/raphael/code/my/document/title.hh
diff --git a/milena/doc/outputs/accu-right-instantiation.txt
b/scribo/sandbox/raphael/code/my/math/sqrt.hh
similarity index 100%
copy from milena/doc/outputs/accu-right-instantiation.txt
copy to scribo/sandbox/raphael/code/my/math/sqrt.hh
diff --git a/scribo/sandbox/raphael/code/my/util/graph.hh
b/scribo/sandbox/raphael/code/my/util/graph.hh
new file mode 100644
index 0000000..44ef5c9
--- /dev/null
+++ b/scribo/sandbox/raphael/code/my/util/graph.hh
@@ -0,0 +1,8 @@
+template<typename Image, typename Data>
+util::graph create_influance_graph(Image ima, Data& area_detected)
+{
+ image2d<Data> ima_blob = labeling::blobs(ima, c4(), area_detected);
+ image2d<Data> ima_influ = transform::influence_zone_geodesic(ima_blob, c4());
+ util::graph grph = make::influence_zone_adjacency_graph(ima_influ, c4(),
area_detected);
+ return grph;
+}
\ No newline at end of file
diff --git a/scribo/sandbox/raphael/code/my/util/vec2.hh
b/scribo/sandbox/raphael/code/my/util/vec2.hh
new file mode 100644
index 0000000..4a41493
--- /dev/null
+++ b/scribo/sandbox/raphael/code/my/util/vec2.hh
@@ -0,0 +1,23 @@
+#ifndef INC_VECTOR_2_TOOLS
+#define INC_VECTOR_2_TOOLS
+namespace mymln
+{
+ namespace util
+ {
+ template<typename dataType>
+ class vec2
+ {
+ public:
+ vec2(dataType X,dataType Y)
+ {_x = X; _y = Y;}
+ public dataType x(){return x;}
+ public dataType y(){return y;}
+ bool allign_x(vec2<dataType>& V,dataType T)
+ {
+ if(_x < V._x + T && _x < V._y + T)
+ {return }
+ }
+ private:
+
+ }
+#endif
\ No newline at end of file
diff --git a/scribo/sandbox/raphael/code/my/util/vector_bbox.hh
b/scribo/sandbox/raphael/code/my/util/vector_bbox.hh
new file mode 100644
index 0000000..4be715d
--- /dev/null
+++ b/scribo/sandbox/raphael/code/my/util/vector_bbox.hh
@@ -0,0 +1,97 @@
+#ifndef INC_VECTOR_BBOX
+#define INC_VECTOR_BBOX
+#include <mln/draw/box.hh>
+namespace mymln
+{
+ namespace util
+ {
+ template<unsigned int D, typename C>class vector_bbox
+ {
+ public :
+ vector_bbox()
+ {
+ init = false;
+ for(unsigned int N = 0; N < D; N++)
+ {
+ initN[N] = false;
+ }
+ }
+ void add(const unsigned int N, C value)
+ {
+ if(!init && !initN[N])
+ {
+ max[N] = value;
+ min[N] = value;
+ initN[N] = true;
+ for(unsigned int I = 0; I < D; I++)
+ {
+ if(!initN[I]){return;}
+ }
+ init = true;
+ return;
+ }
+ if(value > max[N]){max[N] = value;}
+ if(value < min[N]){min[N] = value;}
+ }
+ void add(mln::algebra::vec<D,C> vector)
+ {
+ if(!init)
+ {
+ for(unsigned int N = 0; N < D; N++)
+ {
+ max[N] = vector[N];
+ min[N] = vector[N];
+ }
+ init = true;
+ return;
+ }
+ for(unsigned int N = 0; N < D; N++)
+ {
+ if(vector[N] > max[N]){max[N] = vector[N];}
+ if(vector[N] < min[N]){min[N] = vector[N];}
+ }
+ }
+ // one define the value to use as one;
+ // it is usualy 1 !
+ inline C volume()
+ {
+ C Acc = 1;
+ for(unsigned int N = 0; N < D; N++)
+ {
+ Acc *= size(N);
+ }
+ return Acc;
+ }
+ inline bool contain(const unsigned int N,const C value)
+ {
+ return max[N] >= value && min[N] <= value;
+ }
+ inline C size(const unsigned int N)
+ {
+ return max[N] - min[N];
+ }
+ inline C start(const unsigned int N)
+ {
+ return min[N];
+ }
+ inline C end(const unsigned int N)
+ {
+ return max[N];
+ }
+
+ /* NOT VERY GENERIC : REMOVE AFTER TEST*/
+
+ template<typename I, typename V> void draw_to_picture(I& dest, V& value)
+ {
+ mln::draw::box(dest,
mln::box<mln::point2d>(mln::point2d(min[0],min[1]),mln::point2d(max[0], max[1])),
value);
+ }
+
+ private:
+ bool init;
+ mln::algebra::vec<D,bool>initN;
+ mln::algebra::vec<D,C> max;
+ mln::algebra::vec<D,C> min;
+ };
+ }
+}
+#endif
\ No newline at end of file
diff --git a/scribo/sandbox/raphael/code/my/util/vector_bbox_group.hh
b/scribo/sandbox/raphael/code/my/util/vector_bbox_group.hh
new file mode 100644
index 0000000..4768638
--- /dev/null
+++ b/scribo/sandbox/raphael/code/my/util/vector_bbox_group.hh
@@ -0,0 +1,67 @@
+#ifndef INC_VECTOR_BBOX_GROUP
+#define INC_VECTOR_BBOX_GROUP
+#include "vector_bbox.hh"
+namespace mymln
+{
+ namespace util
+ {
+ template<unsigned int D, typename C, typename Lbl>class vector_bbox_group
+ {
+ typedef vector_bbox<D,C> vbbox;
+ public :
+ vector_bbox_group()
+ {
+ bboxes = mln::util::array<vbbox>(0);
+ }
+ vector_bbox_group(unsigned nlabel)
+ {
+ bboxes = mln::util::array<vbbox>(nlabel);
+ bboxes.fill(vbbox());
+ }
+ void add(mln::algebra::vec<D,C> vector, Lbl label)
+ {
+ bboxes[label].add(vector);
+ }
+ void add(const unsigned int N, C value, Lbl label)
+ {
+
+ bboxes[label].add(N, value);
+
+ }
+ inline C volume(Lbl label)
+ {
+ return bboxes[label].volume();
+ }
+ template<typename I, typename V> void draw_to_picture(I& dest, V& value)
+ {
+ for(unsigned int N = 0; N < bboxes.size(); N++)
+ {
+ draw_to_picture(dest, value);
+ }
+ }
+ inline bool contain(const unsigned int N,const C value, Lbl label)
+ {
+ return bboxes[label].contain(N,value);
+ }
+ inline C start(const unsigned int N, Lbl label)
+ {
+ return bboxes[label].start(N);
+ }
+ inline C size(const unsigned int N, Lbl label)
+ {
+ return bboxes[label].size(N);
+ }
+ inline C end(const unsigned int N, Lbl label)
+ {
+ return bboxes[label].end(N);
+ }
+ inline unsigned int size()
+ {
+ return bboxes.size();
+ }
+ private:
+ mln::util::array<vbbox> bboxes;
+ };
+ }
+}
+#endif
\ No newline at end of file
diff --git a/scribo/sandbox/raphael/code/test.cc b/scribo/sandbox/raphael/code/test.cc
new file mode 100644
index 0000000..a73ebe6
--- /dev/null
+++ b/scribo/sandbox/raphael/code/test.cc
@@ -0,0 +1,180 @@
+
+#include <vector>
+#include <mln/io/all.hh>
+
+#include <mln/core/site_set/p_vertices.hh>
+#include <mln/core/image/graph_elt_window.hh>
+#include <mln/core/image/vertex_image.hh>
+#include <mln/core/image/graph_elt_neighborhood.hh>
+#include <mln/core/concept/function.hh>
+#include <mln/core/neighb.hh>
+#include <mln/core/image/graph_elt_neighborhood_if.hh>
+#include <mln/core/var.hh>
+#include <mln/accu/shape/bbox.hh>
+#include <mln/fun/i2v/array.hh>
+#include <mln/fun/p2b/all.hh>
+#include <mln/util/graph.hh>
+#include <mln/util/timer.hh>
+#include <mln/debug/draw_graph.hh>
+#include <mln/debug/println.hh>
+#include <mln/transform/all.hh>
+#include <mln/make/image2d.hh>
+#include <mln/core/alias/neighb2d.hh>
+#include <mln/make/influence_zone_adjacency_graph.hh>
+#include <mln/make/w_window2d.hh>
+#include <mln/labeling/all.hh>
+#include <mln/make/image.hh>
+#include <mln/value/rgb8.hh>
+#include <mln/value/int_u8.hh>
+#include <mln/value/int_u.hh>
+#include <mln/data/all.hh>
+#include <mln/core/alias/neighb2d.hh>
+#include <mln/algebra/all.hh>
+#include <mln/core/image/graph_elt_neighborhood.hh>
+#include <mln/literal/all.hh>
+#include <mln/graph/compute.hh>
+
+#include <mln/draw/plot.hh>
+#include <my/debug/pict.hh>
+#include <my/debug/bbox.hh>
+#include <my/util/vector_bbox.hh>
+#include <my/util/vector_bbox_group.hh>
+#include <my/document/document.hh>
+
+#include <my/document/clean.hh>
+using namespace mln;
+using namespace std;
+void Process(std::string File)
+{
+
+ std::cout << "Processing : " << File << endl;
+ /* CREATE GRAPH */
+ typedef value::int_u<16> uint16;
+ image2d<bool> ima;
+
+ mln::util::timer timer;
+ timer.start();
+ io::pbm::load(ima, File);
+ std::cout << "LOADING FILE : " << timer.stop() << endl;
+ timer.restart();
+
+
+
+ uint16 areas_detected;
+ timer.start();
+ image2d<uint16> ima_blob = labeling::blobs(ima, c4(), areas_detected);
+ std::cout << "CREATE BLOBS : " << timer.stop() << endl;
+ timer.restart();
+ timer.start();
+ image2d<uint16> ima_influ = transform::influence_zone_geodesic(ima_blob,
c8());
+ std::cout << "CREATE INFLUENCE ZONE GEODESIC : " <<
timer.stop() << endl;
+ timer.restart();
+ timer.start();
+ util::graph grph = make::influence_zone_adjacency_graph(ima_influ, c4(),
areas_detected);
+
+
+ std::cout << "CREATE GRAPH : " << timer.stop() << endl;
+
+
+ /* COMPUTE GRAPH POINT POSITION */
+ timer.restart();
+ util::array<box2d> boxes = labeling::compute(accu::meta::shape::bbox(),
ima_blob, areas_detected);
+ typedef p_vertices<util::graph, fun::i2v::array<mln::point2d> >
g_vertices_p;
+ typedef graph_elt_neighborhood<util::graph, g_vertices_p> g_nbh;
+ fun::i2v::array<point2d> graph_points(areas_detected + 1);
+ graph_points(0) = point2d(0,0);
+ for(unsigned int N = 0; N < areas_detected; N++)
+ {graph_points(N + 1) = boxes[N + 1].pcenter();}
+ g_vertices_p area_grph(grph, graph_points);
+
+ std::cout << "COMPUTE GRAPH POINT POSITION : " << timer.stop()
<< endl;
+
+ /* WORK ON GRAPH */
+
+
+
+ timer.restart();
+
+ mymln::document::document<uint16,float,short> doc(ima_blob, ima_influ, boxes,
area_grph, areas_detected);
+ doc.vertical_separator_ratio_range(0.0f, 0.1f);
+ doc.horizontal_separator_ratio_range(6.0f, 1000.0f);
+ doc.container_volume_range(40, 100);
+ for (uint16 N = 1; N <= areas_detected; N++)
+ {
+
+ g_nbh grph_nbh;
+ mln_psite_(g_vertices_p) plist(area_grph, N);
+ mln_fwd_niter_(g_nbh) fq(grph_nbh, plist);
+ unsigned link = 0;
+ for_all((fq))
+ {
+ link++;
+ }
+ doc.add(N, (uint16)link);
+
+ }
+ //mymln::debug::save_label_image(ima_influ, "influ_" + File);
+ mymln::document::clean_containers_items(doc);
+ mymln::document::clean_letters_items(doc);
+ mymln::document::clean_get_lines(doc);
+ doc.stat();
+ std::cout << "WORK ON GRAPH : " << timer.stop() << endl;
+ //io::ppm::save(ima_influ, "separator.ppm");
+ //io::pbm::save(doc.image_mask_separators(),"separators");
+ io::pbm::save(doc.image_mask_letters(),"letters_" + File);
+ io::pbm::save(doc.image_mask_separators(),"separators_" + File);
+ io::pbm::save(doc.image_mask_containers(),"containers_" + File);
+ io::pbm::save(doc.image_mask_noise(),"noise_" + File);
+ /* typedef vertex_image<point2d,bool> v_ima_g;
+ v_ima_g mask = doc.fun_mask_letters();
+*/
+ /*image2d<bool> out(3500,3500);
+
+
+
+
+ mln_piter_(v_ima_g) v(mask.domain());
+ typedef graph_elt_neighborhood_if<util::graph, g_vertices_p, v_ima_g> nbh_t;
+ nbh_t nbh(mask);
+ mln_niter_(nbh_t) q(nbh, v);
+
+ unsigned int fnds = 0;
+ for_all(v)
+ {
+ unsigned int nds = 0;
+ for_all(q)
+ {
+ nds++;
+
+ draw::line(out, q,v, true);
+ }
+ if(nds > 0)
+ {
+ std::cout << v << endl;
+ fnds++;
+ }
+
+
+ }*/
+ //mymln::debug::draw_graph(out, mask);
+ //io::pbm::save(out, "maskltt.dgb");
+ //std::cout << "NODES:" << fnds << endl;
+ // mymln::debug::save_graph_image(area_grph, ima, "graph_" + File);
+ // mymln::debug::save_graph_image(doc.fun_mask_separators(), ima,
"separator_graph_" + File);
+ mymln::debug::save_graph_image(area_grph, doc.image_mask_letters(),
"graph_" + File);
+ mymln::debug::save_graph_image(doc.fun_mask_letters(), doc.image_mask_letters(),
"container_graph_" + File);
+ //mymln::debug::save_boxes_image(doc.bbox_mask_letters(), ima, "lbox_" +
File);
+ //mymln::debug::save_boxes_image(doc.bbox_enlarge_mask_letters(10, 0), ima,
"linebox_" + File);
+}
+
+
+int main( int argc, char** argv)
+{
+ if(argc <= 1){Process("ima.pbm");}
+ else
+ {
+ for(int N = 1 ; N < argc; N++)
+ {Process(argv[N]);}
+ }
+
+}
diff --git a/scribo/sandbox/raphael/test b/scribo/sandbox/raphael/test
deleted file mode 120000
index bc9ab42..0000000
--- a/scribo/sandbox/raphael/test
+++ /dev/null
@@ -1 +0,0 @@
-/lrde/beyrouth/stage/boissel/Bureau/test
\ No newline at end of file
--
1.7.2.5