<s>
In	O
computer	B-Application
vision	I-Application
or	O
natural	B-Language
language	I-Language
processing	I-Language
,	O
document	B-Algorithm
layout	I-Algorithm
analysis	I-Algorithm
is	O
the	O
process	O
of	O
identifying	O
and	O
categorizing	O
the	O
regions	B-Algorithm
of	I-Algorithm
interest	I-Algorithm
in	O
the	O
scanned	B-Application
image	I-Application
of	O
a	O
text	B-Application
document	O
.	O
</s>
<s>
A	O
reading	O
system	O
requires	O
the	O
segmentation	O
of	O
text	B-Application
zones	O
from	O
non-textual	O
ones	O
and	O
the	O
arrangement	O
in	O
their	O
correct	O
reading	O
order	O
.	O
</s>
<s>
Detection	O
and	O
labeling	B-Application
of	O
the	O
different	O
zones	O
(	O
or	O
blocks	O
)	O
as	O
text	B-Application
body	O
,	O
illustrations	O
,	O
math	O
symbols	O
,	O
and	O
tables	O
embedded	O
in	O
a	O
document	O
is	O
called	O
geometric	O
layout	O
analysis	O
.	O
</s>
<s>
But	O
text	B-Application
zones	O
play	O
different	O
logical	O
roles	O
inside	O
the	O
document	O
(	O
titles	O
,	O
captions	O
,	O
footnotes	O
,	O
etc	O
.	O
)	O
</s>
<s>
and	O
this	O
kind	O
of	O
semantic	O
labeling	B-Application
is	O
the	O
scope	O
of	O
the	O
logical	O
layout	O
analysis	O
.	O
</s>
<s>
Document	B-Algorithm
layout	I-Algorithm
analysis	I-Algorithm
is	O
the	O
union	O
of	O
geometric	O
and	O
logical	O
labeling	B-Application
.	O
</s>
<s>
It	O
is	O
typically	O
performed	O
before	O
a	O
document	O
image	O
is	O
sent	O
to	O
an	O
OCR	B-Application
engine	O
,	O
but	O
it	O
can	O
be	O
used	O
also	O
to	O
detect	O
duplicate	O
copies	O
of	O
the	O
same	O
document	O
in	O
large	O
archives	O
,	O
or	O
to	O
index	O
documents	O
by	O
their	O
structure	O
or	O
pictorial	O
content	O
.	O
</s>
<s>
There	O
are	O
two	O
main	O
approaches	O
to	O
document	B-Algorithm
layout	I-Algorithm
analysis	I-Algorithm
.	O
</s>
<s>
These	O
approaches	O
typically	O
first	O
parse	O
a	O
document	O
into	O
connected	O
regions	O
of	O
black	O
and	O
white	O
,	O
then	O
these	O
regions	O
are	O
grouped	O
into	O
words	O
,	O
then	O
into	O
text	B-Application
lines	O
,	O
and	O
finally	O
into	O
text	B-Application
blocks	O
.	O
</s>
<s>
There	O
are	O
two	O
issues	O
common	O
to	O
any	O
approach	O
at	O
document	B-Algorithm
layout	I-Algorithm
analysis	I-Algorithm
:	O
noise	O
and	O
skew	O
.	O
</s>
<s>
Noise	O
refers	O
to	O
image	O
noise	O
,	O
such	O
as	O
salt	B-Algorithm
and	I-Algorithm
pepper	I-Algorithm
noise	I-Algorithm
or	O
Gaussian	O
noise	O
.	O
</s>
<s>
Skew	O
refers	O
to	O
the	O
fact	O
that	O
a	O
document	O
image	O
may	O
be	O
rotated	O
in	O
a	O
way	O
so	O
that	O
the	O
text	B-Application
lines	O
are	O
not	O
perfectly	O
horizontal	O
.	O
</s>
<s>
It	O
is	O
a	O
common	O
assumption	O
in	O
both	O
document	B-Algorithm
layout	I-Algorithm
analysis	I-Algorithm
algorithms	O
and	O
optical	B-Application
character	I-Application
recognition	I-Application
algorithms	O
that	O
the	O
characters	O
in	O
the	O
document	O
image	O
are	O
oriented	O
so	O
that	O
text	B-Application
lines	O
are	O
horizontal	O
.	O
</s>
<s>
It	O
follows	O
that	O
the	O
first	O
steps	O
in	O
any	O
document	B-Algorithm
layout	I-Algorithm
analysis	I-Algorithm
code	O
are	O
to	O
remove	O
image	O
noise	O
and	O
to	O
come	O
up	O
with	O
an	O
estimate	O
for	O
the	O
skew	O
angle	O
of	O
the	O
document	O
.	O
</s>
<s>
In	O
this	O
section	O
we	O
will	O
walk	O
through	O
the	O
steps	O
of	O
a	O
bottom-up	O
document	B-Algorithm
layout	I-Algorithm
analysis	I-Algorithm
algorithm	O
developed	O
in	O
1993	O
by	O
O`Gorman	O
.	O
</s>
<s>
Preprocess	O
the	O
image	O
to	O
remove	O
Gaussian	O
and	O
salt-and-pepper	B-Algorithm
noise	I-Algorithm
.	O
</s>
<s>
For	O
each	O
symbol	O
,	O
determine	O
its	O
k	B-General_Concept
nearest	I-General_Concept
neighbors	I-General_Concept
where	O
k	O
is	O
an	O
integer	O
greater	O
than	O
or	O
equal	O
to	O
four	O
.	O
</s>
<s>
The	O
reason	O
to	O
use	O
at	O
least	O
k	O
=	O
4	O
is	O
that	O
for	O
a	O
symbol	O
in	O
a	O
document	O
,	O
the	O
two	O
or	O
three	O
nearest	O
symbols	O
are	O
the	O
ones	O
right	O
next	O
to	O
it	O
on	O
the	O
same	O
text	B-Application
line	O
.	O
</s>
<s>
The	O
fourth-nearest	O
symbol	O
is	O
typically	O
on	O
a	O
line	O
right	O
above	O
or	O
below	O
,	O
and	O
it	O
is	O
important	O
to	O
include	O
these	O
symbols	O
in	O
the	O
nearest	B-General_Concept
neighbor	I-General_Concept
calculation	O
for	O
the	O
following	O
.	O
</s>
<s>
Each	O
nearest	B-General_Concept
neighbor	I-General_Concept
pair	O
of	O
symbols	O
is	O
related	O
by	O
a	O
vector	O
pointing	O
from	O
one	O
symbol	O
’s	O
centroid	O
to	O
the	O
other	O
symbol	O
’s	O
centroid	O
.	O
</s>
<s>
If	O
these	O
vectors	O
are	O
plotted	O
for	O
every	O
pair	O
of	O
nearest	B-General_Concept
neighbor	I-General_Concept
symbols	O
,	O
then	O
one	O
gets	O
what	O
is	O
called	O
the	O
docstrum	O
for	O
the	O
document	O
(	O
See	O
figure	O
below	O
)	O
.	O
</s>
<s>
One	O
can	O
also	O
use	O
the	O
angle	O
Θ	O
from	O
the	O
horizontal	O
and	O
distance	O
D	O
between	O
two	O
nearest	B-General_Concept
neighbor	I-General_Concept
symbols	O
and	O
create	O
a	O
nearest-neighbor	O
angle	O
and	O
nearest-neighbor	O
distance	O
histogram	O
.	O
</s>
<s>
For	O
each	O
symbol	O
,	O
look	O
at	O
its	O
nearest	B-General_Concept
neighbors	I-General_Concept
and	O
flag	O
any	O
of	O
them	O
that	O
are	O
a	O
distance	O
away	O
which	O
is	O
within	O
some	O
tolerance	O
of	O
the	O
between-character	O
spacing	O
distance	O
or	O
between-word	O
spacing	O
distance	O
.	O
</s>
<s>
For	O
each	O
nearest	B-General_Concept
neighbor	I-General_Concept
symbol	O
which	O
is	O
flagged	O
,	O
draw	O
a	O
line	O
segment	O
connecting	O
their	O
centroids	O
.	O
</s>
<s>
Symbols	O
connected	O
to	O
their	O
neighbors	O
by	O
line	O
segments	O
form	O
text	B-Application
lines	O
.	O
</s>
<s>
Using	O
all	O
the	O
centroids	O
in	O
a	O
text	B-Application
line	O
,	O
one	O
can	O
compute	O
an	O
actual	O
line	O
segment	O
representing	O
the	O
text	B-Application
line	O
with	O
linear	O
regression	O
.	O
</s>
<s>
This	O
is	O
important	O
because	O
it	O
is	O
unlikely	O
that	O
all	O
the	O
centroids	O
of	O
symbols	O
in	O
a	O
text	B-Application
line	O
are	O
actually	O
collinear	O
.	O
</s>
<s>
For	O
each	O
pair	O
of	O
text	B-Application
lines	O
,	O
one	O
can	O
compute	O
a	O
minimum	O
distance	O
between	O
their	O
corresponding	O
line	O
segments	O
.	O
</s>
<s>
If	O
this	O
distance	O
is	O
within	O
some	O
tolerance	O
of	O
the	O
between-line	O
spacing	O
calculated	O
in	O
step	O
7	O
,	O
then	O
the	O
two	O
text	B-Application
lines	O
are	O
grouped	O
into	O
the	O
same	O
text	B-Application
block	O
.	O
</s>
<s>
Finally	O
,	O
one	O
can	O
calculate	O
a	O
bounding	O
box	O
for	O
each	O
text	B-Application
block	O
,	O
and	O
the	O
document	B-Algorithm
layout	I-Algorithm
analysis	I-Algorithm
is	O
complete	O
.	O
</s>
<s>
OCRopus	B-Language
–	O
A	O
free	O
document	B-Algorithm
layout	I-Algorithm
analysis	I-Algorithm
and	O
OCR	B-Application
system	O
,	O
implemented	O
in	O
C++	O
and	O
Python	O
and	O
for	O
FreeBSD	O
,	O
Linux	O
,	O
and	O
Mac	O
OS	O
X	O
.	O
</s>
<s>
This	O
software	O
supports	O
a	O
plug-in	O
architecture	O
which	O
allows	O
the	O
user	O
to	O
select	O
from	O
a	O
variety	O
of	O
different	O
document	B-Algorithm
layout	I-Algorithm
analysis	I-Algorithm
and	O
OCR	B-Application
algorithms	O
.	O
</s>
<s>
OCRFeeder	B-Language
–	O
An	O
OCR	B-Application
suite	O
for	O
Linux	O
,	O
written	O
in	O
python	O
,	O
which	O
also	O
supports	O
document	B-Algorithm
layout	I-Algorithm
analysis	I-Algorithm
.	O
</s>
