Professional Documents
Culture Documents
Thesis/Dissertation Collections
2004
This Thesis is brought to you for free and open access by the Thesis/Dissertation Collections at RIT Scholar Works. It has been accepted for inclusion
in Theses by an authorized administrator of RIT Scholar Works. For more information, please contact ritscholarworks@rit.edu.
Computer Engineering
Nicholas P. Sardino
Primary Advisor:
Kenneth Hsu
Dr. Kenneth W. Hsu, Professor, Dept. of Computer Engineering
Committee Member:
Andreas Savakis
Dr. Andreas Savakis, Dept. Head, Dept. of Computer Engineering
Committee Member:
Roy S. Czernikowski
Dr. Roy S. Czernikowski, Professor, Dept. of Computer Engineering
April, 2004
I, Nicholas P. Sardino, hereby grant pennission to the Wallace Library of the Rochester
Institute of Technology to reproduce my thesis in whole or in part, on or after April 19,
2004. Any reproduction will not be for commercial use or profit.
Nicholas Sardina
Nicholas P. Sardino
Date
Abstract:
As the
algorithms used
in these
In
keep
up
the speed at
with
implementation
This thesis
binarization
while
adapt
was utilized
modeled
FPGA
to
High-level
programming
an
implementations
where
be
increasingly
our
of
the
need
for
software
important issue in
technological society
and
examined.
and
is
throughout the
methods
does the
algorithm
their
an
the goals of
system
properties of
course of
and
operation was
were
simulation
used
the
of
four image
thresholding
a simple global
to the luminescent
the image.
research.
simulated
in both the
A high-level
Each
in VHDL,
tested using a
custom
modeling
algorithm,
algorithm
and
then
PC interface.
and
VHDL
of the algorithms.
on
development board.
synthesize
realize
in MATLAB, implemented
synthesized
The
which
The first
first
to
design philosophy
was
order
so
grow,
The implementation
algorithms.
continues to
power microchips.
systems
computing
to
an
thresholding
loop
global
commands
which
thresholding, running
were
utilized
average
in the
thresholding,
with
7.12%, 89.76%
global
thresholding
thresholding
MHz.
and
58.52%
utilization of
algorithm
achieved
achieved
17.6 MHz,
and quick
clock
frequency
thresholding
of
respectively.
62.1
obtained a
MHz,
frequency
The
running
of
21.4
Table
of
Table
Contents
of
Contents
List
of
Figures
in
List
of
Tables
iv
List
of
Equations
Acknowledgements
vi
Glossary
vii
Chapter 1 : Introduction
1.1 Purpose
1.2 Design
of HDL
Image
Processing Research
Philosophy
.5
Chapter 2: Algorithm
Thresholding
Theory
2.1 Image
2.2 Adaptive
Chapter 3: Algorithm
Modeling
10
16
16
17
17
20
27
32
3.1 Global
32
3.2 Local
33
Thresholding
Thresholding
3.3 Running Average Thresholding
3.4 Quick Adaptive Thresholding
Chapter 4: VHDL Implementation
37
39
42
4.1 Global
45
4.2 Local
45
4.3
46
4.4
Thresholding
Thresholding
Running Average Thresholding
Quick Adaptive Thresholding
47
48
48
5.2 Global
51
Thresholding
5.3 Local Thresholding
5.4 Running Average Thresholding
5.5 Quick Adaptive Thresholding
Chapter 6: Results
and
Analysis
51
53
53
54
54
6.3 Analysis
56
55
"
References
11
List of Figures
Figure 1.1
Figure 1.2
Figure 1
Design
Philosophy
Histogram-Based
12
Global
Thresholding Example
Thresholding Example
Local Thresholding Example (Equations)
Horizontal Running Average
Running Averages (Combination)
16
Local
18
.3
Figure 2.1
Figure 2.2
Figure 2.3
Figure 2.4
Figure 2.5
Figure 2.6
Figure 2.7
Thresholding Example
Vertical
19
20
21
Running Averages
Running Average Thresholding Example 1
Figure 2.8 Running Average Thresholding Example 1 (Equations)
Figure 2.9 Running Average Thresholding Example 2
Figure 2.10 Running Average Thresholding Example 2 (Equations)
Figure 2.11 Quick Adaptive Thresholding (Left to Right Scheme)
Figure 2.12 Quick Adaptive Thresholding (Right to Left Scheme)
Figure 2.13 Quick Adaptive Thresholding (Alternating Scheme)
Figure 2.14 Quick Thresholding Example
Figure 2.15 Quick Thresholding Example (Equations)
21
Figure 3.1
Local
34
Local
35
23
24
25
26
27
28
28
30
31
Figure 3.2
Figure 3.3
Figure 3.4
Figure 3.5
Figure 4.1
43
Figure 5.1
50
36
39
40
List
of
Tables
44
Table 6.2
Algorithm Runtime
55
(MATLAB)
56
Synthesis Results
IV
List of Equations
Equation 1.1
Equation 1
.2
Iterative
12
Entropic
13
Thresholding Equations
Thresholding Equations
Field Matching Thresholding Equations
Equation 1.3
-Edge
Equation 1.4
-Niblack's
Equation 1.5
Equation 2.1
Equation 2.2
Equation 2.3
Equation 2.4
Equation 2.5
Equation 2.6
Equation 2.7
Equation 2.8
Equation 2.9
Equation 4.1
Equation 4.2
Equation 4.3
Sauvola
and
Possible Local
Thresholding Equations
Running Average Thresholding (Horizontal Average)
Running Average Thresholding (Horizontal Weighting Function)
Running Average Thresholding (Vertical Average)
Running Average Thresholding (Vertical Weighting Function)
Running Average Thresholding (Final Determination)
Quick Adaptive Thresholding (Determination of 's')
Quick Adaptive Thresholding (Weighted Average)
Quick Adaptive Thresholding (Threshold Calculation)
Global
13
14
14
17
20
20
21
22
22
28
29
29
45
46
47
ACKNOWLEDGEMENTS
The
author wishes
and
Dr.
to thank
his
committee
Hsu, Dr.
Andreas
Savakis,
equipment when
it
was needed.
VI
support
special
for FPGA
synthesis.
Glossary
describe
and
Language) [1]
the
model
Programming
discrete
of
operation
one
VHDL
[1]
The
Verilog [1]
example of a
MATLAB
[2]
Array) [1]
Assistant) [1]
In this project, it
implementation in VHDL.
one
Global
bit (black
[7]
Adaptive
used as
and can
Small,
be
used
used
mobile
of
was used
converting
research.
circuit
in the design
that can
be
of custom chips.
provides
to
model
the
algorithms
each pixel of an
Term
used
methods
Local
Thresholding [8]
lighting
in this
perform
before their
image from
n-bits
to
or white).
Thresholding [7]
is
Process
designed to
and vectors.
Image Binarization
circuit
An integrated
components.
manufacturing
information
personal
to
efficiendy.
hardware
used
and structural.
Custom
specific
Another
Circuit) [1]
language that is
white.
to describe any
a given pixel
of
is determined
dynamically by the
vn
each pixel
is
Chapter 1: Introduction
1.1 Purpose
Mobile
of
HDL Image
computing is
multimedia
higher performance,
no
longer
suitable
the-fly image
examined so
Since
are
can
that
be
flexible
and
for
lower
technology
the
rise
and as a
result, so is the
Standard
such as
demands
considered as
and
on
power microprocessors.
real-time
manipulation.
designing
Verilog
Processing Research
the
valid,
of
of
day
modern
for smaller,
streaming
these
video and
on-
algorithms must
be
and
Implementation
cost-effective approaches.
performance
need
or
strategies
of
current
microprocessors.
and video
chips
may be
specific
role
in the future
1.2 Design
and
Regardless
algorithms will
digital cameras,
to their target
of how
as well as
application or
they
are
home
may be
used, FPGAs
personal computers.
reprogrammable
will
play
to have
very important
Philosophy
simply
processing
means
the
course of
used
this
project.
This
modeling
design
VHDL implementation.
and the
shows
process.
K
MATLAB
High-Level
VHDL
Figure 1.1
Initially,
Design
Philosophy
of
understanding
theory behind
the
algorithms
The
next
machine.
A testbench
supply the
required
target
see
code.
FPGA,
was
and
This
and
was
also
done to
to
gain a
establish
better
baseline
VHDL implementations.
was
step
FPGA
Synthesis
to
overall
was created
data in the
for
each algorithm
to
gather
in
simple state
and
correct order.
synthesize
verify the
results
made use of
the
through the
available
use of a
hardware
PC interface. The
and
how the
goals were
to
algorithms performed
overall.
The
and
clarity
of
mainly in
Two
a qualitative
fashion, looking
at
the quality
however
which
indication
provide a good
algorithms.
These two
and maximum
of
how the
synthesis
operating
FPGA logic
elements
There
boards in
existence
today,
in
so
each with
It is
their
a good
used
in this
needed
for the
FPGA,
Figure 1.2.
software,
scope of
ease of
and
research
can
is
FPGAs
which
vary tremendously
chosen selectively.
by
which
Altera Corporation
was chosen
picture of the
and
is
called
This board
be
made
This kit,
documentation,
the project.
of
development
and
itself, bundled
lines
own
implementation details
size
logic devices
functionality
development board
than
was
fairly large
can
be
seen
in
Figure 1.2
inputs. A C
the FPGA.
five
volt
could
be
sent
using
directly
standard
to
TTL level
order
to verify
of reconfigurable
academic
by decreasing
and
cost
commercial
implementations for
recent
trends in
more research
arenas,
was
computing
technology
in this
specifically
born
area
increasing
has taken
dealing
hardware.
with
with
performance
place
in both the
high-performance
Research
two
and
development in this
directions
structural
high-level
software
researchers
synthesize
projects
study existing
directly
to
compilers
do the
Gokhale,
oriented
or
in
one of
low-level
and
and
synthesis
Others
and
on
develop
protocols.
applications written
effectiveness of
behavioral
code.
own
efforts on
and
designing
programming languages
called
Using
(RTL)
contrast
the
the Streams-C
Evaluation of the
Streams-C,
the
and
which
plus
Streams-C
structural
and
their
is
small
group
which uses
performance
compiler
of
the
All
subset
libraries
of
and
same algorithms
using
implementations
methods
in synthesizing parallel,
of
four
different
work
synthesize
they
compiler,
VHDL.
Their
synthesizable
Register-Transfer-Level
compare
focus their
synthesized
Dominique Lavenier
existing language
communication
Some
in
same.
to
be
based designs,
compiler
themselves
manifest
hardware,
compiler algorithms to
involves
and
space tends to
designs.
High-level design
Maya
design
particular
to
pipelined
are
goal
gauge
is
the
designs from
Malay Haldar,
entitled
Compilers, Architectures,
[REF 3].
Their
MATLAB
code
work
and
commercial synthesis
through their
use
is
and
on a
VHDL through
of
compiler
by
to
take
algorithm
The
generated
2000
pipelining.
then compiler,
To test the
into
compiler
effectiveness
implemented in three
each
VHDL,
the
second
passed
structural
and
on
of
passed
loop
Image
on
Programming
presented
a paper
compiler algorithm
and
Pedro Diniz
and
of
describing parallelizing
is to integrate high-level
optimized
Language Design
Implementation in June
the
University
of
Southern
of
which
on
in FPGA-Based Systems,
goal
presented a paper
VHDL.
structural
Their
Prith Banerjee
VHDL
At the Conference
California
at
create
they
methods.
un-optimized
and
optimize the
their compiler,
different
is
and
Processing
of
Choudhary,
developers
compilers with
a method
of
compiler
existing behavioral
to take C
todays technology.
pipelined
programs
This
synthesis
directly
to
tools to
hardware
code.
They
compare
the performance of the same compiler algorithm with different levels of parallelization on
In June
of
Southern
algorithms.
California,
Their
different
work
and
began
with
at
the
40th
Pedro Diniz,
of
the
Stanford SUIF
of an
VHDL is
with
VHDL
standard
four
and
on
presented a compiler
FPGAs
with
Power
and
Compilers, Architecture,
[REF 6].
Their
Their
delivers high
consumption.
paper
in their
paper
Using five
HDL
and compiles
behavioral VHDL.
simulated
in
it
This
software
Alok
Choudhary,
at
and
to
synthesized
designs
processing
optimized
designs
flexible C to HDL
which
Prith
Targeting ASICs
signal
takes a
compiler
Performance Optimizations
and
and
performance
consumption of PACT
compiler
showing how
communication methods.
compiler
of
the adaptation
C implementation
University
standard sequential
the
again with
focus
on
benchmarks, they
against unoptimized
of
2002
compiler which
minimizing
compare
designs.
power
the power
Computer
Science
students
October
1998
of
the
at
faculty
and
at
of various
Workshop
on
Reconfigurable
the
it
In
Computing
implementation
more
July
widely
of
of
They had
developed
generate
VHDL
at
and
in
goal
In
years.
in Paris,
Processing
is to
Applications
develop
reconfigurable
on
tools to aid in
computers, making
they
again presented
their
called
SA-C
to
hardware.
In
reconfigurable
Workshop
with a compiler
on
the
Colorado State
University have
done
much more
Their
most
recent
FPGAs"
on
faculty
the
papers,
that time.
students and
and students at
published more
Applications
and
Machine Perception
since
algorithms
few
Computing (PACT'98)
Image
past
was presented at
faculty
for the
R. Beveridge
of
have been
University
accessible.
Systems, Architectures,
The
Machines"
of
and
Prograrnming
image processing
September
High-Level
State
algorithms
Reconfigurable
Colorado
and
was
publication
presented
is
entitled
in August
of
research,
institutions
"Implementing
2002
at
the
Image
International
Conference
on
information
on
the
Cameron Project,
synthesizing
structural
figure
performance and
February
University,
VHDL.
They
out ways
Marc Trepanier
breaking
them
They
up.
complex
hardware
take these
structural
algorithms, ultimately
performance
to
software
of
and
building
detailed
more
http://www.cs.colostate.edu/cameron/
In
visit
For
[REF 10].
City
of
Miram Leeser,
Mercury
Computer
and
Eric Miller
Systems, Inc.
of
Northeastern
presented a paper at
entitled
Parallel-Beam
application of reconfigurable
research
which
used
is
in the
very
the
a software
Jorg
and
imaging field.
parallelized
performance of
of
and
The
presented
parallel-beam
reconstruction
algorithm
parallelized
of
their paper
[REF 11].
backprojection
from dense
hardware
performance.
Their
algorithm
projection
data
structural
against non-parallel
hardware
and
Martin-Luther-University
entitled
imaging
medical
the
Paul Molitor
the
for image
Ritter
Germany
common method
medical
components
compare
computing to
marked
Halle-
Wittenberg
in
Halle,
Based
for
of
February
hardware implementation
at
Their
research
et alii presented
implementation
of
2002
at
on a custom
and synthesized
Processing Applications
International
the
of
in
paper
reconfigurable
July 10,
describes his
FPGA
2000
the Brno
work
co-processor
press release
reconfigurable signal
in taking
great
success
ASIC
and
Graphics
complex
success
story
Processing
processing boards.
10
and
Interactive
presented
a paper
a general purpose
in the
involves
process.
Technology
of
research
chip.
Computer
on
for performing
details the
0.5um CMOS
University
Reconfigurable Image
Conference
14]. His
of
the HiPAR-DSP
the
Wittenburg,
In
with
the
deals
DSP
and
pairing it
[REF
with a
of
VisiCom
Module"
commercial
"VisiCom Uses
[REF 15].
arena
as
well
Annapolis
with
their
of
recent
survey
Electronic
of
Thresholding
thresholding
Imaging
entitled
Survey
into
six
distinct
categories
Over Image
This
paper categorizes
Histogram-Based thresholding
and
Local
algorithms work
methods
by
by
In the
identified
sample
Techniques
thresholding
using concavity
points
to
shape of
one example of a
choose
potential
threshold
3f
Histogram-Based
11
Thresholding Example
the image's
histogram-based
Figure 1.3
Entropy-
[REF 23].
analyzing the
and
algorithms
image.
Thresholding
in the Journal
a particular
values
are
Clustering-Based thresholding
particular clusters
determined
example of a clustering-based
developed
model.
the
an
For
iterative thresholding
foreground
and
assigning
by fitting Gaussians
thresholding
a given number of
by
methods work
algorithm
iterations,
background
method
class
a new
means
be
used
Top,
pixel
to one of two
One
based
on a
two-class Gaussian
threshold is determined
until
as
the
mixture
average of
equations can
each
small
new
following
lun
mf(T)
mb(T)
where
mf(Tn)
T!g=oSP^)
Equation 1.1
Entropy-Based
methods use
and
Iterative
the entropy
of
mb(T)
Thresholding
background
and
the sum
the two
of
as
distinct signals,
Equations
equations
12
of
gray levels in
Entropic thresholding
of which
Y?g=Tm^gp{g)
the distribution
the threshold is
image to
analyzes
determined
J. N. Kapur, P. K. Sahoo,
[REF 23].
an
and
the
when
A. K. C.
Top,=argmax[Hf(T) + Hb(T)
where
Hf(T)
j
*'g=o
P(T)
Equation 1.2
Entropic
version of
field
created
the
field images
*-ig=T+\ pff\
image
and
An
from the
global
i^log^
p(T)
Thresholding Equations
is
an edge
Hb(T)
and
prp\
original
edge
image is
being
compared
an
compared
between
value
to
that
an edge
maximizes
concept can
where
the overlap of
be described
by
following equation.
Top,
arg mmiEgray
PI Ebmary (T)]
where
Egray
Ebmary
edSe
=
edge
Equation 13
Spatial thresholding
neighboring
pixels
recognizes the
order
entropies
field from
field from
Edge Field
methods
original grayscale
use
both
due to
spatial
binary image
the
to determine a threshold
image
could
structure.
gray
value
value
distribution
and properties
with
different
13
of
n*
by
considering the
adaptive
detennined
method of
thresholding
per pixel
is the
Niblack'
based
deviation
each
horizontal
pixel's
vertical
and
on
number of
any
W. Niblack
and
statistics
[REF 23].
following
equation
window and a
A. K. Jain
is the
show
bxb,
The
by the
around
is
simplest
local
mean
the pixel of
standard
that using b
deviation.
15
and
Using
=
-0.2
results.
Equation 1.4
and
the
in the
T(i, j)
J. Sauvola
local
uses
mean of pixels
satisfactory
for
calculated
method, O. D. Trier
produces
of
and standard
where m
probability
[REF 23].
neighbors
Locally
co-occurance
M. Pietaksinen's
0.5
T(i,j)
Equation 1.5
km(i, j) +
a(i, j)
method
and
and
upon
Niblack's
method
m(i,j)
Sauvola
improves
\l + k
vQJ)
14
by
using the
The three
adaptive
adaptive
category.
thresholding
algorithms studied
These types
hardware implementations
where
of algorithms
data is
streamed
15
in
locally
and out.
2.1 Image
The
is
Thresholding
purpose of
greater
whose
thresholding is
intensity
being black
used
and one
to binarize
being
Standard thresholding
interest is less than
this
greater
method can
image that
can
be
an
white.
image
The
that
the global
threshold, the
be
below
where
to be
intensity
the
be to
for the
is
new pixel
is
entire
set
Figure 2.1
Global
16
zero
size of the
image. If the
white.
threshold
Example
one,
machines.
An
105
Thresholding
the
to
Global Thresholding
zero or
If
eight-bit grayscale.
Threshold
to
pixels
Typically
to black.
set
specified global
level.
reduce
copy
intensity
setting the
while
new pixel
threshold, the
machines and
threshold value
global
assumed
another
is to
fax
than the
seen
setting
applications such as
uses a global
by
intensity level,
is beneficial in
and
interest is
to segment an image
thresholding is
image
A Global Scheme
pixel of
the pixel of
example of
is 105 for
test
2.2 Adaptive
Thresholding
dynamically
changed as
images
dramatic
with
were chosen
this
for this
project was
pixels
in
for
lighting
changes
in
embedded real-time
than
thresholding in
standard
applications,
image,
read an entire
image. The
2.2.1 Local
Thresholding
great
that the
possible
adaptive
to
process
it,
and
might
be
used
the
methods
detail below.
then
is
accommodate
thresholding
that
produce
of
stream
the
new
requirements.
threshold
center.
One
of the
on a window of
following methods
mean
median
-or
max+min
2
Equation 2.1
In
order
large.
to get a
valid
has
Possible Local
Thresholding Equations
In contrast, choosing
each region
uniform
a region
intensity
17
following
against
be
fairly
of
3x3
original
and
image is
determining
an eight-bit grayscale
image.
Local Thresholding
Window Size
Figure 2.2
Local
3x3
Thresholding Example
18
D.
100 + 110 + 80 + 85
..
Pixel #1
P/*g/#2:100
..,
Pixel #3
110 + 140 + 80 + 85 +
139=109
r
=
100 + 110 + 80 + 85 + 75 + 78
:
110 + 140 + 80 + 85
88
139 + 75 + 78 + 139
1/iri1
=
Etc.
Figure 2.3
126.5
00
=
,^100
Pixel #6
93.75
1Jic
Pixel #5
Mne
=
Local
19
1 05. 1 1
2.2.2
In the running
stream changes.
calculated
arbitrary
by
average
the
following difference
given an
image,
pixel,
the data
(i,j),
myimage.
can
be
is
an
that
size:
7(/)
Equation 2.2
Y(i
1) + f[my image(i, j)
The function
{[delta]
is
f[my
Horizontal
1)]
Running Average
weighting function
in
a scan
image (i,j)
f[x]
Equation 23
y(i
successive points
weighting function
Figure 2.4
between
equation,
a given
as
Running
which
1)]
be
given
0.2x[my_ image(i, j)
Average
For the
-y(i
Thresholding
20
returns
the change
sake of
in
by:
y(i
(Horizontal
average
1)]
Weighting Function)
The
actual
running
threshold
is determined bv
of
vertical
averages.
Figure 2.5
The
a combination
vertical
running average,
Z(j), is
ZU)
Equation 2.4
calculated
similarly
Z(j-l) + g[Y(i)-ZU-l)]
Running
Figure 2.6
Average
Thresholding
Vertical
21
(Vertical
Running Averages
Average)
Z(j
1)] is
a special
Equation 2.5
If
following
did
be
not
not
purposes, a
j)
<
functions,
[REF 17]:
else
WHITE
have
o.2x[r(o|y.-z(j-i)]
weighting
my_image(i
Equation 2.6
does
which can
and
f[delta]
by:
gM
The
this
algorithm produces a
algorithm produces
enough contrast
second example
completely
the
white
first
22
binary
sample
image.
to clearly define
is
image. For
image
the
This
image
result
input image
For illustrative
with
both black
Figure 2.7
23
Y(0)
Z(0)
.'.
7(2)
Z(0)
Z(l)
.-.
102
-+
102
20.4
0.2(1 40 -102)
WHITE
0 + 0.2(109.6-0)
Pixel #3
20
#7#r
0 + 0.2(102-0)
Pixel #2
7(0)
->
100 + 0.2(110-100)
Z(0)
.-.
0 + 0.2(100-0)
Pixel #1
F(l)
.'.
109.6
21.92
WHITE
80 (y?r^ pixel)
20 + 0.2(80-20)
Pzxe/ #5
32
FF///TE
Etc.
Figure 2.8
24
(Equations)
Running
Figure 2.9
Average Thresholding
25
7(0)
Z(0)
.-.
0 + 0.2(232-0)
Pixel #1
7(1)
Z(0)
.-.
Z(0)
Z(\)
0.2(230
232)
0.2(23 1.6-0)
->
23 1
.6
->
23 1
.6
46.32
WHITE
0.2(224
0 + 0.2(230.08
Pixel #3
7(0)
.-.
Pixel #2
7(2)
/.
46.4
FFH77E
->
232
23 1 .6)
0)
230.08
46.016
WHITE
Pixel #5
->>
0.2(230
46.4)
83.12
0H77E
Etc.
Figure 2.10
26
Quick
adaptive
Thresholding
thresholding is
weighted average
one pass
through the
is
[REF 18].
not confined
strikingly different
its
algorithm
quickness and
is
or
of
calculated
the average
very basic
to one specific
on
row or
the way in
low memory
constraints.
's'
pixels
the running
column, but
which
the
seen,
which requires
out
Quick Adaptive
Thresholding
27
only
because
average algorithm
that
(Left to Right
left to
results.
Figure 2.11
Scheme)
Figure 2.12
Figure 2.13
It
was
best
Quick Adaptive
Quick Adaptive
results.
Therefore,
's'
research
of
the
width of
is determined by:
Equation 2.7
Number of Columns
Quick Adaptive
Thresholding (Determination
28
of s')
The
average
specifically
is
weighted
by
the pixel of
interest. The
following
formula is
's'
last
used
pixels,
to
calculate
G(s + l)
G(s)-
G(s)
V
Equation 2.8
The
actual
given
by
Quick Adaptive
threshold is computed
as a percentage of the
an absolute percentage of
threshold for
The
the average.
following
formula is
should
used
percentage
be,
rather
is
than
to calculate the
each pixel:
T(n)
Equation 2.9
The
following
100
G(s)-
Quick Adaptive
example uses
32,
making
29
4,
and
and
image.
assume
that t
15.
that the
right to left.
Also
assume
Figure 2.14
30
>JUU
I
G(s)
r()
100
0-- +
25
25
()
21.25
,100,
.'.
Pixe/ #1
G(s)
T(n)
J*7//r
->
25-
46.25
4
^85^
46.25
39.3125
vlOOy
Pzxe/ #2
G(,)
T(n)
^/Y/r
46.25-^^ +
69.68
85
69.68
^
=
59.23
vlOOy
.".
P/xe/ #3
->
^/7/7/
G(,)
88.51-== +
T(n)
100.49-
.-.
-+
101.383
85 ^
=
Uoo,
Pixe/ #5
86.1751
JPH77E
Etc.
Figure 2.15
Quick
31
feasibility
to assess the
useless as a
so.
in this case,
of
It
them in
implementing
would
step in this
filled sequentially to
cycle
implementing
native
whole
method would
image
have been
'imwriteO'
'imreadO'
were used
and
specified.
Thresholding
The modeling
previous pixel
state
in the
functions
3.1 Global
simple to read
known. This
insight
process though.
simulate
hardware
of
the global
information is
information
must
be
thresholding
required
stored
The MATLAB
code
"myGlobal.m"
and can
for the
be
seen
to
algorithm
compute
to compute the
or white
global
based
the
on
the
32
given global
algorithm
on page
A-l.
is
For
trivial,
as
no
In addition,
no
was
thresholding
in Appendix A
in MATLAB
each pixel
coming
threshold
contained
in the file
3.2 Local
Thresholding
Two different
versions of the
fixed
version used a
understanding
much more
of
how the
flexible
implementation.
local thresholding
window
implementation
It does
size
version
be
window
As
stated
algorithm.
(window
The
size +
pixel of
specified, the
before,
size
of
have been
read.
be in the
in the
code
On
for
of
the
to verify the
3x3.
variable
with
Since the
version,
all
used
was
that, if
-I)
>r
to hold pixels as
they
33
is
can
an even
entered
actually
Window Size
,-,-,,
Number of Columns
To
was used.
once
case
better
used
a window size of
using
gain a
designed to be
the goal
specific
must
temporary buffer
done to
purposes.
interest
Window Size
processed
and was
for illustrative
used
for this,
is simply
with respect
explanations will
3x3
The
algorithm worked.
fixed
algorithm were
read
into
equal
start
the
to
being
1
pixels
the
buffer
at
following
while
The
example.
is
window
red pixel
a window size of
3x3
and
is the
being
begins
This
analyzed.
at
pixel of
can
best be illustrated
interest
the time
at
the
the window,
center of
source.
through the
The
example assumes
have been
read
to begin
processing.
Row 1
<
Row 1
Legend
Row 2
Pixel
Row 3
Interest
of
Row?
Window
Area
Row 1
Row 2
i
w m m m m
Row 3
Row?
RowX
Row
Pixel
Row 1
Being
Being
Row 2
Row 3
Row?
Figure 3.1
Local
Thresholding
34
1)
Filled
Filled
Row 2
Row 3
Row 1
Row 5
Row 2
Row 2
'
Row 3
Row 4
Row 3
Row 4
Row 5
^Row
Row 3
Row 4
Figure 3.2
The
interesting thing
begins to be
read
in.
Local
to note
from the
Since the
above
algorithm
illustration is
(Rows 2 &
what
happens
35
3)
row
when row
one, the
five
values
contained there
dimensional
begin to be
overwritten
matrix minimizes
by
the amount
Row 4
This
circular 2-
the algorithm.
Row 5
Row 5
Row 2
Row3
V
Row 4
Row 3
Row 4
UJ
Row 5
Row 5
Row 2
Row 3
Row 6 j
Row 3
Row 4
Row 4
Row 5
Row 6
Row 3
Row 4
Figure 3.3
The
above
illustration
back to the
Local
shows
beginning
implementation detail
as
Thresholding
how the
processing
calculating the
continues.
from the
end of
window extremities
36
5)
for
each pixel.
next
the buffer
important
The
x coordinates
coordinate
is the
the
bounds
rows
is
(window
of the
used
image,
size +
then
1)
row
horizontal
(window
/ 2. If the
1 is
used
size
row
1) / 2
calculated
easy to
limits
The
calculate.
the end
while
depending
coordinate,
are
coordinate
of the window
the
x coordinate or
lie
start
is the
outside
number of
image is
being
much
more
analyzed.
The y
coordinates
They
complicated.
incremented
and
vertical
An
decremented.
The MATLAB
in the files
A-2 & A-5
3.3
be
Again,
adjusted
image is known in
addition
code
within
must
image.
position
if the
be
be both
in the
the
local thresholding
and can
and
at
top
or
buffer.
"myLocalX.m"
"myLocal3.m"
by
can
of the
versions of the
interest is
that
bottom
pixel of
counters
are
be
seen
algorithm
is
contained
in Appendix A
on pages
respectively.
The running
average algorithm
they
are
is
similar
input. Storage
however to
track of the running averages for each row and column, which ultimately
37
keep
determine the
The
buffer
size of the
required to
Since
is
used
average
of
pixels, the
the results
in the buffer is
this
used
is 2
algorithm
the
number of columns
while
the
no previous
horizontal
row
implement
information is
is
first
set equal
row are
the successive
quickly become
a more
to that pixel
running
rows, but
value.
slightly biased
previous vertical
for
available upon
by
The horizontal
this assumption.
average was
as more
taken as
the
first
calculated
for
the rest of
averages
For
zero.
the entire
This slightly
accurate representation of
image's light
the
first
row
affects
averages
intensity
at that
The weighting
equal
functions, f(
to 0.02 x (Current
coding
and
g( y
),
were
Previous Average).
Although
in itself,
The MATLAB
file
which was
code
beyond the
"myRunningAvg.m"
and can
be
Using
as simple
could
linear function
a more complex
taken
function
have been
might
simplified
have
the
produced
average
seen
thresholding
in Appendix A
38
algorithm
on page
A-9.
is
contained
in the
Thresholding
As
2.2.3, choosing
stated
in
section
since
it had been
used to
important
determine
the
in the quality
role
best results,
of
that the
thresholding
the output.
alternating
It
algorithm
was
decided,
scheme would
be
'
'p=x=
Figure 3.4
In
order
order
to
process
alternation.
information
is
the
storage rows
connectivity
this
Thresholding
Processing
end.
Quick
information is 2
the two
number of columns
in
occurs
the
row
available at
were
1, last
needs
size of
pixel, to
the buffer
in the image. To
implemented
repeatedly from
exists as row
One
buffer
The
start
row
to
to store this
as one continuous
end of
2, last
make
required
the buffer
pixel, effectively
row, laid
end
to
implementing
the
the time it is
needed.
accomplished.
39
shows
how
Sample Image
1
Legend
>^ ^<
| 10 ]
11
13
14
15
16
17
19
; 20
21
i 22 ! 23 | 24
25
26
27
| 28 i 29 ; 30
31
! 32
33
34
12
18
^yp
-~-
13
13
14
'
'
>
-^
-~
4^4%
^Br^3
12
12
r^M
14
15
16
14
15
16
-"
| 12
^J
Pixel
Being
14
'
Interest
Filled
15
16
15
I 16
17
I 18 I 12 I 11 T 10
Y 17 Y 18 Y 12 Y
14
mum
14
15
14
15
16
^J
14
15
16
17
^^
15
16
17
13
11
Y 10
ie
o
|n
17
m>M
22
10
11
11
10
And
^^M
24
Quick
40
4Bp
19
19
21
: 21
20
22
so on...
12
Figure 3.5
25
18
::
r~-
r~*
-~
e
6
11I10I9I8T7
^M
o
of
"
fj
'
10
Pixel
| 35 | 36
M3!4!5!9!'!'!'!'!'
'
;:,;;;:
The
weighted
MATLAB
the
average
is
calculated
implementation,
simply
as
described in
was
section
taken as a
2.2.3.
For the
parameter passed
into
function.
The MATLAB
code
for the
"myQuick.m"
and can
be
quick adaptive
seen
thresholding
in Appendix A
41
on page
algorithm
A-l 1
is
contained
in the file
state machines
functions
separate
using
of
parameters,
very well,
the
and
data
VHDL, it
was
decided to implement
VHDL
synthesis
tools handle
algorithm
processing
pixels.
width and
This fundamental
height,
reading
the
in
different
algorithm
all
VHDL
implementations.
The
state
based
on
algorithms are
the
essentially the
same with
thresholding
following page.
42
intermediate
to be read in. As
algorithm can
be
seen on
an
the
Note IS_DONE is
an
processing the
entire
DATA_VALID = '0
RESTTt^T
DATA_VALID =
RESEfb^'1
'0'
DATA_VALID
'0"
REST>?=T
Figure 4.1
43
internally
determines
image.
common
I/O interface
The details
mechanisms.
of the
Port
DATAJN
designed
was
I/O
can
be
Direction
[7:0]
be tested using
seen
similar
Description
INPUT
DATA_READY
INPUT
RESETL
INPUT
Asynchronous
CLOCK
INPUT
System
present at
DATAJN
clock
read
in
data is
valid
[7:0]
reset
device is driven
be in
by
an external
sync
with
the device
if
the
DATAOUT
OUTPUT
DATAJVALID
OUTPUT
DONE
OUTPUT
Asserted
Since
implementing floating
floating
point
point
be
read
the
the entire
by the
algorithm
has
finished
image
I/O List
divisions
on
information
when
processing
Table 4.1
data
were
in MATLAB.
Some
already
previously
in
operations
used
being applied.
For
each of the
number of
hardware,
four algorithms,
columns,
and
the
an
'end
nature of
is
pixel'
the
algorithm.
allowing the
discussed in
state machine
more specific
calculated
based
counter
on
is
the
number or
rows,
maintained within
signal
is
the
asserted
to exit the Process state and enter the Done state. This will be
detail in the
sections
44
below.
Testing
of
testbench reads in
text file.
new
can
value, image
be
the file
simple
including
image information to
VHDL I/O
operations.
be
designation,
the
ASCII text
seen
and can
in Appendix B
on page
maximum
values and
contained
B-l
in
Thresholding
global
Process
The
used
new
"thresholdingtestbench.vhd"
Since the
out.
.ppm
dimensions,
in using
read
4.1 Global
one
The
Image information
simplicity.
pixel
The
thresholding
When
state.
end pixel
is
algorithm requires no
being
calculated
simply
as
the
internal
read
in,
storage
being
by the
sent
number
of columns.
END
PLXEL
Equation 4.1
The VHDL
code
for the
Global
quick adaptive
"globalthreshold.vhd"
and can
4.2 Local
NUM
be
seen
ROWS NUM
Thresholding End
thresholding
in Appendix B
COLS
Pixel
algorithm
on page
is
B-21
contained
in
the
file
Thresholding
be
sent
to the
output.
As
45
be
states
read
in before
Process 1
and
Process2
are created
in the
in Process2 it is
while
account
END
PIXEL
((NUM
T.
equal to
for the
(NUM
The
DATAVALID is
be
ROWS NUM
EACH
EACH
calculated
equal
to
'0'
accordingly to
COLS) +
SIDE) + (NUM
where
Processl,
beginning.
COLS NUM
NUM
In
state machine.
SIDE
EACH
SIDE +
_
1))
WINDOW
SIZE
-I
2
Equation 4.2
Local
Thresholding
versions
is known
of the
"local_rhreshold_3.vhd"
so
it
4.3
window
local thresholding
is
algorithm
"local_threshold.vhd"
and
pages
End Pixel
and can
be
The VHDL
contained
seen
on
code
in the files
in Appendix B
on
respectively.
The ninning
average
algorithm
information is
required
exactly the
contained
page
same.
The VHDL
in the file
code
similar
for
the
to
global
thresholding in
equation
running
for calculating
average
"mnning_avg_threshold.vhd''
and can
B-46.
46
that no
is
algorithm
is
thresholding
be
seen
pixel
in Appendix B
on
The
quick adaptive
in before the
Thresholding
thresholding
pixels can
END
be
processed.
PIXEL
NUM
The VHDL
code
for the
ROWS NUM
Equation 43
Therefore, the
Quick
quick adaptive
"quickthreshold.vhd"
and can
be
seen
is
end pixel
COLS
has been
read
given as:
NUM
COLS
_
thresholding
in Appendix B
47
algorithm
on page
is
B-52.
contained
in the file
In
the transition
from VHDL
algorithms were
FPGA
being
be
could
could
be
being
physically
FPGA synthesis, it
from the
constructed
in the
standard
logic
processed.
processed
using the
result, limits
physical
and
consequently the
were placed on
the
discovered
was
thresholding
adaptive
rather
that
software simulation to
in
elements
the
number of storage
size of
size of the
the images
images that
hardware.
processing
It has
and
is
connectivity
moderately
fairly
of uses
This kit
kit containing
complete
required
algorithms.
in
was used as
was chosen
for
development board
hardware, development
inexpensive. Overall it is
undergraduate
the hardware
a number of reasons.
which
software,
FPGA,
flexible
on which
interfaces
and
full
directly
good
of
image
all, it is
to a
PC,
all
documentation.
(EP20K200EFC484),
run the
First
product
to
have
opportunity to
a wide range
evaluate
its
performance.
One
unknown at
had been
written
convenient
the
beginning
of
to the hardware.
the
project was
way to do this.
48
algorithms once
provided an
easy
they
and
all of the
I/O
pins of
the FPGA device. This made it possible to implement a TTL logic interface to the FPGA
which could
LEDs for
be driven
debugging
information to
schematic of
code
and
by
a simple
purposes,
from
the
and
program.
and
of
An interface board
program
30, C-37,
49
written
which
transferred
following
C-44.
was
seen
page
PC.
The
in Appendix C
on pages C-
$ I
D7
DataT71
D6
D4
D5
D3
$
D1
D2
do
<9>
Data|6]
<8>
Data[5]
<7>
Data[4]
<6>
Data|3)
<5>
Data:2;
<4>
Data[l]
<3>
Data{Ol
<2>
.
<?
<
DATA READY
<14>
/JesrapK
v:.
DATA VALID
'
<15>
'
R19
,
Status(5]
<12>
'
DONE
Status[3]
Status|6]
<10>
,
Figure 5.1
50
5.2 Global
Thresholding
The
thresholding
global
simulated
work on
VHDL.
algorithm was
Since
images up to the
be
seen
53 Local
synthesized
on page
of the
C-l
local thresholding
global
algorithm
It
reason
was created
for this is
to
apparent
separate
It
the
upper
thresholding
bound
of
algorithm can
cycle,
state,
or clock cycle
window
known
when
would also
51
3x3,
in this
In addition,
the RAM
stated
size
that the
was
largest
a state machine
calculation of the
case.
a write
be
before,
In the
of the algorithm.
accesses
RAM
Even
in the implementation. As
total memory
use of a
was also
written.
one
fixed
the greatest
not synthesize.
in
that
provided
threshold, for
same
by
the
could
in hardware
was clear
The
challenge throughout
shrunk
to the
Thresholding
The implementation
required
with no changes
an
in Appendix C
implemented in hardware
This
would
have
required
needed.
implementation
standard
to work.
this algorithm in
modules
There
provided
two ways
are
would
and output
be
timing
every
interface
a standard
The
second
If a faster
way
was used
would
be to
for
all
clock
Since only
and output
This
was
Units
of
data
further
VHDL
which
allowed
read
in
This
to implement
reads
to
would change
would
have had to
was not
this
really
Since
an option.
the FPGA
or
could
be
driving two
realized
distinct
a divide-
by implementing
clock signals
in
and synchronize
the
complicated
code
by
for specialty
is designed to
they
be
nine cycles
This
utilize
an
incomplete development
modules such as
could not
be
RAM
environment.
cells and
simulated
52
Since the
the development
project.
Altera
Arithmetic Logic
worked
input
provides
inside
have
have
counter
not
to the execution.
stages
algorithms, this
by-nine
which could
nine cycles.
every
could
created once
Altera
by
stages of the
As
result,
it
was
and
the I/O
local thresholding
5.4
interface
code.
The
be
seen
algorithm can
restructuring
of
both the
in Appendix C
on page
be
not
would
algorithm
for
the
C-6.
The
quick adaptive
thresholding
integer divide
implementing
situation.
seen
The
algorithm was
synthesized
The
thresholding
average algorithm.
were
quick
where
If
to 127
the divisor
is
a power of
module could
average
from
have been
thresholding
two,
taken in
used
in this
algorithm can
be
C-17.
Thresholding
divide functions
divider
standard
running
divisions
on page
quick adaptive
this algorithm, a
in Appendix C
implemented
algorithm underwent
The image
changed
size was
to divide
thresholding
by
same
basic
be
changes as
decreased to 127x127
a constant power of
algorithm can
53
the
seen
2.
in Appendix C
and
The
the
the integer
synthesized
on page
C-23.
images
from
were used
the
to test the
thresholding
be
seen
due to its
No
algorithms.
synthesize
in Appendix D. In
algorithm
output
end, 20
the
images
sample
were obtained
would not
complexity.
Some
nature.
cannot
analyzed
user
window
size,
thresholding
noise
project and
Given
can
be greatly
themselves
therefore no
situations.
fashion due to
about the
their subjective
algorithms
with
varying
is very
reduced
different input
images using
produce
clean
54
each
image
to
noise.
which
given
The
parameters
quick
output,
is
3x3
By increasing the
larger
for
susceptible
since
both
average
given
additional
a conservative set of
thresholding
be drawn
algorithm
algorithms against
a qualitative
in
the global scheme is the simplest and produces clean results, but
intelligent
requires an
be
Clearly
algorithms.
must
performance of
not
the focus
pixel
these
of
this
thresholding
and
running
quick
thresholding
average
in different
algorithm seems
to handle images
better,
while
cleaner output on
for
each
image
and the
corresponding
# Pixels
size of each
Time
following
(Seconds)
Running
Width
Height
Global
Local
01_test.j P9
02_test.j pg
03_test.j pg
04_test.j pg
05_test.j pg
06_test.j pg
07_test.j pg
08_test.j pg
09_test.j pg
10_test.j pg
11_test.j pg
12_test.j pg
13_test.j pg
14_test.j pg
15_test.j pg
16_test.j pg
17_test.j pg
18_test.jpg
400
525
20
304
70
172
400
518
14
309
69
171
400
518
16
339
73
177
400
530
18
324
68
183
400
526
18
311
72
184
400
547
20
312
75
191
400
550
20
367
75
206
400
529
18
285
76
162
400
529
18
283
69
167
400
533
17
283
70
153
400
523
19
282
68
157
400
518
15
289
62
170
400
533
19
286
66
174
400
533
19
292
68
171
400
245
138
30
76
400
536
18
298
71
175
540
540
17
449
90
239
540
540
18
427
98
249
rockefeller.jpg
960
1280
225
1482
451
941
yankees.jpg
1280
960
176
1490
441
932
following
synthesized algorithms.
no synthesis
data is
Again,
Algorithm Runtime
the local
55
Quick
(MATLAB)
FPGA logic
thresholding
available.
table
image.
Image
Table 6.1
The
The
utilization
for
each of
the
synthesize,
so
Algorithm
Utilization
Frequency
Global
62.1 MHz
Local
:-'
Quick
Average
Running
Table 6.2
M;-
(%)
7.12
:
;-/\r
21.4 MHz
58.52
17.6 MHz
89.76
Synthesis Results
6.3 Analysis
Each
continuous streams of
enough
data. Some
infinity however,
More
in this
read
of
to begin processing.
complex adaptive
thresholding
pass cases
since
the integer
number
slower clock
process an
is
nested
images
particular pixel.
of order
not considered
frequency,
temporarily
until
0(n),
in the
to
complete.
or scan pixel
data
even
in the
multiple
The
complexity.
of
more
and
therefore
will
take longer
overall
to
image.
with a
for loops
for any
because they
stored
be
pixels
cycle, resulting in a
As
the same
optimum threshold
algorithms,
completely
fixed
window size.
which worked
great
in
algorithm
would
The behavioral
simulation
56
but
have been
code
a pipelined
these
statements
on
the
frequently
FPGA,
Even though
were met
while
the
synthesize
making
to asynchronous
circuit
local thresholding
successfully.
logic
Three relatively
algorithms
design
all
both
the way to a
gained
qualitative and
along the
physical
process of
take up too
timing uncontrollable.
complex
and
VHDL,
quantitative,
image processing
57
algorithms
and
the trials
the
of
taking
project
it's
experience and
not
were
to hardware in
and
way.
project objectives
implementation. In this
getting there
synthesize, the
of
the three
result
knowledge that
that
was
References
[1]
Gerald Estrin
Transactions
[2]
et al.
on
Parallel processing in
Electronic
Computers,
pages
IEEE
Jan Frigo, Maya Gokhale, and Dominique Lavenier. Evaluation of the Streams-C
C-to-FPGA Compiler: An Applications Perspective. International Symposium on
Field Programmable Gate Arrays, November 2001
.
[3]
Malay Haldar,
Anshuman
and
[4]
Byoungro So, Mary W. Hall, and Pedro C. Diniz. A Compiler Approach to Fast
Conference on
Hardware Design Space Exploration in FPGA-based Systems.
Programming Language
[5]
Heidi E.
Design
and
and
Pedro C. Diniz.
Compiler-Generated
Conference,
June 2003.
Jones, Debabrata Bagchi, Satrajit Pal, Xiaoyong Tang, Alok Choudhary, and
Prith Banerjee. PACT HDL: A C Compiler Targeting ASICs and FPGAs with
Power and Performance Optimizations. International Conference on Compilers,
Architecture, and Synthesis for Embedded Systems, October 2002.
[6]
Alex
[7]
W.
[8]
Robert Rinker, Jeff Hammes, Walid A. Najjar, Wim Bohm, Bruce Draper.
Compiling Image Processing Applications to Reconfigurable Hardware. ASAP'OO
-
and
[9]
Processors.
Application-Specific
on
Systems, Architectures,
Bruce Draper, Walid Najjar, Wim Bohm, Jeff Hammes, Bob Rinker, Charlie Ross,
Monica Chawathe, Jose Bins.
Compiling and Optimizing Image Processing
IEEE International Workshop on Computer
Algorithms for FPGA 's. CAMP'OO
Architecture for Machine Performance. Padova, Italy. September 2000.
-
58
[10]
Bruce A. Draper, J. Ross Beveridge, A.P. Willem Bohm, Charles Ross, and Monica
Chawathe. Implementing Image Applications on FPGAs. International Conference
on Pattern Recognition. Quebec City. August, 2002.
[11]
February 2002.
[12] Jorg Ritter, and Paul Molitor. A Pipelined Architecture for Partitioned DWT Based
Lossy Image Compression Using FPGAs. International Symposium on Field
Programmable Gate Arrays, February 2001.
[13]
Jens Peter
[14]
[15]
Tamara Snowden.
Processing Module.
July
Reconfigurable Image
10, 2000.
Adaptive
[17]
[18]
EPC-1993-110,
[19]
[20]
Peter M. Athanas
the
DigitalDesk.
Technical Report
and
Processing
on a
Custom
1995.
Computing Platform.
February
R.
Hartenstein,
et al.
Video Compression.
and
[21]
Thresholding for
1993.
A. Benedetti
Computer.
and
In
and
1998.
59
[22]
[23]
T.
Darrell,
et
Integrated
al.
person
In
Recognition,
Proceedings:
B. Sankur, M. Sezgin.
tracking using
Conference
detection.
Survey
on
Over Image
60
stereo,
Computer
of
Vision
and
Pattern
Techniques
and
146-
Thresholding