Olena-patches
Threads by month
- ----- 2025 -----
- 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
September 2011
- 7 participants
- 173 discussions

last-svn-commit-970-g63a1ff7 scribo/toolchain/internal/toolchain_functor.hh: Fix a warning with GCC 4.5.
by Guillaume Lazzara 08 Sep '11
by Guillaume Lazzara 08 Sep '11
08 Sep '11
---
scribo/ChangeLog | 5 +++++
.../scribo/toolchain/internal/toolchain_functor.hh | 4 ++++
2 files changed, 9 insertions(+), 0 deletions(-)
diff --git a/scribo/ChangeLog b/scribo/ChangeLog
index d667e43..7010044 100644
--- a/scribo/ChangeLog
+++ b/scribo/ChangeLog
@@ -1,3 +1,8 @@
+2011-03-29 Guillaume Lazzara <z(a)lrde.epita.fr>
+
+ * scribo/toolchain/internal/toolchain_functor.hh: Fix a warning
+ with GCC 4.5.
+
2011-09-07 Guillaume Lazzara <z(a)lrde.epita.fr>
* tests/estim/font_boldness.cc: Make the test deterministic.
diff --git a/scribo/scribo/toolchain/internal/toolchain_functor.hh b/scribo/scribo/toolchain/internal/toolchain_functor.hh
index 5621c7c..197a84b 100644
--- a/scribo/scribo/toolchain/internal/toolchain_functor.hh
+++ b/scribo/scribo/toolchain/internal/toolchain_functor.hh
@@ -44,6 +44,7 @@ namespace scribo
public:
Toolchain_Functor();
+ virtual ~Toolchain_Functor();
virtual int nsteps() const = 0;
@@ -70,6 +71,9 @@ namespace scribo
{
}
+ Toolchain_Functor::~Toolchain_Functor()
+ {
+ }
//==========
// Triggers
--
1.7.2.5
1
0

08 Sep '11
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 unstable/scribo has been updated
via 9bb74f4d6d55d208fa0f31ec6a0df03b451a3b5e (commit)
via f925bd94c1c6ecba0e70b7636e4edbc673dbc40e (commit)
via 6f7885a26734f43117a62384f650c430d925a4fd (commit)
via 63a1ff7470f73fec8396a40f0c3131e0f86f800d (commit)
via f6b3eedf8372f99ee3bafff823c2c38ce9583b93 (commit)
via 1eb0e9ab700d03106edcf7cc12314ea63dd7c6be (commit)
via 13db8ed45606d72f93dc43df86e2b4fa8ca43a69 (commit)
from b072c6336956c5ab43f4b46f3d20959b3110c529 (commit)
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 -----------------------------------------------------------------
9bb74f4 Fix doc generation.
f925bd9 AUTHORS: Update.
6f7885a mln/core/image/vertex_image.hh: Fix invalid construction.
63a1ff7 scribo/toolchain/internal/toolchain_functor.hh: Fix a warning with GCC 4.5.
f6b3eed tests/estim/font_boldness.cc: Make the test deterministic.
1eb0e9a Add comments.
13db8ed tests/border/mirror.cc: Revamp test.
-----------------------------------------------------------------------
Summary of changes:
AUTHORS | 6 ++-
ChangeLog | 4 +
milena/ChangeLog | 31 ++++++++
milena/doc/Doxyfile.in | 10 +--
milena/doc/ref-guide.tex | 8 ++-
milena/doc/technical.tex | 8 ++-
milena/doc/tutorial.tex | 40 +++++-----
milena/mln/accu/take.hh | 2 +
milena/mln/border/mirror.hh | 10 ++-
milena/mln/core/concept/object.hh | 7 +-
milena/mln/core/image/vertex_image.hh | 2 +-
milena/tests/border/mirror.cc | 74 ++++++++------------
scribo/ChangeLog | 9 +++
.../scribo/toolchain/internal/toolchain_functor.hh | 4 +
scribo/tests/estim/font_boldness.cc | 6 +-
15 files changed, 135 insertions(+), 86 deletions(-)
hooks/post-receive
--
Olena, a generic and efficient image processing platform
1
0
* doc/Doxyfile.in: Enable source code parsing and listing. Fix
include directories.
* doc/ref-guide.tex,
* doc/technical.tex: Use .sty files as input files instead of
packages.
* doc/tutorial.tex: Use .sty files as input files instead of
packages. Fix references.
* mln/core/concept/object.hh: Fix copyright.
---
milena/ChangeLog | 16 ++++++++++++++
milena/doc/Doxyfile.in | 10 +++-----
milena/doc/ref-guide.tex | 8 ++++--
milena/doc/technical.tex | 8 ++++--
milena/doc/tutorial.tex | 40 ++++++++++++++++++------------------
milena/mln/core/concept/object.hh | 7 +++--
6 files changed, 54 insertions(+), 35 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 5c629c1..cb63be3 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,21 @@
2011-09-08 Guillaume Lazzara <z(a)lrde.epita.fr>
+ Fix doc generation.
+
+ * doc/Doxyfile.in: Enable source code parsing and listing. Fix
+ include directories.
+
+ * doc/ref-guide.tex,
+ * doc/technical.tex: Use .sty files as input files instead of
+ packages.
+
+ * doc/tutorial.tex: Use .sty files as input files instead of
+ packages. Fix references.
+
+ * mln/core/concept/object.hh: Fix copyright.
+
+2011-09-08 Guillaume Lazzara <z(a)lrde.epita.fr>
+
* mln/core/image/vertex_image.hh: Fix invalid construction.
2011-09-07 Guillaume Lazzara <z(a)lrde.epita.fr>
diff --git a/milena/doc/Doxyfile.in b/milena/doc/Doxyfile.in
index 5b20a7c..843280a 100644
--- a/milena/doc/Doxyfile.in
+++ b/milena/doc/Doxyfile.in
@@ -36,7 +36,6 @@ STRIP_FROM_INC_PATH =
SHORT_NAMES = YES
JAVADOC_AUTOBRIEF = YES
MULTILINE_CPP_IS_BRIEF = NO
-DETAILS_AT_TOP = NO
INHERIT_DOCS = YES
SEPARATE_MEMBER_PAGES = NO
TAB_SIZE = 8
@@ -101,8 +100,8 @@ EXCLUDE = @top_srcdir@/milena/sandbox \
@top_srcdir@/milena/trash \
@top_srcdir@/milena/mln/core/concept/proxy.hxx \
@top_srcdir@/milena/doc/examples/trash \
- @top_srcdir@/milena/doc/user-refman
- @top_srcdir@/milena/doc/devel-refman
+ @top_srcdir@/milena/doc/user-refman \
+ @top_srcdir@/milena/doc/devel-refman \
@top_srcdir@/milena/tests/unit_test
EXCLUDE_SYMLINKS = YES
EXCLUDE_PATTERNS = *spe.hh
@@ -115,8 +114,7 @@ EXAMPLE_PATTERNS = *.cc \
*.cc.raw \
*.txt
EXAMPLE_RECURSIVE = NO
-IMAGE_PATH = @top_srcdir@/milena/doc/devel/figures \
- @top_srcdir@/milena/doc/img \
+IMAGE_PATH = @top_srcdir@/milena/doc/img \
@top_srcdir@/milena/doc/figures
INPUT_FILTER =
FILTER_PATTERNS =
@@ -126,7 +124,7 @@ INPUT_ENCODING = ISO-8859-1
#---------------------------------------------------------------------------
# configuration options related to source browsing
#---------------------------------------------------------------------------
-SOURCE_BROWSER = NO
+SOURCE_BROWSER = YES
INLINE_SOURCES = NO
STRIP_CODE_COMMENTS = YES
REFERENCED_BY_RELATION = YES
diff --git a/milena/doc/ref-guide.tex b/milena/doc/ref-guide.tex
index cdd5791..3328947 100644
--- a/milena/doc/ref-guide.tex
+++ b/milena/doc/ref-guide.tex
@@ -1,4 +1,5 @@
-%% Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+%% Copyright (C) 2009, 2011 EPITA Research and Development Laboratory
+%% (LRDE)
%%
%% This file is part of Olena.
%%
@@ -33,8 +34,9 @@
\usepackage{hyperref}
\usepackage{pgf}
\usepackage{hyperref}
-\usepackage{doxyfuns}
-\usepackage{milena}
+
+\input{doxyfuns.sty}
+\input{milena.sty}
\title{Olena -- Quick Reference Guide}
\author{LRDE}
diff --git a/milena/doc/technical.tex b/milena/doc/technical.tex
index 4afc908..b74b7b5 100644
--- a/milena/doc/technical.tex
+++ b/milena/doc/technical.tex
@@ -1,4 +1,5 @@
-%% Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+%% Copyright (C) 2009, 2011 EPITA Research and Development Laboratory
+%% (LRDE)
%%
%% This file is part of Olena.
%%
@@ -33,8 +34,9 @@
\usepackage{hyperref}
\usepackage{pgf}
\usepackage{hyperref}
-\usepackage{doxyfuns}
-\usepackage{milena}
+
+\input{doxyfuns.sty}
+\input{milena.sty}
\title{Milena -- Technical documentation}
\author{LRDE}
diff --git a/milena/doc/tutorial.tex b/milena/doc/tutorial.tex
index 5a61461..8fee888 100644
--- a/milena/doc/tutorial.tex
+++ b/milena/doc/tutorial.tex
@@ -1,5 +1,5 @@
-%% Copyright (C) 2008, 2009 EPITA Research and Development Laboratory
-%% (LRDE)
+%% Copyright (C) 2008, 2009, 2011 EPITA Research and Development
+%% Laboratory (LRDE)
%%
%% This file is part of Olena.
%%
@@ -32,8 +32,6 @@
\usepackage{color}
\usepackage{hyperref}
\usepackage{pgf}
-\usepackage{doxyfuns}
-\usepackage{milena}
% FIXME: Consider using the package FiXme from Didier Verna instead.
%\newcommand{\tofix}[1]{{\color{red}(FIXME: #1)}}
@@ -45,10 +43,12 @@
\date{}
\makeindex
-
+\input{doxyfuns.sty}
+\input{milena.sty}
\begin{document}
+
% Doxygen use only - Generate the left menu.
%Write foreword below.
\begin{htmlonly}
@@ -233,11 +233,11 @@ $ cd trunk
\end{verbatim}
You are now ready to configure the directory and install Milena as described
-in section \ref{tuto2}.
+in section \doxyref{tuto2}.
We invite you to take a look at the description of the directory structure
-(section \ref{tuto1dirstruct}).
+(section \doxyref{tuto1dirstruct}).
If you encounter any issues in the installation process or if you have any
-question, do not forget to join the mailing lists (section \ref{tuto1mailinglists})
+question, do not forget to join the mailing lists (section \doxyref{tuto1mailinglists})
and/or use the other documentations resources (section ref{tuto1documentation}).
@@ -275,13 +275,13 @@ $ cd olena
You are now ready to configure the directory and install Milena as described
-in section \ref{tuto2}.
+in section \doxyref{tuto2}.
We invite you to take a look at the description of the directory structure
-(section \ref{tuto1dirstruct}).
+(section \doxyref{tuto1dirstruct}).
If you encounter any issues in the installation process or if you have any
question, do not forget to join the mailing lists (section
-\ref{tuto1mailinglists}) and/or use the other documentations resources
-(section \ref{tuto1documentation})).
+\doxyref{tuto1mailinglists}) and/or use the other documentations resources
+(section \doxyref{tuto1documentation})).
@@ -467,7 +467,7 @@ for new contributors.
Did you find what you wanted? Do you miss something?
\item Please report bugs and defects in the API. Mailing lists are the best
- way for reporting that (section \ref{tuto1mailinglists}).
+ way for reporting that (section \doxyref{tuto1mailinglists}).
\item Developers, if you write cool open source programs or algorithms with Milena,
send them to us. We may ship your code with Olena and/or add it to
@@ -477,7 +477,7 @@ for new contributors.
share your materials, you can send it to us through our mailing-lists.
\item We are also interested in partnership or commercial use of Milena.
- If you are interested, contact us directly (\ref{tuto1contacts}).
+ If you are interested, contact us directly (\doxyref{tuto1contacts}).
\end{itemize}
@@ -486,7 +486,7 @@ for new contributors.
\doxysection{tuto1projectstatus}{Project status}
If you want to stay tuned to Milena's development, the best way is probably
-the mailing-lists (section \ref{tuto1mailinglists}).
+the mailing-lists (section \doxyref{tuto1mailinglists}).
There are other ways to get to know what is the status of the project.
@@ -604,7 +604,7 @@ your system, generating the doc and compiling the test suite and the examples.
\doxysection{tuto2bootstrap}{Bootstrap (SVN Sources)}
If you got the sources from a package/tarball, you can skip this section. Go
-to section \ref{tuto2configure}.
+to section \doxyref{tuto2configure}.
If you downloaded the sources from the SVN repository, you must launch a
script before configuring the build directory.
@@ -704,10 +704,10 @@ $ make install
When the installation is finished, you are done. Milena is installed on your
system. But maybe you would like to build the examples? This is described
-in section \ref{tuto2optionalcomp}.
+in section \doxyref{tuto2optionalcomp}.
A description of the installation content is also available in section
-\ref{tuto2installcontent}.
+\doxyref{tuto2installcontent}.
@@ -894,7 +894,7 @@ The important point to remember is that a generic function should not return
\doxycode[3]{tuto3_first_routine}
Like any Milena's routine, note that we use \code{trace}. This debugging tool
-will be detailed in section \ref{tuto3debughints}.
+will be detailed in section \doxyref{tuto3debughints}.
\doxycode[4]{tuto3_first_routine}
@@ -1187,7 +1187,7 @@ sites in an image, consequently they do not store any values.
Site sets can used as standalone containers.
-A list of available site sets is available in section \ref{siteset}.
+A list of available site sets is available in section \doxyref{siteset}.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% MOVE PARTS OF THE NEXT CHAPTERS RIGHT HERE. %
diff --git a/milena/mln/core/concept/object.hh b/milena/mln/core/concept/object.hh
index 03408db..4d58fbf 100644
--- a/milena/mln/core/concept/object.hh
+++ b/milena/mln/core/concept/object.hh
@@ -1,5 +1,5 @@
-// Copyright (C) 2007, 2008, 2009, 2010 EPITA Research and Development
-// Laboratory (LRDE)
+// Copyright (C) 2007, 2008, 2009, 2010, 2011 EPITA Research and
+// Development Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -107,7 +107,8 @@
<LI> \ref mln::win
\section copyright Copyright and License.
- Copyright (C) 2007, 2008, 2009, 2010 EPITA Research and Development (LRDE)
+ Copyright (C) 2007, 2008, 2009, 2010, 2011 EPITA Research and
+ Development (LRDE)
This documentation is part of Olena.
--
1.7.2.5
1
0
---
AUTHORS | 6 +++++-
ChangeLog | 4 ++++
2 files changed, 9 insertions(+), 1 deletions(-)
diff --git a/AUTHORS b/AUTHORS
index 554bf89..73aed4a 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -65,6 +65,8 @@ Interns.
* Arthur Crépin-Leblond
- SCRIBO structured outputs (XML, HTML, PDF).
+* Raphaël Boissel
+ - Graph implementation of a DIA toolchain in SCRIBO.
=========================
Students from Class 2012.
@@ -74,6 +76,8 @@ Students from Class 2012.
- Prototype of the upcoming functions system.
* Julien Marquegnies julien.marquegnies(a)lrde.epita.fr
+ - Fast implementation of the Hough transform.
+ - Many improvements in SCRIBO layout analysis.
=========================
Students from Class 2011.
@@ -102,7 +106,7 @@ Students from Class 2009.
- Data routines.
* Matthieu Garrigues
- - Value types and i/o.
+ - Value types and i/o.
- Draft of the FLLT.
* Ugo Jardonnet
diff --git a/ChangeLog b/ChangeLog
index d6dfc6d..0f69cb8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2011-09-08 Guillaume Lazzara <z(a)lrde.epita.fr>
+
+ * AUTHORS: Update.
+
2011-09-02 Guillaume Lazzara <z(a)lrde.epita.fr>
* configure.ac: Remove references to deprecated Makefiles.
--
1.7.2.5
1
0

08 Sep '11
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 raphael has been deleted
was 485817ced01f1d00df8a080a1a87c3caacc0cc90
-----------------------------------------------------------------------
485817ced01f1d00df8a080a1a87c3caacc0cc90 Clean everything and create the function influence_and_graph in milena. influance_and_graph saves 400 ms during the creation of the graph.
-----------------------------------------------------------------------
hooks/post-receive
--
Olena, a generic and efficient image processing platform
1
0

08 Sep '11
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 sandbox/raphael has been created
at 485817ced01f1d00df8a080a1a87c3caacc0cc90 (commit)
- Log -----------------------------------------------------------------
No new revisions were added by this update.
-----------------------------------------------------------------------
hooks/post-receive
--
Olena, a generic and efficient image processing platform
1
0

last-svn-commit-894-g36186b0 Optimize the code. Some optimization has not been tested, if there is some problem please use the previous version.
by Raphael Boissel 08 Sep '11
by Raphael Boissel 08 Sep '11
08 Sep '11
---
scribo/sandbox/raphael/code/my/document/clean.hh | 63 ++++++++++---------
.../sandbox/raphael/code/my/document/separator.hh | 53 ++++++++++-------
scribo/sandbox/raphael/code/my/runtime/runtime.hh | 4 +-
scribo/sandbox/raphael/code/test.cc | 2 +-
4 files changed, 68 insertions(+), 54 deletions(-)
diff --git a/scribo/sandbox/raphael/code/my/document/clean.hh b/scribo/sandbox/raphael/code/my/document/clean.hh
index 0f5276d..023ac1f 100644
--- a/scribo/sandbox/raphael/code/my/document/clean.hh
+++ b/scribo/sandbox/raphael/code/my/document/clean.hh
@@ -401,21 +401,23 @@ namespace mymln
mln_niter_(nbh_t) q(nbh, v);
for_all(v)
{
- if(doc.contain_line(v))
+ L lv = doc[v];
+ if(doc.contain_line(lv))
{
for_all(q)
{
+ L lq = doc[q];
if(
- doc.contain_line(q) &&
- !doc.same_line(q,v) &&
- doc.get_line_length(q) == 1 &&
- doc.line_influence_has(v,q) &&
- !doc.align_H_large(v,q) &&
- (doc.align_base_line_strict(v,q) || doc.align_V(v,q))
+ doc.contain_line(lq) &&
+ !doc.same_line(lq,lv) &&
+ doc.get_line_length(lq) == 1 &&
+ doc.line_influence_has(lv,q) &&
+ !doc.align_H_large(lv,lq) &&
+ (doc.align_base_line_strict(lv,lq) || doc.align_V(lv,lq))
)
{
doc.debug_draw_line_green_buffer(q,v);
- doc.add_to_line_link(q,v);
+ doc.add_to_line_link(lq,lv);
}
}
}
@@ -436,63 +438,64 @@ namespace mymln
mln_niter_(nbh_t) q(nbh, v);
for_all(v)
{
+ L lv = doc[v];
if(doc.contain_line(v))
{
for_all(q)
{
+ L lq = doc[q];
+ if(doc.same_line(lq,lv)){ continue;}
- if(doc.same_line(q,v)){ continue;}
-
- if(doc.contain_alone_letter(q))
+ if(doc.contain_alone_letter(lq))
{
- if(doc.align_V(q,v) && doc.align_proximity_strict(q, v) && doc.align_size_height(q, v))
+ if(doc.align_V(lq,lv) && doc.align_proximity_strict(lq, lv) && doc.align_size_height(lq, lv))
{
- doc.add_to_line_link(v, q);
+ doc.add_to_line_link(lv, lq);
}
}
- else if(doc.contain_line(q))
+ else if(doc.contain_line(lq))
{
- if(doc.align_V(q,v) && doc.align_size_height_line_strict(q, v) && doc.align_proximity_strict(q,v))
+ if(doc.align_V(lq,lv) && doc.align_size_height_line_strict(lq, lv) && doc.align_proximity_strict(lq,lv))
{
- doc.add_to_line_link(v, q);
+ doc.add_to_line_link(lv, lq);
}
- else if(doc.align_size_height_line(q,v))
+ else if(doc.align_size_height_line(lq,lv))
{
- if(doc.align_proximity_line(q,v) && doc.align_V_line_strict(q, v))
+ if(doc.align_proximity_line(lq,lv) && doc.align_V_line_strict(lq, lv))
{
- doc.add_to_line_link(v, q);
+ doc.add_to_line_link(lv, lq);
doc.debug_draw_line_green_buffer(v,q);
}
- else if(doc.line_influence_reciprocal(q, v) && doc.align_V_line_strict(q, v) && doc.align_size_height_line(q,v))
+ else if(doc.line_influence_reciprocal(lq, lv) && doc.align_V_line_strict(lq, lv) && doc.align_size_height_line(lq,lv))
{
- doc.add_to_line_link(v, q);
+ doc.add_to_line_link(lv, lq);
doc.debug_draw_line_red_buffer(v,q);
}
else if(
- doc.line_influence_reciprocal(q, v) &&
- !doc.same_line(q,v) &&
- doc.align_V(q,v) &&
- doc.align_size_x_height(v,q) &&
- doc.get_line_length(v) > 4 &&
- doc.align_proximity_line(v,q)
+ doc.line_influence_reciprocal(lq, lv) &&
+ !doc.same_line(lq,lv) &&
+ doc.align_V(lq,lv) &&
+ doc.align_size_x_height(lv,lq) &&
+ doc.get_line_length(lv) > 4 &&
+ doc.align_proximity_line(lv,lq)
)
{
doc.debug_draw_box_red_buffer(v);
doc.debug_draw_box_green_buffer(q);
- doc.add_to_line_link(v, q);
+ doc.add_to_line_link(lv, lq);
}
- else if(doc.align_V(q,v) && doc.align_proximity_strict(q,v))
+ else if(doc.align_V(lq,lv) && doc.align_proximity_strict(lq,lv))
{
doc.debug_draw_line_orange_buffer(q,v);
- doc.add_to_line_link(v, q);
+ doc.add_to_line_link(lv, lq);
}
}
diff --git a/scribo/sandbox/raphael/code/my/document/separator.hh b/scribo/sandbox/raphael/code/my/document/separator.hh
index be33d38..b7ddc27 100644
--- a/scribo/sandbox/raphael/code/my/document/separator.hh
+++ b/scribo/sandbox/raphael/code/my/document/separator.hh
@@ -52,50 +52,59 @@ namespace mymln
nbh_t nbh(mask);
mln_niter_(nbh_t) q(nbh, v);
mymln::util::union_find<L> sep_union(doc.size());
+ bool Change = false;
for_all(v)
{
- if(!doc[v]){continue;}
- if(doc.contain_Vseparator(doc[v]) && !sep_union[doc[v]])
+ L lv = doc[v];
+ if(!lv){continue;}
+ if(doc.contain_Vseparator(lv) && !sep_union[lv])
{
- sep_union[doc[v]] = sep_union.new_set();
- sep_union.add_self_link(doc[v]);
- if(doc.is_very_big_element_V(v))
+ sep_union[lv] = sep_union.new_set();
+ sep_union.add_self_link(lv);
+ Change = true;
+ if(doc.is_very_big_element_V(lv))
{ continue; }
}
for_all(q)
{
- if(doc.contain_Vseparator(doc[q])){continue;}
- if(doc.contain_Vseparator(doc[v]) &&
- doc.separator_has(v, q))
+ L lq = doc[q];
+ if(doc.contain_Vseparator(lq)){continue;}
+ if(doc.contain_Vseparator(lv) &&
+ doc.separator_has(lv, lq))
{
- doc.add_Vseparator(doc[q]);
- doc.debug_draw_box_red_buffer(doc[q]);
- sep_union[doc[q]] = sep_union[doc[v]];
- sep_union.add_link(doc[v], doc[q]);
+ doc.add_Vseparator(lq);
+ doc.debug_draw_box_red_buffer(lq);
+ sep_union[lq] = sep_union[lv];
+ sep_union.add_link(lv, lq);
+ Change = true;
}
else if(
- doc.letter_ratio_XY (q) <= 1 &&
- doc.align_H_large_one(q, v) &&
- doc.align_proximity_top_strict(q,v)
+ doc.letter_ratio_XY (lq) <= 1 &&
+ doc.align_H_large_one(lq, lv) &&
+ doc.align_proximity_top_strict(lq,lv)
)
{
- sep_union.add_link(doc[v], doc[q]);
+ sep_union.add_link(lv, lq);
+ Change = true;
}
}
}
- doc.debug_union(sep_union);
- sep_union.propage_links();
- for(int N = 0; N < doc.size(); N++)
+ //doc.debug_union(sep_union);
+ if(Change)
{
- if(sep_union[N])
+ sep_union.propage_links();
+ for(int N = 0; N < doc.size(); N++)
{
- if(!doc.contain_Vseparator(N))
+ if(sep_union[N])
{
- doc.add_Vseparator(N);
+ if(!doc.contain_Vseparator(N))
+ {
+ doc.add_Vseparator(N);
+ }
}
}
}
diff --git a/scribo/sandbox/raphael/code/my/runtime/runtime.hh b/scribo/sandbox/raphael/code/my/runtime/runtime.hh
index 110283a..7c3d41d 100644
--- a/scribo/sandbox/raphael/code/my/runtime/runtime.hh
+++ b/scribo/sandbox/raphael/code/my/runtime/runtime.hh
@@ -108,7 +108,9 @@ namespace mymln
{
float time = timer.stop() ;
if(time < 0.001f){time = 0.0f;}
- std::cout << program_instruction[CP] << " : " << time << std::endl; timer.restart();
+ if(time > 0.035f)
+ {std::cout << program_instruction[CP] << " : " << time << std::endl; }
+ timer.restart();
}
}
}
diff --git a/scribo/sandbox/raphael/code/test.cc b/scribo/sandbox/raphael/code/test.cc
index 00acd1c..a3d94a6 100644
--- a/scribo/sandbox/raphael/code/test.cc
+++ b/scribo/sandbox/raphael/code/test.cc
@@ -148,7 +148,7 @@ void Process(std::string File, std::string Dir, mymln::runtime::runtime< value::
}
- runtime.run_debug();
+ runtime.run();
std::cout << "WORK ON GRAPH : " << timer.stop() << endl;
//mymln::data::page<uint16,float,short> page(doc);
// page.export_HTML(Dir + "/debug_" + File + ".html");
--
1.7.2.5
1
0

last-svn-commit-893-ge0f8e0e Optimize the code and add debugging options for runtime
by Raphael Boissel 08 Sep '11
by Raphael Boissel 08 Sep '11
08 Sep '11
---
scribo/sandbox/raphael/code/README | 2 +-
scribo/sandbox/raphael/code/makefile | 5 +-
scribo/sandbox/raphael/code/my/document/clean.hh | 21 +-
.../sandbox/raphael/code/my/document/document.hh | 978 +++++++++++++-------
scribo/sandbox/raphael/code/my/runtime/runtime.hh | 25 +
scribo/sandbox/raphael/code/test.cc | 16 +-
6 files changed, 685 insertions(+), 362 deletions(-)
diff --git a/scribo/sandbox/raphael/code/README b/scribo/sandbox/raphael/code/README
index 79390f6..ce8a63b 100644
--- a/scribo/sandbox/raphael/code/README
+++ b/scribo/sandbox/raphael/code/README
@@ -2,7 +2,7 @@
** MAKE **
make release create an executable without the demos
-make demo create an executable with all the demos inside
+make dem create an executable with all the demos inside
** COMMAND LINE **
diff --git a/scribo/sandbox/raphael/code/makefile b/scribo/sandbox/raphael/code/makefile
index 0c8e61e..cda7794 100644
--- a/scribo/sandbox/raphael/code/makefile
+++ b/scribo/sandbox/raphael/code/makefile
@@ -3,7 +3,7 @@ QT4 = -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtUiTools -I/usr
QT4_LIB = -L/usr/lib -lQtXml -lQtGui -lQtCore -lQtUiTools -lpthread
speed:
- ccache g++ test.cc -o ~/Bureau/test/bin/test.elf -I . -I ./../../../../milena -O3 -fwhole-program
+ ccache g++ test.cc -o ~/Bureau/test/bin/test.elf -I . -I ./../../../../milena -DNDEBUG -DNDEMO -O3 -fwhole-program -march=native
~/Bureau/test/bin/test.elf -D ~/Bureau/test/bin -P ~/Bureau/test/bin/script ima.pbm
std:
ccache g++ test.cc -o ~/Bureau/test/bin/test.elf -I . -I ./../../../../milena
@@ -11,6 +11,9 @@ std:
release:
ccache g++ test.cc -msse3 -o ~/Bureau/test/bin/test.elf -I . -I ./../../../../milena $(QT4) $(QT4_LIB) -DNDEBUG -DNDEMO -O2 -march=native
~/Bureau/test/bin/test.elf -D ~/Bureau/test/bin -P ~/Bureau/test/bin/script ima.pbm
+release_ndebug:
+ ccache g++ test.cc -msse3 -o ~/Bureau/test/bin/test.elf -I . -I ./../../../../milena $(QT4) $(QT4_LIB) -DNDEBUG -DNDEMO -DNDEBUGGRAPH -O2 -march=native
+ ~/Bureau/test/bin/test.elf -D ~/Bureau/test/bin -P ~/Bureau/test/bin/script ima.pbm
dem:
ccache g++ test.cc -msse3 -o ~/Bureau/test/bin/test.elf -I . -I ./../../../../milena $(QT4) $(QT4_LIB) -DNDEBUG -O2 -march=native
~/Bureau/test/bin/test.elf -D ~/Bureau/test/bin -P ~/Bureau/test/bin/script ima.pbm
diff --git a/scribo/sandbox/raphael/code/my/document/clean.hh b/scribo/sandbox/raphael/code/my/document/clean.hh
index 5d55b3f..0f5276d 100644
--- a/scribo/sandbox/raphael/code/my/document/clean.hh
+++ b/scribo/sandbox/raphael/code/my/document/clean.hh
@@ -1024,27 +1024,30 @@ namespace mymln
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_line(v))
+ L lv = doc[v];
+ if(doc.contain_line(lv))
{
for_all(q)
{
+ L lq = doc[q];
if(
- doc.contain_line(q) &&
- !doc.same_line(q, v) &&
- doc.align_H_large(q, v) &&
- doc.align_size_height_line(q,v))
+ doc.contain_line(lq) &&
+ !doc.same_line(lq, lv) &&
+ doc.align_H_large(lq, lv) &&
+ doc.align_size_height_line(lq,lv))
{
- if(doc.align_top_large(q,v))
+ if(doc.align_top_large(lq,lv))
{
doc.debug_draw_line_green_buffer(q,v);
- doc.add_line_previous(q,v);
+ doc.add_line_previous(lq,lv);
}
- else if(doc.align_bottom_large(q,v))
+ else if(doc.align_bottom_large(lq,lv))
{
doc.debug_draw_line_red_buffer(q,v);
- doc.add_line_next(q,v);
+ doc.add_line_next(lq,lv);
}
}
}
diff --git a/scribo/sandbox/raphael/code/my/document/document.hh b/scribo/sandbox/raphael/code/my/document/document.hh
index 2ac9537..6da3df9 100644
--- a/scribo/sandbox/raphael/code/my/document/document.hh
+++ b/scribo/sandbox/raphael/code/my/document/document.hh
@@ -107,34 +107,55 @@ namespace mymln
lines_cooked = false;
Enable_Debug_Buffer = false; // Remanant version of debug_buffer_enable
}
+
+ // This method only return the height of the document
inline unsigned int height()
{return img_influ.domain().height();}
+ // This method only return the height of the document
inline unsigned int width()
{return img_influ.domain().width();}
+ // Return true if the label has been killed
inline bool killed(const Label lbl)
{return kill_mask(lbl);}
+ // Return kill a label
inline void kill(const Label lbl)
{
kill_mask(lbl) = true;
all_mask(lbl) = false;
}
+ // Return the number of Label in the document
inline unsigned int count()
{return Areas_Number_;}
/* OPERATION ON PAGE */
+
+ // Return true if the point is in the header
inline bool in_header(const point2d& p)
{ return p[0] < (img_influ.domain().len(0) / 8);}
+ // Return true if the label is in the header
inline bool in_header(Label lbl)
{ return in_header(_bboxgp[lbl]); }
-
+
+ // Return true if the point is in the footer
inline bool in_footer(const point2d& p)
{ return p[0] > ((img_influ.domain().len(0) / 8) * 7);}
+ // Return true if the label is in the footer
inline bool in_footer(Label lbl)
{ return in_footer(_bboxgp[lbl]); }
+
+ // Return true if the point is in a line composed only by a single word
+ // lines space must be cooked before
+ // WARNING : This method is depreciated
inline bool is_word(const point2d& p)
{ return is_word(img_influ(p)); }
+
+ // Same thing as is_word(const point2d& p) but with a Label
inline bool is_word(const Label lbl)
{ return lines_space[lbl] < lines_width[lbl] / 15.0f; }
+
+
/* OPERATION ON PARAGRAPH */
+
+ // precomputes the links in the paragraphs_union
inline bool link_paragraphs()
{
paragraphs_union[0] = 0;
@@ -167,38 +188,58 @@ namespace mymln
-
+ // Tests if the point is a part of a paragraph
inline bool contain_paragraph(const point2d& point)
{return contain_paragraph(img_influ(point));}
+ // Tests if the label is a part of a paragraph
inline bool contain_paragraph(const Label lbl)
{return paragraphs_union[lbl] != 0;}
+ // add the point to the current paragraph
inline void add_to_paragraph(const point2d& point)
{add_to_paragraph(img_influ(point));}
+ // add the labeltothecurrent paragraph
inline void add_to_paragraph(const Label lbl)
{paragraphs_union[lbl] = CPar;}
-
+
+ // creates a new paragraph and define it as the current paragraph
+ // NOTE : The point is here only for compatibility reason
+ // it should be the first point to add to the new paragraph
inline void add_new_paragraph(const point2d& point)
{add_new_paragraph(img_influ(point));}
+ // creates a new paragraph and define it as the current paragraph
+ // NOTE : The label is here only for compatibility reason
+ // it should be the first label to add to the new paragraph
inline void add_new_paragraph(const Label lbl)
{CPar = NPar; NPar++;}
+ // Add a paragraph link between two points. A will be the parent
inline void add_to_paragraph_link(const point2d& A, const point2d& B)
{add_to_paragraph_link(img_influ(A),img_influ(B));}
+ // Add a paragraph link between two labels. A will be the parent
inline void add_to_paragraph_link(const Label A, const Label B)
{paragraphs_union.add_link(A, B);}
+ // Set A as a self paragraph link. That means that A is it's
+ // own parent
inline void add_to_paragraph_self_link(const point2d& A)
{add_to_paragraph_self_link(img_influ(A));}
+ // Set A as a self paragraph link. That means that A is it's
+ // own parent
inline void add_to_paragraph_self_link(const Label A)
{paragraphs_union.add_self_link(A);}
+ // Propage all the paragraph links
inline void propage_paragraph_link()
{paragraphs_union.propage_links();}
+ // Set the paragraph that contain the point "point" as the current paragraph
+ // WARNING: If the point is not inside a paragraph the result is undefined
inline void jump_to_paragraph(const point2d& point)
{
jump_to_paragraph(img_influ(point));
}
+ // Set the paragraph that contain the label "lbl" as the current paragraph
+ // WARNING: If the label is not inside a paragraph the result is undefined
inline void jump_to_paragraph(const Label lbl)
{
if(paragraphs_union[lbl] != 0)
@@ -206,9 +247,14 @@ namespace mymln
else
add_new_paragraph(lbl);
}
+
+
/* OPERATION ON LINES */
+
+ // prepare the line tobe splitted at the specified point
inline void split_line_exclusive(const point2d& point)
{split_line_exclusive(img_influ(point));}
+ // prepare the line tobe splitted at the specified label
inline void split_line_exclusive(const Label lbl)
{
if(lbl == 0){return;}
@@ -232,9 +278,10 @@ namespace mymln
}
-
+ // prepare the line tobe splitted at the specified point
inline void split_line(const point2d& point)
{split_line(img_influ(point));}
+ // prepare the line tobe splitted at the specified label
inline void split_line(const Label lbl)
{
if(lbl == 0){return;}
@@ -258,17 +305,15 @@ namespace mymln
}
-
+ // Split all the lines prepared with split_line_exclusive
inline void cook_line_splitting_exclusive()
{
- std::cout << "--> start union exclusive" << std::endl;
for(unsigned int N = 1; N < Areas_Number_; N++)
{
lines_union.invalidate_link(N);
if(end_lines_mask(N) || implicit_separators_right_mask(N))
split_line_exclusive(N);
}
- std::cout << "--> start linking" << std::endl;
for(unsigned int N = 1; N < Areas_Number_; N++)
{
if(lines_union.is_self_link(N))
@@ -284,7 +329,6 @@ namespace mymln
}
lines_union[0] = 0;
lines_union.invalidate_link(0);
- std::cout << "--> propage union " << std::endl;
for(unsigned int N = 1; N < Areas_Number_; N++)
{
if(!contain_line(N) || lines_union.is_self_link(N))
@@ -296,11 +340,11 @@ namespace mymln
if(pos != 0 && pos != N && pos < Areas_Number_ )
{lines_union[N] = lines_union[pos]; lines_union.add_link(pos,N);}
}
- std::cout << "--> end propage union " << std::endl;
//lines_union.propage_links();lines_union
cook_lines();
}
-
+
+ // Split all the lines prepared with split_line
inline void cook_line_splitting()
{
for(unsigned int N = 1; N < Areas_Number_; N++)
@@ -337,38 +381,105 @@ namespace mymln
//lines_union.propage_links();lines_union
cook_lines();
}
+
+
+ // Set A as a self paragraph link. That means that A is it's
+ // own parent
+ inline void add_to_line_self_link(const Label A)
+ {lines_union.add_self_link(A);}
+ // Set A as a self paragraph link. That means that A is it's
+ // own parent
inline void add_to_line_self_link(const point2d& point)
{ add_to_line_self_link(img_influ(point));}
+
+ // Set the line that contain the point "point" as the current line
+ // WARNING: If the point is not inside a line the result is undefined
+ inline void jump_to_line(const point2d& point)
+ { jump_to_line(img_influ(point)); }
+ // Set the line that contain the point "point" as the current line
+ // WARNING: If the point is not inside a line the result is undefined
+ inline void jump_to_line(const Label lbl)
+ {
+ if(lines_union[lbl] != 0)
+ CLine = lines_union[lbl];
+ else
+ add_new_line(lbl);
+ }
+
+
+ inline void add_new_line(const point2d& point)
+ { add_new_line(img_influ(point)); }
+ inline void add_new_line(const Label lbl)
+ { CLine = NLine; NLine++; }
+
+
+
+
+
+ // Add the point to the current line
inline void add_to_line(const point2d& point)
{ add_to_line(img_influ(point)); }
+ // Add the label to the current line
+ inline void add_to_line(const Label lbl)
+ { lines_union[lbl] = CLine; }
+
+ // The label A will be linked with nothing
+ inline void invalidate_line_link(const Label A)
+ {lines_union.invalidate_link(A);}
+ // The point A will be linked with nothing
+ inline void invalidate_line_link(const point2d& A)
+ { invalidate_line_link(img_influ(A)); }
+
-
+ // Set A as a self paragraph link. That means that A is it's
+ // own parent
inline void add_to_line_link(const point2d& A, const point2d& B)
{ add_to_line_link(img_influ(A), img_influ(B)); }
- inline void invalidate_line_link(const point2d& A)
- { invalidate_line_link(img_influ(A)); }
+ // Set A as a self paragraph link. That means that A is it's
+ // own parent
+ inline void add_to_line_link(const Label A, const Label B)
+ {lines_union.add_link(A, B);}
+
+ // Tests if A and B are in the same line
inline bool same_line(const point2d& A, const point2d& B)
{ return same_line(img_influ(A), img_influ(B)); }
+ // Tests if A and B are in the same line
inline bool same_line(const Label A, const Label B)
{ return lines_union[A] == lines_union[B]; }
+
+ // Tests if A and B are in the same paragraph
inline bool same_paragraph(const point2d& A, const point2d& B)
{ return same_paragraph(img_influ(A), img_influ(B)); }
+ // Tests if A and B are in the same paragraph
inline bool same_paragraph(const Label A, const Label B)
{ return paragraphs_union[A] == paragraphs_union[B]; }
-
+
+ // Return true if the point A is in the beginning of the line
inline bool in_beginning_of_line(const point2d& A)
{return in_beginning_of_line(img_influ(A));}
+ // Return true if the label A is in the beginning of the line
inline bool in_beginning_of_line(const Label A)
{return lines_bbox[lines_union[A]].len(1) / 8 + lines_bbox[lines_union[A]].pmin()[1] > _bboxgp[A].pmax()[1];}
+ // Return true if the point A is in the end of the line
+ inline bool in_end_of_line(const point2d& A)
+ {return in_end_of_line(img_influ(A));}
+ // Return true if the point A is in the end of the line
+ inline bool in_end_of_line(const Label A)
+ {return lines_bbox[lines_union[A]].pmax()[1] - lines_bbox[lines_union[A]].len(1) / 8 < _bboxgp[A].pmax()[1];}
+
+
+
+ // Return true if the point can be use as a clasic element of the line_base
+ // (i.e : it is not a . , ' " ...)
inline bool is_line_representative(const point2d& A)
{return is_line_representative(img_influ(A));}
inline bool is_line_representative(const Label A)
{return lines_bbox[lines_union[A]].len(0) < _bboxgp[A].len(0) * 2 ;}
-
+ // Tests if the point is an artefact according to the bounding box of the line
inline bool is_line_artefact(const point2d& A)
{return is_line_artefact(img_influ(A));}
inline bool is_line_artefact(const Label A)
@@ -376,6 +487,8 @@ namespace mymln
return lines_bbox[lines_union[A]].len(0) > _bboxgp[A].len(0) * 24;
}
+ // remove all the labels that have been marked as noise
+ // from the lines_union
inline void clean_noise_lines()
{
for(int N = 0;N < Areas_Number_; N++)
@@ -386,7 +499,6 @@ namespace mymln
{
lines_union.invalidate_link(N);
lines_union[N] = 0;
-
}
}
}
@@ -406,11 +518,8 @@ namespace mymln
}
- inline bool in_end_of_line(const point2d& A)
- {return in_end_of_line(img_influ(A));}
- inline bool in_end_of_line(const Label A)
- {return lines_bbox[lines_union[A]].pmax()[1] - lines_bbox[lines_union[A]].len(1) / 8 < _bboxgp[A].pmax()[1];}
-
+ // return the space between the bounding box of A and
+ // the bounding box of B
inline unsigned int space(const point2d& A,const point2d& B)
{return space(img_influ(A), img_influ(B));}
inline unsigned int space(const Label A, const Label B)
@@ -430,38 +539,45 @@ namespace mymln
-
+ // Return true if the point is a part of the first line of a paragraph
inline bool contain_start_paragraph(const point2d& point)
{ return contain_start_paragraph(img_influ(point)); }
+ // Return true if the label is a part of the first line of a paragraph
+ inline bool contain_start_paragraph(const Label lbl)
+ { return paragraphs_first_line[paragraphs_union[lbl]] == lines_union[lbl];}
+
+
+ // Return true if the point is a part of the last line of the paragraph
inline bool contain_end_paragraph(const point2d& point)
{ return contain_end_paragraph(img_influ(point)); }
-
+ // Return true if the label is a part of the last line of the paragraph
+ inline bool contain_end_paragraph(const Label lbl)
+ { return paragraphs_last_line[paragraphs_union[lbl]] == lines_union[lbl];}
+ // Tests if the point is the first component of the line
inline bool contain_start_line(const point2d& point)
{ return contain_start_line(img_influ(point)); }
+ // Tests if the label is the last component of the line
+ inline bool contain_start_line(const Label lbl)
+ { return start_lines_mask(lbl);}
+ // Tests if the point is the last component of the line
inline bool contain_end_line(const point2d& point)
{ return contain_end_line(img_influ(point)); }
-
+ // Tests if the label is the last component of the line
+ inline bool contain_end_line(const Label lbl)
+ { return end_lines_mask(lbl);}
+
+ // Tests if the point is inside a line
inline bool contain_line(const point2d& point)
{ return contain_line(img_influ(point)); }
-
- inline bool contain_line_start(const point2d& point)
- { return contain_line_start(img_influ(point)); }
- inline bool contain_line_start(const Label lbl)
- { return lines_first_label(lbl); }
-
-
+ // Tests if the label is inside a line
inline bool contain_line(const Label lbl)
{ return lines_union[lbl] != 0;}
- inline bool contain_start_line(const Label lbl)
- { return start_lines_mask(lbl);}
-
- inline bool contain_start_paragraph(const Label lbl)
- { return paragraphs_first_line[paragraphs_union[lbl]] == lines_union[lbl];}
+
- inline bool contain_end_paragraph(const Label lbl)
- { return paragraphs_last_line[paragraphs_union[lbl]] == lines_union[lbl];}
+
+
///DIRECT VERSION OF contain_start_paragraph. A LINE ID MUST BE PASSED
inline bool contain_start_paragraph_direct(const unsigned int line_ID)
@@ -471,44 +587,23 @@ namespace mymln
{ return paragraphs_last_line[paragraphs_union[lines_last_label[line_ID]]] == line_ID;}
- inline bool contain_end_line(const Label lbl)
- { return end_lines_mask(lbl);}
-
-
-
-
- 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 void add_to_line(const Label lbl)
- { lines_union[lbl] = CLine; }
-
- inline void add_new_line(const Label lbl)
- { CLine = NLine; NLine++; }
+
- inline void add_to_line_self_link(const Label A)
- {lines_union.add_self_link(A);}
-
- inline void add_to_line_link(const Label A, const Label B)
- {lines_union.add_link(A, B);}
- inline void invalidate_line_link(const Label A)
- {lines_union.invalidate_link(A);}
- inline void jump_to_line(const Label lbl)
- {
- if(lines_union[lbl] != 0)
- CLine = lines_union[lbl];
- else
- add_new_line(lbl);
- }
+
+ // Tests if the Label as been marked as a line self link
+ // See add_line_self_link
inline bool contain_line_self_link(const Label lbl)
{ return lines_union[lbl].is_self_link();}
+
+ // Move the line self link when the label containing the self link
+ // must be removed
+ // NOTE : A LOT OF OPTIMIZATIONS AND CORRECTIONS CAN BE DONE HERE
+ // WARNING : Depreciated, please don't use it and replace it by methods
+ // like clean_noise_lines
inline bool move_line_self_link(const Label lbl)
{
if(lines_union[lbl] && lines_union.is_self_link(lbl))
@@ -564,37 +659,22 @@ namespace mymln
- inline void add_noise(const point2d& point)
- {add_noise(img_influ(point));}
+
- /// DEPRECIATED
+ /// WARNING: DEPRECIATED
/// THE METHOD SIZE IS HERE ONLY TO USE THE SAME SYNTAX AS MILENA ARRAYS
/// USE count() INSTEED
inline unsigned int size(){return Areas_Number_;}
+ // Return the number of line in the document
inline unsigned int line_count(){return lines_bbox.size();}
+ // Return the number of paragraph in the document
inline unsigned int paragraph_count(){return paragraphs_bbox.size();}
- void add_noise(Label lbl)
- {
- separators_mask(lbl) = false;
- letters_mask(lbl) = false;
- alone_letters_mask(lbl) = false;
- containers_mask(lbl) = false;
- Hseparator_mask(lbl) = false;
- Vseparator_mask(lbl) = false;
- alone_letters_mask(lbl) = false;
- all_letters_mask(lbl) = false;
- if(lines_cooked)
- {
- start_end_lines_mask(lbl) = false;
- end_lines_mask(lbl) = false;
- start_lines_mask(lbl) = false;
- }
- noise_mask(lbl) = true;
- lines_union[lbl] = 0;
- }
+ // Add the label to the document
+ // Some pre-processing operatios will be released to
+ // classify the label
void inline add(Label lbl, int link)
{
image_mask(lbl) = false;
@@ -613,62 +693,52 @@ namespace mymln
kill_mask(lbl) = false;
temp_letter(lbl) = false;
}
+
+ // Add the point to the noise
+ inline void add_noise(const point2d& point)
+ {add_noise(img_influ(point));}
+ // Add the label to the noise
+ inline void add_noise(Label lbl)
+ {
+ separators_mask(lbl) = false;
+ letters_mask(lbl) = false;
+ alone_letters_mask(lbl) = false;
+ containers_mask(lbl) = false;
+ Hseparator_mask(lbl) = false;
+ Vseparator_mask(lbl) = false;
+ alone_letters_mask(lbl) = false;
+ all_letters_mask(lbl) = false;
+ if(lines_cooked)
+ {
+ start_end_lines_mask(lbl) = false;
+ end_lines_mask(lbl) = false;
+ start_lines_mask(lbl) = false;
+ }
+ noise_mask(lbl) = true;
+ lines_union[lbl] = 0;
+ }
+
+ // The point will not be consider as a letter
void inline invalid_letter(const point2d& point)
{invalid_letter(img_influ(point));}
+ // The label will not be consider as a letter
void invalid_letter(Label lbl)
{letters_mask(lbl) = false;}
+ // The point will not be consider as a separator
void inline invalid_separator(const point2d& point)
{invalid_separator(img_influ(point));}
+ // The label will not be consider as a separator
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 inline add_letter_coerce(const point2d& point)
- {add_letter_coerce(img_influ(point)); }
-
-
- void add_image(const Label lbl)
- {
- image_mask(lbl) = true;
- separators_mask(lbl) = false;
- containers_mask(lbl) = false;
- Vseparator_mask(lbl) = false;
- Hseparator_mask(lbl) = false;
- alone_letters_mask(lbl) = false;
- noise_mask(lbl) = false;
- all_letters_mask(lbl) = false;
- temp_letter = false;
- }
-
-
-
- void add_anomaly(const point2d& point)
- {add_anomaly(img_influ(point));}
- void add_anomaly(const Label lbl)
- {anomaly_mask(lbl) = true;}
-
-
- void remove_anomaly(const point2d& point)
- {remove_anomaly(img_influ(point));}
- void remove_anomaly(const Label lbl)
- {anomaly_mask(lbl) = false;}
-
-
- bool contain_anomaly(const point2d& point)
- {return contain_anomaly(img_influ(point));}
- void contain_anomaly(const Label lbl)
- {return anomaly_mask(lbl);}
+ // The point will now be consider as an alone letter
void add_alone_letter(const point2d& point)
{add_alone_letter(img_influ(point));}
+ // The label will now be consider as an alone letter
void add_alone_letter(const Label lbl)
{
letters_mask(lbl) = false;
@@ -681,19 +751,18 @@ namespace mymln
all_letters_mask(lbl) = true;
temp_letter = false;
}
- void add_letter_coerce(const Label lbl)
- {
-
- letters_mask(lbl) = true;
- all_letters_mask(lbl) = true;
- separators_mask(lbl) = false;
- containers_mask(lbl) = false;
- Vseparator_mask(lbl) = false;
- Hseparator_mask(lbl) = false;
- alone_letters_mask(lbl) = false;
- noise_mask(lbl) = false;
- temp_letter = false;
- }
+
+
+ // The point will not be consider as a container
+ void inline invalid_container(const point2d& point)
+ {invalid_container(img_influ(point));}
+ // The label will not be consider as a container
+ void invalid_container(const Label lbl)
+ {containers_mask(lbl) = false;}
+ // Add the point to the letters
+ void inline add_letter(const point2d& point)
+ {add_letter(img_influ(point)); }
+ // Add the label to the letters
void add_letter(const Label lbl)
{
CLet++;
@@ -717,44 +786,33 @@ namespace mymln
}
else
add_noise(lbl);
- }
- inline bool is_big_element_V(const point2d& point)
- {return is_big_element_V(img_influ(point));}
- inline bool is_big_element_V(const Label lbl)
- {
- return _bboxgp[lbl].len(0) > img_influ.domain().len(0) / 13;
- }
- inline bool is_big_element_H(const point2d& point)
- {return is_big_element_H(img_influ(point));}
- inline bool is_big_element_H(const Label lbl)
- {
- return _bboxgp[lbl].len(1) > img_influ.domain().len(1) / 13;
- }
-
-
-
+ }
- inline bool is_very_big_element_V(const point2d& point)
- {return is_very_big_element_V(img_influ(point));}
- inline bool is_very_big_element_V(const Label lbl)
- {
- return _bboxgp[lbl].len(0) > img_influ.domain().len(0) / 6;
- }
- inline bool is_very_big_element_H(const point2d& point)
- {return is_very_big_element_H(img_influ(point));}
- inline bool is_very_big_element_H(const Label lbl)
+ // Add the point to the letters without doing the tests to check
+ // if the letter is valid
+ void inline add_letter_coerce(const point2d& point)
+ {add_letter_coerce(img_influ(point)); }
+ // Add the label to the letters without doing the tests to check
+ // if the letter is valid
+ void add_letter_coerce(const Label lbl)
{
- return _bboxgp[lbl].len(1) > img_influ.domain().len(1) / 6;
+
+ letters_mask(lbl) = true;
+ all_letters_mask(lbl) = true;
+ separators_mask(lbl) = false;
+ containers_mask(lbl) = false;
+ Vseparator_mask(lbl) = false;
+ Hseparator_mask(lbl) = false;
+ alone_letters_mask(lbl) = false;
+ noise_mask(lbl) = false;
+ temp_letter = false;
}
-
-
-
-
-
+ // Add the point to the containers
void inline add_container(const point2d& point)
{add_container(img_influ(point)); }
+ // Add the label to the containers
void add_container(const Label lbl)
{
if(label_valid_size_Min_(lbl, 2))
@@ -773,103 +831,265 @@ namespace mymln
else
add_noise(lbl);
}
- void add_Hseparator(const Label lbl)
+
+ // Add the point to the separators
+ void inline add_separator(const point2d& point)
+ {add_letter(img_influ(point)); }
+ // Add the point to the separators
+ 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);
+ }
+
+ // Used by add_separator
+ void add_Hseparator(const Label lbl)
+ {
+ _bboxgp_influ[lbl] = _bboxgp[lbl].to_larger(4);
+ CSep++;
+ containers_mask(lbl) = false;
+ Vseparator_mask(lbl) = false;
+ Hseparator_mask(lbl) = true;
+ letters_mask(lbl) = false;
+ separators_mask(lbl) = true;
+ alone_letters_mask(lbl) = false;
+ noise_mask(lbl) = false;
+ all_letters_mask(lbl) = false;
+ }
+
+ // Used by add_separator
+ void add_Vseparator(const Label lbl)
+ {
+ _bboxgp_influ[lbl] = _bboxgp[lbl].to_larger(4);
+ CSep++;
+ containers_mask(lbl) = false;
+ Vseparator_mask(lbl) = true;
+ Hseparator_mask(lbl) = false;
+ letters_mask(lbl) = false;
+ separators_mask(lbl) = true;
+ alone_letters_mask(lbl) = false;
+ noise_mask(lbl) = false;
+ all_letters_mask(lbl) = false;
+ }
+
+ // Add the label to the images
+ // WARNING : NOT YET FINALIZED
+ void add_image(const Label lbl)
+ {
+ image_mask(lbl) = true;
+ separators_mask(lbl) = false;
+ containers_mask(lbl) = false;
+ Vseparator_mask(lbl) = false;
+ Hseparator_mask(lbl) = false;
+ alone_letters_mask(lbl) = false;
+ noise_mask(lbl) = false;
+ all_letters_mask(lbl) = false;
+ temp_letter = false;
+ }
+
+
+ // The point will now be mark as an anomaly
+ void add_anomaly(const point2d& point)
+ {add_anomaly(img_influ(point));}
+ // The label will now be mark as an anomaly
+ void add_anomaly(const Label lbl)
+ {anomaly_mask(lbl) = true;}
+
+ // The point will be mark as a normal point
+ void remove_anomaly(const point2d& point)
+ {remove_anomaly(img_influ(point));}
+ // The label will be mark as a normal label
+ void remove_anomaly(const Label lbl)
+ {anomaly_mask(lbl) = false;}
+
+ // Tests if the point is an anomaly
+ bool contain_anomaly(const point2d& point)
+ {return contain_anomaly(img_influ(point));}
+ // Tests if the label is an anomaly
+ void contain_anomaly(const Label lbl)
+ {return anomaly_mask(lbl);}
+
+
+
+
+ // Tests if the component defined by the point is
+ // a big element according to the height of the document
+ inline bool is_big_element_V(const point2d& point)
+ {return is_big_element_V(img_influ(point));}
+ // Tests if the component defined by the label is
+ // a big element according to the height of the document
+ inline bool is_big_element_V(const Label lbl)
+ {
+ return _bboxgp[lbl].len(0) > img_influ.domain().len(0) / 13;
+ }
+
+ // Tests if the component defined by the point is a
+ // big element according to the width of the document
+ inline bool is_big_element_H(const point2d& point)
+ {return is_big_element_H(img_influ(point));}
+ // Tests if the component defined by the point is a
+ // big element according to the height of the document
+ inline bool is_big_element_H(const Label lbl)
+ {
+ return _bboxgp[lbl].len(1) > img_influ.domain().len(1) / 13;
+ }
+
+
+
+
+ // same thing as is_big_element_V but for very big element
+ inline bool is_very_big_element_V(const point2d& point)
+ {return is_very_big_element_V(img_influ(point));}
+ inline bool is_very_big_element_V(const Label lbl)
{
- _bboxgp_influ[lbl] = _bboxgp[lbl].to_larger(4);
- CSep++;
- containers_mask(lbl) = false;
- Vseparator_mask(lbl) = false;
- Hseparator_mask(lbl) = true;
- letters_mask(lbl) = false;
- separators_mask(lbl) = true;
- alone_letters_mask(lbl) = false;
- noise_mask(lbl) = false;
- all_letters_mask(lbl) = false;
+ return _bboxgp[lbl].len(0) > img_influ.domain().len(0) / 6;
}
- void add_Vseparator(const Label lbl)
+
+ // same thing as is_big_element_H but for very big element
+ inline bool is_very_big_element_H(const point2d& point)
+ {return is_very_big_element_H(img_influ(point));}
+ inline bool is_very_big_element_H(const Label lbl)
{
- _bboxgp_influ[lbl] = _bboxgp[lbl].to_larger(4);
- CSep++;
- containers_mask(lbl) = false;
- Vseparator_mask(lbl) = true;
- Hseparator_mask(lbl) = false;
- letters_mask(lbl) = false;
- separators_mask(lbl) = true;
- alone_letters_mask(lbl) = false;
- noise_mask(lbl) = false;
- all_letters_mask(lbl) = false;
+ return _bboxgp[lbl].len(1) > img_influ.domain().len(1) / 6;
}
+
+
+
+
+
+
+
+ // Tests if the extended bounding box of the separator
+ // defined by the point A contain the component defined by the point B
bool inline separator_has(const point2d& A, const point2d& B)
{
return _bboxgp_influ[img_influ(A)].has(B) || separator_has(img_influ(A), img_influ(B));
}
+
+ // Tests if the extended bounding box of the separator
+ // defined by the Label A contain the component defined by the point B
bool inline separator_has(const Label A,const Label B)
{
return _bboxgp_influ[A].has(_bboxgp[B].pmin()) || _bboxgp_influ[A].has(_bboxgp[B].pmax());
}
- 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);
- }
-
+
+ // Tests if the label is an alone letter
bool inline contain_alone_letter(const Label lbl)
{return contain_(lbl, alone_letters_mask);}
+ // Tests if the point is an alone letter
bool inline contain_alone_letter(const point2d& point)
{return contain_alone_letter(img_influ(point));}
+ // Tests if the label is a separator
bool inline contain_separator(const Label lbl)
{return contain_(lbl, separators_mask);}
+ // Tests if the label is a Vseparator
bool inline contain_Vseparator(const Label lbl)
{return contain_(lbl, Vseparator_mask);}
- bool inline contain_Hseparator(const Label lbl)
+
+ // Tests if the label is a HSeparator
+ bool inline contain_Hseparator(const Label lbl)
{return contain_(lbl, Hseparator_mask);}
+ // Tests if the label is a letter
bool inline contain_letter(const Label lbl)
{return contain_(lbl, letters_mask);}
-
-
-
+ // Tests if the point is a letter
+ bool inline contain_letter(const point2d& point)
+ {return contain_letter(img_influ(point));}
+
+
+ // Tests if the point is a container
+ bool inline contain_container(const point2d& point)
+ {return contain_container(img_influ(point));}
+ // Tests if the label is a container
bool inline contain_container(const Label lbl)
{return contain_(lbl, containers_mask);}
-
+
+
+ // Tests if the point is a separator
bool inline contain_separator(const point2d& point)
{return contain_separator(img_influ(point));}
+
+
+ // Tests if a point is a part of noise
+ inline bool contain_noise(const point2d& point)
+ { return contain_noise(img_influ(point)); }
+ // Tests if a label is a part of noise
+ inline bool contain_noise(const Label lbl)
+ {return noise_mask(lbl); }
+
+
+ // Tests if the point is an implicit separator
+ // NOTE:This method is used during the detection of implicit separators
+ inline bool contain_implicit_separator(const point2d& point)
+ { return contain_implicit_separator(img_influ(point)); }
+ // Tests if the label is an implicit separator
+ //NOTE:This method is used during the detection of implicit separators
+ inline bool contain_implicit_separator(const Label lbl)
+ {return implicit_separators_union[lbl] != 0; }
+
+ // Tests if the point is an implicit separator
+ //NOTE:This method is used after the detection of implicit separators
+ bool contain_implicit_separator_fixed(const point2d& point)
+ {return contain_implicit_separator_fixed(img_influ(point));}
+ // Tests if the point is an implicit separator
+ //NOTE:This method is used after the detection of implicit separators
+ bool contain_implicit_separator_fixed(const Label Id)
+ {return implicit_separators_left_mask(Id) || implicit_separators_right_mask(Id);}
+
+ // Tests if the point is a left implicit separator
+ bool contain_implicit_separator_left(const point2d& point)
+ {return contain_implicit_separator_left(img_influ(point));}
+ // Tests if the point is a left implicit separator
+ bool contain_implicit_separator_left(const Label Id)
+ {return implicit_separators_left_mask(Id);}
+
+ // Tests if the point is a right implicit separator
+ bool contain_implicit_separator_right(const point2d& point)
+ {return contain_implicit_separator_right(img_influ(point));}
+ // Tests if the point is a right implicit separator
+ bool contain_implicit_separator_right(const Label Id)
+ {return implicit_separators_right_mask(Id);}
+
+
- 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));}
-
+ //Obtains the bounding box associated with the point
box2d inline get_bbox(const point2d& point)
{return _bboxgp(img_influ(point));}
-
+ //Obtains the bounding box associated with the label
box2d inline get_bbox(const Label lbl)
{return _bboxgp(lbl);}
-
+
+ /* Defines the ratio range of Vseparators */
+ /* WARNING : Depreciated */
inline void vertical_separator_ratio_range(Float min, Float max)
{_VSepRatio_Min = min; _VSepRatio_Max = max;}
-
+
+ /* Defines the ratio range of Hseparators */
+ /* WARNING : Depreciated */
inline void horizontal_separator_ratio_range(Float min, Float max)
{_HSepRatio_Min = min; _HSepRatio_Max = max;}
-
+
+ /* Defines the volume range of letters */
+ /* WARNING : Depreciated */
inline void letter_volume_range(Data min, Data max)
{_LeterVolume_Min = min; _LeterVolume_Max = max;}
+ /* Defines the volume range of comtainers */
+ /* WARNING : Depreciated */
inline void container_volume_range(Data min, Data max)
{_ContainerVolume_Min = min; _ContainerVolume_Max = max;}
/* ALLIGN FUNCTION */
+ /* The working of these function is explain in the quickreference guide */
inline bool align_top( const point2d& Left, const point2d& Right)
{return align_top(img_influ(Left), img_influ(Right));}
@@ -1548,6 +1768,10 @@ namespace mymln
inline bool align_top_paragraph( const Label Left, const Label Right )
{return paragraphs_bbox[paragraphs_union[Left]].pmin()[0] > paragraphs_bbox[paragraphs_union[Right]].pmax()[0]; }
+
+
+
+
inline bool decal_left_paragraph(const point2d& Left, const point2d& Right)
{return decal_left_paragraph(img_influ(Left), img_influ(Right));}
inline bool decal_left_paragraph( const Label Left, const Label Right )
@@ -1955,10 +2179,45 @@ namespace mymln
Float AFactor = label_align_(1, Left, Right);
return AFactor < label_size_(1,Left);
}
+ inline bool align_size_x_height( const point2d& Left, const point2d& Right)
+ {return align_size_x_height(img_influ(Left), img_influ(Right));}
+
+ inline bool align_size_x_height( const Label Left, const Label Right)
+ {
+ short int SizeL0 = label_size_(0, Left);
+ short int SizeR0 = label_size_(0, Right);
+ short int SizeL1 = label_size_(1, Left);
+ short int SizeR1 = label_size_(1, Right);
+ short int Swap = 0;
+ if(SizeL0 < SizeL1)
+ { SizeL0 = SizeL1; }
+ if(SizeR0 < SizeR1){SizeR0 = SizeR1;}
+ return SizeR0 > (SizeL0 / 3) && SizeR0 < (SizeL0);
+ }
+
+ inline bool align_size_large_inside( const point2d& Left, const point2d& Right)
+ {return align_size_large_inside(img_influ(Left), img_influ(Right));}
+
+ inline bool align_size_large_inside( const Label Left, const Label Right)
+ {
+ short int SizeL0 = label_size_(0, Left);
+ short int SizeR0 = label_size_(0, Right);
+ short int SizeL1 = label_size_(1, Left);
+ short int SizeR1 = label_size_(1, Right);
+ short int Swap = 0;
+ if(SizeL0 < SizeL1)
+ { SizeL0 = SizeL1; }
+ if(SizeR0 < SizeR1){SizeR0 = SizeR1;}
+ return SizeR0 > (SizeL0 / 5) && SizeR0 < (SizeL0);
+ }
+ /* Test if the paragraph starts with a tab and if the line doesn't end */
+ /* with a return */
inline bool paragraph_start_with_tab_strict(const point2d& Point)
{ return paragraph_start_with_tab_strict(img_influ(Point));}
+ /* Test if the paragraph starts with a tab and if the line doesn't end */
+ /* with a return */
inline bool paragraph_start_with_tab_strict(const Label Paragraph)
{
Label FirstLine = paragraphs_first_line[paragraphs_union[Paragraph]];
@@ -1969,9 +2228,10 @@ namespace mymln
(paragraphs_bbox[paragraphs_union[Paragraph]].len(1) / 40)
;
}
-
+ /* Test if the paragraph starts with a tab */
inline bool paragraph_start_with_tab(const point2d& Point)
{ return paragraph_start_with_tab(img_influ(Point));}
+ /* Test if the paragraph starts with a tab */
inline bool paragraph_start_with_tab(const Label Paragraph)
{
Label FirstLine = paragraphs_first_line[paragraphs_union[Paragraph]];
@@ -1980,8 +2240,10 @@ namespace mymln
(paragraphs_bbox[paragraphs_union[Paragraph]].len(1) / 40)
;
}
+ // Tests if the paragraph ends with a return
inline bool paragraph_end_with_return(const point2d& Point)
{ return paragraph_end_with_return(img_influ(Point));}
+ // Tests if the paragraph ends with a return
inline bool paragraph_end_with_return(const Label Paragraph)
{
Label LastLine = paragraphs_last_line[paragraphs_union[Paragraph]];
@@ -1989,38 +2251,9 @@ namespace mymln
lines_bbox[LastLine].pmax()[1] < paragraphs_bbox[paragraphs_union[Paragraph]].pmax()[1] -
(paragraphs_bbox[paragraphs_union[Paragraph]].len(1) / 20)
;
- }
- 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;
-
}
-
-
- void debug_breakpoint()
- {
- if(debug_buffer_enable)
- {
- debug_save_buffer("break.ppm");
- std::system("eog break.ppm");
- debug_buffer_enable = true;
- Enable_Debug_Buffer = true;
- }
- else
- {
- debug_save_all("break.ppm");
- std::system("eog break.ppm");
- }
- }
- void debug_set_image(image2d<bool>& source)
- {debug_source = source;}
-
+
/// ADD TEMP LETTER
/// description : add a label to the letter mask. The label will remain a letter while
/// reset_temp_letter is not called
@@ -2038,6 +2271,8 @@ namespace mymln
temp_letter(lbl) = true;
}
}
+
+ // Reset all the temp letters
inline void reset_temp_letter()
{
for(int N = 0; N < Areas_Number_; N++)
@@ -2052,10 +2287,54 @@ namespace mymln
}
}
}
- inline void debug_disable_buffer()
+
+
+ // Display the stat of the document
+ // WARNING : Depreciated , use the class page insteed
+ 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;
+ }
+
+
+
+ // Add a breakpoint.
+ // If a debug buffer is enable then the debug buffer is displayed
+ // Else it will display the debug image of the document
+ void debug_breakpoint()
+ {
+ if(debug_buffer_enable)
+ {
+
+ debug_save_buffer("break.ppm");
+ std::system("eog break.ppm");
+ debug_buffer_enable = true;
+ Enable_Debug_Buffer = true;
+ }
+ else
+ {
+ debug_save_all("break.ppm");
+ std::system("eog break.ppm");
+ }
+ }
+
+ // Set the image used as a background when a debug command is called
+ void debug_set_image(image2d<bool>& source)
+ {debug_source = source;}
+
+ // If a debug buffer is activate the debug buffer will be disable
+ // However the debuf buffer will nit be reseted
+ inline void debug_disable_buffer()
{
debug_buffer_enable = false;
}
+ // Enable the debug buffer. This is usefull only when a debug buffer has been disable
+ // otherwise when a debug buffer is created, it is automaticaly enable
inline void debug_enable_buffer()
{
if(Enable_Debug_Buffer)
@@ -2067,12 +2346,18 @@ namespace mymln
debug_create_buffer();
}
}
+
+ // Create a debug buffer
inline void debug_create_buffer()
{
mln::initialize(debug_buffer,img_influ);
debug_buffer_enable = true;
Enable_Debug_Buffer = true;
}
+
+
+ // Export the current graph used by the document into
+ // a dot file
inline void debug_save_dot_graph(std::string file)
{
fstream filestream(file.c_str(), fstream::in | fstream::out);
@@ -2130,12 +2415,19 @@ namespace mymln
filestream.close();
}
+ // Save the current debug buffer, otherwise nothing happend
+ // NOTE : if the debug buffer is disable nothing will happend too
inline void debug_save_buffer(std::string file)
{
+ if(debug_buffer_enable)
+ {
+ io::ppm::save(mln::debug::superpose(debug_buffer, debug_source, literal::white) , file);
+ }
debug_buffer_enable = false;
Enable_Debug_Buffer = false;
- io::ppm::save(mln::debug::superpose(debug_buffer, debug_source, literal::white) , file);
+
}
+ // Same thing as debug_save_buffer with the paragraphs drawn in background
inline void debug_save_buffer_paragraphs(std::string file)
{
Enable_Debug_Buffer = false;
@@ -2154,6 +2446,8 @@ namespace mymln
}
io::ppm::save(mln::debug::superpose(debug_buffer, debug_source, literal::white) , file);
}
+
+ // Same thing as debug_save_buffer with the lines draw in background
inline void debug_save_buffer_lines(std::string file)
{
Enable_Debug_Buffer = false;
@@ -2168,6 +2462,8 @@ namespace mymln
}
io::ppm::save(mln::debug::superpose(debug_buffer, debug_source, literal::white) , file);
}
+
+ // A mix between debug_save_buffer_paragraphs and debug_save_buffer_lines
inline void debug_save_buffer_paragraphs_lines(std::string file)
{
Enable_Debug_Buffer = false;
@@ -2196,12 +2492,17 @@ namespace mymln
}
+ //Draw an Int near the line Id
inline void debug_draw_line_string(const Label Id,int value)
{
+ #ifndef NDEBUGGRAPH
debug_draw_line_string(Id, itoa(value).c_str());
+ #endif
}
+ //Draw a string near the line Id
inline void debug_draw_line_string(const Label Id, const char* string)
{
+ #ifndef NDEBUGGRAPH
if(debug_buffer_enable)
{
mln_VAR(pmin,lines_bbox[Id].pmax());
@@ -2213,15 +2514,20 @@ namespace mymln
box2d font_size(pmin, pmax);
mln::draw::string(debug_buffer, string,font_size , mln::literal::red);
}
+ #endif
}
-
+ // Draw an int near the paragraph Id
inline void debug_draw_paragraph_string(const Label Id,int value)
{
+ #ifndef NDEBUGGRAPH
debug_draw_paragraph_string(Id, itoa(value).c_str());
+ #endif
}
+ // Draw a string near the paragraph Id
inline void debug_draw_paragraph_string(const Label Id, const char* string)
{
+ #ifndef NDEBUGGRAPH
if(debug_buffer_enable)
{
mln_VAR(pmin, paragraphs_bbox[Id].pmin());
@@ -2233,9 +2539,12 @@ namespace mymln
box2d font_size(pmin, pmax);
mln::draw::string(debug_buffer, string,font_size , mln::literal::red);
}
+ #endif
}
+ // Draw a string near the component associated with point P
inline void debug_draw_string(const point2d& P, const char* string)
{
+ #ifndef NDEBUGGRAPH
if(debug_buffer_enable)
{
mln_VAR(pmin, _bboxgp[img_influ(P)].pmax());
@@ -2247,61 +2556,95 @@ namespace mymln
box2d font_size(pmin, pmax);
mln::draw::string(debug_buffer, string,font_size , mln::literal::red);
}
+ #endif
}
+ // Draw an int near the component associated with point P
inline void debug_draw_string(const point2d& P,int value)
{
+ #ifndef NDEBUGGRAPH
debug_draw_string(P, itoa(value).c_str());
+ #endif
}
+ // draw a red box arround the component associated with the point L
inline void debug_draw_box_red_buffer(const point2d& L)
{debug_draw_box_red_buffer(img_influ(L));}
+ // draw a green box arround the component associated with the point L
inline void debug_draw_box_green_buffer(const point2d& L)
{debug_draw_box_green_buffer(img_influ(L));}
+ // draw a red box arround the component defined by the label L
inline void debug_draw_box_red_buffer(const Label L)
{
+ #ifndef NDEBUGGRAPH
if(debug_buffer_enable)
draw::box(debug_buffer, _bboxgp[L], mln::literal::red);
+ #endif
}
+ // draw a green box arround the component defined by the label L
inline void debug_draw_box_green_buffer(const Label L)
{
+ #ifndef NDEBUGGRAPH
if(debug_buffer_enable)
draw::box(debug_buffer,_bboxgp[L], mln::literal::green);
+ #endif
}
+
+ // draw the enlarged bounding box arround the component defined by the label L
inline void debug_draw_box_green_influence_buffer(const Label L)
{
+ #ifndef NDEBUGGRAPH
if(debug_buffer_enable)
{
draw::box(debug_buffer,_bboxgp[L], mln::literal::green);
draw::box(debug_buffer,_bboxgp_influ[L], mln::literal::green);
}
- }
+ #endif
+ }
+
+ // draw the enlarged bounding box arround the component defined by the label L
inline void debug_draw_box_red_influence_buffer(const Label L)
{
+ #ifndef NDEBUGGRAPH
if(debug_buffer_enable)
{
draw::box(debug_buffer,_bboxgp[L], mln::literal::red);
draw::box(debug_buffer,_bboxgp_influ[L], mln::literal::red);
}
+ #endif
}
+
+ // draw a red line on a debug buffer from A to B
inline void debug_draw_line_red_buffer(const point2d& A,const point2d& B )
{
+ #ifndef NDEBUGGRAPH
if(debug_buffer_enable)
draw::line(debug_buffer, A, B, mln::literal::red);
+ #endif
}
+ // draw a green line on a debug buffer from A to B
inline void debug_draw_line_green_buffer(const point2d& A,const point2d& B )
{
+ #ifndef NDEBUGGRAPH
if(debug_buffer_enable)
draw::line(debug_buffer, A, B, mln::literal::green);
+ #endif
}
+ // draw an orange line on a debug buffer from A to B
inline void debug_draw_line_orange_buffer(const point2d& A,const point2d& B )
{
+ #ifndef NDEBUGGRAPH
if(debug_buffer_enable)
draw::line(debug_buffer, A, B, mln::literal::orange);
+ #endif
}
+
+ // draw debug informations associated with an union class.
+ // it is draw on a debug buffer
template<typename UnionData>
void debug_union(mymln::util::union_find<UnionData> dat)
{
+ #ifndef NDEBUGGRAPH
if(debug_buffer_enable)
{
for(unsigned int N = 1; N < dat.size(); N++)
@@ -2319,9 +2662,14 @@ namespace mymln
}
}
}
+ #endif
}
+ //save a debug image that contain informations on lines
+ //no debug buffer is required
void debug_save_lines(std::string file)
- {debug_save_lines(file, debug_source);}
+ {debug_save_lines(file, debug_source);}
+ //save a debug image that contain informations on lines and specified the background
+ //no debug buffer is required
void debug_save_lines(std::string file, image2d<bool> source)
{
image2d<value::rgb8> ima_color;
@@ -2344,9 +2692,12 @@ namespace mymln
io::ppm::save(mln::debug::superpose(ima_color, source, literal::white) , file);
}
-
+ //save a debug image that contain informations on separators
+ //no debug buffer is required
void debug_save_all_separators(std::string file)
{debug_save_all_separators(file, debug_source);}
+ //save a debug image that contain informations on separators and specified the background
+ //no debug buffer is required
void debug_save_all_separators(std::string file, image2d<bool> source)
{
image2d<value::rgb8> ima_color;
@@ -2388,15 +2739,18 @@ namespace mymln
io::ppm::save(mln::debug::superpose(ima_color, source, literal::white) , file);
}
-
+ //save a debug image that contain everything (line, separator ...)
+ //no debug buffer is required
void debug_save_all(std::string file)
{debug_save_all(file, debug_source);}
+ //save a debug image that contain everything (line, separator ...) and specified the background
+ //no debug buffer is required
void debug_save_all(std::string file, image2d<bool> source)
{
image2d<value::rgb8> ima_color;
mln::initialize(ima_color,img_influ);
- for(unsigned int N = 0; N < _bboxgp.size(); N++)
+ for(unsigned int N = 0; N < _bboxgp.size(); N++)
{
if(_bboxgp[N].is_valid() && contain_letter(N))
{
@@ -2436,13 +2790,6 @@ namespace mymln
draw::box(ima_color, lines_bbox[N], mln::literal::blue);
}
}
- for(unsigned int N = 0; N < lines_influ_bbox.size(); N++)
- {
- if(lines_influ_bbox[N].is_valid())
- {
- //draw::box(ima_color, lines_influ_bbox[N], mln::literal::cyan);
- }
- }
for(unsigned int N = 0; N < paragraphs_bbox.size(); N++)
{
if(paragraphs_bbox[N].is_valid())
@@ -2453,16 +2800,7 @@ namespace mymln
draw::box(ima_color, paragraphs_bbox_influ[N], mln::literal::orange);
}
}
-
- }
- for(unsigned int N = 0; N < _bboxgp.size(); N++)
- {
- if(_bboxgp[N].is_valid() && (implicit_separators_left_mask(N) || implicit_separators_right_mask(N)))
- {
- // draw::box(ima_color, _bboxgp[N], mln::literal::yellow);
- }
}
-
io::ppm::save(mln::debug::superpose(ima_color, source, literal::white) , file);
}
@@ -2542,12 +2880,14 @@ namespace mymln
mln::util::array<box2d> bbox_enlarge_mask_noise(short int x, short int y)
{ return bbox_mask_enlarge_(noise_mask, x, y); }
+ // get the label associated with the point
Label get_label(const point2d& point)
{ return img_influ(point); }
+ // Get the bounding box of the paragraph that contain the point
inline box2d get_paragraph_bbox(const point2d& point)
{ return get_paragraph_bbox(img_influ(point)); }
-
+ // Get the bounding box of the paragraph that contain the label
inline box2d get_paragraph_bbox(Label L)
{ return paragraphs_bbox[paragraphs_union[L]]; }
@@ -2555,16 +2895,17 @@ namespace mymln
inline box2d get_paragraph_bbox_direct(unsigned int ID)
{ return paragraphs_bbox[ID]; }
-
+ // Get the bounding box of the line that contain the point
inline box2d get_line_bbox(const point2d& point)
{ return get_line_bbox(img_influ(point)); }
-
+ // Get the bounding box of the line that contain the label
inline box2d get_line_bbox(Label L)
{ return lines_bbox[lines_union[L]]; }
+ // Get the number of line in the paragraph that contain the point
inline unsigned int get_paragraph_length(const point2d& point)
{ return get_paragraph_length(img_influ(point)); }
-
+ // Get the number of line in the paragraph that contain the label
inline unsigned int get_paragraph_length(Label L)
{ return paragraphs_len[paragraphs_union[L]]; }
@@ -2572,9 +2913,10 @@ namespace mymln
inline unsigned int get_paragraph_length_direct(unsigned int ID)
{ return paragraphs_len[ID]; }
+ // Get the number of letter in the line that contain the point
inline unsigned int get_line_length(const point2d& point)
{ return get_line_length(img_influ(point)); }
-
+ // Get the number of letter in the line that contain the label
inline unsigned int get_line_length(Label L)
{ return lines_len[lines_union[L]]; }
@@ -2584,9 +2926,10 @@ namespace mymln
/// USE THIS METHOD ONLY IF YOU KNOW THE LINE ID
inline box2d get_line_bbox_direct(unsigned int ID)
{ return lines_bbox[ID]; }
+ // Get the width of the line that contain the point
inline unsigned int get_line_width(point2d point)
{ return get_line_width(img_influ(point)); }
-
+ // Get the width of the line that contain the label
inline unsigned int get_line_width(Label L)
{ return lines_bbox[lines_union[L]].len(1); }
@@ -2741,37 +3084,7 @@ namespace mymln
- inline bool align_size_x_height( const point2d& Left, const point2d& Right)
- {return align_size_x_height(img_influ(Left), img_influ(Right));}
-
- inline bool align_size_x_height( const Label Left, const Label Right)
- {
- short int SizeL0 = label_size_(0, Left);
- short int SizeR0 = label_size_(0, Right);
- short int SizeL1 = label_size_(1, Left);
- short int SizeR1 = label_size_(1, Right);
- short int Swap = 0;
- if(SizeL0 < SizeL1)
- { SizeL0 = SizeL1; }
- if(SizeR0 < SizeR1){SizeR0 = SizeR1;}
- return SizeR0 > (SizeL0 / 3) && SizeR0 < (SizeL0);
- }
-
- inline bool align_size_large_inside( const point2d& Left, const point2d& Right)
- {return align_size_large_inside(img_influ(Left), img_influ(Right));}
-
- inline bool align_size_large_inside( const Label Left, const Label Right)
- {
- short int SizeL0 = label_size_(0, Left);
- short int SizeR0 = label_size_(0, Right);
- short int SizeL1 = label_size_(1, Left);
- short int SizeR1 = label_size_(1, Right);
- short int Swap = 0;
- if(SizeL0 < SizeL1)
- { SizeL0 = SizeL1; }
- if(SizeR0 < SizeR1){SizeR0 = SizeR1;}
- return SizeR0 > (SizeL0 / 5) && SizeR0 < (SizeL0);
- }
+
inline bool paragraph_has(point2d Par, point2d Point)
{ return paragraph_has(img_influ(Par), Point); }
@@ -2868,6 +3181,7 @@ namespace mymln
{return masked_image_(letters_mask); }*/
/* IMPLICIT SEPARATORS */
+
inline void add_new_separator(const point2d& point)
{ add_new_separator(img_influ(point));}
inline void add_new_separator(const Label lbl)
@@ -2891,8 +3205,12 @@ namespace mymln
inline void propage_separator_link()
{ implicit_separators_union.propage_links(); }
+ // Set the separator that contain the point "point" as the current separator
+ // WARNING: If the point is not inside a separator the result is undefined
inline void jump_to_separator(const point2d& point)
{ jump_to_separator(img_influ(point)); }
+ // Set the separator that contain the point "point" as the current separator
+ // WARNING: If the point is not inside a separator the result is undefined
inline void jump_to_separator(const Label lbl)
{
if(implicit_separators_union[lbl] != 0)
@@ -2901,33 +3219,7 @@ namespace mymln
add_new_separator(lbl);
}
- inline bool contain_noise(const point2d& point)
- { return contain_noise(img_influ(point)); }
- inline bool contain_noise(const Label lbl)
- {return noise_mask(lbl); }
-
-
-
- inline bool contain_implicit_separator(const point2d& point)
- { return contain_implicit_separator(img_influ(point)); }
- inline bool contain_implicit_separator(const Label lbl)
- {return implicit_separators_union[lbl] != 0; }
-
- bool contain_implicit_separator_fixed(const point2d& point)
- {return contain_implicit_separator_fixed(img_influ(point));}
- bool contain_implicit_separator_fixed(const Label Id)
- {return implicit_separators_left_mask(Id) || implicit_separators_right_mask(Id);}
-
- bool contain_implicit_separator_left(const point2d& point)
- {return contain_implicit_separator_left(img_influ(point));}
- bool contain_implicit_separator_left(const Label Id)
- {return implicit_separators_left_mask(Id);}
-
- bool contain_implicit_separator_right(const point2d& point)
- {return contain_implicit_separator_right(img_influ(point));}
- bool contain_implicit_separator_right(const Label Id)
- {return implicit_separators_right_mask(Id);}
@@ -3335,13 +3627,13 @@ namespace mymln
lines_seq_pos_reverse = mln::util::array<unsigned int>(NLine + 1);
}
inline void add_line_previous(const point2d& A,const point2d& Prev)
- {add_line_previous(img_influ(A),img_influ(Prev)); }
+ {lines_seq_pos_reverse[lines_union[img_influ(A)]] = lines_union[img_influ(Prev)]; }
inline void add_line_next(const point2d& A, const point2d& Next)
- {add_line_next(img_influ(A),img_influ(Next)); }
+ {lines_seq_pos[lines_union[img_influ(A)]] = lines_union[img_influ(Next)];}
inline void add_line_previous(const Label A,const Label Prev)
- {lines_seq_pos_reverse[get_line_ID(A)] = get_line_ID(Prev); }
+ {lines_seq_pos_reverse[lines_union[A]] = lines_union[Prev]; }
inline void add_line_next(const Label A, const Label Next)
- {lines_seq_pos[get_line_ID(A)] = get_line_ID(Next); }
+ {lines_seq_pos[lines_union[A]] = lines_union[Next]; }
private:
bool Enable_Debug_Buffer;
fun::i2v::array<bool> temp_letter;
diff --git a/scribo/sandbox/raphael/code/my/runtime/runtime.hh b/scribo/sandbox/raphael/code/my/runtime/runtime.hh
index 0e47488..110283a 100644
--- a/scribo/sandbox/raphael/code/my/runtime/runtime.hh
+++ b/scribo/sandbox/raphael/code/my/runtime/runtime.hh
@@ -88,6 +88,31 @@ namespace mymln
doc_local_fun = map<string, int >();
call_stack = stack<int>();
}
+
+
+ void run_debug()
+ {
+ mln::util::timer timer; timer.start();
+ for(CP = 0; CP < program_instruction.size(); CP++)
+ {
+
+ if(!program_instruction[CP].compare("end"))
+ ret();
+ else if(program_argument2[CP].compare(""))
+ call_function(program_instruction[CP], get_variable(program_argument[CP]), get_variable(program_argument2[CP]));
+ else if(program_argument[CP].compare(""))
+ call_function(program_instruction[CP], get_variable(program_argument[CP]));
+ else if(program_instruction[CP].compare(""))
+ call_function(program_instruction[CP]);
+ if(program_instruction[CP].compare(""))
+ {
+ float time = timer.stop() ;
+ if(time < 0.001f){time = 0.0f;}
+ std::cout << program_instruction[CP] << " : " << time << std::endl; timer.restart();
+ }
+ }
+ }
+
void run()
{
for(CP = 0; CP < program_instruction.size(); CP++)
diff --git a/scribo/sandbox/raphael/code/test.cc b/scribo/sandbox/raphael/code/test.cc
index 9d7cbb3..00acd1c 100644
--- a/scribo/sandbox/raphael/code/test.cc
+++ b/scribo/sandbox/raphael/code/test.cc
@@ -148,7 +148,7 @@ void Process(std::string File, std::string Dir, mymln::runtime::runtime< value::
}
- runtime.run();
+ runtime.run_debug();
std::cout << "WORK ON GRAPH : " << timer.stop() << endl;
//mymln::data::page<uint16,float,short> page(doc);
// page.export_HTML(Dir + "/debug_" + File + ".html");
@@ -159,15 +159,15 @@ void Process(std::string File, std::string Dir, mymln::runtime::runtime< value::
// THE DEMOS START HERE
#ifndef NDEMO
- //demo_extract_paragraphs(doc);
- //demo_label_to_point(doc);
- //demo_draw_full_graph(doc);
- //demo_draw_line_graph(doc);
- //demo_draw_line_length(doc);
- //demo_draw_tab(doc);
+ demo_extract_paragraphs(doc);
+ demo_label_to_point(doc);
+ demo_draw_full_graph(doc);
+ demo_draw_line_graph(doc);
+ demo_draw_line_length(doc);
+ demo_draw_tab(doc);
demo_compute_align(doc);
demo_compute_align_page(doc);
- //demo_draw_implicit_separators(doc);
+ demo_draw_implicit_separators(doc);
#endif
}
--
1.7.2.5
1
0

last-svn-commit-891-gfd4c5d3 Update and add exemples . Add debug draw string to draw strings on an image
by Raphael Boissel 08 Sep '11
by Raphael Boissel 08 Sep '11
08 Sep '11
---
.../raphael/code/demo/demo_extract_paragraphs.hh | 31 +
.../raphael/code/demo/demo_label_to_point.hh | 24 +
scribo/sandbox/raphael/code/makefile | 2 +-
scribo/sandbox/raphael/code/my/data/image.hh | 26 +
scribo/sandbox/raphael/code/my/data/line.hh | 9 +-
scribo/sandbox/raphael/code/my/data/page.hh | 67 ++-
scribo/sandbox/raphael/code/my/data/paragraph.hh | 18 +-
scribo/sandbox/raphael/code/my/data/style.hh | 8 +-
scribo/sandbox/raphael/code/my/document/clean.hh | 89 ++-
.../sandbox/raphael/code/my/document/document.hh | 188 +++++-
.../raphael/code/my/document/filter/filter.hh | 182 -----
scribo/sandbox/raphael/code/my/document/image.hh | 20 +-
scribo/sandbox/raphael/code/my/draw/string.hh | 817 ++++++++++++++++++++
scribo/sandbox/raphael/code/my/runtime/lib.hh | 5 +-
scribo/sandbox/raphael/code/my/util/union.hh | 5 +
scribo/sandbox/raphael/code/test.cc | 133 +---
16 files changed, 1290 insertions(+), 334 deletions(-)
create mode 100644 scribo/sandbox/raphael/code/demo/demo_extract_paragraphs.hh
create mode 100644 scribo/sandbox/raphael/code/demo/demo_label_to_point.hh
delete mode 100644 scribo/sandbox/raphael/code/my/document/filter/filter.hh
create mode 100644 scribo/sandbox/raphael/code/my/draw/string.hh
diff --git a/scribo/sandbox/raphael/code/demo/demo_extract_paragraphs.hh b/scribo/sandbox/raphael/code/demo/demo_extract_paragraphs.hh
new file mode 100644
index 0000000..f527fa7
--- /dev/null
+++ b/scribo/sandbox/raphael/code/demo/demo_extract_paragraphs.hh
@@ -0,0 +1,31 @@
+#include <my/document/document.hh>
+
+// THIS DEMO SHOW YOU HOW TO EXTRACT INFORMATION ON
+// A PARAGRAPH WHEN THE DATA HAVE BEEN
+// COMPUTED
+
+template<typename L,typename F,typename D>
+void demo_extract_paragraphs(const document<L,F,D>& doc)
+{
+
+ std::cout << "Demo : extract paragraphs" << std::endl;
+ for(int Id = 0; Id < doc.paragraph_count(); Id++)
+ {
+ // get_paragraph_length_direct must be use because here
+ // we have directly the Id of the paragraph
+ // NOTE :
+ // if we are working on a node and if we want the length of the paragraph that
+ // contain the node, the method get_paragraph_length must be called
+ if(doc.get_paragraph_length_direct(Id) > 0) // Check if the paragraph exists
+ {
+
+ // here we can directly extract all the info that the document contain on the paragraph
+ // by using the methods *_direct
+ std::cout
+ << "Paragraph : "
+ << doc.get_paragraph_length_direct(Id)
+ << doc.get_paragraph_bbox_direct(Id)
+ std::endl;
+ }
+ }
+}
\ No newline at end of file
diff --git a/scribo/sandbox/raphael/code/demo/demo_label_to_point.hh b/scribo/sandbox/raphael/code/demo/demo_label_to_point.hh
new file mode 100644
index 0000000..2ff7525
--- /dev/null
+++ b/scribo/sandbox/raphael/code/demo/demo_label_to_point.hh
@@ -0,0 +1,24 @@
+#include <my/document/document.hh>
+
+// THIS DEMO SHOW YOU HOW TO OBTAIN THE POINT THAT
+// IS THE BOUNDING BOX CENTER OF THE COMPONENT
+
+template<typename L,typename F,typename D>
+void demo_extract_paragraphs(const document<L,F,D>& doc)
+{
+
+ std::cout << "Demo : label to point" << std::endl;
+ for(int Id = 0; Id < doc.size(); Id++)
+ {
+ // Note that if you have got a point and if the want the label
+ // you can use exactly the same syntax
+ // label = document[point]
+ std::cout
+ << "The center of : "
+ << Id
+ << " is : "
+ << doc[Id]
+ << std::endl;
+ }
+ }
+}
\ No newline at end of file
diff --git a/scribo/sandbox/raphael/code/makefile b/scribo/sandbox/raphael/code/makefile
index 2e1e3f6..bad2d2f 100644
--- a/scribo/sandbox/raphael/code/makefile
+++ b/scribo/sandbox/raphael/code/makefile
@@ -9,7 +9,7 @@ std:
ccache g++ test.cc -o ~/Bureau/test/bin/test.elf -I . -I ./../../../../milena
~/Bureau/test/bin/test.elf -D ~/Bureau/test/bin -P ~/Bureau/test/bin/script ima.pbm
release:
- ccache g++ test.cc -o ~/Bureau/test/bin/test.elf -I . -I ./../../../../milena $(QT4) $(QT4_LIB) -DNDEBUG -O2
+ ccache g++ test.cc -msse3 -o ~/Bureau/test/bin/test.elf -I . -I ./../../../../milena $(QT4) $(QT4_LIB) -DNDEBUG -O2 -march=native
~/Bureau/test/bin/test.elf -D ~/Bureau/test/bin -P ~/Bureau/test/bin/script ima.pbm
debug:
ccache g++ test.cc -o ~/Bureau/test/bin/test.elf -I . -I ./../../../../milena -DNDEBUG -ggdb
diff --git a/scribo/sandbox/raphael/code/my/data/image.hh b/scribo/sandbox/raphael/code/my/data/image.hh
index e69de29..de5464a 100644
--- a/scribo/sandbox/raphael/code/my/data/image.hh
+++ b/scribo/sandbox/raphael/code/my/data/image.hh
@@ -0,0 +1,26 @@
+#ifndef MLN_DATA_IMAGE
+#define MLN_DATA_IMAGE
+#include <stdlib.h>
+namespace mymln
+{
+ namespace data
+ {
+ enum image_type
+ {
+ Gray,
+ Color,
+ Black_And_White
+ };
+
+ /// The class image is use to contain images
+ class image
+ {
+ public:
+ image()
+ { }
+ private:
+
+ };
+ }
+}
+#endif
\ No newline at end of file
diff --git a/scribo/sandbox/raphael/code/my/data/line.hh b/scribo/sandbox/raphael/code/my/data/line.hh
index d5ed237..99e133b 100644
--- a/scribo/sandbox/raphael/code/my/data/line.hh
+++ b/scribo/sandbox/raphael/code/my/data/line.hh
@@ -8,14 +8,19 @@ namespace mymln
{
public:
line()
- {bbox_ = mln::box2d(); ID_ = 0;}
+ {bbox_ = mln::box2d(); ID_ = 0; value_ = "-*-";}
line(box2d bounding_box, int ID)
- {bbox_ = bounding_box; ID_ = ID;}
+ {bbox_ = bounding_box; ID_ = ID;value_ = "-*-";}
mln::box2d bbox()
{return bbox_;}
+ std::string get_value()
+ {return value_;}
+ void set_value(std::string value)
+ {value_ = value;}
private:
int ID_;
mln::box2d bbox_;
+ std::string value_;
};
}
}
diff --git a/scribo/sandbox/raphael/code/my/data/page.hh b/scribo/sandbox/raphael/code/my/data/page.hh
index 0b1c0aa..04f4e99 100644
--- a/scribo/sandbox/raphael/code/my/data/page.hh
+++ b/scribo/sandbox/raphael/code/my/data/page.hh
@@ -3,7 +3,9 @@
#include <my/data/style.hh>
#include <my/data/paragraph.hh>
#include <my/data/line.hh>
+#include <my/data/image.hh>
#include <my/document/document.hh>
+
namespace mymln
{
namespace data
@@ -18,31 +20,68 @@ namespace mymln
{
doc_ = doc;
paragraphs = mln::util::array<paragraph>(0);
+ images = mln::util::array<image>(0);
paragraphs.reserve(doc_.paragraph_count());
unsigned int paragraph_count = doc_.paragraph_count();
+
+ mln::util::array<int> paragraphs_IDS;
+ paragraphs_IDS.reserve(doc_.paragraph_count());
+
for(int N = 0; N < paragraph_count; N++)
{
+
if(doc_.get_paragraph_length_direct(N))
{
paragraphs.append(paragraph(doc_.get_paragraph_bbox_direct(N), N));
paragraphs[paragraphs.size() - 1].set_font_size(doc_.get_paragraph_middle_width_direct(N));
paragraphs[paragraphs.size() - 1].set_line_count(doc_.get_paragraph_length_direct(N));
+ paragraphs_IDS.append(paragraphs.size() - 1);
+ }
+ else
+ {
+ paragraphs_IDS.append(-1);
}
}
unsigned int lines_count = doc_.line_count();
lines.reserve(lines_count);
for(int N = 0; N < lines_count; N++)
{
- lines.append(line(doc_.get_line_bbox_direct(N), N));
+ if(doc_.get_line_length_direct(N))
+ {
+ lines.append(line(doc_.get_line_bbox_direct(N), N));
+ if(paragraphs_IDS[doc_.get_line_parent(N)] >= 0)
+ {
+ paragraphs[paragraphs_IDS[doc_.get_line_parent(N)]].add_line(lines[lines.size() - 1]);
+ }
+ }
}
}
+ void set_source_image(image2d<value::rgb8> source)
+ {
+ src_ = source;
+ }
+ void add_line(data::line Line)
+ {
+ lines.append(Line);
+ }
+ void add_paragraph(data::paragraph Paragraph)
+ {
+ paragraphs.append(Paragraph);
+ }
+ void add_image(data::image Image)
+ {
+ images.append(Image);
+ }
+
+ inline void export_PRima(std::string file, const char qname)
+ {
+
+ }
inline void export_HTML(std::string file)
{
fstream filestream(file.c_str(), std::fstream::out);
- if(filestream.is_open())
- std::cout << "EXPORT : " + file;
filestream << "<html>\n";
filestream << "<head>\n";
filestream << "<style type=\"text/css\">\n";
@@ -65,33 +104,27 @@ namespace mymln
filestream.close();
- std::cout << "EXPORTED : " + file;
}
+
inline unsigned int paragraph_count()
{ return paragraphs.size();}
inline unsigned int line_count()
{ return lines.size();}
-
+ inline unsigned int image_count()
+ { return images.size();}
+
inline paragraph get_paragraph(unsigned int ID)
{ return paragraphs[ID];}
inline line get_line(unsigned int ID)
{ return lines[ID];}
+ inline line get_image(unsigned int ID)
+ { return images[ID];}
private:
+ image2d<value::rgb8> src_;
document::document<L,F,D> doc_;
mln::util::array<paragraph> paragraphs;
mln::util::array<line> lines;
- template<typename I>
- inline mln::util::array<image2d<I> > extract_lines_(image2d<I>& source)
- {
- mln::util::array<image2d<I> > array(0);
- array.reserve(lines.size());
-
- for(int N = 0; N < lines.size();N++)
- {
- array.append((source | lines[N].bbox()).rw());
- }
- return array;
- }
+ mln::util::array<image> images;
};
}
}
diff --git a/scribo/sandbox/raphael/code/my/data/paragraph.hh b/scribo/sandbox/raphael/code/my/data/paragraph.hh
index 9e277c9..e11c205 100644
--- a/scribo/sandbox/raphael/code/my/data/paragraph.hh
+++ b/scribo/sandbox/raphael/code/my/data/paragraph.hh
@@ -16,6 +16,7 @@ namespace mymln
bbox_ = mln::box2d();
style_ = style();
LineC = 1;
+ mln::util::array<line>();
}
paragraph(mln::box2d bbox, int ID)
{
@@ -23,11 +24,18 @@ namespace mymln
bbox_ = bbox;
style_ = style();
LineC = 1;
+ mln::util::array<line>();
}
void set_line_count(int count)
- {LineC = count;}
+ {LineC = count;lines.reserve(count);}
+ void add_line(line Line)
+ {lines.append(Line);}
+ int line_count(int count)
+ {return LineC;}
void set_font_size(int px)
{style_.set_font_size(px);}
+ int get_font_size()
+ { style_.get_font_size(); }
int ID(){return ID_;}
std::string To_HTML_Paragraph_Style()
{
@@ -38,9 +46,14 @@ namespace mymln
{
std::string output = "";
output += "<st" + itoa(ID_) + ">\n";
+ output += "X:";
+ output += itoa(bbox_.pmin()[1]);
+ output += "Y:";
+ output += itoa(bbox_.pmin()[0]);
for(int N = 0; N < LineC; N++)
{
- output += "!!--FIXME--!! <br> \n";
+ output += lines[N].get_value();
+ output += "</br> \n";
}
@@ -52,6 +65,7 @@ namespace mymln
{return bbox_;}
private:
mln::box2d bbox_;
+ mln::util::array<line> lines;
style style_;
int LineC;
int ID_;
diff --git a/scribo/sandbox/raphael/code/my/data/style.hh b/scribo/sandbox/raphael/code/my/data/style.hh
index 823fbeb..e6eb534 100644
--- a/scribo/sandbox/raphael/code/my/data/style.hh
+++ b/scribo/sandbox/raphael/code/my/data/style.hh
@@ -9,7 +9,7 @@ namespace mymln
{
std::string output = "";
if(value < 0){output+="-"; value = -value;}
- while(value > 10)
+ while(value >= 10)
{
output = (char)('0' + (value % 10)) + output;
value /= 10;
@@ -43,6 +43,10 @@ namespace mymln
{
Font_Size_ = px;
}
+ int get_font_size()
+ {
+ return Font_Size_;
+ }
// WARNING THIS FUNCTION USE iota
// iota is define only in mymln::data
// this is not a standart function you can use everywhere
@@ -55,7 +59,7 @@ namespace mymln
output += "position:absolute;";
output += "left:" + itoa(pmin_X) + ";";
output += "top:" + itoa(pmin_Y) + ";";
- output += "}";
+ output += "} \n";
// FIXME
return output;
}
diff --git a/scribo/sandbox/raphael/code/my/document/clean.hh b/scribo/sandbox/raphael/code/my/document/clean.hh
index cf61a1c..f2c4992 100644
--- a/scribo/sandbox/raphael/code/my/document/clean.hh
+++ b/scribo/sandbox/raphael/code/my/document/clean.hh
@@ -728,9 +728,9 @@ namespace mymln
{
if(doc.contain_line(N))
if (doc.get_letter_middle_height(N) * 3 < doc.get_bbox(N).len(0))
- {doc.move_line_self_link(N); doc.add_noise(N);}
+ {doc.move_line_self_link(N); doc.add_noise(N); doc.invalidate_line_link(N);}
else if(doc.get_letter_middle_width(N) * 4 < doc.get_bbox(N).len(1))
- {doc.move_line_self_link(N); doc.add_noise(N);}
+ {doc.move_line_self_link(N); doc.add_noise(N); doc.invalidate_line_link(N);}
}
}
@@ -1476,8 +1476,91 @@ namespace mymln
doc.propage_line_link();
}
-
+ template<typename L, typename F, typename D>
+ void clean_finalize_letters(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_noise(v))
+ {
+ unsigned int Count = 0;
+ bool HasLink = false;
+ L line = 0;
+ for_all(q)
+ {
+ if(doc.contain_paragraph(q) && doc.contain_line(q) && doc.paragraph_included_letter(q,v))
+ {
+ if(doc.allign_V_line_artefact(q,v) && doc.allign_size_height_line_artefact(q,v))
+ {
+ HasLink = true;
+ if(!line)
+ line = doc[q];
+ else if(doc.get_line_distance(q,v) < doc.get_line_distance(doc[line], v))
+ line = doc[q];
+ }
+ else if(doc.allign_top_large(q,v) && !doc.allign_V(q,v))
+ {
+ Count++;
+ }
+ }
+
+ }
+ if(Count > 0 && HasLink)
+ {
+ doc.debug_draw_box_green_buffer(v);
+ doc.debug_draw_line_green_buffer(v, doc[line]);
+ doc.debug_draw_string(v, Count);
+ doc.add_to_line_link(doc[line],v);
+ doc.add_to_paragraph_link(doc[line], v);
+ }
+ }
+ }
+
+ doc.propage_line_link();
+ doc.propage_paragraph_link();
+
+ }
+
+ template<typename L, typename F, typename D>
+ void clean_lines_artefacts(mymln::document::document<L,F,D>& doc)
+ {
+ //image2d<value::rgb8> out;
+ //mln::initialize(out, s);
+ 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_line(v))
+ {
+ for_all(q)
+ {
+ //draw::line(out, q,v, mln::literal::red);
+ if(doc.same_line(v,q) && doc.is_line_artefact(q))
+ {
+ doc.debug_draw_string(q, "ARTEFACT");
+ doc.add_noise(q);
+ }
+ }
+ }
+ }
+ doc.clean_noise_lines();
+ doc.propage_line_link();
+ //io::ppm::save(mln::debug::superpose(out, s, literal::white),dgb_out);
+ }
}
diff --git a/scribo/sandbox/raphael/code/my/document/document.hh b/scribo/sandbox/raphael/code/my/document/document.hh
index 1d50e5c..ae4a51a 100644
--- a/scribo/sandbox/raphael/code/my/document/document.hh
+++ b/scribo/sandbox/raphael/code/my/document/document.hh
@@ -1,6 +1,25 @@
#ifndef INC_DOCUMENT_DOC
#define INC_DOCUMENT_DOC
#include <mln/accu/shape/bbox.hh>
+#include <mln/fun/i2v/array.hh>
+#include <mln/util/graph.hh>
+#include <mln/debug/draw_graph.hh>
+#include <mln/core/site_set/p_vertices.hh>
+#include <mln/transform/influence_zone_geodesic.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/value_and_compute.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/labeling/colorize.hh>
+#include <mln/core/alias/neighb2d.hh>
+#include <mln/algebra/vec.hh>
+#include <mln/core/image/graph_elt_neighborhood.hh>
+#include <mln/graph/compute.hh>
#include<my/util/vector_bbox_group.hh>
#include<my/util/union.hh>
#include<my/debug/pict.hh>
@@ -9,9 +28,11 @@
using namespace mln;
namespace mymln
{
+
namespace document
{
-
+ /// THE CLASS DOCUMENT STORE DATA THAT ALLOW THE USER TO PERFORM OPPERATIONS ON A DOCUMENT
+ /// DESCRIBED BY A GRAPH
template<typename Label, typename Float, typename Data>
class document
{
@@ -86,6 +107,10 @@ namespace mymln
lines_cooked = false;
Enable_Debug_Buffer = false; // Remanant version of debug_buffer_enable
}
+ inline unsigned int height()
+ {return img_influ.domain().height();}
+ inline unsigned int width()
+ {return img_influ.domain().width();}
inline bool killed(const Label lbl)
{return kill_mask(lbl);}
inline void kill(const Label lbl)
@@ -102,7 +127,10 @@ namespace mymln
{ return p[0] > ((img_influ.domain().len(0) / 8) * 7);}
inline bool in_footer(Label lbl)
{ return in_footer(_bboxgp[lbl]); }
-
+ inline bool is_word(const point2d& p)
+ { return is_word(img_influ(p)); }
+ inline bool is_word(const Label lbl)
+ { return lines_space[lbl] < lines_width[lbl] / 15.0f; }
/* OPERATION ON PARAGRAPH */
inline bool link_paragraphs()
{
@@ -337,6 +365,43 @@ namespace mymln
{return lines_bbox[lines_union[A]].len(0) < _bboxgp[A].len(0) * 2 ;}
+ inline bool is_line_artefact(const point2d& A)
+ {return is_line_artefact(img_influ(A));}
+ inline bool is_line_artefact(const Label A)
+ {
+ return lines_bbox[lines_union[A]].len(0) > _bboxgp[A].len(0) * 24;
+ }
+
+ inline void clean_noise_lines()
+ {
+ for(int N = 0;N < Areas_Number_; N++)
+ {
+ if(noise_mask(N))
+ {
+ if(lines_union[N] || lines_union.link(N))
+ {
+ lines_union.invalidate_link(N);
+ lines_union[N] = 0;
+
+ }
+ }
+ }
+ for(int N = 0;N < Areas_Number_; N++)
+ {
+ if(lines_union[N] && lines_union[lines_first_label[lines_union[N]]])
+ {
+
+ lines_union.add_link(lines_first_label[lines_union[N]], N);
+ }
+ else if(lines_union[N])
+ {
+ lines_union.add_self_link_coerce(N);
+ lines_first_label[lines_union[N]] = N;
+ }
+ }
+ }
+
+
inline bool in_end_of_line(const point2d& A)
{return in_end_of_line(img_influ(A));}
inline bool in_end_of_line(const Label A)
@@ -413,19 +478,28 @@ namespace mymln
{
if(lines_union[lbl] && lines_union.is_self_link(lbl))
{
+
+ if(lines_len[lbl] < 2){ return false; } // THE ITEM IS ALONE ON THE LINE
+
if(lines_first_label[lines_union[lbl]] == lbl)
{
+
if(lines_union[lines_last_label[lines_union[lbl]]] == 0) // CHECK IF THE LAST LABEL HAS NOT BEEN REMOVED
+ {
+ if(lines_len[lbl] < 3){ return false; } // THE LINE HAS TWO ITEM AND ONE HAS BEEN REMOVED
recook_lines();
-
+ }
lines_union.add_link(lines_last_label[lines_union[lbl]], lbl);
lines_union.add_self_link(lines_last_label[lines_union[lbl]]);
}
else if(lines_last_label[lines_union[lbl]] == lbl)
{
+
if(lines_union[lines_first_label[lines_union[lbl]]] == 0) // CHECK IF THE FIRST LABEL HAS NOT BEEN REMOVED
+ {
+ if(lines_len[lbl] < 3){ return false; } // THE LINE HAS TWO ITEM AND ONE HAS BEEN REMOVED
recook_lines();
-
+ }
lines_union.add_link(lines_first_label[lines_union[lbl]], lbl);
lines_union.add_self_link(lines_first_label[lines_union[lbl]]);
}
@@ -463,7 +537,7 @@ namespace mymln
{ return paragraphs_first_line[paragraphs_union[lbl]] == lines_union[lbl];}
inline bool contain_end_line(const Label lbl)
- { return start_lines_mask(lbl);}
+ { return end_lines_mask(lbl);}
inline void add_noise(const point2d& point)
{add_noise(img_influ(point));}
@@ -1203,6 +1277,22 @@ namespace mymln
}
+
+ inline bool allign_size_height_line_artefact( const point2d& Line, const point2d& Artefact)
+ {
+ return allign_size_height_line_artefact(img_influ(Line), img_influ(Artefact));
+ }
+
+ inline bool allign_size_height_line_artefact( const Label Line, const Label Artefact)
+ {
+ short int SizeL = lines_bbox[lines_union[Line]].len(0);
+ short int SizeR = _bboxgp[Artefact].len(0);
+ return SizeR > (SizeL / 2.3f) && SizeR < (SizeL * 1.1f);
+ }
+
+
+
+
inline bool allign_size_height_line( const point2d& Left, const point2d& Right)
{
return allign_size_height_line(img_influ(Left), img_influ(Right));
@@ -1587,6 +1677,21 @@ namespace mymln
return allignV < lines_bbox[lines_union[Left]].len(0) && allignV < lines_bbox[lines_union[Right]].len(0);
}
+
+
+ inline bool allign_V_line_artefact( const point2d& Line, const point2d& Artefact)
+ {return allign_V_line_artefact(img_influ(Line), img_influ(Artefact));}
+
+ inline bool allign_V_line_artefact( Label Line, Label Artefact)
+ {
+ short int allignV = lines_bbox[lines_union[Line]].pcenter()[0] - _bboxgp[Artefact].pcenter()[0];
+ if(allignV<0){allignV = -allignV;}
+ allignV *= 5;
+ return allignV < lines_bbox[lines_union[Line]].len(0) && allignV < _bboxgp[Artefact].len(0);
+ }
+
+
+
inline bool allign_V_line_strict( const point2d& Left, const point2d& Right)
{return allign_V_line_strict(img_influ(Left), img_influ(Right));}
@@ -1643,7 +1748,6 @@ namespace mymln
-
inline bool allign_smaller_paragraph( const point2d& Left, const point2d& Right)
{return allign_smaller_paragraph(img_influ(Left), img_influ(Right));}
inline bool allign_smaller_paragraph( Label Left, Label Right)
@@ -2002,6 +2106,26 @@ namespace mymln
}
io::ppm::save(mln::debug::superpose(debug_buffer, debug_source, literal::white) , file);
}
+ inline void debug_draw_string(const point2d& P, const char* string)
+ {
+ if(debug_buffer_enable)
+ {
+ mln_VAR(pmin, _bboxgp[img_influ(P)].pmax());
+ mln_VAR(pmax, _bboxgp[img_influ(P)].pmax());
+ pmin[0] = _bboxgp[img_influ(P)].pmin()[0];
+ pmin[1] = pmin[1] + 3;
+ pmax[0] = pmin[0] + 20;
+ pmax[1] = pmin[1] + 11;
+ box2d font_size(pmin, pmax);
+ mln::draw::string(debug_buffer, string,font_size , mln::literal::red);
+ }
+ }
+
+ inline void debug_draw_string(const point2d& P,int value)
+ {
+ debug_draw_string(P, itoa(value).c_str());
+ }
+
inline void debug_draw_box_red_buffer(const point2d& L)
{debug_draw_box_red_buffer(img_influ(L));}
inline void debug_draw_box_green_buffer(const point2d& L)
@@ -2326,7 +2450,9 @@ namespace mymln
/// USE THIS METHOD ONLY IF YOU KNOW THE LINE ID
inline unsigned int get_line_length_direct(unsigned int ID)
{ return lines_len[ID]; }
-
+ /// USE THIS METHOD ONLY IF YOU KNOW THE LINE ID
+ inline box2d get_line_bbox_direct(unsigned int ID)
+ { return lines_bbox[ID]; }
inline unsigned int get_line_width(point2d point)
{ return get_line_width(img_influ(point)); }
@@ -2334,6 +2460,12 @@ namespace mymln
{ return lines_bbox[lines_union[L]].len(1); }
+ /// USE THIS METHOD ONLY IF YOU KNOW THE LINE ID
+ inline unsigned int get_line_parent(unsigned int ID)
+ { return paragraphs_union[lines_first_label[ID]]; }
+
+
+
inline Float letter_ratio_YX(const point2d& point)
{return letter_ratio_YX(img_influ(point));}
inline Float letter_ratio_YX(Label Letter)
@@ -2414,6 +2546,14 @@ namespace mymln
paragraphs_bbox_influ[paragraphs_union[Par1]].has(lines_bbox[lines_union[Line2]].pmax()) ;
}
+ inline bool paragraph_included_letter(point2d Par1, point2d Letter2)
+ { return paragraph_included_letter(img_influ(Par1), img_influ(Letter2)); }
+ inline bool paragraph_included_letter(Label Par1, Label Letter2)
+ {
+ return
+ paragraphs_bbox[paragraphs_union[Par1]].has(_bboxgp[Letter2].pmin()) &&
+ paragraphs_bbox[paragraphs_union[Par1]].has(_bboxgp[Letter2].pmax()) ;
+ }
inline bool paragraph_included(point2d Par1, point2d Par2)
{ return paragraph_included(img_influ(Par1), img_influ(Par2)); }
@@ -2857,6 +2997,25 @@ namespace mymln
{return lines_space[lines_union[lbl]];}
+ inline short int get_line_distance(const point2d& Line, const point2d& Item)
+ { return get_line_distance(img_influ(Line), img_influ(Item));}
+ inline short int get_line_distance(const Label Line, const Label Item)
+ {
+ short int DisLeft = _bboxgp[Item].pmin()[1] - lines_bbox[lines_union[Line]].pmax()[1];
+ if(DisLeft < 0){DisLeft = -DisLeft;}
+ short int DisRight = _bboxgp[Item].pmax()[1] - lines_bbox[lines_union[Line]].pmin()[1];
+ if(DisRight < 0){DisRight = -DisRight;}
+ short int DisUp = _bboxgp[Item].pmin()[0] - lines_bbox[lines_union[Line]].pmax()[0];
+ if(DisUp < 0){DisUp = -DisUp;}
+ short int DisDown = _bboxgp[Item].pmax()[0] - lines_bbox[lines_union[Line]].pmin()[0];
+ if(DisDown < 0){DisDown = -DisDown;}
+ if(DisLeft > DisRight){DisLeft = DisRight;}
+ if(DisUp > DisDown){DisUp = DisDown;}
+ if(DisUp > DisLeft){return DisLeft;}
+ else{return DisUp;}
+ }
+
+
inline unsigned int get_letter_middle_height(const point2d& point)
{return get_letter_middle_height(img_influ(point));}
inline unsigned int get_letter_middle_height(const Label lbl)
@@ -3404,6 +3563,7 @@ namespace mymln
Data SY = label_size_(1, label);
return SX >= Min && SY >= Min || SX >= Min * 2 || SY >= Min * 2;
}
+
inline bool label_valid_ratio_(Label label, Float Min, Float Max)
{
Float Ratio = label_ratio_(label);
@@ -3653,6 +3813,20 @@ namespace mymln
/* IMPLICIT SEPARATOR DETECTION */
mymln::util::union_find<Label> implicit_separators_union;
mymln::util::union_find<Label> implicit_separators_union_right;
+
+
+ std::string itoa(int value)
+ {
+ std::string output = "";
+ if(value < 0){output+="-"; value = -value;}
+ while(value >= 10)
+ {
+ output = (char)('0' + (value % 10)) + output;
+ value /= 10;
+ }
+ output = (char)('0' + value) + output;
+ return output;
+ }
};
}
}
diff --git a/scribo/sandbox/raphael/code/my/document/filter/filter.hh b/scribo/sandbox/raphael/code/my/document/filter/filter.hh
deleted file mode 100644
index c3a294c..0000000
--- a/scribo/sandbox/raphael/code/my/document/filter/filter.hh
+++ /dev/null
@@ -1,182 +0,0 @@
-#ifndef INC_DOCUMENT_FILTER_GENERIC
-#define INC_DOCUMENT_FILTER_GENERIC
-namespace mymln
-{
- namespace document
- {
- namespace filter
- {
- template<typename L, typename F, typename D, typename Left, typename Right>
- class filter
- {
- public:
- filter(){}
- filter(document<L,F,D>& doc){ doc_ = doc; }
- filter(document<L,F,D>& doc, vertex_image<point2d,bool> mask){ doc_ = doc; mask_ = mask; }
- inline bool link_test(point2d& A, point2d& B){ return true; }
- inline bool vertex_test(point2d& A){ return true; }
- inline bool gen_link_test(point2d& A, point2d& B)
- {
- return link_test(A, B);
- }
- inline bool gen_vertex_test(point2d& A)
- {
- return vertex_test(A);
- }
- inline void iter_dgb(std::string dgb_out, image2d<bool> s)
- {
- image2d<value::rgb8> out;
- mln::initialize(out, s);
- typedef vertex_image<point2d,bool> v_ima_g;
- typedef p_vertices<mln::util::graph, fun::i2v::array<mln::point2d> > g_vertices_p;
- 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(gen_vertex_test(v))
- {
- for_all(q)
- {
- if(gen_link_test(v, q))
- {
- draw::line(out, q,v, mln::literal::green);
- }
- else
- {
- draw::line(out, q,v, mln::literal::magenta);
- }
- }
- }
- else
- {
- draw::line(out, q,v, mln::literal::magenta);
- }
- }
- }
- inline void iter()
- {
- typedef vertex_image<point2d,bool> v_ima_g;
- typedef p_vertices<mln::util::graph, fun::i2v::array<mln::point2d> > g_vertices_p;
- 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(gen_vertex_test(v))
- {
- for_all(q)
- {
- if(gen_link_test(v, q))
- {
-
- }
- }
- }
- }
- }
-
- inline filter& operator|(filter& B)
- {
- filter<L,F,D> PFilter = filter_or(doc_, mask_);
- PFilter.sub_filter_A_ = this;
- PFilter.sub_filter_B_ = B;
- B.doc_ = doc_;
- B.mask_ = mask_;
- return PFilter;
- }
-
- inline filter& operator&(filter& B)
- {
- filter<L,F,D> PFilter = filter_and(doc_, mask_);
- PFilter.sub_filter_A_ = this;
- PFilter.sub_filter_B_ = B;
- B.doc_ = doc_;
- B.mask_ = mask_;
- return PFilter;
- }
-
- protected:
- Left sub_filter_A_;
- Right sub_filter_B_;
-
- document<L,F,D> doc_;
- vertex_image<point2d,bool> mask_;
-
-
-
- };
-
-
-
-
-
-
-
-
-
-
- template<typename L, typename F, typename D>
- class filter_or : filter<L,F,D>
- {
- public:
- inline bool gen_link_test(point2d& A, point2d& B)
- {
- return sub_filter_A_.gen_link_test(A, B) || sub_filter_B_.gen_link_test(A, B);
- }
- inline bool gen_vertex_test(point2d& A)
- {
- return sub_filter_A_.gen_vertex_test(A) || sub_filter_B_.gen_vertex_test(A);
- }
-
- protected:
- filter<L,F,D> sub_filter_A_;
- filter<L,F,D> sub_filter_B_;
-
- document<L,F,D> doc_;
- vertex_image<point2d,bool> mask_;
- };
-
- template<typename L, typename F, typename D>
- class filter_and : filter<L,F,D>
- {
- public:
- inline bool gen_link_test(point2d& A, point2d& B)
- {
- return sub_filter_A_.gen_link_test(A, B) || sub_filter_B_.gen_link_test(A, B);
- }
- inline bool gen_vertex_test(point2d& A)
- {
- return sub_filter_A_.gen_vertex_test(A) || sub_filter_B_.gen_vertex_test(A);
- }
-
- protected:
- filter<L,F,D> sub_filter_A_;
- filter<L,F,D> sub_filter_B_;
-
- document<L,F,D> doc_;
- vertex_image<point2d,bool> mask_;
- };
-
- template<typename L, typename F, typename D>
- class filter_letter : filter<L,F,D>
- {
- public:
- inline bool vertex_test(point2d& A){ return doc_.contain_letter(A); }
-
- protected:
- filter<L,F,D> sub_filter_A_;
- filter<L,F,D> sub_filter_B_;
-
- document<L,F,D> doc_;
- vertex_image<point2d,bool> mask_;
- };
-
-
-
- }
- }
-}
-#endif
\ No newline at end of file
diff --git a/scribo/sandbox/raphael/code/my/document/image.hh b/scribo/sandbox/raphael/code/my/document/image.hh
index 158be87..edec471 100644
--- a/scribo/sandbox/raphael/code/my/document/image.hh
+++ b/scribo/sandbox/raphael/code/my/document/image.hh
@@ -37,8 +37,10 @@ namespace mymln
)
{
+ doc.move_line_self_link(doc[v]);
doc.debug_draw_line_green_buffer(q,v);
doc.debug_draw_box_green_buffer(v);
+ doc.add_noise(v);
}
}
}
@@ -58,23 +60,33 @@ namespace mymln
mln_niter_(nbh_t) q(nbh, v);
for_all(v)
{
+ if(doc.contain_end_line(v))
+ {
+ doc.debug_draw_string(v, doc.get_line_length(v));
+ }
if(
doc.contain_paragraph(v) &&
doc.get_paragraph_length(v) < 3 &&
- doc.get_line_length(v) < 4
+ doc.get_line_length(v) < 20
)
{
+ unsigned int noise_count = 0;
for_all(q)
{
if(doc.contain_noise(q))
{
- doc.debug_draw_line_green_buffer(q,v);
- doc.debug_draw_box_green_buffer(v);
+
+ noise_count++;
}
}
+ if(noise_count > 3)
+ {
+ doc.move_line_self_link(doc[v]);
+ doc.debug_draw_box_green_buffer(v);
+ doc.add_noise(v);
+ }
}
}
- doc.propage_line_link();
}
}
}
diff --git a/scribo/sandbox/raphael/code/my/draw/string.hh b/scribo/sandbox/raphael/code/my/draw/string.hh
new file mode 100644
index 0000000..5eefa66
--- /dev/null
+++ b/scribo/sandbox/raphael/code/my/draw/string.hh
@@ -0,0 +1,817 @@
+// Copyright (C) 2007, 2008, 2009 EPITA Research and Development
+// Laboratory (LRDE)
+//
+// This file is part of Olena.
+//
+// Olena is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation, version 2 of the License.
+//
+// Olena is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Olena. If not, see <http://www.gnu.org/licenses/>.
+//
+// As a special exception, you may use this file as part of a free
+// software project without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to produce
+// an executable, this file does not by itself cause the resulting
+// executable to be covered by the GNU General Public License. This
+// exception does not however invalidate any other reasons why the
+// executable file might be covered by the GNU General Public License.
+
+#ifndef MLN_DRAW_STRING_HH
+# define MLN_DRAW_STRING_HH
+
+/*! \file
+ *
+ * \brief Draw a string in an image.
+ *
+ *
+ */
+
+# include <mln/core/concept/image.hh>
+# include <mln/core/alias/box2d.hh>
+# include <mln/data/paste.hh>
+# include <mln/draw/line.hh>
+# include <mln/draw/box.hh>
+# include <mln/pw/image.hh>
+# include <mln/pw/cst.hh>
+# include <mln/core/var.hh>
+
+namespace mln
+{
+
+ namespace draw
+ {
+ /*! Draw a char at value \p v in image \p ima
+ *
+ * \param[in,out] ima The image to be drawn.
+ * \param[in] c the char draw.
+ * \param[in] _b the bounding box of the character.
+ * \param[in] v The value to assign to all drawn pixels.
+ *
+ * \pre \p ima has to be initialized.
+ * \pre \p ima has \p beg.
+ * \pre \p ima has \p end.
+ *
+ */
+ template <typename I, typename B>
+ void character(Image<I>& ima,
+ const char c,
+ const Box<B>& b,
+ const mln_value(I)& v);
+
+
+ /*! Draw a string at value \p v in image \p ima
+ *
+ * \param[in,out] ima The image to be drawn.
+ * \param[in] s the string draw.
+ * \param[in] _b the bounding box of one character.
+ * \param[in] v The value to assign to all drawn pixels.
+ *
+ * \pre \p ima has to be initialized.
+ * \pre \p ima has \p beg.
+ * \pre \p ima has \p end.
+ *
+ */
+ template <typename I, typename B>
+ void string(Image<I>& ima,
+ const char* s,
+ const Box<B>& b,
+ const mln_value(I)& v);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+
+
+ namespace internal
+ {
+ template <typename I, typename B>
+ inline
+ void string_dot(Image<I>& ima,
+ const Box<B>& _b,
+ const mln_value(I)& v)
+ {
+ B b = exact(_b);
+ mln_VAR(cp_min, b.pcenter());
+ mln_VAR(cp_max, b.pcenter());
+ cp_min[1] -= 1;
+ cp_min[0] -= 1;
+ B cb(cp_min, cp_max);
+ draw::box(ima, cb, v);
+ }
+ template <typename I, typename B>
+ inline
+ void string_box(Image<I>& ima,
+ const Box<B>& _b,
+ const mln_value(I)& v)
+ {
+ B b = exact(_b);
+ mln_VAR(cp_min, b.pmin());
+ mln_VAR(cp_max, b.pmax());
+ cp_min[0] -= 1; cp_min[1] -= 1;
+ cp_max[0] -= 1; cp_max[1] -= 1;
+ B cb(cp_min, cp_max);
+ draw::box(ima, cb, v);
+ draw::box(ima, b, v);
+ }
+
+ template <typename I, typename B>
+ inline
+ void string_pipe(Image<I>& ima,
+ const Box<B>& _b,
+ const mln_value(I)& v)
+ {
+ B b = exact(_b);
+ mln_VAR(cp_min, b.pcenter());
+ mln_VAR(cp_max, b.pcenter());
+ cp_min[1] -= 1; cp_min[0] = b.pmin()[0];
+ cp_min[0] -= 1; cp_max[0] = b.pmax()[0];
+ B cb(cp_min, cp_max);
+ draw::box(ima, cb, v);
+ }
+
+ template <typename I, typename B>
+ inline
+ void string_pipe_down(Image<I>& ima,
+ const Box<B>& _b,
+ const mln_value(I)& v)
+ {
+ B b = exact(_b);
+ mln_VAR(cp_min, b.pcenter());
+ mln_VAR(cp_max, b.pcenter());
+ cp_min[1] -= 1; cp_min[0] = b.pmin()[0];
+ cp_min[0] -= 1; cp_max[0] = b.pmax()[0];
+ cp_min[0] = cp_max[0] - b.len(0) / 2;
+ B cb(cp_min, cp_max);
+ draw::box(ima, cb, v);
+ }
+ template <typename I, typename B>
+ inline
+ void string_pipe_top(Image<I>& ima,
+ const Box<B>& _b,
+ const mln_value(I)& v)
+ {
+ B b = exact(_b);
+ mln_VAR(cp_min, b.pcenter());
+ mln_VAR(cp_max, b.pcenter());
+ cp_min[1] -= 1; cp_min[0] = b.pmin()[0];
+ cp_min[0] -= 1; cp_max[0] = b.pmax()[0];
+ cp_max[0] = cp_min[0] + b.len(0) / 2;
+ B cb(cp_min, cp_max);
+ draw::box(ima, cb, v);
+ }
+ template <typename I, typename B>
+ inline
+ void string_right_pipe(Image<I>& ima,
+ const Box<B>& _b,
+ const mln_value(I)& v)
+ {
+ B b = exact(_b);
+ mln_VAR(cp_min, b.pmax());
+ mln_VAR(cp_max, b.pmax());
+ cp_min[1] -= 1; cp_min[0] = b.pmin()[0];
+ cp_min[0] -= 1; cp_max[0] = b.pmax()[0];
+ B cb(cp_min, cp_max);
+ draw::box(ima, cb, v);
+ }
+
+
+ template <typename I, typename B>
+ inline
+ void string_right_pipe_top(Image<I>& ima,
+ const Box<B>& _b,
+ const mln_value(I)& v)
+ {
+ B b = exact(_b);
+ mln_VAR(cp_min, b.pmax());
+ mln_VAR(cp_max, b.pmax());
+ cp_min[1] -= 1; cp_min[0] = b.pmin()[0];
+ cp_min[0] -= 1; cp_max[0] = b.pmax()[0];
+ cp_max[0] = cp_min[0] + b.len(0) / 2;
+ B cb(cp_min, cp_max);
+ draw::box(ima, cb, v);
+ }
+
+ template <typename I, typename B>
+ inline
+ void string_right_pipe_down(Image<I>& ima,
+ const Box<B>& _b,
+ const mln_value(I)& v)
+ {
+ B b = exact(_b);
+ mln_VAR(cp_min, b.pmax());
+ mln_VAR(cp_max, b.pmax());
+ cp_min[1] -= 1; cp_min[0] = b.pmin()[0];
+ cp_min[0] -= 1; cp_max[0] = b.pmax()[0];
+ cp_min[0] = cp_max[0] - b.len(0) / 2;
+ B cb(cp_min, cp_max);
+ draw::box(ima, cb, v);
+ }
+
+ template <typename I, typename B>
+ inline
+ void string_left_pipe(Image<I>& ima,
+ const Box<B>& _b,
+ const mln_value(I)& v)
+ {
+ B b = exact(_b);
+ mln_VAR(cp_min, b.pmin());
+ mln_VAR(cp_max, b.pmin());
+ cp_min[1] -= 1; cp_min[0] = b.pmin()[0];
+ cp_min[0] -= 1; cp_max[0] = b.pmax()[0];
+ B cb(cp_min, cp_max);
+ draw::box(ima, cb, v);
+ }
+
+ template <typename I, typename B>
+ inline
+ void string_left_pipe_top(Image<I>& ima,
+ const Box<B>& _b,
+ const mln_value(I)& v)
+ {
+ B b = exact(_b);
+ mln_VAR(cp_min, b.pmin());
+ mln_VAR(cp_max, b.pmin());
+ cp_min[1] -= 1; cp_min[0] = b.pmin()[0];
+ cp_min[0] -= 1; cp_max[0] = b.pmax()[0];
+ cp_max[0] = cp_min[0] + b.len(0) / 2;
+ B cb(cp_min, cp_max);
+ draw::box(ima, cb, v);
+ }
+
+ template <typename I, typename B>
+ inline
+ void string_down_slash(Image<I>& ima,
+ const Box<B>& _b,
+ const mln_value(I)& v)
+ {
+ B b = exact(_b);
+ mln_VAR(cp_min, b.pcenter());
+ mln_VAR(cp_max, b.pmax());
+ cp_min[1] = b.pmin()[1];
+ draw::line(ima,cp_min, cp_max, v );
+ cp_min[0] -= 1; cp_max[0] -= 1;
+ draw::line(ima,cp_min, cp_max, v );
+ }
+
+
+ template <typename I, typename B>
+ inline
+ void string_top_slash(Image<I>& ima,
+ const Box<B>& _b,
+ const mln_value(I)& v)
+ {
+ B b = exact(_b);
+ mln_VAR(cp_min, b.pcenter());
+ mln_VAR(cp_max, b.pmin());
+ cp_min[1] = b.pmin()[1]; cp_max[1] = b.pmax()[1];
+ draw::line(ima,cp_min, cp_max, v );
+ cp_min[0] -= 1; cp_max[0] -= 1;
+ draw::line(ima,cp_min, cp_max, v );
+ }
+
+
+ template <typename I, typename B>
+ inline
+ void string_left_slash(Image<I>& ima,
+ const Box<B>& _b,
+ const mln_value(I)& v)
+ {
+ B b = exact(_b);
+ mln_VAR(cp_min, b.pmax());
+ mln_VAR(cp_max, b.pmin());
+ draw::line(ima,cp_min, cp_max, v );
+ cp_min[0] -= 1; cp_max[0] -= 1;
+ draw::line(ima,cp_min, cp_max, v );
+ }
+
+ template <typename I, typename B>
+ inline
+ void string_right_slash(Image<I>& ima,
+ const Box<B>& _b,
+ const mln_value(I)& v)
+ {
+ B b = exact(_b);
+ mln_VAR(cp_min, b.pmin());
+ mln_VAR(cp_max, b.pmax());
+ cp_min[1] = b.pmax()[1]; cp_max[1] = b.pmin()[1];
+ draw::line(ima,cp_min, cp_max, v );
+ cp_min[0] -= 1; cp_max[0] -= 1;
+ draw::line(ima,cp_min, cp_max, v );
+ }
+
+ template <typename I, typename B>
+ inline
+ void string_left_pipe_down(Image<I>& ima,
+ const Box<B>& _b,
+ const mln_value(I)& v)
+ {
+ B b = exact(_b);
+ mln_VAR(cp_min, b.pmin());
+ mln_VAR(cp_max, b.pmin());
+ cp_min[1] -= 1; cp_min[0] = b.pmin()[0];
+ cp_min[0] -= 1; cp_max[0] = b.pmax()[0];
+ cp_min[0] = cp_max[0] - b.len(0) / 2;
+ B cb(cp_min, cp_max);
+ draw::box(ima, cb, v);
+ }
+
+ template <typename I, typename B>
+ inline
+ void string_minus(Image<I>& ima,
+ const Box<B>& _b,
+ const mln_value(I)& v)
+ {
+ B b = exact(_b);
+ mln_VAR(cp_min, b.pcenter());
+ mln_VAR(cp_max, b.pcenter());
+ cp_min[1] -= 1; cp_min[1] = b.pmin()[1];
+ cp_min[0] -= 1; cp_max[1] = b.pmax()[1];
+ B cb(cp_min, cp_max);
+ draw::box(ima, cb, v);
+ }
+
+ template <typename I, typename B>
+ inline
+ void string_underscore(Image<I>& ima,
+ const Box<B>& _b,
+ const mln_value(I)& v)
+ {
+ B b = exact(_b);
+ mln_VAR(cp_min, b.pmax());
+ mln_VAR(cp_max, b.pmax());
+ cp_min[1] -= 1; cp_min[1] = b.pmin()[1];
+ cp_min[0] -= 1; cp_max[1] = b.pmax()[1];
+ B cb(cp_min, cp_max);
+ draw::box(ima, cb, v);
+ }
+
+ template <typename I, typename B>
+ inline
+ void string_topscore(Image<I>& ima,
+ const Box<B>& _b,
+ const mln_value(I)& v)
+ {
+ B b = exact(_b);
+ mln_VAR(cp_min, b.pmin());
+ mln_VAR(cp_max, b.pmin());
+ cp_min[1] -= 1; cp_min[1] = b.pmin()[1];
+ cp_min[0] -= 1; cp_max[1] = b.pmax()[1];
+ B cb(cp_min, cp_max);
+ draw::box(ima, cb, v);
+ }
+
+ template <typename I, typename B>
+ inline
+ void string_topbox(Image<I>& ima,
+ const Box<B>& _b,
+ const mln_value(I)& v)
+ {
+ string_topscore(ima, _b, v);
+ string_minus(ima, _b, v);
+ string_left_pipe_top(ima, _b, v);
+ string_right_pipe_top(ima, _b, v);
+ }
+
+ template <typename I, typename B>
+ inline
+ void string_downbox(Image<I>& ima,
+ const Box<B>& _b,
+ const mln_value(I)& v)
+ {
+ string_underscore(ima, _b, v);
+ string_minus(ima, _b, v);
+ string_left_pipe_down(ima, _b, v);
+ string_right_pipe_down(ima, _b, v);
+ }
+ } // end of namespace mln::draw::internal
+
+
+
+ template <typename I, typename B>
+ inline
+ void character(Image<I>& ima,
+ const char c,
+ const Box<B>& _b,
+ const mln_value(I)& v)
+ {
+ B b = exact(_b);
+ switch(c)
+ {
+ case 'A':
+ mln::draw::internal::string_left_pipe(ima, b, v);
+ mln::draw::internal::string_right_pipe(ima, b, v);
+ mln::draw::internal::string_topbox(ima, b, v);
+ break;
+ case 'a':
+ mln::draw::internal::string_left_pipe(ima, b, v);
+ mln::draw::internal::string_right_pipe(ima, b, v);
+ mln::draw::internal::string_topbox(ima, b, v);
+ break;
+
+ case 'B':
+ mln::draw::internal::string_left_pipe(ima, b, v);
+ mln::draw::internal::string_downbox(ima, b, v);
+ break;
+ case 'b':
+ mln::draw::internal::string_left_pipe(ima, b, v);
+ mln::draw::internal::string_downbox(ima, b, v);
+ break;
+ case 'C':
+ mln::draw::internal::string_left_pipe(ima, b, v);
+ mln::draw::internal::string_topscore(ima, b, v);
+ mln::draw::internal::string_underscore(ima, b, v);
+ break;
+ case 'c':
+ mln::draw::internal::string_left_pipe_down(ima, b, v);
+ mln::draw::internal::string_minus(ima, b, v);
+ mln::draw::internal::string_underscore(ima, b, v);
+ break;
+ case 'D':
+ mln::draw::internal::string_right_pipe(ima, b, v);
+ mln::draw::internal::string_downbox(ima, b, v);
+ break;
+ case 'd':
+ mln::draw::internal::string_right_pipe(ima, b, v);
+ mln::draw::internal::string_downbox(ima, b, v);
+ break;
+
+ case 'E':
+ mln::draw::internal::string_left_pipe(ima, b, v);
+ mln::draw::internal::string_minus(ima, b, v);
+ mln::draw::internal::string_underscore(ima, b, v);
+ mln::draw::internal::string_topscore(ima, b, v);
+ break;
+ case 'e':
+ mln::draw::internal::string_left_pipe(ima, b, v);
+ mln::draw::internal::string_minus(ima, b, v);
+ mln::draw::internal::string_underscore(ima, b, v);
+ mln::draw::internal::string_topscore(ima, b, v);
+ break;
+
+ case 'F':
+ mln::draw::internal::string_left_pipe(ima, b, v);
+ mln::draw::internal::string_minus(ima, b, v);
+ mln::draw::internal::string_topscore(ima, b, v);
+ break;
+ case 'f':
+ mln::draw::internal::string_left_pipe(ima, b, v);
+ mln::draw::internal::string_minus(ima, b, v);
+ mln::draw::internal::string_topscore(ima, b, v);
+ break;
+
+
+ case 'G':
+ mln::draw::internal::string_left_pipe(ima, b, v);
+ mln::draw::internal::string_topscore(ima, b, v);
+ mln::draw::internal::string_downbox(ima, b, v);
+ mln::draw::internal::string_left_pipe_top(ima, b, v);
+ break;
+ case 'g':
+ mln::draw::internal::string_left_pipe(ima, b, v);
+ mln::draw::internal::string_topscore(ima, b, v);
+ mln::draw::internal::string_downbox(ima, b, v);
+ mln::draw::internal::string_left_pipe_top(ima, b, v);
+ break;
+
+ case 'H':
+ mln::draw::internal::string_left_pipe(ima, b, v);
+ mln::draw::internal::string_minus(ima, b, v);
+ mln::draw::internal::string_right_pipe(ima, b, v);
+ break;
+ case 'h':
+ mln::draw::internal::string_left_pipe(ima, b, v);
+ mln::draw::internal::string_minus(ima, b, v);
+ mln::draw::internal::string_right_pipe_down(ima, b, v);
+ break;
+
+ case 'I':
+ mln::draw::internal::string_pipe(ima, b, v);
+ mln::draw::internal::string_underscore(ima, b, v);
+ mln::draw::internal::string_topscore(ima, b, v);
+ break;
+ case 'i':
+ mln::draw::internal::string_pipe_down(ima, b, v);
+ break;
+
+ case 'J':
+ mln::draw::internal::string_right_pipe(ima, b, v);
+ mln::draw::internal::string_down_slash(ima, b, v);
+ mln::draw::internal::string_topscore(ima, b, v);
+ break;
+ case 'j':
+ mln::draw::internal::string_right_pipe(ima, b, v);
+ mln::draw::internal::string_down_slash(ima, b, v);
+ mln::draw::internal::string_topscore(ima, b, v);
+ break;
+
+
+ case 'K':
+ mln::draw::internal::string_top_slash(ima, b, v);
+ mln::draw::internal::string_down_slash(ima, b, v);
+ mln::draw::internal::string_left_pipe(ima, b, v);
+ break;
+ case 'k':
+ mln::draw::internal::string_down_slash(ima, b, v);
+ mln::draw::internal::string_top_slash(ima, b, v);
+ mln::draw::internal::string_left_pipe(ima, b, v);
+ break;
+
+ case 'L':
+ mln::draw::internal::string_left_pipe(ima, b, v);
+ mln::draw::internal::string_underscore(ima, b, v);
+ break;
+ case 'l':
+ mln::draw::internal::string_left_pipe(ima, b, v); break;
+
+ case 'M':
+ mln::draw::internal::string_topscore(ima, b, v);
+ mln::draw::internal::string_left_pipe(ima, b, v);
+ mln::draw::internal::string_pipe_top(ima, b, v);
+ mln::draw::internal::string_right_pipe(ima, b, v);
+ break;
+ case 'm':
+ mln::draw::internal::string_minus(ima, b, v);
+ mln::draw::internal::string_left_pipe_down(ima, b, v);
+ mln::draw::internal::string_pipe_down(ima, b, v);
+ mln::draw::internal::string_right_pipe_down(ima, b, v);
+ break;
+
+
+ case 'N':
+ mln::draw::internal::string_topscore(ima, b, v);
+ mln::draw::internal::string_left_pipe(ima, b, v);
+ mln::draw::internal::string_right_pipe(ima, b, v);
+ break;
+ case 'n':
+ mln::draw::internal::string_minus(ima, b, v);
+ mln::draw::internal::string_left_pipe_down(ima, b, v);
+ mln::draw::internal::string_right_pipe_down(ima, b, v);
+ break;
+
+ case 'O':
+ mln::draw::internal::string_box(ima, b, v); break;
+ case 'o':
+ mln::draw::internal::string_downbox(ima, b, v); break;
+
+ case 'P':
+ mln::draw::internal::string_topbox(ima, b, v);
+ mln::draw::internal::string_left_pipe(ima, b, v);
+ break;
+ case 'p':
+ mln::draw::internal::string_topbox(ima, b, v);
+ mln::draw::internal::string_left_pipe(ima, b, v);
+ break;
+
+ case 'Q':
+ mln::draw::internal::string_topbox(ima, b, v);
+ mln::draw::internal::string_right_pipe(ima, b, v);
+ break;
+ case 'q':
+ mln::draw::internal::string_topbox(ima, b, v);
+ mln::draw::internal::string_right_pipe(ima, b, v);
+ break;
+
+ case 'R':
+ mln::draw::internal::string_down_slash(ima, b, v);
+ mln::draw::internal::string_left_pipe(ima, b, v);
+ mln::draw::internal::string_topbox(ima, b,v);
+ break;
+ case 'r':
+ mln::draw::internal::string_down_slash(ima, b, v);
+ mln::draw::internal::string_left_pipe(ima, b, v);
+ mln::draw::internal::string_topbox(ima, b,v);
+ break;
+ case 'S':
+ mln::draw::internal::string_underscore(ima, b, v);
+ mln::draw::internal::string_topscore(ima, b, v);
+ mln::draw::internal::string_minus(ima, b, v);
+ mln::draw::internal::string_right_pipe_down(ima, b, v);
+ mln::draw::internal::string_left_pipe_top(ima, b, v);
+ break;
+
+ case 's':
+ mln::draw::internal::string_underscore(ima, b, v);
+ mln::draw::internal::string_topscore(ima, b, v);
+ mln::draw::internal::string_minus(ima, b, v);
+ mln::draw::internal::string_right_pipe_down(ima, b, v);
+ mln::draw::internal::string_left_pipe_top(ima, b, v);
+ break;
+
+ case 'T':
+ mln::draw::internal::string_pipe(ima, b, v);
+ mln::draw::internal::string_topscore(ima, b, v);
+ break;
+ case 't':
+ mln::draw::internal::string_pipe(ima, b, v);
+ mln::draw::internal::string_topscore(ima, b, v);
+ break;
+
+ case 'U':
+ mln::draw::internal::string_underscore(ima, b, v);
+ mln::draw::internal::string_left_pipe(ima, b, v);
+ mln::draw::internal::string_right_pipe(ima, b, v);
+ break;
+ case 'u':
+ mln::draw::internal::string_underscore(ima, b, v);
+ mln::draw::internal::string_left_pipe_down(ima, b, v);
+ mln::draw::internal::string_right_pipe_down(ima, b, v);
+ break;
+ case 'V':
+ mln::draw::internal::string_left_pipe_top(ima, b, v);
+ mln::draw::internal::string_down_slash(ima, b, v);
+ mln::draw::internal::string_right_pipe(ima, b, v);
+ break;
+ case 'v':
+ mln::draw::internal::string_left_pipe_down(ima, b, v);
+ mln::draw::internal::string_down_slash(ima, b, v);
+ mln::draw::internal::string_right_pipe_down(ima, b, v);
+ break;
+
+ case 'W':
+ mln::draw::internal::string_underscore(ima, b, v);
+ mln::draw::internal::string_left_pipe(ima, b, v);
+ mln::draw::internal::string_pipe_down(ima, b, v);
+ mln::draw::internal::string_right_pipe(ima, b, v);
+ break;
+ case 'w':
+ mln::draw::internal::string_underscore(ima, b, v);
+ mln::draw::internal::string_left_pipe_down(ima, b, v);
+ mln::draw::internal::string_right_pipe_down(ima, b, v);
+ mln::draw::internal::string_pipe_down(ima, b, v);
+ break;
+
+ case 'X':
+ mln::draw::internal::string_left_slash(ima, b, v);
+ mln::draw::internal::string_right_slash(ima, b, v);
+ break;
+ case 'x':
+ mln::draw::internal::string_left_slash(ima, b, v);
+ mln::draw::internal::string_right_slash(ima, b, v);
+ break;
+
+ case 'Y':
+ mln::draw::internal::string_pipe_top(ima, b, v);
+ mln::draw::internal::string_right_slash(ima, b, v);
+ break;
+ case 'y':
+ mln::draw::internal::string_pipe_top(ima, b, v);
+ mln::draw::internal::string_right_slash(ima, b, v);
+ break;
+
+ case 'Z':
+ mln::draw::internal::string_topscore(ima, b, v);
+ mln::draw::internal::string_right_slash(ima, b, v);
+ mln::draw::internal::string_underscore(ima, b, v);
+ break;
+ case 'z':
+ mln::draw::internal::string_minus(ima, b, v);
+ mln::draw::internal::string_underscore(ima, b, v);
+ mln::draw::internal::string_down_slash(ima, b, v);
+ break;
+
+
+ case '0':
+ mln::draw::internal::string_box(ima, b, v);
+ mln::draw::internal::string_dot(ima, b, v);
+ break;
+ case '1':
+ mln::draw::internal::string_pipe(ima, b, v);break;
+ case '2':
+ mln::draw::internal::string_right_pipe_top(ima, b, v);
+ mln::draw::internal::string_left_pipe_down(ima, b, v);
+ mln::draw::internal::string_minus(ima, b, v);
+ mln::draw::internal::string_underscore(ima, b, v);
+ mln::draw::internal::string_topscore(ima, b, v);
+ break;
+ case '3':
+ mln::draw::internal::string_right_pipe(ima, b, v);
+ mln::draw::internal::string_minus(ima, b, v);
+ mln::draw::internal::string_underscore(ima, b, v);
+ mln::draw::internal::string_topscore(ima, b, v);
+ break;
+ case '4':
+ mln::draw::internal::string_right_pipe(ima, b, v);
+ mln::draw::internal::string_minus(ima, b, v);
+ mln::draw::internal::string_left_pipe_top(ima, b, v);
+ break;
+ case '5':
+ mln::draw::internal::string_underscore(ima, b, v);
+ mln::draw::internal::string_topscore(ima, b, v);
+ mln::draw::internal::string_minus(ima, b, v);
+ mln::draw::internal::string_right_pipe_down(ima, b, v);
+ mln::draw::internal::string_left_pipe_top(ima, b, v);
+ break;
+ case '6':
+ mln::draw::internal::string_left_pipe(ima, b, v);
+ mln::draw::internal::string_topscore(ima, b, v);
+ mln::draw::internal::string_downbox(ima, b, v);
+ mln::draw::internal::string_left_pipe_top(ima, b, v);
+ break;
+
+ case '7':
+ mln::draw::internal::string_right_pipe(ima, b, v);
+ mln::draw::internal::string_topscore(ima, b, v);
+ break;
+ case '8':
+ mln::draw::internal::string_box(ima, b, v);
+ mln::draw::internal::string_minus(ima, b, v);
+ break;
+ case '9':
+ mln::draw::internal::string_right_pipe(ima, b, v);
+ mln::draw::internal::string_topbox(ima, b, v);
+ break;
+ case '.':
+ mln::draw::internal::string_dot(ima, b, v);break;
+ case ' ':
+ break;
+ case '-':
+ mln::draw::internal::string_minus(ima, b, v);break;
+ break;
+ case '_':
+ mln::draw::internal::string_underscore(ima, b, v);
+ break;
+ case '=':
+ mln::draw::internal::string_minus(ima, b, v);
+ mln::draw::internal::string_underscore(ima, b, v);
+ break;
+ case '$':
+ mln::draw::internal::string_right_pipe_top(ima, b, v);
+ mln::draw::internal::string_left_pipe_down(ima, b, v);
+ mln::draw::internal::string_minus(ima, b, v);
+ mln::draw::internal::string_underscore(ima, b, v);
+ mln::draw::internal::string_topscore(ima, b, v);
+ mln::draw::internal::string_pipe(ima, b, v);
+ break;
+
+ case '(':
+ mln::draw::internal::string_underscore(ima, b, v);
+ mln::draw::internal::string_topscore(ima, b, v);
+ mln::draw::internal::string_left_pipe(ima, b, v);
+ break;
+
+ case ')':
+ mln::draw::internal::string_underscore(ima, b, v);
+ mln::draw::internal::string_topscore(ima, b, v);
+ mln::draw::internal::string_right_pipe(ima, b, v);
+ break;
+
+ case '|':
+ mln::draw::internal::string_pipe(ima, b, v);
+ break;
+ case '/':
+ mln::draw::internal::string_right_slash(ima, b, v);
+ break;
+ case '\\':
+ mln::draw::internal::string_left_slash(ima, b, v);
+ break;
+ }
+ }
+
+
+ template <typename I, typename B>
+ inline
+ void string(Image<I>& ima,
+ const char* s,
+ const Box<B>& _b,
+ const mln_value(I)& v)
+ {
+ B b = exact(_b);
+ const char* ptr = &(s[0]);
+ int Decal = 0;
+ int DecalY = 0;
+ int DecalX = 0;
+ while(ptr[Decal])
+ {
+ if(ptr[Decal] == '\n'){DecalY++; DecalX = 0; ptr++; continue;}
+ if(ptr[Decal] == '\t'){ DecalX += 5; ptr++; continue;}
+ mln_VAR(cp_min, b.pmin());
+ mln_VAR(cp_max, b.pmax());
+ cp_min[1] += (b.len(1) + (b.len(1) / 2)) * DecalX;
+ cp_max[1] += (b.len(1) + (b.len(1) / 2)) * DecalX;
+
+ cp_min[0] += (b.len(0) + (b.len(1) / 2)) * DecalY;
+ cp_max[0] += (b.len(0) + (b.len(1) / 2)) * DecalY;
+
+ B cb(cp_min, cp_max);
+ character(ima, ptr[Decal], cb, v);
+ Decal++;
+ DecalX++;
+ }
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::draw
+
+} // end of namespace mln
+
+
+#endif // ! MLN_DRAW_BOX_HH
diff --git a/scribo/sandbox/raphael/code/my/runtime/lib.hh b/scribo/sandbox/raphael/code/my/runtime/lib.hh
index 951c571..41b2a43 100644
--- a/scribo/sandbox/raphael/code/my/runtime/lib.hh
+++ b/scribo/sandbox/raphael/code/my/runtime/lib.hh
@@ -68,10 +68,11 @@ namespace mymln
run.add_function("clean.paragraphs_first_line", &(mymln::document::clean_paragraphs_first_line));
run.add_function("clean.ellipsis", &(mymln::document::clean_ellipsis));
run.add_function("clean.apostrophe_items", &(mymln::document::clean_apostrophe_items));
-
-
+ run.add_function("clean.finalize_letters", &(mymln::document::clean_finalize_letters));
+ run.add_function("clean.lines_artefacts", &(mymln::document::clean_lines_artefacts));
run.add_function("image.bad_paragraph", &(mymln::document::image_bad_paragraph));
run.add_function("image.anomalies_paragraph", &(mymln::document::image_anomalies_paragraph));
+
}
template<typename L, typename F, typename D>
diff --git a/scribo/sandbox/raphael/code/my/util/union.hh b/scribo/sandbox/raphael/code/my/util/union.hh
index 81b551d..e86e15f 100644
--- a/scribo/sandbox/raphael/code/my/util/union.hh
+++ b/scribo/sandbox/raphael/code/my/util/union.hh
@@ -32,6 +32,11 @@ namespace mymln
{return mark_link[A] == A;}
inline void invalidate_link(const Label A)
{ mark_link[A] = 0; }
+ inline void add_self_link_coerce(const Label A)
+ {
+ if(!A){return;}
+ mark_link[A] = A;
+ }
inline void add_self_link(const Label A)
{
if(!A){return;}
diff --git a/scribo/sandbox/raphael/code/test.cc b/scribo/sandbox/raphael/code/test.cc
index 99d6600..83be0d9 100644
--- a/scribo/sandbox/raphael/code/test.cc
+++ b/scribo/sandbox/raphael/code/test.cc
@@ -34,6 +34,7 @@
#include <mln/algebra/vec.hh>
#include <mln/core/image/graph_elt_neighborhood.hh>
#include <mln/graph/compute.hh>
+#include <my/draw/string.hh>
#include <mln/draw/plot.hh>
#include <my/debug/pict.hh>
@@ -54,6 +55,16 @@
#include <my/debug/remote/document_remote.hh>
#include <my/debug/remote/lib.hh>
#endif
+
+
+
+
+#ifndef NDEMO
+#include <demo/demo_extract_paragraphs.hh>
+#endif
+
+
+
using namespace mln;
using namespace std;
@@ -133,127 +144,25 @@ void Process(std::string File, std::string Dir, mymln::runtime::runtime< value::
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);
-
-
- mymln::document::clean_letters_alone(doc);
- doc.cook_lines();
- mymln::document::clean_included_letters(doc);
- doc.recook_lines();
- mymln::document::clean_dot_items(doc);
- doc.recook_lines();
- mymln::document::clean_quote_items(doc);
- doc.recook_lines();
+ runtime.run();
+ std::cout << "WORK ON GRAPH : " << timer.stop() << endl;
+ mymln::data::page<uint16,float,short> page(doc);
+ page.export_HTML(Dir + "/debug_" + File + ".html");
-
- mymln::document::clean_between(doc);
- doc.recook_lines();
- doc.compute_letter_middle_height();
- doc.compute_letter_middle_width();
- mymln::document::clean_odd_letters(doc);
- doc.recook_lines();
-
-*/
-
- /*doc.compute_letter_middle_space();
- mymln::document::clean_lines_space(doc, Dir + "/" + "quote_graph_" + File, doc.image_mask_letters());
- doc.recook_lines();*/
-
-/*
-
- mymln::document::separators::separators_find_allign(doc);
- mymln::document::separators::separators_make_clean(doc);
- doc.cook_separators();
- doc.cook_line_splitting();
-
-
- mymln::document::clean_line_link_item(doc);
- mymln::document::clean_proximity_lines(doc);
- mymln::document::clean_quote_lines(doc);
- doc.recook_lines();
-
-
- doc.reset_implicit_separators();
- mymln::document::separators::separators_find_allign_right(doc);
- mymln::document::separators::separators_make_clean_right(doc);
- doc.cook_separators_right();
- doc.cook_line_splitting_exclusive();
- mymln::document::clean_line_link_item(doc);
-
- mymln::document::clean_proximity_lines(doc);
- mymln::document::clean_quote_lines(doc);
- mymln::document::clean_alone_letters_lines(doc);
- doc.recook_lines();
-
- doc.compute_letter_middle_height();
- doc.compute_letter_middle_width();
- mymln::document::clean_odd_letters(doc);
- doc.recook_lines();
- */
- /*
- mymln::document::clean_lines_space(doc, Dir + "/" + "alone_graph_" + File, doc.image_mask_letters());
- doc.recook_lines();*/
-
- /*
- mymln::document::remove_alone_letter(doc);
-
- doc.recook_lines();
-
- mymln::document::clean_paragraph_items(doc);
- doc.cook_paragraphs();
-
-
- mymln::document::clean_paragraphs_up(doc);
- doc.recook_paragraphs();
-
- mymln::document::clean_paragraphs_large(doc);
- doc.recook_paragraphs();
- mymln::document::clean_included_paragraphs(doc);
- doc.recook_paragraphs();
-
-
- doc.recook_lines();
- */
-
-
- runtime.run();
- std::cout << "WORK ON GRAPH : " << timer.stop() << endl;
+
+ // THE DEMOS START HERE
+#ifndef NDEMO
+ demo_extract_paragraphs(doc);
+#endif NDEMO
- //mymln::data::page<uint16,float,short> page(doc);
- //page.export_HTML( Dir + "/" + File + ".html");
-
-
- /*
- doc.cook_lines_iter();
- std::cout << doc.get_first_line();
-
-
-
-
- doc.compute_letter_middle_space();
-
- mymln::document::recognize_minus(doc);
- mymln::document::recognize_dot(doc);
- for(int Line = doc.get_first_line(); Line; doc.get_next_line(Line))
- {
- std::cout << doc.get_line_string(Line) << endl;
- }
-
- //doc.debug_save_lines(Dir + "/" + "lines_" + File);
- //doc.debug_save_all(Dir + "/" + "debug_" + File, ima);
- */
-
}
+
#ifndef NREMOTE
// THIS IS USED TO CREATE A FILTER WITHOUT RECOMPILING
mymln::document::debug::remote< value::int_u<16> ,float,short> rem;
--
1.7.2.5
1
0

last-svn-commit-890-ga709ecb Fix bug with finalize function. Add functions to recognize pictures.
by Raphael Boissel 08 Sep '11
by Raphael Boissel 08 Sep '11
08 Sep '11
---
scribo/sandbox/raphael/code/my/document/clean.hh | 98 ++++++++++++++++++--
.../sandbox/raphael/code/my/document/document.hh | 95 ++++++++++++++++++-
scribo/sandbox/raphael/code/my/document/image.hh | 81 ++++++++++++++++
scribo/sandbox/raphael/code/my/document/outline.hh | 52 ++++++++++
scribo/sandbox/raphael/code/my/runtime/lib.hh | 8 ++-
scribo/sandbox/raphael/code/test.cc | 2 -
6 files changed, 319 insertions(+), 17 deletions(-)
diff --git a/scribo/sandbox/raphael/code/my/document/clean.hh b/scribo/sandbox/raphael/code/my/document/clean.hh
index cfff068..cf61a1c 100644
--- a/scribo/sandbox/raphael/code/my/document/clean.hh
+++ b/scribo/sandbox/raphael/code/my/document/clean.hh
@@ -144,7 +144,7 @@ namespace mymln
if((!doc.contain_line(q)))
{
// draw::line(out, q,v, mln::literal::blue);
- if(doc.allign_V(q,v) && doc.allign_size(q, v) && doc.allign_proximity_large(q, v) )
+ if(doc.allign_V(q,v) && doc.allign_size_medium(q, v) && doc.allign_proximity_large(q, v) )
{
doc.add_to_line_link(v, q);
All_Alone = false;
@@ -152,7 +152,7 @@ namespace mymln
}
else
{
- if(doc.allign_V(q,v) && doc.allign_size(q, v) && doc.allign_proximity_large(q, v))
+ if(doc.allign_V(q,v) && doc.allign_size_medium(q, v) && doc.allign_proximity_large(q, v))
{
doc.add_to_line_link(q, v);
All_Alone = false;
@@ -303,6 +303,53 @@ namespace mymln
doc.propage_line_link();
doc.recook_lines();
}
+
+
+
+
+
+ template<typename L, typename F, typename D>
+ void clean_apostrophe_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_start_end_lines();
+ 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_line(v) )
+ {
+ for_all(q)
+ {
+ if(
+ doc.get_line_length(q) == 1 &&
+ doc.line_reciprocal(q,v) &&
+ doc.allign_top(v,q) &&
+ doc.letter_ratio_YX(q) > 1 &&
+ !doc.allign_H_tube(v,q) &&
+ doc.allign_proximity_strict_left(v,q) &&
+ doc.allign_small_item_large(v,q)
+
+ )
+ {
+ doc.debug_draw_line_green_buffer(q,v);
+ doc.add_to_line_link(v,q);
+ }
+ }
+ }
+ }
+ doc.propage_line_link();
+ doc.recook_lines();
+ }
+
+
+
+
+
+
template<typename L, typename F, typename D>
void clean_line_link_item(mymln::document::document<L,F,D>& doc)
@@ -474,7 +521,7 @@ namespace mymln
L End = 0;
for_all(q)
{
- if(doc.allign_V(q,v) && doc.allign_size(q, v) && doc.allign_proximity(q,v))
+ if(doc.allign_V(q,v) && doc.allign_size_medium(q, v) && doc.allign_proximity(q,v))
{
if(doc[q] == doc.get_beginning_of_line(q))
{Start = doc[q]; }
@@ -485,7 +532,7 @@ namespace mymln
}
if(Start && End){doc.add_to_line_link(Start, doc[v]);}
}
- doc.propage_paragraph_link();
+ doc.propage_line_link();
}
@@ -1167,10 +1214,14 @@ namespace mymln
doc.return_previous_line(doc[q]) == doc.return_previous_line(doc[v])
)
{
- if(doc.get_line_length(q) < 4 || doc.get_line_length(v) < 4 )
- doc.debug_draw_line_green_buffer(q,v);
- doc.add_to_line_link(v, q);
- doc.add_to_paragraph_link(v, q);
+ //if(doc.get_line_length(q) < 4 || doc.get_line_length(v) < 4 )
+
+ if(doc.get_paragraph_length(v) < 3 || doc.get_line_length(q) < 3)
+ {
+ doc.debug_draw_line_green_buffer(q,v);
+ doc.add_to_line_link(v, q);
+ doc.add_to_paragraph_link(v, q);
+ }
}
}
}
@@ -1396,10 +1447,37 @@ namespace mymln
doc.propage_paragraph_link();
}
+ template<typename L, typename F, typename D>
+ void clean_ellipsis(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_start_end_lines();
+ 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.get_line_length(q) == 3 &&
+ doc.allign_base_line_line_strict(v, q) &&
+ doc.allign_smaller_line_strict(v,q) &&
+ doc.allign_proximity_large_left(v,q)
+ )
+ {
+ doc.debug_draw_line_green_buffer(q,v);
+ doc.add_to_line_link(v,q);
+ }
+ }
+ }
+ doc.propage_line_link();
+ }
-
-
+
}
diff --git a/scribo/sandbox/raphael/code/my/document/document.hh b/scribo/sandbox/raphael/code/my/document/document.hh
index c7fc0c1..1d50e5c 100644
--- a/scribo/sandbox/raphael/code/my/document/document.hh
+++ b/scribo/sandbox/raphael/code/my/document/document.hh
@@ -58,6 +58,7 @@ namespace mymln
alone_letters_mask = fun::i2v::array<bool>(Areas + 1);
implicit_separators_left_mask = fun::i2v::array<bool>(Areas + 1);
implicit_separators_right_mask = fun::i2v::array<bool>(Areas + 1);
+ anomaly_mask = fun::i2v::array<bool>(Areas + 1);
kill_mask = fun::i2v::array<bool>(Areas + 1);
all_mask = fun::i2v::array<bool>(Areas + 1);
CImpSep = 1;
@@ -509,6 +510,7 @@ namespace mymln
/* SET UP SPECIAL MASK TO FALSE */
implicit_separators_left_mask(lbl) = false;
implicit_separators_right_mask(lbl) = false;
+ anomaly_mask(lbl) = false;
kill_mask(lbl) = false;
temp_letter(lbl) = false;
}
@@ -547,6 +549,25 @@ namespace mymln
temp_letter = false;
}
+
+
+ void add_anomaly(const point2d& point)
+ {add_anomaly(img_influ(point));}
+ void add_anomaly(const Label lbl)
+ {anomaly_mask(lbl) = true;}
+
+
+ void remove_anomaly(const point2d& point)
+ {remove_anomaly(img_influ(point));}
+ void remove_anomaly(const Label lbl)
+ {anomaly_mask(lbl) = false;}
+
+
+ bool contain_anomaly(const point2d& point)
+ {return contain_anomaly(img_influ(point));}
+ void contain_anomaly(const Label lbl)
+ {return anomaly_mask(lbl);}
+
void add_alone_letter(const point2d& point)
{add_alone_letter(img_influ(point));}
void add_alone_letter(const Label lbl)
@@ -1399,7 +1420,26 @@ namespace mymln
return (DisA) * 3 < HA * 2;
}
-
+ inline bool allign_proximity_strict_left( const point2d& Left, const point2d& Right)
+ {return allign_proximity_strict_left(img_influ(Left), img_influ(Right));}
+
+ inline bool allign_proximity_strict_left( const Label Left, const Label Right)
+ {
+ box2d LB = _bboxgp[Left];
+ box2d RB = _bboxgp[Right];
+
+ int DisA = LB.pmax()[1] - RB.pmin()[1];
+ int DisB = RB.pmax()[1] - LB.pmin()[1];
+ if(DisA < 0){DisA = -DisA;}
+ if(DisB < 0){DisB = -DisB;}
+ if(DisA > DisB)
+ { DisA = DisB; }
+ unsigned int HA = LB.len(0);
+ unsigned int VA = LB.len(1);
+ if(VA > HA)
+ { HA = VA; }
+ return (DisA) * 2 < HA;
+ }
inline bool allign_proximity_large_left( const point2d& Left, const point2d& Right)
@@ -1499,6 +1539,23 @@ namespace mymln
}
+ inline bool allign_size_medium( const point2d& Left, const point2d& Right)
+ {return allign_size_medium(img_influ(Left), img_influ(Right));}
+
+ inline bool allign_size_medium( const Label Left, const Label Right)
+ {
+ short int SizeL0 = label_size_(0, Left);
+ short int SizeR0 = label_size_(0, Right);
+ short int SizeL1 = label_size_(1, Left);
+ short int SizeR1 = label_size_(1, Right);
+ short int Swap = 0;
+ if(SizeL0 < SizeL1)
+ { SizeL0 = SizeL1; }
+ if(SizeR0 < SizeR1){SizeR0 = SizeR1;}
+ return SizeR0 > (SizeL0 / 3) && SizeR0 < (SizeL0 * 3);
+ }
+
+
inline bool allign_size_height_max( const point2d& Left, const point2d& Right)
{return allign_size_height_max(img_influ(Left), img_influ(Right));}
@@ -1567,7 +1624,14 @@ namespace mymln
lines_bbox[lines_union[Left]].len(0) < (_bboxgp[Right].len(0) * 12) &&
lines_bbox[lines_union[Left]].len(0) > (_bboxgp[Right].len(0) * 2);
}
-
+ inline bool allign_small_item_large( const point2d& Left, const point2d& Right)
+ {return allign_small_item_large(img_influ(Left), img_influ(Right));}
+ inline bool allign_small_item_large( Label Left, Label Right)
+ {
+ return
+ lines_bbox[lines_union[Left]].len(0) < (_bboxgp[Right].len(0) * 12) &&
+ lines_bbox[lines_union[Left]].len(0)*2 > (_bboxgp[Right].len(0) * 3);
+ }
inline bool allign_small_item_line( const point2d& Left, const point2d& Right)
{return allign_small_item(img_influ(Left), img_influ(Right));}
inline bool allign_small_item_line( Label Left, Label Right)
@@ -1594,7 +1658,12 @@ namespace mymln
{
return lines_bbox[lines_union[Left]].len(0) > (lines_bbox[lines_union[Right]].len(0) * 2);
}
-
+ inline bool allign_smaller_line_strict( const point2d& Left, const point2d& Right)
+ {return allign_smaller_line_strict(img_influ(Left), img_influ(Right));}
+ inline bool allign_smaller_line_strict( Label Left, Label Right)
+ {
+ return lines_bbox[lines_union[Left]].len(0) > (lines_bbox[lines_union[Right]].len(0) * 3);
+ }
inline bool allign_smaller_line_letter( const point2d& Left, const point2d& Right)
{return allign_smaller_line_letter(img_influ(Left), img_influ(Right));}
inline bool allign_smaller_line_letter( Label Left, Label Right)
@@ -2170,6 +2239,8 @@ namespace mymln
{ return fun_mask_(image_mask); }
vertex_image<point2d,bool> fun_mask_letters()
{ return fun_mask_(letters_mask); }
+ vertex_image<point2d,bool> fun_mask_anomalies()
+ { return fun_mask_(anomaly_mask); }
vertex_image<point2d,bool> fun_mask_start_lines()
{ return fun_mask_(start_lines_mask); }
vertex_image<point2d,bool> fun_mask_end_lines()
@@ -2353,6 +2424,18 @@ namespace mymln
paragraphs_bbox[paragraphs_union[Par1]].has(paragraphs_bbox[paragraphs_union[Par2]].pmax()) ;
}
+ inline bool line_reciprocal(const point2d& L1, const point2d& L2)
+ {return line_reciprocal(img_influ(L1), img_influ(L2));}
+
+ inline bool line_reciprocal(Label L1, Label L2)
+ {
+ return
+ lines_bbox[lines_union[L1]].has(lines_bbox[lines_union[L2]].pmin()) ||
+ lines_bbox[lines_union[L1]].has(lines_bbox[lines_union[L2]].pmax()) ||
+ lines_bbox[lines_union[L2]].has(lines_bbox[lines_union[L1]].pmin()) ||
+ lines_bbox[lines_union[L2]].has(lines_bbox[lines_union[L1]].pmax()) ;
+ }
+
inline bool line_influence_reciprocal(const point2d& L1, const point2d& L2)
{return line_influence_reciprocal(img_influ(L1), img_influ(L2));}
@@ -2541,9 +2624,12 @@ namespace mymln
}
inline bool contain_implicit_separator(const point2d& point)
{ return contain_implicit_separator(img_influ(point)); }
-
+ inline bool contain_noise(const point2d& point)
+ { return contain_noise(img_influ(point)); }
inline bool contain_implicit_separator(const Label lbl)
{return implicit_separators_union[lbl] != 0; }
+ inline bool contain_noise(const Label lbl)
+ {return noise_mask(lbl); }
inline void merge_separators(const point2d& A, const point2d& B)
{
@@ -3389,6 +3475,7 @@ namespace mymln
fun::i2v::array<bool> kill_mask;
fun::i2v::array<bool> all_mask;
fun::i2v::array<bool> image_mask;
+ fun::i2v::array<bool> anomaly_mask;
mln::util::array<std::string> tag_lbl;
mln::util::array<bool> Btag_lbl;
diff --git a/scribo/sandbox/raphael/code/my/document/image.hh b/scribo/sandbox/raphael/code/my/document/image.hh
index e69de29..158be87 100644
--- a/scribo/sandbox/raphael/code/my/document/image.hh
+++ b/scribo/sandbox/raphael/code/my/document/image.hh
@@ -0,0 +1,81 @@
+#ifndef INC_IMAGE_DOC
+#define INC_IMAGE_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 image_bad_paragraph(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_all_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_paragraph(v) &&
+ doc.get_paragraph_length(v) == 1 &&
+ doc.get_line_length(v) < 4
+
+ )
+ {
+ for_all(q)
+ {
+ if
+ (
+ doc.contain_noise(q)
+
+
+ )
+ {
+ doc.debug_draw_line_green_buffer(q,v);
+ doc.debug_draw_box_green_buffer(v);
+ }
+ }
+ }
+ }
+ doc.propage_line_link();
+ }
+
+ template<typename L, typename F, typename D>
+ void image_anomalies_paragraph(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_all_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_paragraph(v) &&
+ doc.get_paragraph_length(v) < 3 &&
+ doc.get_line_length(v) < 4
+ )
+ {
+ for_all(q)
+ {
+ if(doc.contain_noise(q))
+ {
+ doc.debug_draw_line_green_buffer(q,v);
+ doc.debug_draw_box_green_buffer(v);
+ }
+ }
+ }
+ }
+ doc.propage_line_link();
+ }
+ }
+}
+#endif
\ No newline at end of file
diff --git a/scribo/sandbox/raphael/code/my/document/outline.hh b/scribo/sandbox/raphael/code/my/document/outline.hh
index cff52e3..e6244d4 100644
--- a/scribo/sandbox/raphael/code/my/document/outline.hh
+++ b/scribo/sandbox/raphael/code/my/document/outline.hh
@@ -59,7 +59,59 @@ namespace mymln
return out;
}
+ template <typename I, typename N>
+ image2d<bool> threshold(const Image<I>& iz_, const Neighborhood<N>& nbh_)
+ {
+ const I& iz = exact(iz_);
+ const N& nbh = exact(nbh_);
+
+
+ image2d<bool> out(iz.domain());
+
+ mln_pixter(const I) p(iz);
+ mln_nixter(const I, N) n(p, nbh);
+
+ for_all(p)
+ {
+ unsigned int count = 0;
+ int variate = 0;
+ for_all(n)
+ {
+ variate += n.val();
+ count++;
+ }
+ variate /= count;
+ variate -= p.val();
+ if(variate > 10)
+ {
+ out.element(p.offset()) = true;
+ }
+ }
+
+
+ for_all(p)
+ {
+ unsigned int count = 0;
+ int variate = 0;
+ if(out.element(p.offset()))
+ {
+ for_all(n)
+ {
+ if(out.element(n.offset()))
+ count++;
+ }
+ if(count == 0)
+ {
+ out.element(p.offset()) = false;
+ }
+ }
+ }
+
+
+
+ return out;
+ }
template <typename I, typename N>
image2d<value::int_u8> luminance(const Image<I>& iz_)
{
diff --git a/scribo/sandbox/raphael/code/my/runtime/lib.hh b/scribo/sandbox/raphael/code/my/runtime/lib.hh
index f60a995..951c571 100644
--- a/scribo/sandbox/raphael/code/my/runtime/lib.hh
+++ b/scribo/sandbox/raphael/code/my/runtime/lib.hh
@@ -1,6 +1,6 @@
#ifndef INC_RUNTIME_LIB
#define INC_RUNTIME_LIB
-
+#include<my/document/image.hh>
using namespace mln;
using namespace std;
namespace mymln
@@ -66,6 +66,12 @@ namespace mymln
run.add_function("clean.paragraphs_couple", &(mymln::document::clean_paragraphs_couple));
run.add_function("clean.paragraphs_first_line", &(mymln::document::clean_paragraphs_first_line));
+ run.add_function("clean.ellipsis", &(mymln::document::clean_ellipsis));
+ run.add_function("clean.apostrophe_items", &(mymln::document::clean_apostrophe_items));
+
+
+ run.add_function("image.bad_paragraph", &(mymln::document::image_bad_paragraph));
+ run.add_function("image.anomalies_paragraph", &(mymln::document::image_anomalies_paragraph));
}
template<typename L, typename F, typename D>
diff --git a/scribo/sandbox/raphael/code/test.cc b/scribo/sandbox/raphael/code/test.cc
index 3eab190..99d6600 100644
--- a/scribo/sandbox/raphael/code/test.cc
+++ b/scribo/sandbox/raphael/code/test.cc
@@ -44,7 +44,6 @@
#include <my/document/separator.hh>
#include <my/document/clean.hh>
#include <my/document/recognition.hh>
-
#include <my/runtime/runtime.hh>
#include <my/runtime/lib.hh>
@@ -72,7 +71,6 @@ void Process(std::string File, std::string Dir, mymln::runtime::runtime< value::
/* CREATE GRAPH */
typedef value::int_u<16> uint16;
image2d<bool> ima;
-
mln::util::timer timer;
timer.start();
io::pbm::load(ima, Dir + "/" + File);
--
1.7.2.5
1
0