Вы находитесь на странице: 1из 118

QUANTIFYING NOISE EFFECTS IN BILEVEL DOCUMENT IMAGES

by

Craig D. McGillivary

A thesis

submitted in partial fulfillment

of the requirements for the degree of

Master of Science in Electrical Engineering

Boise State University

October, 2007
© 2007
Craig D. McGillivary
ALL RIGHTS RESERVED
The thesis presented by Craig D. McGillivary entitled “Quantifying Noise Effects in
Bilevel Document Images” is hereby approved

Elisa H. Barney Smith Date


Advisor

Tim Andersen Date


Committee Member

Jim Browning Date


Committee Member

John R. Pelton Date


Dean of the Graduate College

iii
ACKNOWLEDGEMENTS

I would like to Dr. Barney Smith who encouraged me to get a graduate degree and

then poked and prodded me until I completed it. I would not have succeeded without her

support and mentorship.

I would also like to thank my friends and family. They helped me to overcome the

stress and frustrations that came up from time to time as I worked towards my goals. I

would especially like to thank my coworkers Joetta Anderson, Chris Hale, Darrin Reed,

Jim Steele who acted as sounding boards for ideas, reviewed and edited my writing and

provided friendship in this journey. I am honored and grateful to my committee members

Dr. Tim Anderson and Dr. Jim Browning who provided time and energy to review this

thesis.

This material is based upon work supported by the National Science Foundation

under Grant No. CCR- 0238285.. Any opinions, findings, and conclusions or

recommendations expressed in this material are those of the author(s) and do not

necessarily reflect the views of the National Science Foundation.

iv
ABSTRACT

The effect of binarization via global thresholding on additive Gaussian noise in high

contrast images is explored. A measure of noise in bilevel images called noise spread is

developed with the use of a degradation model that applies to many image degradations

included in desktop scanning. When high contrast images are binarized, noise is

concentrated on the edges of objects in the image. Noise spread is the breadth of the

domain in which pixels are affected by noise after binarization. It depends on both the

noise level and the gradients of the image prior to thresholding.

There is a strong linear relationship between noise spread and the expected Hamming

distance between an image with noise added and the same image without noise added. It

is also known that if two images of an object are synthetically generated with

independent random phases and zero noise, there is a small Hamming distance between

them. Experiments on circles and on a ‘5’ were run to determine the combined effect of

random independent phase and noise spread on the expected Hamming distance. The two

factors are not additive and that the phase effects become less significant when the noise

spread increases. The degree to which this is true depends on the shape of the object

being scanned.

In addition to experiments on Hamming distance, experiments were run to determine

the geometric precision of images with noise. This includes experiments relating noise

spread on the localizability of straight edges at several different orientations. The

localizability of and edge is defined by the ability to determine the orientation and

v
position of an edge segment. The quality of edge measurements is quantified by the angle

between the measured edge and the true edge and by the distance between the measured

edge segment and the midpoint of the true edge segment. Surprisingly the distance

measurements for edges at certain orientations actually are precise when the noise spread

increases, but this variation is offset by less precision in the measurements of edge

orientation. For most edge orientations the precision of both distance measurements and

orientation measurements decreases when noise spread increases. Experiments relating

noise spread to the localizability of circles were also conducted. These experiments

reveal that the positional error in circle measurements has a Rayleigh distribution, while

the radius measurements have a normal distribution, and that circle localizability

decreases as noise spread increases.

Noise Spread provides a strong theoretical foundation for future research. Since

random effects play a critical role in optical character recognition (OCR) and in pattern

recognition generally, it is important to understand and quantify them. Future research

will focus on relating noise spread to human preference, on finding novel techniques for

measuring noise spread directly from binary images, and on developing filters and other

techniques which will make OCR systems less susceptible to noise. Noise spread may

also have unforeseen applications in problems other than document research.

vi
TABLE OF CONTENTS

LIST OF FIGURES ........................................................................................................... ix

LIST OF TABLES........................................................................................................... xiii

LIST OF SYMBOLS, TERMS & ABBREVIATIONS ...................................................... i

1. INTRODUCTION ........................................................................................................ 1

2. TECHNICAL BACKGROUND................................................................................... 5

2.1. GENERATING SYNTHETIC SCANNED IMAGES .................................................. 6

2.1.1. Basic Scanner Model ...................................................................... 7

2.1.2. Scanned Straight Edges................................................................. 10

2.1.3. Scanned Strokes ............................................................................ 13

2.1.4. Scanned Circles............................................................................. 17

2.1.5. Scanned Characters....................................................................... 20

2.2. EDGE FINDING TECHNIQUES ......................................................................... 22

2.3. CIRCLE FITTING TECHNIQUES ....................................................................... 26

2.4. EFFECT OF SAMPLING ................................................................................... 29

3. NOISE SPREAD THEORY ....................................................................................... 35

3.1. NOISE SPREAD FOR STRAIGHT ISOLATED EDGES............................................ 35

3.2. EXTENDING NOISE SPREAD TO GENERAL SHAPES ......................................... 40

3.3. RELATIONSHIP BETWEEN NOISE SPREAD AND HAMMING DISTANCE ............ 42

3.4. NOISE SPREAD WITH VARYING NOISE LEVELS .............................................. 45

vii
4. HAMMING DISTANCE BETWEEN SCANNED OBJECTS.................................. 49

4.1. HAMMING DISTANCE BETWEEN SCANNED EDGES ........................................ 49

4.2. HAMMING DISTANCE OF SCANNED CIRCLES................................................. 52

4.3. HAMMING DISTANCE OF SCANNED CHARACTERS ......................................... 56

5. GEOMETRIC MEASUREMENTS OF BILEVEL SCANS...................................... 60

5.1. LOCALIZABILITY OF SCANNED EDGES .......................................................... 60

5.1.1. Comparing Various Approaches to Finding Edges ...................... 63

5.1.2. Effect of Threshold ....................................................................... 65

5.1.3. Effect of PSF Width...................................................................... 67

5.1.4. Effect of Edge Orientation ............................................................ 70

5.2. LOCALIZABILITY OF SCANNED CIRCLES ....................................................... 77

6. CONCLUSIONS AND FUTURE WORK ................................................................. 81

REFERENCES ..................................................................................................................84

APPENDIX A 86

Iso Curves for Cauchy and Gaussian PSF’s

APPENDIX B 100

Code for Calculating ∆

APPENDIX C 102

Code for Calculating Ri

viii
LIST OF FIGURES

Figure 1.1 The ideal edge and the noisy edge have the same phase and orientation.
The Hamming distance between the two images is the number of pixels
that are different between the two images. ................................................. 3

Figure 2.1 This scanner model is used to determine the value of the pixel f[i,j]
centered on each sensor element................................................................. 8

Figure 2.2 Gaussian ESFs are shown with w1=1 and w2=2. When the image is
blurred and thresholded the position of the edge is shifted from the dotted
step function to the solid edge function. This shift is called δc and is by
convention positive when the edge is shifted to the left. .......................... 11

Figure 2.3 When a stroke characterized by two parallel edges is scanned the resulting
stroke thickness changes. Interference between the parallel edges causes
the grayscale value of pixels to be less than that predicted by the ESF. As
a result the stroke thickness will be less than that predicted by δc. .......... 14

Figure 2.4 The Iso Curves for a Cauchy PSF are significantly different from the δc
curves even when the stroke width is 15. ................................................. 16

Figure 2.5 When a circle is scanned its radius changes. As with scanned strokes if the
threshold is too high the circle will disappear when it is scanned. ........... 18

Figure 2.6 Algebraic Fitting can sometimes result in a poor fit. The center of the
Algebraic fit is (10.24,20.98) and the radius is 4.83. The center of the
Geometric fit is (10.10,7.92) and the raidus is 11.77............................... 29

Figure 2.7 Spirographs are a useful tool for studying the phase effects of straight
edges. This spirograph was created using N=20 and an edge with a 35
degree angle of inclination. The marks on the circle represent the locations
of sample points relative to the edge. The lines on the interior of the circle
connect sample points that are on adjacent columns of the image. The
location of the edge can be represented by a point on the circle. ............. 31

Figure 2.8 (a) The variance of the distance between the measured and actual edges is
determined for edges that are 20 pixels long. (b) The variance in the
angular error is determined for noiseless edges that are 20 pixels long. .. 33

ix
Figure 3.1 Edges with varying amounts of noise spread. While the standard deviation
of the noise in first three images is the same, the noise spread is different.
The picture on the far left shows an extreme amount of noise. ................ 35

Figure 3.2 (a) Edge after blurring with a generic PSF of width, w. When no noise is
added, the thresholding produces the edge shift δc. (b) Edge with noise.
The uncertain boundary shown in gray, is the noise spread region. The
effects of sampling are not shown. ........................................................... 36

Figure 3.3 The threshold probability (THP) function is shown for a Gaussian PSF
with w=1, Θ=0.7 and σnoise=0.1. Noise spread in this case is about .72. The
piecewise approximation of threshold probability is inaccurate at the tails
of the THP function. ................................................................................. 38

Figure 3.4 The threshold probability function given in Equation 3.1 (solid) is
compared to the approximation in Equation 3.8 (dashed) with the
parameters w=1, Θ=0.7 and σνοισε=0.1. The actual threshold probability
is a little lower on the tails. ....................................................................... 40

Figure 4.1 The relationship between the expected Hamming distance and the noise
spread is shown for (a) 13 different PSF widths (b) 7 different thresholds
and (c) 8 different angles of inclination. The PSF width, threshold and
orientation of the edge don’t affect the relationship between Hamming
distance and noise spread as long as it is not a degenerate orientation with
a slope that can be represented by an irreducible fraction of small integers
such as 0 degrees....................................................................................... 51

Figure 4.2 Hamming Distance versus noise spread for circles of varying radii. (a)
Both images have the same phase shift (b) Images have random
independent phases. (c) Noise spread is plotted against the Hamming
distance for both in-phase and independent phase together using the
average of the results from each radius. The effect of phase is less
significant when the noise spread is higher. ............................................ 55

Figure 4.3 (a) Results of in-phase experiments. (b) Results of independent phase
experiments show a strong relationship between noise spread and
expected Hamming distance. .................................................................... 58

Figure 4.4 The effect of using an independent phase becomes less significant as
Noise increases.......................................................................................... 59

Figure 5.1 An example of a straight edge scanned with w=3, Θ=.3 and NS=.6. The
solid line shows the position of the original edge. The dotted line is the
theoretical position of the scanned edge which results from shifting by δc.
The center point is the midpoint of the theoretical edge segment. ........... 63

x
Figure 5.2 (a) The variance of angle measurements from perpendicular fitting and
standard fitting out perform the other methods and LoG is particularly
poor. (b) The variance of distance measurements clearly shows that
standard and perpendicular fitting both perform markedly better then the
other methods............................................................................................ 64

Figure 5.3 (a) The perpendicular and standard fitting both low perpendicular bias.
However, this is not true of the other methods. (b) There is a small angular
bias in the standard fitting compared to the perpendicular fitting. LoG has
a very large angular bias. .......................................................................... 64

Figure 5.4 (a) Variance of angular error with a fixed sampling grid. (b) Variance of
distance measurements for fixed sampling grid........................................ 66

Figure 5.5 (a) Bias in angle measurement with a fixed sampling grid. (b) Bias in edge
position measurement with a fixed sampling grid. ................................... 66

Figure 5.6 (a) Variance of angular error with a random sampling grid. (b) Variance of
distance measurements for random sampling grid.................................... 67

Figure 5.7 (a) Bias in angle measurement. (b) Bias in edge position measurement. . 67

Figure 5.8 (a) Variance of angular error with a random sampling grid and several
different values of w. (b) Variance of distance measurements for a random
sampling grid and several different values of w. ...................................... 68

Figure 5.9 (a) Bias in the orientation measurements of edges with fixed sampling grid
and several different values of w. (b) Bias of distance measurements for a
fixed sampling grid and several different values of w. ............................. 68

Figure 5.10 (a) Variance of angular error with a random sampling grid and several
different values of w. (b) Variance of distance measurements for a random
sampling grid and several different values of w. ...................................... 69

Figure 5.11 (a) Bias in the orientation measurements of edges with random sampling
grid and several different values of w. (b) Bias of distance measurements
for a random sampling grid and several different values of w.................. 69

Figure 5.12 (a) Bias in the orientation measurements of edges with a fixed sampling
grid and several different edge orientations. (b) Bias in the distance
measurements of edges with a fixed sampling grid and several different
edge orientations. ...................................................................................... 71

Figure 5.13 (a) Variance in the orientation measurements of edges with a fixed
sampling grid and several different edge orientations. (b) Variance of the
distance measurements of edges with a fixed sampling grid and several
different edge orientations ........................................................................ 71

xi
Figure 5.14 (a) Variance of angular error with a random sampling grid and several
different edge orientations. (b) Variance of distance measurements for
random sampling grid and several different edge orientations................. 72

Figure 5.15 (a) Bias in the orientation measurements of edges with random sampling
grid and several different edge orientations. (b) Bias of distance
measurements for random sampling grid and several different edge
orientations................................................................................................ 72

Figure 5.16 (a) Variance of angular error with a fixed sampling grid and degenerate
edge orientations. (b) Variance of distance measurements for a fixed
sampling grid and degenerate edge orientations....................................... 73

Figure 5.17 (a) Bias of angular error with a fixed sampling grid and degenerate edge
orientations. (b) Bias of distance measurements for a fixed sampling grid
and degenerate edge orientations. ............................................................. 73

Figure 5.18 (a) Variance of angular error with a random sampling grid and degenerate
edge orientations. (b) Variance of distance measurements for a random
sampling grid and degenerate edge orientations....................................... 74

Figure 5.19 (a)Bias in the orientation measurements of edges with random sampling
grid and degenerate edge orientations. (b) Bias of distance measurements
for random sampling grid and degenerate edge orientations. ................... 74

Figure 5.20 Distance and Angular Error for 0 degree edge without noise................... 75

Figure 5.21 Distance and Angular Error for 20 degree edge without noise................. 75

Figure 5.22 Distance and Angular Error for 0 degree edge with NS=.3. ..................... 76

Figure 5.23 Distance and Angular Error for 20 degree edge with NS=.3. ................... 76

Figure 5.24 (a) The radius measurements from Experiment 1 have a normal
distribution. (b) The distances between the measured circle centers and the
actual circles centers from Experiment 1 have a Rayleigh distribution.... 78

Figure 5.25 (a)The Rayleigh parameter of the positional error for several different
values of w. (b) Variance of radius measurements for several different
values of w. ............................................................................................... 79

Figure 5.26 (a)The Rayleigh parameter of the positional error for several different
values of Θ. (b) Variance of radius measurements for several different
values of Θ. ............................................................................................... 80

xii
LIST OF TABLES

Table 2.1 Simple operators used for edge detection. .................................................24

Table 3.1 Functions for calculating blurred noise......................................................48

Table 4.1 Edge experiment parameters......................................................................50

Table 5.1 Parameters for threshold experiments........................................................65

Table 5.2 Parameters for PSF width experiments......................................................68

Table 5.3 Parameters for edge orientation experiments.............................................70

Table 5.4 Circle Experiment Parameters ...................................................................77

xiii
LIST OF SYMBOLS, TERMS & ABBREVIATIONS

OCR Optical Character Recognition


PSF Point Spread Function
ESF Edge Spread Function
LSF Line Spread Function
CSF Circle Spread Function
o(x,y) bilevel continuous input image
s(x,y) intensity of pixels at (x, y) before noise
s(x) intensity of pixels at position x before noise
s[i,j] sampled unquantized output of blurring convolution
f[i,j] final binary scanner output
n[i,j] Gaussian noise added in degradation model

σnoise standard deviation of Gaussian noise


w general width parameter for PSF

Θ binarization or threshold level

Λ Distance between samples

Θmax binarization or threshold level which causes stroke to disappear.

δc This is the distance that an edge shifts when it is scanned

τ Thickness of a scanned stroke before scanning

τscanned Thickness of a scanned stroke after scanning

∆ Amount that the thickness of a scanned stroke increases by


Rf Scanned circle radius
Ri Original circle radius

α Cutoff used for noise spread

Zα Z value for alpha cutoff for noise spread


ρ(x) Density of pixels
v(x,y) Noise on source image
qs(x,y) Variance of noise on source image
qb(x,y) Variance of noise after blurring

φ Angle of inclination for edge


1

1. INTRODUCTION

High contrast images, which occur frequently in document images, are often digitized

into binary images. These binary images are then analyzed by optical character

recognition (OCR) systems which convert the text images into ASCII characters. OCR

systems depend on many features measured from the text images. They use large sets of

images that have already been classified and ideally are representative of the characters in

document images. Features are then measured from these training sets and those

measurements are used to label unclassified characters. One way of generating these

training sets is to generate large numbers of synthetic character images whose labels are

known and then to use these images to train the OCR system. To do this effectively it is

best if the synthetic characters are as similar as possible to real scanned characters. It is

not enough that individual characters be similar to characters in real document images;

the statistical properties of large numbers of characters need to match those of real

characters. This means that a good theoretical basis for the nondeterministic effects in the

generation of scanned characters is required.

Part of the nondeterministic aspects of generated characters is the random position or

phase of the sampling grid relative to a scanned object. When the sampling grid is shifted

relative to a continuous character, a large number of different bitmaps can result. It is

possible to determine the number and frequency of each of these bitmaps using modulo

grid diagrams [1]. Modulo grid diagrams are formed by performing a modulo one

operation with respect to both the horizontal and vertical coordinates of an objects
2

boundary. The effects of random phase can be incorporated into OCR by generating

training sets with random phases.

Unfortunately random phase is not the only nondeterministic aspect of scanned

characters. Another source of randomness is the noise that is in the document image prior

to digitization and the noise that is added during scanning. When the image is binarized,

the noise becomes concentrated on the boundaries of objects. In order for training sets to

have the same statistical properties as real scanned characters, it is necessary for the

training sets to have the appropriate amount of noise. Before this problem can be

addressed the amount of noise on the edges of binary images must be quantified and

understood theoretically.

The amount of noise in binary images is not only dependent on the amount of noise

added to the image, but on the shape of the object being scanned and on the scanner

model parameters. This research focuses on quantifying the noise in bilevel images and

on relating that amount of noise to the parameters of a commonly used degradation

model. The quantity that was developed is called noise spread. Noise spread is the size of

the domain over which pixels in the binary image are affected by noise. While the

research in this thesis focuses on document images, the concept of noise spread could be

applied to other situations where an image is binarized.

Noise spread provides a theoretical basis for understanding and measuring noise in

document images. It is critical for developing methods to mitigate the effects of noise in

binary images. Noise spread allows bilevel images to be created with different

degradation parameters but the same amount of noise. Filters can be tested to see if the

negative effects of noise can be suppressed. Measurement techniques can also be


3

Ideal Edge Noisy Edge Hamming Distance

Figure 1.1: The ideal edge and the noisy edge have the same phase and orientation. The Hamming
distance between the two images is the number of pixels that are different between the two
images.
developed to measure noise directly from document images. The noise in a binary

document image can be measured, and the training sets that are used to design an OCR

system could have the same levels of noise as the documents that the OCR system is

being applied to. Alternatively the noise measurement could be included into a general

OCR system as an additional feature.

Noise in binary images is equivalent to errors in general binary signals. In

information theory the Hamming distance between two binary signals of the same length

is the number of bits that are different between the two signals. The amount of noise in a

bilevel image can reasonably be measured by the Hamming distance between the image

with noise and the same image without noise. Figure 1.1 shows the Hamming distance for

images of a straight edge with and without noise. Theory about the relationship between

Hamming distance and noise spread will be introduced in Section 3.3, and experiments to

verify this theory are described in Chapter 4. Chapter 4 also includes experiments on the

relationship between the Hamming distance and noise spread when the phases of the two

objects are independent.

Since objects with noise are likely harder to precisely locate in an image, several

localization experiments were conducted to verify that noise spread accurately quantifies
4

the noise in thresholded images. The experiments were designed to verify that noise

spread accounts for all the effects of different document degradation parameters on the

localizability of circles and straight edges. There are applications where the ability to

precisely locate edges in bilevel images is important. For instance Hok Sum Yam [2]

developed a method for finding the degradation parameters from bilevel document

images. The method depended on precise edge measurements in order to determine how

much the corners of characters were eroded by scanning.

Chapter 2 discusses the technical background. That chapter includes a discussion of

how synthetic scanned images are created, a review of edge and circle localization

techniques, and a discussion of the effect of sampling. Chapter 3 introduces noise spread

in great detail and shows that it is related to Hamming distance. Chapter 4 provides an

experimental relationship between Hamming distance and noise spread that reinforces

and expands upon the relationship theorized in Chapter 3. Experiments in Chapter 5

provide evidence that all of the effects of the document degradation parameters on the

localizability of scanned edges and circles are determined by the noise spread.
5

2. TECHNICAL BACKGROUND

Before the theory behind noise in binarized images can be presented, it is necessary to

discuss the basic degradation model upon which it is based. It is also necessary to review

literature on the precise geometric measurements of straight edges and circles in images.

Determining the effect of noise on localizability is important to prove that noise spread is

a good quantitative measure of edge noise in bilevel images. The effects of phase are also

important because phase affects both localizability and Hamming distance between

objects.

The degradation model describes the acquisition of a binary scanned image as a

multistage process whose steps include: convolving with a point spread function (PSF),

sampling, adding noise, and thresholding. Section 2.1 will discuss the document

degradation model in more depth and show how the model can be applied to scanned

edges, circles, and strokes. A method for determining the gradients of the simulated grey

level images is also discussed.

Edge finding is a very basic computer vision task and has been widely studied. The

experiments in this thesis are designed to determine the localizability of scanned edges

under different amounts of noise. Section 2.2 provides a review of the literature on edge

finding techniques and discusses in detail the edge finding techniques that were used in

this thesis.

There are several techniques for localizing circles. All the techniques that were

considered use least squares, but some techniques work better than others. Section 2.3
6

discusses these circle localization techniques and describes the Gauss-Newton algorithm

used to solve the nonlinear least squares problem.

The effects of sampling images have been studied extensively. Section 2.4 reviews

the literature on sampling effects, discusses the effect of sampling and edge orientation

on the localizability of scanned edges, and also discusses tools like the modulo-grid

diagram which provide a means for predicting the possible bitmaps that result from

different shapes due to phase effects alone.

2.1. Generating Synthetic Scanned Images

This thesis uses a degradation model based on a model proposed by Baird [3]. In that

model an ideal continuous bilevel image is convolved and sampled by a point spread

function (PSF). Then Gaussian noise is added to the image to represent noise added

during scanning and noise that would have been originally present on the paper image.

Finally, the image is binarized at a certain threshold level as shown in Figure 2.1.

This section begins with a detailed mathematical description of the scanner model.

Then in subsequent subsections this model is applied to straight edges, scanned strokes,

circles, and general scanned characters. In order to understand how noise affects scanned

bilevel images, we will need to determine the intensity gradients of the image before

thresholding. These gradients help determine how noisy a bilevel image will be. A

technique for obtaining these gradients is discussed for each of the different types of

scanned objects.
7

2.1.1. Basic Scanner Model

The basic scanner model describes the sampling of the spatially continuous image of

“blackness” or absorptance, o(x,y), where absorptance is one minus the reflectance. The

values of o(x,y) can be either 0 (white) or 1 (black). The image is digitized by a sensor

array in the scanner. A PSF is used to model the fact that for each point on a physical

paper image different amounts of light are reflected to each sensor. The PSF is the 2-D

equivalent to the impulse response of a scanner. This equivalence means that convolution

can be used to predict the amount of reflected light each sensor detects. If the image is

sampled at points xj, yi on a rectangular grid, then the image is given by

( )
s[i, j ] = ∫∫ PSF x j − u, yi − v ⋅o(u, v )dudv . (2.1)

This equation assumes that the scanner is spatially invariant over the field of view, which

is valid for small regions. In order to model the noise that would exist on the original

image and the noise that is added during scanning, Gaussian noise n[i,j] is added to the

image

a[i, j ] = s[i, j ] + n[i, j ] . (2.2)

The noise is added to every sensor independently and has a mean of zero and a standard

deviation of σnoise. Other types of additive noise could be used as well.

To produce a bilevel image the intensity is quantized using a thresholding operation

⎧1 a[i, j ] ≥ Θ
f [i, j ] = ⎨ . (2.3)
⎩0 a[i, j ] < Θ

A higher threshold value, Θ, reduces the number of black pixels in f[i,j]. This whole

process is combined in the diagram in Figure 2.1.


8

s[i,j] a[i,j]
f[i,j]
n[i,j]

Figure 2.1: This scanner model is used to determine the value of the pixel f[i,j] centered on each sensor
element.
There are two properties that a PSF shape must have. The first requirement is that the

total volume under the PSF must be 1. The second requirement is that the function must

be nonnegative everywhere. However, there are three additional assumptions about the

PSF that are helpful for the analysis in this thesis. One of these is that the PSF should be

circularly symmetric about the origin. Otherwise, objects with different orientations

would be affected differently by the PSF. The second is that the PSF should decrease

monotonically from the origin. This requirement prevents ripples in the image intensity

which are probably not present in actual document images and which would complicate

our analysis. Finally the shape of the PSF should be described in terms of a single

parameter w, which describes the width of the PSF. This parameter is useful because

there is a relationship between the width of the PSF and the gradients in the intensity of

the image. While some of these assumptions could be relaxed this would significantly

complicate the analysis.

Several PSF shapes which satisfy these requirements are discussed by Barney Smith

[4]; however the two PSF shapes from her dissertation that are used in this thesis are the

bivariate Gaussian and the bivariate Cauchy distributions. The bivariate Gaussian is

primarily used because of its familiarity to researchers and because it is easy to accurately
9

simulate the convolution. The equation for the bivariate Gaussian is

1 ⎛ x2 + y2 ⎞
PSFGaussian ( x,y;w) = exp⎜ − ⎟. (2.4)
2πw 2 ⎜ 2 w 2 ⎟
⎝ ⎠

The second PSF that is used is the bivariate Cauchy distribution. This function is believed

to be closer to the true PSF shape for scanners [4]. The Cauchy PSF is

w
PSFCauchy ( x,y;w) = . (2.5)
(
2π w + x + y2 2
)
2 3/ 2

The problem with the bivariate Cauchy distribution is that it is difficult to accurately

simulate convolution with a continuous bivariate Cauchy distribution. Some of the

techniques for simulating the continuous convolution of an image and the PSF require

that the PSF be truncated. For a Cauchy distribution the truncated portion is not

insignificant unless a very large convolution kernel is used.

The value of w is measured in terms of pixels, which means that w changes when an

image is down sampled. If the rows and columns of the sampling grid are spaced apart by

the distance Λ, then Equation 2.1 can be rewritten as

s ( Λ ⋅ x,Λ ⋅ y ) = o( Λ ⋅ x,Λ ⋅ y ) ⊗ PSF( x,y;w) , (2.6)

where the image s[i,j] is obtained by sampling s(Λx, Λy) at integer values of x and y. It

can be shown through the properties of convolution that Equation 2.6 can be rewritten as

s ( x,y ) = o( x,y ) ⊗ PSF( x,y; Λ ⋅ w) . (2.7)

Since the original image can be described using any rectangular coordinate system, a

coordinate system is sometimes chosen so that Λ is one. Equation 2.7 is then used to

compare the PSF taken at one resolution to the PSF for another resolution.
10

2.1.2. Scanned Straight Edges

When isolated straight edges are scanned using the basic scanner model described

previously they are degraded in several ways. After convolving the scanned edge with the

PSF the intensity of pixels as a function of their distance from the original edge is defined

by their edge spread function (ESF) [5]. Figure 2.2 shows the ESFs that result from

Gaussian PSFs with two different values of w. The ESF is obtained from the PSF by

taking the cumulative marginal

x ∞
ESF( x;w) = ∫ ∫ PSF(xˆ,y;w)dydxˆ . (2.8)
−∞ −∞

It can be shown that the ESF for a Gaussian distribution is

⎛x⎞ 1 ⎛ x ⎞ 1
ESFGauss ( x;w) = ESFGauss ⎜ ⎟ = ⋅ erf ⎜ ⎟+ , (2.9)
⎝ w⎠ 2 ⎝ w⋅ 2 ⎠ 2

where

x
2 −t 2
erf ( x ) = ∫e dt . (2.10)
π 0

Likewise the ESF for a Cauchy distribution is

⎛x⎞ 1 ⎛x⎞ 1
ESFCauchy ( x;w) = ESFCauchy ⎜ ⎟ = arctan⎜ ⎟ + . (2.11)
⎝ w⎠ π ⎝ w⎠ 2

As can be seen the value of both ESF functions can be represented by a single parameter

obtained by dividing x by w.

When the image of a scanned edge is binarized, its position changes from its original

location. This change is shown in Figure 2.2. The new edge location occurs where the

amplitude equals the threshold Θ,


11

Figure 2.2: Gaussian ESFs are shown with w1=1 and w2=2. When the image is blurred and
thresholded the position of the edge is shifted from the dotted step function to the solid edge
function. This shift is called δc and is by convention positive when the edge is shifted to the
left.
⎛x⎞
ESF⎜ ⎟ = Θ . (2.12)
⎝ w⎠

The position would occur at x=-δc, where

δc = − w ESF −1 (Θ ) . (2.13)

There are multiple values of w and Θ that result in the same value of δc and, therefore,

produce the same distortion on an isolated edge [5].

As will be discussed in more detail later, the effect of noise on scanned bilevel images

is dependent on the gradient of the scanned image at the location of edges after scanning.

The derivative of the ESF is called the line spread function (LSF). It is the theoretical

response to a straight line and is sometimes referred to as the one-dimensional PSF. For a

Gaussian PSF the LSF is

1
∂ 1 − x2
LSFGaussian (x ) = ESFGaussian ( x ) = e 2 . (2.14)
∂x 2π
12

For a Cauchy PSF the LSF is

∂ 1
LSFCauchy ( x ) = ESFCauchy ( x ) =
∂x (
π x2 +1). (2.15)

If we include the width parameter and evaluate the derivative at x=-δc we get

∂ ⎛x⎞
ESF⎜ ⎟ =
(
LSF ESF −1 (Θ )
.
) (2.16)
∂x ⎝ w ⎠ x = −δ w
c

This gives the gradient as a function of the degradation parameters. When noise spread is

introduced in Section 3.1, this formula will be important.

Another concern for generating scanned straight edges has to do with generating edge

segments with a specified length regardless of orientation. To do this there are two

options. One is to determine the number of columns that an edge image needs to have in

order for the edge to be a certain approximated length. There is some ambiguity with this

method though. To understand this ambiguity, consider a horizontal edge in an image

whose size is 20 pixels by 20 pixels. If the length is measured from one side of the

displayed image to the other then the length is 20, but if it is measured from the center of

the left most pixel to the center of the right most pixel then the length is 19. Some of the

experiments that are performed for this thesis used this technique, and the image

described above is considered to have a length of 20. A better technique, however, is to

generate an edge segment that is larger than is necessary. Then a rectangle can be

imagined with one side having the length of the desired edge segment and the other side

being twenty pixels or less. The rectangle is rotated so that it is at the same angle as the

edge and positioned so that the edge runs through the center of the rectangle. At this point

pixels that are inside the rectangle are considered part of the edge segment. In addition
13

when the phase of the edge is shifted, the rectangle should remain fixed in space so that

as the phase changes different pixels are considered part of the edge.

2.1.3. Scanned Strokes

In the previous subsection the effect of scanning on isolated edges was discussed.

Scanned strokes are objects in which the original image is black between two parallel

straight edges. Many characters have edges that are like this. When the stroke is scanned

it changes in thickness. This change is not the same as the shift predicted for isolated

edges because the opposite edges in the stroke interfere with one another. This is

especially true when the PSF is Cauchy. Figure 2.3 shows the result of scanning a

scanned stroke with a Cauchy PSF.

The one dimensional cross section of a scanned stroke is a square pulse with a width

τ. We will assume that the square pulse is centered on the origin. In this case the value of

pixels as a function of their position, s(x), can be found using

⎛ τ − 2x ⎞ ⎛ -τ − 2 x ⎞
s( x ) = s(− x ) = ESF⎜ ⎟ − ESF⎜ ⎟. (2.17)
⎝ 2w ⎠ ⎝ 2w ⎠

As with scanned edges the new edge locations occur where s(x) is equal to Θ. If the

thickness of the stroke after thresholding is given by τscanned and is greater than zero, then

the threshold is given by

⎛ τ-τ ⎞ ⎛ − τ-τ scanned ⎞


Θ = ESF⎜ scanned ⎟ − ESF⎜ ⎟. (2.18)
⎝ 2w ⎠ ⎝ 2w ⎠

The change of stroke thickness ∆ can be defined as

τ scanned = τ + ∆ , (2.19)

which leads to
14

Θma

Θ
τscann s(x)
- -

Figure 2.3 When a stroke characterized by two parallel edges is scanned the resulting stroke thickness
changes. Interference between the parallel edges causes the grayscale value of pixels to be
less than that predicted by the ESF. As a result the stroke thickness will be less than that
predicted by δc.

⎛ ∆ ⎞ ⎛ − 2τ − ∆ ⎞
Θ = ESF⎜ − ⎟ − ESF⎜ ⎟. (2.20)
⎝ 2w ⎠ ⎝ 2w ⎠

As τ gets larger Equation 2.20 becomes

⎛ ∆ ⎞
Θ = ESF⎜ − ⎟. (2.21)
⎝ 2w ⎠

When τ is large enough to make the edges independent the change in stroke thickness

becomes twice the δc.

In addition to the change in stroke thickness, there is also the possibility that a stroke

will disappear altogether. This will occur any time that the threshold exceeds the

maximum value of s(x). We can find this Θmax by setting τscanned in Equation 2.18 to zero

which results in

⎛ τ ⎞ ⎛ τ ⎞ ⎛ τ ⎞
Θmax = ESF⎜ ⎟ − ESF⎜ − ⎟ = 1 − 2 ⋅ ESF⎜ − ⎟. (2.22)
⎝ 2w ⎠ ⎝ 2w ⎠ ⎝ 2w ⎠
15

For a given set of values for τ, w and Θ it is possible to determine the value of ∆. First

it must be confirmed that Θ is greater than Θmax by using Equation 2.22. Once this is

confirmed upper and lower bounds are set on ∆. These bounds are

∆ > −τ (2.23)

and

∆ ≤ 2 ⋅δc . (2.24)

The lower bound comes from the fact that τscanned cannot be negative, and the upper

bound comes from Equation 2.20, Equation 2.13 and the fact that the ESF is always

positive. These upper and lower bounds can be used with the bisection method of root

finding to find ∆.

Values of w and Θ which result in certain ∆/2 values can be represented by iso curves

which are equipotential curves in w and Θ on which ∆/2 has the same values. Figure 2.4

shows these iso curves for a Cauchy PSF on the same plot as the δc curves. As can be

seen the values of ∆/2 are significantly smaller than δc even when τ is 15. Appendix A

shows the iso curves that result from both Gaussian and Cauchy PSFs and for several

different values of τ.. Code for calculating ∆ is included in Appendix B.

For a Gaussian PSF the difference between ∆/2 and δc becomes insignificant as τ gets

larger. If δc is used to estimate the size of the scanned stroke after scanning, then it is

necessary to determine whether the edges are close enough to have interference. As a rule

of thumb, a Gaussian ESF is approximately either 1 or 0 at 3w from an edge. This means

that if the size of the stroke after scanning predicted by δc is greater than 3w, no

interference occurs. This rule of thumb can be summarized by the following inequality
16

δc ∆/2

∆/2
δc

-2 -3
-1 -3 -2
-1
0
0
1
1
2
2
3 3

Figure 2.4 The Iso Curves for a Cauchy PSF are significantly different from the δc curves even when
the stroke width is 15.

which if satisfied means that no interference occurs

3w − δc ≥ τ . (2.25)

As with straight edges it is very important to determine the magnitude of the gradient

of s(x) at the location of the thresholded edges. The derivative of s(x) is given by

⎛ τ-2 x ⎞ ⎛ − τ − 2x ⎞
− LSF⎜ ⎟ + LSF⎜ ⎟
⎝ 2w ⎠ ⎝ 2w ⎠
s (x ) =
′ . (2.26)
w

Since the slope on the rising edge is positive

⎛ τ + τ scanned ⎞ ⎛ − τ + τ scanned ⎞
− LSF⎜ ⎟ + LSF⎜ ⎟
⎛ τ ⎞ ⎝ 2w ⎠ ⎝ 2w ⎠.
s ′⎜ − scanned ⎟ = (2.27)
⎝ 2 ⎠ w
17

The gradient can also be expressed as a function of ∆

⎛ ∆ + 2τ ⎞ ⎛ ∆ ⎞
− LSF⎜ ⎟ + LSF⎜ ⎟
⎛ τ scanned ⎞ ⎝ 2w ⎠ ⎝ 2w ⎠
s ′⎜ − ⎟= . (2.28)
⎝ 2 ⎠ w

2.1.4. Scanned Circles

Circles are among the simplest geometric shapes. As a consequence, when

experiments are done on the effects of noise on bilevel images, it is useful to apply them

to circles. A circle spread function CSF can be defined to describe the intensity of pixels

as a function of the distance from the center of the circle. When the circle is scanned, its

size changes. The scanned circle radius Rf can be found from the original circle radius Ri

given the scanner parameters. Likewise sometimes when circles are generated for

experiments, Ri needs to obtained from Rf. As with edges and scanned strokes the

gradient of the scanned circle can be determined for both Gaussian and Cauchy PSFs.

Figure 2.5 shows the cross section of a circle scanned with a Cauchy PSF.

The intensity of a pixel as a function of the distance from the center of the circle can

be obtained using

Ri Ri2 − x 2
CSF(r ) = ∫ ∫ PSF (x − r,y;w)dydx . (2.29)
− Ri − R − x 2
2
i

For a Gaussian PSF the equation becomes

Ri
1 ⎛ (x − r )2 ⎞ ⎛⎜ Ri2 − x 2 ⎞

CSFGaussian (r ) = ∫ exp⎜ − ⎟erf
⎜ ⎟dx . (2.30)
w 2 π ⎜ 2 ⎟
2w ⎠ ⎜ w 2 ⎟
− Ri ⎝ ⎝ ⎠

For a Cauchy PSF the equation becomes


18

Θ
R

Figure 2.5 When a circle is scanned its radius changes. As with scanned strokes if the threshold is too
high the circle will disappear when it is scanned.

Ri
w Ri2 − x 2
CSFCauchy (r ) = ∫ dx . (2.31)
− R (( x − r ) + w ) r − 2 ⋅ r ⋅ x + Ri + w
π 2 2 2 2 2
i

The integrals have to be evaluated numerically. Special care must be taken when

numerically solving for the Gaussian CSF. The value of the integrand is near zero for a

large part of the domain over which it is integrated. This causes large errors when certain

numerical algorithms are used. If

r − 5w ≥ − Ri , (2.32)

then the following integral should be used to calculate the Gaussian CSF

Ri
⎛ ( x − r )2 ⎞ ⎛⎜ Ri2 − x 2
1


CSFGaussian (r ) = ∫ exp⎜ − ⎟erf
⎜ ⎟dx . (2.33)
w 2π ⎜ 2 w ⎟⎠ ⎜ w 2
2 ⎟
r − 5wi ⎝ ⎝ ⎠

The value of Rf depends on Ri, Θ, and w. As with stroke thickness, Rf is defined

implicitly by
19

( )
CSF R f ;Ri ,w = Θ . (2.34)

Numerical methods are necessary to find the value of Rf. The CSF is a monotonically

decreasing function because of the restrictions that were placed on the PSF. As with

scanned strokes there is a Θmax above which Rf will be zero. To find Θmax we use

CSF(0) = Θ max . (2.35)

The easiest way to find CSF(0) is to use polar coordinates

Ri
CSF ( 0 ) = 2π ∫ PSF(r;w)rdr . (2.36)
0

For a Gaussian PSF this simplifies to

⎛ − Ri2 ⎞
CSFGaussian (0 ) = 1 − exp⎜ ⎟. (2.37)
⎜ 2w 2 ⎟
⎝ ⎠

For a Cauchy PSF it is

w
CSFCauchy (0) = 1 − . (2.38)
w 2 + Ri2

Once it is confirmed that Θ is not greater than Θmax the value of Rf can be found. There is

a lower bound on Rf since it cannot be negative. To find an upper bound on Rf, a value

must be found which causes the CSF to be less than Θ. The upper bound is first chosen to

be two times Ri. If this does not result in a CSF value less than Θ, then 2Ri becomes the

new lower bound, and the upper bound is chosen to be four times Ri. The assumption for

the upper bound is doubled until it results in a CSF value less than Θ. Once the upper

bound is determined, a bisection method can be used to find Rf. It is also possible to

determine Ri if Rf, w and Θ are known. Ri is greater than zero and Rf increases
20

monotonically as Ri increases. The algorithm for finding Ri is essentially the same as the

method for finding Rf. The algorithm for finding Ri is included in Appendix C.

The magnitude of the gradient of scanned circles is important for determining the

effects of noise. If the gradient is calculated by evaluating the CSF at two points, the

calculation is prone to error. The numerical integration has some noise which is

magnified by this technique. Instead it is better to take the derivative analytically. The

gradient is given by

Ri R2 −x2
∂ ∂
CSF(r ) = ∫ ∫ (PSF(x − r , y ))dydx . (2.39)
∂r ∂r
− Ri − R 2 − x 2

For a Cauchy PSF this simplifies to

∂ w
Ri
(r − x )(3(x − r )2 − 2 x 2 + 2 Ri2 + 3w 2 ) R2 − x2
CSFCauchy (r ) = − ∫ dx . (2.40)
∂r π
− Ri ((x − r )2 + w 2 )2 ((x − r )2 − x 2 + Ri2 + w 2 )3 / 2
For a Gaussian PSF the gradient is given by


R ⎛ ( x − r )2 ⎞ ⎛⎜ Ri2 − x 2
x−r


CSFGaussian (r ) = ∫ w3 2π exp⎜⎜ − 2w 2 ⎟⎟erf ⎜⎜ w 2 ⎟dx . (2.41)
∂r ⎝ ⎠ ⎝ ⎟
−R ⎠

In both cases the gradient is found by numerical integration. For a Gaussian PSF the same

problem exists with the integrand being near zero over a large part of the domain over

which it is integrated. The solution for finding the CSF can be applied in exactly the same

way to obtain the gradient.

2.1.5. Scanned Characters

The shape of scanned characters is too complicated to use many of the analytical

methods in the previous section. Instead the value of the scanned image is determined by
21

using the discrete convolution of a sampled character image and a sampled PSF. There is

some error associated with this method, but it is reduced by using sampled images and

PSFs with resolutions larger than the resolutions of the final images. The scale factor is

defined as the simulated resolution divided by resolution of the final image. A PSF is

generated which is also sampled at the same scale factor as the character image. Because

each pixel in the sampled PSF represents an area smaller than the pixels in the final

image the PSF kernel is

(
PSF x j , yi )
PSFKernel[i, j ] = . (2.42)
scalefactor 2

Since the PSF kernel must be finite in size, the PSF is effectively truncated.

There are several advantages of using a Gaussian PSF over a Cauchy PSF in terms of

accurately simulating the continuous convolution. A Gaussian PSF can be safely

truncated at four times the w and have very little error. However, for a Cauchy PSF this is

a problem because it is a heavy tailed distribution. To achieve the same accuracy the

Cauchy PSF would have to be truncated at about 3000 times the w. Another advantage of

the Gaussian PSF is that it is separable. This means that the convolution can be calculated

by taking the one dimensional PSF, convolving it with each row, and then convolving it

with each column. While a Gaussian PSF provides several advantages over the Cauchy

PSF, the experiments in this thesis involve isolated characters. The white background

makes it possible for this situation to be simulated even for a Cauchy PSF as long as the

convolution kernel is a little more than twice the size of the original character. This is

because the truncated part of the Cauchy PSF would always be over white background.

After the high resolution images are convolved with the high resolution truncated

PSFs, the images are then down sampled. The location of the final sampling grid does not
22

necessarily coincide with the high resolution sampling grid. In order to have random

continuous phase shifts and non-integer factor values it is necessary to interpolate the

values of pixels. To do this bilinear interpolation can be used because of its simplicity

and because the errors associated with it are not significant.

It is also necessary to determine the gradients of the scanned characters. While the

gradients could be measured from the high resolution grey level image, this is not the

method that was used. The derivative is a linear operation which means that the

derivative of the PSF can be taken and then the gradient of the image can be determined

by convolving the original character image with the resulting kernel. The derivative with

respect to x of the Cauchy PSF is

∂ − 3⋅ w⋅ x
PSFCauchy ( x, y ) = . (2.43)
∂x
(
2π ⋅ x 2 + y 2 + w 2 2 )
5

For the Gaussian PSF the derivative is

∂ x ⎛ x2 + y2 ⎞
PSFGaussian ( x, y ) = − exp⎜ − ⎟. (2.44)
∂x 2π ⋅ w 4 ⎜ 2 ⎟
⎝ 2⋅w ⎠

When these functions are used to create convolution kernels, the functions have to be

divided by the scale factor squared. The kernels for the derivatives with respect to y can

be obtained by transposition. The Gaussian kernel is separable which can be used to

speed up computations.

2.2. Edge Finding Techniques

This thesis focuses on the effect of additive Gaussian noise on scanned images. One

component is to explore the ability to accurately locate edges in scanned document

images. Finding lines in an image is critically important in the fields of image processing
23

and computer vision, and there is a substantial amount of work that has been done on the

topic. A significant amount of attention has gone to developing operators, which bring

out the edges in an image. This is usually followed by techniques that use the Hough

transform to find the location of the line [6]. There has also been study of accurately

locating edges and lines in bilevel rasterized images [8].

One approach to edge detection is to convolve the image with an edge detector and

then to threshold the image and locate the edge using a Hough transform [6]. The Hough

transform works by mapping points to the set of lines that pass through those points.

Edges can be represented by two parameters such as angle and distance from the origin.

These two parameters form a parameter space which can be divided into discrete bins.

The Hough transform is performed by looping through every edge point in the image and

then incrementing the value in every bin that contains parameters to an edge that runs

through the point. After this is done for every edge point the true edge can be determined

by finding the bin with the largest value.

There are a variety of operators that can be used for edge detection. One such

operator is the Sobel operator. The Sobel operator is a combination of two operators

which estimate the two components of the image gradient Gx and Gy. If A is the original

image Gx is given by

⎡ − 1 0 1⎤
G x = ⎢⎢− 2 0 2⎥⎥ ⊗ A . (2.45)
⎢⎣ − 1 0 1 ⎥⎦

Gy is calculated using an operator that is simply the transpose of the one used to calculate

Gx. The magnitude of the gradient can then be estimated as


24

G = G x2 + G y2 . (2.46)

Once the gradient image is determined, it is thresholded to find the edge points, and then

the Hough transform is used to find the edge. The maximums of the Hough transform

correspond to the parameters of the edge. The Prewitt and Roberts operators work in a

way that is similar to that of the Sobel operator. Table 2.1 shows the Sobel, Prewitt, and

Roberts operators.

Table 2.1: Simple operators used for edge detection.


Sobel Operators Prewitt Operators Roberts Operators
-1 0 1 -1 -2 -1 -1 0 1 -1 -1 -1 0 -1 -1 0
-2 0 2 0 0 0 -1 0 1 0 0 0 1 0 0 1
-1 0 1 1 2 1 -1 0 1 1 1 1

In addition to the simple Sobel, Prewitt, and Roberts operators more complicated

operators can be used. One such operator is the Laplacian of Gaussian (LoG) operator.

This operator is given by

⎡r2 −σ 2 ⎤ ⎛ r2 ⎞
h(r ) = ⎢ ⎥ exp⎜ − ⎟. (2.47)
⎢⎣ σ 4 ⎜ 2⎟
⎥⎦ ⎝ 2σ ⎠

This operator is the second derivative of a Gaussian function with a width parameter of σ.

The operator is circularly symmetrical. Numerically it is represented by at least a five by

five kernel. One approximation of the LoG kernel is given by

⎡0 0 −1 0 0⎤
⎢ 0 −1 − 2 −1 0 ⎥
⎢ ⎥
LoG = ⎢− 1 − 2 16 − 2 − 1⎥ . (2.48)
⎢ ⎥
⎢ 0 −1 − 2 −1 0 ⎥
⎢⎣ 0 0 −1 0 0 ⎥⎦

Some of the most important work on finding edges in grey level images was done by

Canny [7]. The theoretical basis for the edge detection mask developed by Canny
25

depends on being able to separate the image into noise and signal components. However,

when an image is subjected to a nonlinearity such as thresholding, the noise and signal

components cannot be separated in this way. The Canny operator begins by smoothing

the image with a Gaussian. Then the gradients of the image are determined. Two

thresholds are used to determine which pixels are edge pixels. The first threshold is set

very higher than the other and any pixel whose gradient exceeds the threshold is labeled

as an edge pixel. Then pixels that are adjacent to an edge pixel are also labeled edge

pixels if their gradient exceeds the second threshold. The Canny operator was

implemented in this thesis using Matlab’s built in edge detection function.

Because using operators such as the Canny operator has no strong theoretical basis in

bilevel images, we can use a more basic approach. This approach involves selecting data

points between each pair of adjacent black and white pixels. Then a line can be fitted to

these points based on the least squared distance. The least squares fitting can either use

the squared vertical distance of points to the edge or use the squared perpendicular

distances. Gordon and Seering [8] analyzed the accuracy of least squares at finding the

location of edges. They use an assumption that the vertical distance between points on a

digitized line and its corresponding continuous line vary independently of one another.

Using this assumption they determined the estimation error of edges. The case in which

the points do not vary independently of one another will be explored in more detail in

Section 2.4.

The least squares approach and the operator based approaches are explored

extensively in Section 5.1.1. In that section experiments are conducted to determine


26

which of the methods work best for bilevel straight edges. The effectiveness of

perpendicular vs. vertical least squares will also be analyzed.

2.3. Circle Fitting Techniques

In order to understand the effects of noise on 2-D objects, it is necessary to explore

the effect of noise on the ability to precisely determine the position and radius of scanned

circles. To do this, data points were selected between adjacent pairs of black and white

pixels, then a circle was fit to these data points. Several classical methods of doing this

fitting are discussed in [9]. This section includes a discussion of these methods.

The simplest method for fitting a circle to data points is called Algebraic circle fitting.

The equation of a circle can be given implicitly by

F (x ) = a ⋅ xT x + b T x + c = 0 , (2.49)

where the coefficients a, b and c are such that a is not zero and b is a two element

column vector. If the values of each data point are plugged into this equation, the result is

B ⋅u = ε , (2.50)

where ε is the error vector which is to be minimized, B is a matrix

⎡ x11
2 2
+ x12 x11 x12 1⎤
⎢ ⎥
B=⎢ M M M M⎥ (2.51)
⎢x2 + x2 x m1 x m 2 1⎥⎥
⎣⎢ m1 m2 ⎦

and u=[a,b1,b2,c]’. Since both sides of Equation 2.49 can be multiplied by a constant, a

constraint can be applied to u that it must be a unit vector. The squared Euclidean norm

of ε can be minimized using Lagrange multipliers. The constraint that u is a unit vector is

applied to create the following equation


27

∂⎛⎜ ε ⎞⎟ ∂⎛⎜ u ⎞⎟
2 2
⎝ ⎠ =λ ⎝ ⎠. (2.52)
∂u ∂u

The left side of the equation becomes

∂⎛⎜ ε ⎞⎟
( ) ( )
2
⎠ = ∂ (B ⋅ u ) (B ⋅ u ) = ∂ u B Bu = 2 ⋅ B T B ⋅ u .
T T T
⎝ (2.53)
∂u ∂u ∂u

The right side also simplifies giving

2 ⋅ BT B ⋅ u = 2 ⋅ λ ⋅ u . (2.54)

The Lagrange multipliers λ are also the eigenvalues of BTB. Substitution gives

2
ε = u T B T Bu = u T λ ⋅ u = λ . (2.55)

This means that the squared Euclidean norm of ε is minimized by using the value of u

associated with the smallest eigenvalue of BTB. Equivalently u is the right singular vector

associated with the smallest singular value of B. The center can be obtained from u using

⎛ b b ⎞
z = ⎜ − 1 ,− 2 ⎟ . (2.56)
⎝ 2a 2a ⎠

The radius is obtained by using

2
b c
r= − . (2.57)
2 a
4a

The problem with Algebraic circle fitting is that minimizing the Euclidean norm of ε does

not necessarily result in the best fitting circle. It is especially poor when fitting a circle to

an arc of data points.

An alternative to the Algebraic method is Geometric circle fitting. Geometric circle

fitting is a nonlinear least squares procedure which minimizes the sum of the squared

distances of points to the nearest point on the circle. If the center point of the circle is z
28

and the radius is r, then the distance of a pixel to the circle is

d i2 = ( x i − z − r ) .
2
(2.58)

If u=[z1,z2,r]T defines the circle, then u needs to be selected to minimize

m
∑ d i2 (u ) . (2.59)
i

A method called Gauss-Newton is used to minimize this expression. The method starts

out with a decent guess of the best value of u. If d(u) is a column vector of the functions

di(u), then the idea is to find the change h in u which will minimize d(u) in the least

squares sense. To do this d(u+h) is approximated using a Taylor series expansion

d(u + h ) = d(u ) + J (u ) ⋅ h , (2.60)

where J(u) is the Jacobian matrix. In this case the Jacobian is given by

⎡ u1 − x11 u 2 − x12 ⎤
⎢ u−x − 1⎥
1 u − x1
⎢ ⎥
J (u ) = ⎢ M M M ⎥. (2.61)
⎢ u1 − x m1 u 2 − xm2
− 1⎥
⎢ u − xm u − xm ⎥
⎣ ⎦

The change in u that is required is found by solving the linear least squares problem

d(u ) + J (u ) ⋅ h ≅ 0 . (2.62)

The value of h is

(
h = − J (u )T J (u) )−1 J(u)T ⋅ d(u) . (2.63)

With every iteration of the algorithm, h is used to update u and a closer approximate

solution of the nonlinear least squares problem is found. This method produces a much

better fit. As was stated earlier, this method requires an initial guess of the value of u.

One way to obtain this is to use the Algebraic circle fitting. Another way is to find the
29

Figure 2.6 Algebraic Fitting can sometimes result in a poor fit. The center of the Algebraic fit is
(10.24,20.98) and the radius is 4.83. The center of the Geometric fit is (10.10,7.92) and the
raidus is 11.77.

mean of all the data points and make this the center of the circle. The radius can be

estimated by taking the distance of each point to this center and taking the mean of those

distances. Figure 2.6 compares the results of Algebraic and Geometric least squares for a

certain set of points. The points were chosen experimentally to show the weakness of the

Algebraic technique. The Geometric technique always produces better results because the

error that it attempts to minimize is more sensible.

2.4. Effect of Sampling

Sampling of continuous bilevel images can produce several undesirable effects. Since

the position of the sampling grid relative to the image is random, there are variations that

occur in the resulting bitmaps. Even without noise there is an unavoidable Hamming

Distance between different scans of an image, even from the same scanner. The

geometric precision of edge and circle measurements is limited by the sampling


30

resolution. In addition the sampling grid for images is anisotropic. This means that edges

at certain orientations are measured with less precision than edges at other orientations.

One of the goals of this thesis is to explore how the random effects of noise and random

phase shifts affect document images.

A review of the literature shows several tools for analyzing the effect of phase on

scanned images. Dorst and Smeulders [10] gave an expression for determining the set of

continuous line segments which could generate a certain chaincode string. This

expression could also be used to find the worst case positional accuracy of an edge

segment. Dorst and Duin [11] introduced the concept of spirographs and used it to

calculate the average and worst case positional accuracy of edges. Havelock [12] used

modulo grids to analyze the positional accuracy of various shapes. Sarkar [1] expanded

upon Havelock’s work by using modulo grids to calculate the number and frequency of

bitmaps that an object would produce.

Spirographs can be used to describe the way in which a continuous edge is sampled.

Any edge can be flipped on the reflection lines x=y, y=0 and x=0. Because of this the

effect of sampling any straight edge can be determined by studying those straight edges

with a slope in the range (0, 1). A spirograph consists of a circle with N points on it

which divide it into N arcs as seen in Figure 2.7

Each consecutive point is placed the same constant clockwise distance around the

circle from the previous point. The sampling grid for an edge can be represented by

making the distance between each consecutive point equal to the slope of the edge. The

random location of the sampling grid with respect to the edge can be represented by

randomly placing the edge as a point on the spirograph; N is then the number of columns
31

2π ⋅ tan (35 ° )

Figure 2.7 Spirographs are a useful tool for studying the phase effects of straight edges. This
spirograph was created using N=20 and an edge with a 35 degree angle of inclination. The
marks on the circle represent the locations of sample points relative to the edge. The lines
on the interior of the circle connect sample points that are on adjacent columns of the
image. The location of the edge can be represented by a point on the circle.

in the edge image. If the edge is shifted up vertically, it is moved clockwise around the

circle. If it crosses a sample point on the spirograph, the bitmap of the edge will change,

and the number of segments formed around the spirograph is the number of bitmaps a

certain edge can have.

One special case is when the slope of an edge can be represented by the irreducible

fraction p/q and when q<<N. In this special case the positional error can be determined

analytically. If N is large enough there will be no error in the measured slope of the edge.

However, the positional error will be given by the length of the segments formed on the

spirograph. If the slope is an irreducible fraction, then the spirograph is broken into equal

size segments. Dorst and Duin [11] gave a formula for the length of the segments of the

spirograph when p/q is the slope

⎛p ⎞ 1
S max ⎜⎜ , N ⎟⎟ = . (2.64)
⎝q ⎠ q

Smax is the most that an edge with a certain slope can be shifted upwards without crossing
32

the sampling grid. The position of the edge relative to the sampling grid is a random

number. So the variance of the perpendicular distance between the measured and actual

positions of a noise free edge is

1
Var =
(
12 ⋅ p 2 + q 2 ). (2.65)

In order for the length of an edge segment with slope m to be L the number of

columns N must be determined by

⎛ L ⎞
N = round ⎜ ⎟. (2.66)
⎜ 2 ⎟
⎝ m +1 ⎠

If a spirograph is defined with the first parameter being the distance between successive

points and the second by N, then the spirograph for this edge is

⎛ ⎛ L ⎞⎞
SPIRO⎜ m, round ⎜ ⎟⎟ . (2.67)
⎜ ⎜ 2 ⎟⎟
⎝ ⎝ m +1 ⎠⎠

The precision of edge measurements can be determined by the combination of two

parameters. The distance parameter is the perpendicular distance of the edge from the

midpoint of the continuous edge segment where the distance is positive if the measured

edge is above the continuous edge and negative otherwise. The angular error is the

difference between the angle of inclination associated with the theoretical edge and the

angle of inclination associated with the measured edge. The variance in the distance for

an edge can be shown to be

⎛ d i3 ⎞
Var (Distance ) = ∑ ⎜ + d i ⋅ pei2 ⎟ ,
(
⎜ 12 m 2 + 1
⎝ ) ⎟

(2.68)

where di is the length of the ith arc on the spirograph and pei is perpendicular distance
33

(a) (b)
Figure 2.8: (a) The variance of the distance between the measured and actual edges is determined for
edges that are 20 pixels long. (b) The variance in the angular error is determined for
noiseless edges that are 20 pixels long.

between the actual and measured edge when the phase is chosen to be the midpoint of the

ith arc. The variance of the angular error between the measured and theoretical edge can

be shown to be

Var ( AngularError ) = ∑ d i ⋅ aei2 , (2.69)

where aei is the angular error of the measured edge when the phase is chosen to be on the

ith arc. Figure 2.8 shows the variance of the distance and angular error as a function of

slope. The slopes of 0, 1/2 and 1 have large distance variance, but the angular errors for

these slopes are zero. The greatest angular errors occur for edges with slopes close to but

not equal to 0, 1/2 and 1.

In addition to the effects of sampling on the geometric measurements, sampling also

affects the Hamming distance between two scans of the same object. If the two scans had

the same phase and there were no noise, then the two scans would have a Hamming

distance of zero. However, because different phases result in different bitmap

configurations, there is some Hamming distance even when two objects are aligned to
34

minimize the difference. The Hamming distance that will occur depends on the shape of

the object being scanned. Modulo grids can be used to determine the expected Hamming

distance between scans with independent random phases and no noise. However, this

approach probably would not be more efficient than large experiments that generate scans

and then find the minimum Hamming distance. Certain shapes like circles are known to

have high Hamming distances because the size of the locals in the modulo grid are small.

For this same reason these shapes have been analyzed for their use in image registration

[13],[14].

Neither modulo grids nor spirographs can predict the effect of combining sampling

and noise on geometric measurements. The phase of simulated scans in an experiment

can be fixed in order to isolate the effects of noise. Then further experiments can explore

the combined effects of noise and random phase. These noise effects are explored in

detail in Chapters 4 and 5.


35

3. NOISE SPREAD THEORY

For grey level images noise is usually described by the standard deviation σnoise of the

additive noise. However the amount of noise present in a bilevel scanned image is not

dependent purely on the level of noise added prior to thresholding. This can be seen

clearly by looking at Figure 3.1. The first three images all have the same amount of

additive noise. However, the noise spread (NS) increases from left to right. One of the

central points of this thesis is to derive this quantity and show that it is a good

representation of the amount of noise in a bilevel image. This makes it possible to

generate synthetic bilevel images with specific amounts of noise.

w=0.64 w=1.27 w=1.9 w=3.16


Θ=0.5 Θ=0.5 Θ=0.5 Θ=0.5
σnoise=0.05 σnoise=0.05 σnoise=0.05 σnoise=0.1
NS=0.2 NS=0.4 NS=0.6 NS=2.0

Figure 3.1 Edges with varying amounts of noise spread. While the standard deviation of the noise in
first three images is the same, the noise spread is different. The picture on the far left shows
an extreme amount of noise.

3.1. Noise Spread for straight isolated edges

The basic idea behind noise spread is that when an image is thresholded the noise is

concentrated on the edges of the objects in the image. The noise spread for a given edge

is the size of the domain in which pixels are affected by additive noise. Typically this

domain, called the noise spread region, is less than a pixel thick. Its size is still relevant

because if it is larger then it is more likely that an edge pixel will be in this region. Noise
36

(a) (b)
Figure 3.2: (a) Edge after blurring with a generic PSF of width, w. When no noise is added, the
thresholding produces the edge shift δc. (b) Edge with noise. The uncertain boundary shown
in gray, is the noise spread region. The effects of sampling are not shown.

spread is dependent in part on the shape of the object being scanned. Initially noise

spread is derived for isolated edges. Isolated edges are among the simplest shapes upon

which to do experiments and can be represented in one dimension as step functions.

Section 2.1.2 discussed how straight edges are affected by scanning, but that section was

focused on the deterministic effects of scanning. Nondeterministic effects such as

additive noise must be discussed in the context of probability.

Figure 3.2 shows how an edge is affected by scanning. Figure 3.2(a) shows what

happens when noise is disregarded. As was discussed in Section 2.1.2 the edge shifts by

δc. However, as shown in Figure 3.2(b), when noise is added there is a region in which

the value of pixels after thresholding is uncertain. This region is called the noise spread

region. The size of this region is called the noise spread (NS), and as illustrated in Figure

3.1, it is a good quantitative measure of how noisy a bilevel image is. To precisely define

NS it is necessary to define the probability that a pixel at a certain distance from the edge

will be above the threshold. This threshold probability (THP) depends on the cumulative

distribution function (CDF) of the noise and is


37

⎛ ⎛x⎞ ⎞
⎜ ESF⎜ ⎟ − Θ ⎟
THP ( x ) = CDFGauss ⎜ ⎝ w⎠ ⎟. (3.1)
⎜ σ noise ⎟
⎜ ⎟
⎝ ⎠

The noisy edge will be above the threshold with probability near 0 on one side of the NS

region and with a probability of near 1 on the other side of the NS region. The THP can

then be represented with a piecewise approximation


⎪ 0 (x + δ c ) ≤ − NS
2
⎪⎪ 1
THP( x) = ⎨ (x + δ c ) − ≤ (x + δ c ) ≤ NS ,
NS
(3.2)
⎪ NS 2 2
NS

⎪⎩
1 (x + δ c ) ≥
2

where

1
NS = . (3.3)
∂ THP
∂x x = −δ
c

The derivative of THP is a function of the noise’s probability density function (PDF)

⎛ ⎛x⎞ ⎞
⎜ ESF⎜ ⎟ − Θ ⎟
PDFGauss ⎜ ⎝ w⎠ ⎟
⎛x⎞ ⎜ σ noise ⎟
LSF⎜ ⎟ ⎜ ⎟
∂ THP ⎝ w⎠ ⎝ ⎠.
= ⋅ (3.4)
∂x w σ noise

Evaluating at x=-δc, which is where ESF(x/w)=Θ, gives

∂ THP
=
(
LSF ESF−1(Θ ) ). (3.5)
∂x x = −δ 2π ⋅ σ noise ⋅ w
c

Substituting this back into Equation 3.3 gives an estimate of the noise spread

2π ⋅ σ noise ⋅ w
NS =
(
LSF ESF −1 (Θ ) ). (3.6)
38

Figure 3.3 The threshold probability (THP) function is shown for a Gaussian PSF with w=1, Θ=0.7
and σnoise=0.1. Noise spread in this case is about .72. The piecewise approximation of
threshold probability is inaccurate at the tails of the THP function.

Figure 3.3 shows the piecewise approximation of the threshold probability curve.

While the piecewise approximation is illustrative it is also fairly crude. The original

definition of the noise spread was the size of the domain in which the values of pixels are

uncertain. This level of uncertainty can be quantified by defining the noise spread as the

breadth of the domain over which the threshold probability is in the range (α,1- α). The

arbitrary cutoff is used to determine the boundaries of the noise spread region. The more

accurate approximation of the THP starts by linearizing the ESF at x=-δc

⎛x⎞
ESF⎜ ⎟ ≈ Θ +
(
LSF ESF −1 (Θ ) )
⋅ (x + δ c ) . (3.7)
⎝ w⎠ w

Substituting this into Equation 3.1 gives

THP ( x ) = CDFGauss ⎜
( )
⎛ LSF ESF −1 (Θ ) ⋅ ( x + δ
c )⎟

. (3.8)
⎜ σ noise ⋅ w ⎟
⎝ ⎠

A parameter Zα can be defined such that


39

1 − α = CDFGauss (Z α ) . (3.9)

Since the Gaussian CDF is odd symmetric, the noise spread region will be centered on δc

so

⎛ NS ⎞
1 − α = THP⎜ ⋅δc ⎟ . (3.10)
⎝ 2 ⎠

This can be evaluated by using Equation 3.8 which gives

1 − α = CDFGauss ⎜
( )
⎛ LSF ESF −1 (Θ ) ⋅ NS ⎞
⎟. (3.11)
⎜ 2σ ⋅ w ⎟
⎝ noise ⎠

NS is then solved for by using Equations 3.9 and 3.11, which produces

2Z α ⋅ σ noise ⋅ w
NS =
(
LSF ESF −1 (Θ ) ). (3.12)

This definition is identical to the one in Equation 3.6 if


Zα = = 1.253 . (3.13)
2

In order to maintain consistency the cutoff defined in Equation 3.13 will be used. The

resulting value of α is 0.105 which is a reasonable level of uncertainty. This cutoff means

that the noise spread is the breadth of the domain over which the threshold probability is

in the range (0.105, 0.895). The edge images in Figure 3.1 show that noise is very

noticeable in images with NS values as low as .2. In most cases NS will be less than the

extreme example on the far right in Figure 3.1. At some point the added noise is extreme

enough that even pixels away from the edge have an uncertain value. When this occurs,

the approximation in Equation 3.8 is no longer valid. Where this occurs depends on the

PSF used and the degradation parameters. Generally the approximation is better when Θ

is close to 0.5 and when noise levels are small. Figure 3.4 illustrates the approximation in
40

Figure 3.4 The threshold probability function given in Equation 3.1 (solid) is compared to the
approximation in Equation 3.8 (dashed) with the parameters w=1, Θ=0.7 and σνοισε=0.1.
The actual threshold probability is a little lower on the tails.

Equation 3.8. The parameters used in Figure 3.4 are extreme; for most sets of degradation

parameters it is very hard to distinguish the results from Equations 3.1 and 3.8.

3.2. Extending Noise Spread to general shapes

Noise spread was introduced for straight edges in Section 3.1, but it is possible to

extend the noise spread theory to arbitrary shapes. In Section 3.1 the noise spread region

was defined to be anywhere the THP is between α and 1-α. This applies directly to

general shapes. However, with the exceptions of isolated straight edges, scanned strokes,

and circles, the noise spread region will not have the same thickness along the boundary

of a general object. For this reason the noise spread must be defined for any point on the

contour C defined by s(x,y)=Θ. To do this NS can be defined as the thickness of the noise

spread region along the direction defined by the gradient at any point on the contour C.
41

NS of an entire object can then be defined as the mean value of the noise spread on the

contour C. If the mean reciprocal of the magnitude of the gradient of s(x,y) along C is

estimated, then this estimate can be used to find the noise spread of the object. To do this

a linearization procedure is required.

If (x0, y0) is a point on the contour s(x,y)=Θ, and the notation sx and sy is used to

denote the partial derivatives with respect to x and y, then the approximation

⎛ s (x , y ) s (x , y ) ⎞
s⎜⎜ x0 + u ⋅ x 0 0 , y 0 + u ⋅ x 0 0 ⎟⎟ ≈ Θ + u ⋅ ∇s ( x0 , y 0 ) (3.14)
⎝ ∇s ( x 0 , y 0 ) ∇s ( x 0 , y 0 ) ⎠

can be made. This relationship can be used to find the value of s(x,y) at any point near the

contour s(x,y)=Θ. Following the reasoning that gave Equation 3.1, the THP can be

represented as a function of u and the magnitude of the gradient

⎛ ∇s u ⎞
THP(u ) = CDFGauss ⎜⎜ ⎟.
⎟ (3.15)
⎝ σ noise ⎠

The noise spread at any point on the contour can be expressed as a function of the

gradient at that point

2 ⋅ Zα ⋅ σ noise
NS ( x0 , y 0 ) = . (3.16)
∇s ( x 0 , y 0 )

The noise spread of the object is just the line integral with respect to arc length divided

by the total arc length L

∫ NS (x, y )dl 2π ⋅ σ noise 1


NS = C = ⋅∫ . (3.17)
L L ∇s ( x , y )
C

In the case of straight edges, scanned strokes, and circles the gradient is constant. For

other shapes the line integral has to be estimated numerically.


42

Noise spread has been generalized to apply to arbitrary shapes. It is a very powerful

measure of the edge noise in binary document images. It makes it possible to compare

noise levels of different objects scanned with different scanner parameters. In Section 3.3

its relationship with the Hamming distance of a scanned object and its noiseless template

is explored.

3.3. Relationship between Noise Spread and Hamming Distance

The real benefit of determining the noise spread of a scanned object is that it provides

an effective measure of how noisy an object is. Since Hamming distance provides a

metric of how different two scanned objects are, it is very useful for analyzing the noise

in bilevel images. The Hamming distance between a template and a scanned character is

determined by the combination of the phase effects and of the noise. The phase effects

were described earlier. If the phase effects are removed by forcing the template and the

scanned object to have the same phase, then the effects of noise alone can be analyzed.

When this is done it is possible to relate the expected Hamming distance H to the noise

spread.

To see how this is true it is best to start with the case of isolated scanned edges. The

probability of error (PE) is defined to relate the expected Hamming distance to the noise

spread. The probability of error is related to the THP and is the probability of a pixel

having a different value because of noise than it would without noise. Formally it is

defined by

⎧ THP( x) x < δc
PE( x) = ⎨ . (3.18)
⎩1 − THP( x) x ≥ δ c

If a vector X is formed to include the distance of each pixel in an image from the original
43

edge, then the expected value of H can be calculated as

E{H } = ∑ PE( x) . (3.19)


x∈X

The Hamming distance depends on the density of pixels ρ(x). The expected Hamming

distance then becomes


E{H } = ∫ ρ (x ) PE( x)dx . (3.20)
−∞

Except under certain circumstances as discussed in Section 2.4, it is reasonable to assume

a uniform distribution of pixels relative to the edge. Using this assumption then ρ(x) is a

constant equal to the length of the edge segment


E{H } = ρ ⋅ ∫ PE(x )dx . (3.21)
−∞

The probability of error is determined by using Equations 3.6 and 3.8 to approximate the

threshold probability. The symmetry of the Gaussian PDF is then used to convert the

threshold probability to the probability of error

⎛ 2π ⎞
PE ( x ) = CDFGauss ⎜ − ⋅ (x + δ c ) ⎟ . (3.22)
⎜ NS ⎟
⎝ ⎠

Substituting this into Equation 3.21 gives

∞ ⎛ ⎞

E{H } = ρ ⋅ ∫ CDF ⎜
Gauss ⎜ − ⋅ ( x + δ ) ⎟
c ⎟. (3.23)
⎝ NS ⎠
−∞

The substitution u=1/NS*(x+δc) gives


E{H } = NS ⋅ ρ ⋅ ∫ CDFGauss (− )
2π ⋅ u du . (3.24)
−∞
44

The integral is just a constant which evaluates to 1/π, so

NS ⋅ ρ
E{H } = . (3.25)
π

This provides a formula relating Hamming distance to noise spread for straight edges and

shows that the Hamming distance is directly proportional to the noise spread. The

relationship between noise spread and Hamming distance can also be found for other

shapes.

The relationship between noise spread of a circle with radius Rf and the Hamming

distance is derived in a similar way. For a circle the THP is a function of the distance

from the center of the circle r. The probability of error is given by

⎧1 − THP(r ) r < R f
PE (r ) = ⎨ . (3.26)
⎩ THP(r ) r ≥ R f

The approximation for THP with arbitrary shapes in Equation 3.15 can be rewritten in

terms of r as

(
⎛ ∇s ⋅ r − R f )⎞⎟
THP(r ) = CDFGauss ⎜ − . (3.27)
⎜ σ noise ⎟
⎝ ⎠

The symmetry of the Gaussian CDF is used to get the probability of error which is

⎛ ∇s ⋅ r − R f ⎞
PE (r ) = CDFGauss ⎜⎜ − ⎟.
⎟ (3.28)
σ noise
⎝ ⎠

This can be written in terms of NS as

⎛ 2π ⎞
PE (r ) = CDFGauss ⎜⎜ − r − Rf ⎟.
⎟ (3.29)
⎝ NS ⎠

In order to approximate the expected Hamming distance it is necessary to assume the

distribution of pixels is uniform. Given this assumption the expected Hamming distance
45

is given by

2π ∞
⎛ 2π ⎞
E{H } = ∫∫ CDFGauss ⎜−
⎜ NS r − R f
⎟rdrdθ .
⎟ (3.30)
0 0 ⎝ ⎠

This evaluates to

⎛ ⎛ πR 2 ⎞ ⎞ ⎛ 2 πR 2 ⎞⎛ ⎛ Rf π ⎞⎞
⎜ ⎜ f ⎟ ⎟ ⎜ NS f ⎟⎜ ⎜ ⎟⎟ .
E{H } = 2 R f NS ⎜1 − exp⎜ − +
⎟⎟ ⎜ 4 + ⎟⎜ 1 − erf (3.31)
⎜ 2
⎜ NS ⎟ ⎟ ⎜ 2 ⎟⎝ ⎜ NS ⎟⎟
⎝ ⎝ ⎠⎠ ⎝ ⎠ ⎝ ⎠⎠

The fraction R f π NS is generally large so the expected Hamming distance can be

approximated by

E{H } = 2 R f NS . (3.32)

The expected Hamming distance of a circle is the same as the expected Hamming

distance of an edge whose length is given by the circumference of the circle.

The linear relationship between noise spread and expected Hamming distance has

been shown for both circles and straight edges. Theory cannot show whether this

relationship holds for arbitrary shapes. Experiments are necessary to explore this

question.

3.4. Noise Spread with varying Noise Levels

In the Sections 3.1 through 3.3 it has been assumed that the noise added in the

degradation model is spatially invariant in its intensity. However, the noise added in the

degradation model is meant to simulate both noise added during scanning and noise on

the original source. There is reason to believe that the noise level on the black parts of the

source image will be different than the noise level on the white parts of the source image.

This is due to the differences between ink and paper.


46

The noise on the source image can be modeled using two parameters to represent the

different noise levels on black and white parts of the original source image. If the noise

on the source image is given by v(x,y), then the variance of that noise qs(x,y) can be

defined as

{ } ⎧ Nb
q s ( x, y ) = E v ( x , y ) 2 = ⎨
o ( x, y ) = 1
o ( x, y ) = 0
. (3.33)
⎩N w

In Section 2.1 it was stated that the coordinate system is usually defined so that Λ would

be one. In the case of analyzing noise this is not the best approach. Instead the coordinate

system is chosen so that Λ is the distance in inches between sample points. The

autocorrelation of the source noise is given by

Rvv ( x1 , y1 , x 2 , y3 ) = q s ( x1 , y1 ) ⋅ δ ( x 2 − x1 , y 2 − y1 ) . (3.34)

If the noise after convolution is given by n(x,y), then the cross-correlation can be found as

as

Rvn ( x1 , y1 , x 2 , y 3 ) = Rvv (x1 , y1 , x 2 , y3 ) ⊗ PSF( x 2 , y 2 ; Λ ⋅ w) . (3.35)

This simplifies to

Rvn ( x1 , y1 , x 2 , y 2 ) = q s ( x1 , y1 ) ⋅ PSF(x 2 − x1 , y 2 − y1 ; Λ ⋅ w) . (3.36)

The autocorrelation of the noise after blurring is then given by

Rnn ( x1 , y1 , x 2 , y 2 ) = Rvn ( x1 , y1 , x 2 , y 2 ) ⊗ PSF(x1 , y1 ; Λ ⋅ w) . (3.37)

If x1=x2 and y1=y2 then the integral can be written out to show

{ }
qb ( x, y ) = E n( x, y )2 = q s ( x, y ) ⊗ (PSF( x, y; Λ ⋅ w))2 . (3.38)

As a consequence of the central limit theorem, the noise after blurring has a Gaussian

distribution. The noise can be modeled as independent which ignores the correlation
47

between pixels in a local area. This is done because a more realistic model would be

difficult to implement.

This thesis only explores varying noise levels in the context of straight isolated edges.

It is useful to derive some of the equations that are used for straight edges. To start with it

is useful to rewrite Equation 3.38 as

qb ( x, y ) = (( N b − N w ) ⋅ o( x, y ) + Nw) ⊗ (PSF( x, y; Λ ⋅ w))2 . (3.39)

To apply this to straight edges the marginal of the squared PSF must be defined


h( x; λ ⋅ w) = ∫ PSF(x, y; Λ ⋅ w)
2
dy . (3.40)
−∞

For a vertical edge the blurred noise is then given by

x ∞
qb ( x ) = ( N b − N w ) ∫ h(t ; Λ ⋅ w)dt + N w ⋅ ∫ h(x; Λ ⋅ w)dx . (3.41)
−∞ −∞

Table 3.1 shows the marginal, cumulative marginal and total volume that results from

using Cauchy and Gaussian PSFs.

In order to apply noise spread theory to these straight edges it is best to use a zero

order approximation of the noise at x=-δc. As long as the noise is relatively constant

inside the noise spread region, then there are no adjustments that need to be made. Since

the variance of the noise depends on convolution with the squared PSF rather than the

PSF, the noise level will vary around the contours of scanned characters. Even for

straight edges the noise levels will vary depending on the values of Θ and w. This makes

it difficult to verify noise spread theory on real scans. Most of the experiments in this

thesis use the simplifying assumption that the noise level is constant for the entire

document.
48

Table 3.1: Functions for calculating blurred noise


Gaussian Cauchy
Squared 1 ⎛
PSF⎜ x, y;
Λ⋅w⎞
⎟ (Λ ⋅ w) 2
PSF
4π (Λ ⋅ w) (2π )2 ((Λ ⋅ w)2 + x 2 + y 2 )
2
⎝ 2 ⎠ 3

h(x) 1 ⎛ Λ⋅w⎞
PSF⎜ x; ⎟ 3(Λ ⋅ w)2
32π (x 2 + (Λ ⋅ w)2 )
4π (Λ ⋅ w)2 ⎝ 2 ⎠ 5/ 2

x 1 ⎛ x⋅ 2 ⎞ 1 (
x 2 x 2 + 3(Λ ⋅ w)2 )
∫ h(t )dt ESF⎜⎜ ⎟ +
−∞
4π (Λ ⋅ w) 2
⎝ Λ ⋅ w ⎟
⎠ 16(Λ ⋅ w) π
2
(
32(Λ ⋅ w)2 π x 2 + (Λ ⋅ w)2
3/ 2
)
∞ 1 1
∫ h(t )dt 4π (Λ ⋅ w) 2
8π (Λ ⋅ w)2
−∞
49

4. HAMMING DISTANCE BETWEEN SCANNED OBJECTS

In Section 3.3 a theoretical basis for relating Hamming distance to noise spread was

developed. The theory only predicts the expected Hamming distance between a noisy

object and a noise free object with the same phase shift. Moreover the theory only proves

this relationship for scanned circles and straight edges. Experiments are conducted to

verify the theory for edges and circles. They are also conducted to prove a relationship

for more general shapes and to provide a relationship between Hamming distance and

noise spread in the case that the phase of the noisy and noise free objects have

independent random phases.

4.1. Hamming Distance between Scanned Edges

The primary purpose of these Hamming distance experiments for edges is to verify

the relationship between Hamming distance and noise spread. These Hamming distance

experiments provide verification that noise spread accounts for most of the effects of w,

Θ, and σnoise. The case where the noisy and noise free images have separate phases is not

considered for straight edges since that involves moving the scanned objects so that the

Hamming distance is minimized, and this analysis does not make sense for edge

segments. In addition as was mentioned in Section 2.1.2 there are two different

techniques for generating scanned edges. For these experiments the technique that

ignores pixels outside of a rectangle aligned parallel to a straight edge is used. The length

of each edge is 60 pixels long. Also degenerate edge orientations, which are vertical
50

edges and edges with slopes represented by fractions of small integers, will not be

considered in these experiments.

Several assumptions were made in Chapter 3 as noise spread was defined. It was

assumed that the perpendicular distance between sample points and the edge are

independent and have a uniform distribution. It was also assumed that the threshold

probability could be approximated by linearizing at x=-δc. These assumptions can be

validated for edges that have non-degenerate orientations.

Several sets of experiments were conducted with different scanner parameters and

edge orientations to determine the relationship between the expected Hamming distance

and the noise spread. For each set of scanner parameters and edge orientations, 1000

simulated scanned edges are created with random phases. For each of these edges the

Hamming distance between the edges and an ideal noise free edge with the same phase is

determined. These Hamming distances are averaged to estimate the expected Hamming

distance for that set of scanner parameters and edge orientations. Table 4.1 shows the

parameters used for the three sets of experiments. The first experiment is designed to

show that noise spread accounts for the effects of w on expected Hamming distance. The

second experiment explores whether noise spread accounts for the effects of Θ on

expected Hamming distance. Finally the third experiment explores the relationship

between the expected Hamming distance and the orientation of the edge.

Table 4.1 Edge experiment parameters


Experiment 1 Experiment 2 Experiment 3
NS 0 through .7 step .1 0 through .7 step .1 0 through .7 step .1
w 1 through 4 step .25 1 1
Θ .3 .2 through .8 step .1 .3
φ 20 20 5 through 40 step 5
51

The results from our edge experiments, Figure 4.1, show a linear relationship between

the expected Hamming distance and the noise spread. Over a range of PSF widths

(Figure 4.1a), thresholds (Figure 4.1b), and edge slopes (Figure 4.1c) the same linear

relationship between NS and Hamming distance holds. There are some outliers that result

when the threshold is varied and the noise spread is large. The outliers can be explained

by the assumption that the ESF is linear throughout the noise spread region. This is less

(a)

(b) (c)
Figure 4.1 The relationship between the expected Hamming distance and the noise spread is shown for
(a) 13 different PSF widths (b) 7 different thresholds and (c) 8 different angles of
inclination. The PSF width, threshold and orientation of the edge don’t affect the
relationship between Hamming distance and noise spread as long as it is not a degenerate
orientation with a slope that can be represented by an irreducible fraction of small integers
such as 0 degrees.
52

true when the threshold is at .2 and .8 and the noise spread is large. The slope on each of

these lines is ρ/π as predicted by Equation 3.25.

It is clear from these edge experiments that noise spread accounts for the interacting

effects of w, Θ and σnoise. The assumptions used to develop noise spread are valid in

practice for straight edges. The relationship between noise spread and Hamming distance

is very strong.

4.2. Hamming Distance of Scanned Circles

Section 3.3 introduced strong theory to show that the expected Hamming distance

between a noisy and a noise free circle with the same phase has a linear relationship to

the noise spread. However some assumptions are made in the noise spread theory, so it

needs to be experimentally verified. Also there is theory which shows that noise free

circles should have very high Hamming distances if they have independent random

phases. Experiments with circles with independent random phases are necessary to

determine how these phase effects and the noise interact.

From the experiments with edges in Section 4.1 it is known that noise spread

incorporates the effects of different values of w, Θ, and σnoise. For in-phase experiments,

where the phase of the noisy and noise free circles is the same, it is necessary to

determine whether the radius of the circle affects the Hamming distance. As was

discussed in Section 2.1.4 the radius of the circle will change when it is scanned. For

these experiments the size of the initial radius is adjusted in order to get the desired final

radius Rf. The phase of the scanned circle is random, but the noisy and the noise free

circles use the same phase. For each set of scanner parameters 1000 scanned circle

images are created. This number of images ensures a good estimate for the expected
53

value of the Hamming distance. For all experiments a PSF width of w=1 and a threshold

of Θ=.3 are used. The noise is varied to produce noise spreads NS ∈{0, 0.1, 0.2, 0.3, 0.4,

0.5, 0.6, 0.7}, and circles of radii Rf ∈{5, 10, 15, 20, 25, 30, 35}. For large amounts of

noise there is some chance that background pixels away from the edge of the circle will

be set. Since the circles are generated on the same size background, these pixels would

give results that do not reflect the edge noise effects. To address this problem, pixels that

did not have N8 connectivity to the main circle were removed.

The results of the in-phase experiments are fairly similar to the results of the edge

experiments. In order to get a meaningful comparison of the Hamming distance of circles

of different sizes, the Hamming distance is divided by the circumference of the circle.

Figure 4.2a shows the results of the in-phase experiments. The different size circles have

very similar results, and the slope is in agreement with Equation 3.32.
54

Up to this point all the experiments on Hamming distance have compared images

with the same phase. Most of the changes in bitmaps of the same shape from sample to

sample result not from additive noise but from changes in phase [1]. The next set of

experiments looks at the Hamming distance of two identical shapes when both the phase

and noise is changed. In addition to the in-phase experiments circles can also be used to

determine the Hamming distance in the independent phase case. The noisy and noise free
55

Noise Spread vs. Normalized


Hamming Distance

Divided by Circumference
Hamming Distance

Noise Spread
(a)
Noise Spread vs. Normalized Noise Spread vs. Normalized
Hamming Distance Hamming Distance
Divided by Circumference

Divided by Circumference
Hamming Distance

Hamming Distance

Noise Spread Noise Spread


(b) (c)
Figure 4.2 Hamming Distance versus noise spread for circles of varying radii. (a) Both images have
the same phase shift (b) Images have random independent phases. (c) Noise spread is
plotted against the Hamming distance for both in-phase and independent phase together
using the average of the results from each radius. The effect of phase is less significant
when the noise spread is higher.

circles are generated with independent random phases. Then the noise free circle is

moved up, down, left and right until the Hamming distance is minimized. The same

scanner parameters are used for the independent phase experiments as for the in-phase

experiments. Because there are more random effects, 10000 circles are used for each set

of scanner parameters in order to provide a better expected value estimate.


56

The approximated phase circle experiments show that the phase shift does not have a

purely additive effect on Hamming distance. There is an interaction between the noise

spread and the fact that the template has a different phase from the scan. This results in a

non-linear relationship between noise spread and Hamming distance. Figure 4.2b shows

the results of the independent phase experiments. There is a very similar relationship

regardless of the radius of the circle. Figure 4.2c shows the results of both the in-phase

and independent phase experiments together. The effects of phase and noise are not

additive. Instead as the noise spread increases, the effect of the phase is less significant.

For circles the expected Hamming distance is higher for images with independent phases

and no noise than it is for images with the same phase and NS=0.7.

4.3. Hamming Distance of Scanned Characters

Straight edges and circles are simple shapes for which formulae relating Hamming

distance and NS can be easily described. Shapes that are more complicated than a single

edge or simple circle are generally of more interest to researchers and practitioners. To

see whether the results presented previously hold on other more arbitrary shapes, the

same set of experiments were run on a character ‘5’. This character was used because it

contains both straight edges as well as curves, plus some corners with various angles. The

experiment consists of simulated scanning of the character, finding the contour of the

character that is formed by thresholding, and then estimating the line integral in Equation

3.17. The noise spread is then adjusted to the desired value by changing the noise level.

The noise spread is plotted against the Hamming distance between the noiseless and

noisy version of the scanned character. Under this construct both the in-phase and

independent phase experiments can be conducted relatively easily.


57

The techniques for simulating the scanning of a character are discussed in detail in

Section 2.1.5. Both the value of the scanned character and the gradient of the scanned

character can be obtained using methods in that section. The contour of the scanned

character where it is equal to Θ can be extracted. However, the contour is sampled

unevenly with respect to arc length. The value of the line integral in Equation 3.17 can be

approximated numerically. The value of the integral over a segment formed by two

adjacent contour points is given by

1⎛ 1 1 ⎞
fi = ⎜⎜ + ⎟ ⋅ ∆li . (4.1)
2 ⎝ ∇S (cxi , cyi ) ∇S (cxi +1, cyi +1 ) ⎟⎠

If there are N points on the contour, including the first point repeated at the end, the NS is

given by

N −1
NS = 2π ⋅ σ noise ⋅
∑ i =1 f i . (4.2)
N −1
∑ i =1 ∆li
Theory does not indicate whether the relationship between noise spread and the

expected Hamming distance will be the same for general scanned characters as it is for

circles and edges. This is especially true for the independent phase case where the

complicated shape of the character can affect the phase estimation. In order to test the

relationship, scanning is simulated for a sans serif ‘5’ with 12pt font and a resolution of

600 dpi.

To determine whether noise spread incorporates the effects of noise on scanned

characters, in-phase experiments were conducted. The scanner parameters used for the

character experiments were w=1, NS ∈{0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7} and Θ ∈{0.2,

0.3, 0.4, 0.5, 0.6, 0.7, 0.8}. The Hamming distance is then normalized by the perimeter of
58

(a) (b)
Figure 4.3 (a) Results of in-phase experiments. (b) Results of independent phase experiments show a
strong relationship between noise spread and expected Hamming distance.
the scanned object after scanning. The results from the in-phase experiments are very

similar to results from circles and edges. Figure 4.3a shows that there is a strong linear

relationship between noise spread and the expected normalized Hamming distance when

the noise free and noisy characters have the same phase. There are some differences in

the Hamming distance that result from different thresholds. Theory provides the strongest

evidence that straight edges and curves should have Hamming distances that are directly

related to noise spread. However, there is no theory about how many pixels should be

changed by noise on the sharp corners of a character. Still, the results suggest that

arbitrary shapes have a similar relationship between noise spread and Hamming distance

as that of circles and edges.

Since the phase of a character after it is scanned is uncertain, it is necessary to

determine the expected Hamming distance when the phase is independent. The same

parameters are used for these experiments as for the in-phase experiments. As is expected

from the experiments in Section 4.2, the effect of phase on Hamming distance is not

additive. As a result the relationship between noise spread and expected Hamming
59

Figure 4.4: The effect of using an independent phase becomes less significant as Noise increases

distance is no longer linear. Figure 4.3b shows that the relationship between noise spread

and Hamming distance is still very strong.

One thing that can be seen by comparing Figures 4.3a and 4.3b is that when the noise

spread is greater, the difference between the in-phase and approximated phase

experiments is less. To illustrate this Figure 4.4 overlays the expect Hamming distance

from both the in-phase and independent phase experiments. As noise spread gets larger,

the additional Hamming distance caused by the template being out of phase with the

scanned image becomes less significant. Also, the normalized Hamming distance in the

zero noise case is significantly lower than it was for circles, which means that NS plays a

bigger role.
60

5. GEOMETRIC MEASUREMENTS OF BILEVEL SCANS

Noise added as part of the document degradation model affects the accuracy of

geometric measurements of bilevel scans. The accuracy of these measurements is also

heavily affected by the fact that digital images are discrete representation of continuous

objects. Even without additive noise, measurement accuracy is reduced by the spatial

sampling and the binarization.

In order to explore how noise spread influences the precision of measurements from

binary scanned images, two separate sets of experiments were performed. The first set of

experiments involves the precision with which the locations of scanned edges can be

determined. The second set of experiments involves locating the position and radius of

scanned circles. The goal of the experiments is to show that noise spread accounts for all

of the influences that the degradation parameters have on the accuracy of these

measurements.

Section 5.1 explores the localizability of scanned edges. A very large set of

experiments are conducted on straight edges. A representative portion of those

experiments is discussed in detail using plots. Section 5.2 discusses the localizability of

scanned circles.

5.1. Localizability of Scanned Edges

The experiments are design to determine whether noise spread accounts for the

effects of Θ and w on scanned edges. The effect of edge orientation is also explored. This
61

is done by generating large numbers of edges with several different sets of scanner

parameters. The variance in the positions of the measured edges indicates their

localizability. If noise spread accounts for most of the effects of Θ and w on scanned

edges, then variances should be similar when noise spreads are the same.

In studying the effect of noise on edge localizability, the research is focused on the

errors in the measurement of scanned edges. The error in this estimated edge is measured

using two numbers. The first number is based on the angles of the two edges with respect

to the x-axis. The angular error is the difference between the angle associated with the

theoretical edge and the angle associated with the measured edge. The second number

used to measure localization error is the distance between the theoretical edge segment

and the estimated edge segment. The distance is obtained by taking the perpendicular

distance of the estimated edge to the midpoint of the theoretical edge segment. The

average distance is positive if the measured edge is above the midpoint of the theoretical

edge and negative otherwise. For each edge orientation and set of scanner parameters 100

scanned edges were generated, and the edge localization errors were found. The mean

and variance of these two localization errors were then plotted to determine the effect of

different scanner parameters on the localizability of scanned edges.

The scanned edge images for these experiments are created using the following

technique. If the angle of the theoretical edge and the x-axis is given by φ, then the

coordinates of the sampling grid are

⎛ ⎞
⎜ ⎟
⎜ 1 ⎟
X = 1,2,3 . . . round ⎜ 20 ⋅ ⎟ (5.1)
2
⎜ −1 ⎛ π ⎞ ⎟
⎜ 1 + tan ⎜ φ ⋅ ⎟ ⎟
⎝ ⎝ 180 ⎠ ⎠
62

and

Y = 1,2,3 . . . 20 . (5.2)

The theoretical edge is then positioned so that the center point of the edge after scanning

is given by

⎛ ⎞
⎜ ⎟
⎜ 1 ⎟
round ⎜ 20 ⋅ ⎟ +1
2
⎜ −1 ⎛ π ⎞ ⎟
⎜ 1 + tan ⎜ ⎟ ⎟
⎝ ⎝ 180 ⎠ ⎠
xcenter = (5.3)
2

y center = 10 + ph , (5.4)

where ph is the random phase shift given by

ph ~ U (0,1) . (5.5)

Sometimes the phase is fixed at .5 so that the effects of noise can be analyzed with a

fixed sampling grid. Given that the edge after scanning goes through the center point, the

y-intercept b of the edge prior to scanning is given by

δc
b = y center − xcenter ⋅ tan (φ ) − . (5.6)
cos(φ )

The grey level value of each pixel is then calculated using the perpendicular distance to

the original edge location. The value of each pixel is given by

s ( x, y ) = ESF(cos(φ )(tan (φ ) ⋅ x − y + b ); w) . (5.7)

Once the value of each pixel is determined, noise is then added and the image is

thresholded. Figure 5.1 shows an example of a scanned edge.


63

Figure 5.1: An example of a straight edge scanned with w=3, Θ=.3 and NS=.6. The solid line shows the
position of the original edge. The dotted line is the theoretical position of the scanned edge
which results from shifting by δc. The center point is the midpoint of the theoretical edge
segment.

5.1.1. Comparing Various Approaches to Finding Edges

In order to assess the localizability of scanned edges it is necessary to examine

different methods of finding edges. Bias or statistical accuracy in the edge measurements

can be studied by taking the mean of the angular errors and the distance for a large

number of scans. In addition the statistical precision or repeatability of edge

measurements can be determined by calculating the variance of the angular errors and the

distances. The methods tested are standard least squares fitting, perpendicular least

squares fitting, and various operators combined with the Hough transform. The operators

used are the Sobel, Prewitt, Roberts, loG and Canny. The data points for the least squares

fitting are the locations midway between each adjacent pair of black and white pixels.

The perpendicular fitting attempts to minimize the squared perpendicular distance

between data points and the line; standard fitting simply uses the squared vertical
64

(a) (b)
Figure 5.2 (a) The variance of angle measurements from perpendicular fitting and standard fitting out
perform the other methods and LoG is particularly poor. (b) The variance of distance
measurements clearly shows that standard and perpendicular fitting both perform markedly
better then the other methods.

(a) (b)
Figure 5.3 (a) The perpendicular and standard fitting both low perpendicular bias. However, this is not
true of the other methods. (b) There is a small angular bias in the standard fitting compared
to the perpendicular fitting. LoG has a very large angular bias.

distances. For these experiments edges were used with a 20 degree incline, w=2, and

Θ=.5. Noise spreads were used in the range [0,.6].

Figures 5.2 and 5.3 show the results of these experiments. From Figure 5.2 it can be

seen that standard and perpendicular fitting perform nearly identically and have more

precise angular measurements than the other methods. The variance of the distance errors

is also significantly lower for standard and perpendicular fitting. Figure 5.3 shows that

the bias in angular measurements is about the same for all of the methods except Sobel.
65

The bias taken from the distance measurements, however, is significantly lower for

perpendicular and standard fitting.

5.1.2. Effect of Threshold

Experiments were conducted in order to demonstrate that the effect of Θ on the

localizability of scanned edges is predicted by the noise spread theory. As was previously

mentioned the experiment is conducted by holding w and φ constant and then plotting the

measurement errors against NS for several different values of Θ. Table 5.1 shows the

parameters used for this portion of the edge experiments. In order to separate imprecision

and inaccuracy that results from a random sampling grid from the imprecision and

inaccuracy that results from noise, these experiments were conducted on both a random

sampling grid and a fixed sampling grid with ph=.5.

Table 5.1: Parameters for threshold experiments


φ 20 degrees
w 2
NS 0 through 0.6 step 0.1
Θ 0.2 through 0.8 step 0.1

The results of the fixed phase experiments are shown in Figures 5.4 and 5.5. Figure

5.4 shows that the edge measurements become more imprecise as the noise spread

increases. They also show that for fixed phase experiments the effect of Θ is accounted

for by the noise spread since different values of Θ have similar relationships between

noise spread and variance of measurement errors. Figure 5.5 shows the bias in

measurements. As would be expected when the noise is zero and the phase is fixed, the

bias is the same regardless of the Θ. As more noise is added there is more randomness

and the bias associated with each value of Θ varies more.


66

(a) (b)
Figure 5.4 (a) Variance of angular error with a fixed sampling grid. (b) Variance of distance
measurements for fixed sampling grid.

(a) (b)
Figure 5.5 (a) Bias in angle measurement with a fixed sampling grid. (b) Bias in edge position
measurement with a fixed sampling grid.

Figure 5.6 shows the results of random phase experiments. As with the fixed phase

experiments, the edge measurements become more imprecise as the noise spread

increases. However, a close examination of Figure 5.6 shows that the relationship

between noise spread and the imprecision appears slightly less linear when random phase

effects are added. The random phase experiments show that as with the fixed phase

experiments the effect of Θ is accounted for by the noise spread. Figure 5.7 shows the

bias in edge measurements with random phase. As would be expected there is more

variation in the inaccuracy of edges when random phase effects are included. No clear

pattern exists between the bias of edge measurements and the noise spread. It is likely
67

(a) (b)
Figure 5.6 (a) Variance of angular error with a random sampling grid. (b) Variance of distance
measurements for random sampling grid.

(a) (b)
Figure 5.7 (a) Bias in angle measurement. (b) Bias in edge position measurement.

that the sample size was too small to measure the small biases in edge measurements, if

any exist to begin with.

5.1.3. Effect of PSF Width

In order to determine the effect of PSF width on the localizability of straight edges, φ

and Θ are held constant, and the measurement errors are plotted against NS for several

different values of w. Experiments were run using both a random phase and a constant

phase. The bias in edge measurements was determined by taking the mean value of the

measurement errors, while the precision or repeatability was determined by taking the
68

(a) (b)
Figure 5.8 (a) Variance of angular error with a random sampling grid and several different values of w.
(b) Variance of distance measurements for a random sampling grid and several different
values of w.

(a) (b)
Figure 5.9 (a) Bias in the orientation measurements of edges with fixed sampling grid and several
different values of w. (b) Bias of distance measurements for a fixed sampling grid and
several different values of w.

variance of the measurement errors. Table 5.2 shows the parameters used for this portion

of the experiments.

Table 5.2: Parameters for PSF width experiments


φ 20 degrees
w 0 through 4 step 0.5
NS 0 through .6 step 0.1
Θ 0.5

Figures 5.8 and 5.9 show the results of the PSF width experiments with fixed phase.

Figure 5.8 shows that the precision of edge measurements decreases as the noise spread

increases. The PSF width does not appear to have a strong effect on the localizability
69

(a) (b)
Figure 5.10 (a) Variance of angular error with a random sampling grid and several different values of w.
(b) Variance of distance measurements for a random sampling grid and several different
values of w.

(a) (b)
Figure 5.11 (a) Bias in the orientation measurements of edges with random sampling grid and several
different values of w. (b) Bias of distance measurements for a random sampling grid and
several different values of w.

once the noise spread is taken into account. The bias of edge measurements as shown in

Figure 5.9 is exactly the same if the noise is zero. As the noise increases the accuracy

varies more, but these differences are not statistically significant.

The results of experiments with a random sampling grid are shown in Figures 5.10

and 5.11. Figure 5.10 shows that when the phase is random the precision of edge

measurements still increases with noise spread but the relationship is less linear.

Threshold has a small effect on the precision of scanned edges once noise spread is taken

into account. The bias of edge measurements when the phase is random has no clear
70

relationship to noise spread. There may be some effects of using different PSF widths on

the bias, but there is no clear pattern, and part of the variation in Figure 5.11 is purely

random.

5.1.4. Effect of Edge Orientation

The orientation of an edge affects the localizability of the edge because of the

anisotropic sampling grid. In Section 2.4 the localizability of noise free edges was

explored using spirographs. However, that approach did not consider the effects of noise.

Table 5.3 shows the parameters used for two experiments on the effect of edge

orientation on geometric measurements. In order to determine how the combination of

noise and edge orientation affect edge localizability, Experiment 1 uses edge orientations

at 5 degree increments, and Experiment 2 specifically chooses edge orientations with

slopes that are irreducible fractions of small integers. As with the other edge experiments

the noise spread is varied from 0 to .6 to show how noise affects localizability. The

experiments are both run twice: one with a fixed sample grid and the other with a random

phase shift.

Table 5.3 Parameters for edge orientation experiments


Experiment 1 Experiment 2
φ 5 degrees through 40 degrees step 5 0, 45, atan(1/2), atan(1/3), atan(1/4),
atan(1/5), atan(1/6)
w 2 2
NS 0 through 0.6 step 0.1 0 through 0.6 step 0.1
Θ 0.5 0.5

Figures 5.12 and 5.13 show the results of Experiment 1 with a fixed sample grid.

While the variance of the distance measurements is not affected much by the different

edge orientations, the variance of the angular error appears to be different for different

edge orientations. This difference suggests that the specific phase that is chosen
71

(a) (b)
Figure 5.12 (a) Bias in the orientation measurements of edges with a fixed sampling grid and several
different edge orientations. (b) Bias in the distance measurements of edges with a fixed
sampling grid and several different edge orientations.

(a) (b)
Figure 5.13 (a) Variance in the orientation measurements of edges with a fixed sampling grid and
several different edge orientations. (b) Variance of the distance measurements of edges with
a fixed sampling grid and several different edge orientations

combined with the true orientation of the edge have an effect on the edge orientation

measurements that is not predicted by noise spread. Figure 5.12 shows that to the extent

that bias in both perpendicular measurements and angular measurements may be affected

by edge orientations this bias is difficult to predict and remove. Also the bias in the

distance measurements when the noise spread is zero is the same regardless of edge

orientation, but the bias in edge orientation measurements for these noiseless edges

depends on the edge orientation.


72

(a) (b)
Figure 5.14 (a) Variance of angular error with a random sampling grid and several different edge
orientations. (b) Variance of distance measurements for random sampling grid and several
different edge orientations.

(a) (b)
Figure 5.15 (a) Bias in the orientation measurements of edges with random sampling grid and several
different edge orientations. (b) Bias of distance measurements for random sampling grid
and several different edge orientations.

Figure 5.14 shows the variance in angular error and distance that results from

Experiment 1 when the sample grid is random. The 5 degree edge has an unusual amount

of variance in the angle measurements. This variance is consistent with the plot of

angular error as a function of slope shown in Figure 2.8b. The perpendicular errors are

fairly similar for the different orientations. Figure 5.15 shows the bias in edge location

measurements for these experiments. No clear patterns of bias are found.

The results from Experiment 2 are much more interesting. Figures 5.16 and 5.17

show the results when the sampling grid is fixed. When the noise is low there is a large
73

(a) (b)
Figure 5.16 (a) Variance of angular error with a fixed sampling grid and degenerate edge orientations.
(b) Variance of distance measurements for a fixed sampling grid and degenerate edge
orientations.

(a) (b)
Figure 5.17 (a) Bias of angular error with a fixed sampling grid and degenerate edge orientations. (b)
Bias of distance measurements for a fixed sampling grid and degenerate edge orientations.

bias in the measurements of certain edge orientations. As noise is added this bias

disappears. The variances all increase with noise spreads, but variances for some edge

orientations grow faster than for others. Because the phase is .5 there are no pixels on a

horizontal edge that are in the noise spread region unless the noise spread is .5 or higher.

Pixels outside the noise spread region can be affected by noise, but there is a low

probability. For the 45 degree edge with a noise spread of 0.1 there are no pixels in the

noise spread region, but there is has a very large amount of measurement error. This is
74

Figure 5.18 (a) Variance of angular error with a random sampling grid and degenerate edge
orientations. (b) Variance of distance measurements for a random sampling grid and
degenerate edge orientations.

Figure 5.19 (a)Bias in the orientation measurements of edges with random sampling grid and
degenerate edge orientations. (b) Bias of distance measurements for random sampling grid
and degenerate edge orientations.

because for a 45 degree edge any pixel that is affected by noise can have a

disproportional effect on the least squares fitting.

When random phase shifts are used, very different results follow. Figure 5.18 and

5.19 show the results of using a random phase. The angular error is essentially what

would be expected; the error increases as the noise increases. However, the distance

variance actually decreases when noise is added to edges with these orientations. The

orientations were specifically chosen because they were known to have large variances in

position in the zero noise case. The variance of the distance measurements in the zero
75

Figure 5.20 Distance and Angular Error for 0 degree edge without noise.

Figure 5.21 Distance and Angular Error for 20 degree edge without noise.

noise case is what is predicted by spirograph theory as discussed in Section 2.4.

However, when these edges have noise added, the edge pixels are more likely to be

affected by noise when the true edge is near the sampling grid than when it is farther

away.

To illustrate how noise effects degenerate edges, Figure 5.20 shows a plot of the

perpendicular and angular error of each of the edges used in the 0 degree edge

experiments when the noise is zero. As expected the angular error is always zero, but the

distance error is uniformly distributed between -0.5 and 0.5. Figure 5.21 shows what
76

Figure 5.22 Distance and Angular Error for 0 degree edge with NS=.3.

Figure 5.23 Distance and Angular Error for 20 degree edge with NS=.3.

happens for the same type of plot from the 20 degree edge. The perpendicular error is

never as large, but different bitmap configurations result in different angular errors.

Figure 5.22 shows what happens to the 0 degree edge when the noise spread is .3. The

noise introduces angular error, but it also reduces the perpendicular error. Finally the

results of the 20 degree edge with noise spread of .3 are shown in Figure 5.23. In both the

20 and 0 degree edges noise causes a greater variety of bitmaps to occur.


77

5.2. Localizability of Scanned Circles

The generalized definition of noise spread allows it to be applied to shapes other than

straight lines. Three sets of experiments were done to determine how w and Θ affect the

localizability of scanned circles. Two parameters were measured from the circle

experiments; one is the measured size of the circle and the other was the distance

between the measured circle center and the true circle center. The parameters are

obtained using the geometric circle fitting method described in Section 2.3. The first

experiment is small and was designed to determine the distribution of the measurements

of scanned circles with a specific set of parameters. The other two experiments are

designed to determine whether the noise spread predicts the localizability of scanned

circles. Table 5.4 shows the parameters used in the two circle experiments.

Table 5.4 Circle Experiment Parameters


Experiment 1 Experiment 2 Experiment 3
w 1 1 through 4 step .5 1
Rf 10 10 10
Θ .4303 0.3 0.2 through 0.8 step
0.1
NS .4 0 through 0.7 step 0.1 0 through 0.7 step 0.1
Number of Samples 10000 1000 1000

The circle localization Experiment 1 is small and is meant to determine the shape of

the probability distributions for the two measurements. Figure 5.24a shows the

cumulative density function for the measured radius of the scanned circle. The

distribution was obtained by sorting the results in ascending order and then plotting each

measured value against the percentage of measurements that have that value or less. A

normal CDF is matched to the data by assuming that the mean is 10 and then measuring

the variance. Figure 5.24b shows the cumulative density function for the distance

between the measured circle center and the actual circle center. The resulting distribution
78

(a) (b)
Figure 5.24: (a) The radius measurements from Experiment 1 have a normal distribution. (b) The
distances between the measured circle centers and the actual circles centers from
Experiment 1 have a Rayleigh distribution.

is a Rayleigh distribution which results from finding the length of a vector defined by two

independent random variables. The Rayleigh distribution has a probability density

function

x ⎛ x2 ⎞
f ( x, σ ) = ⋅ exp⎜ − ⎟. (5.8)
σ 2 ⎜ 2⎟
⎝ 2σ ⎠

The maximum likelihood estimate of the width parameter of the Rayleigh distribution is

obtained by maximizing

N
L(σ ) = ∏ f ( xi , σ ) . (5.9)
i =1

The maximum likelihood can be obtained by taking the natural log

N ⎛ x2 ⎞
l(σ ) = ∑ ⎜ ln ( xi ) − i − 2 ⋅ ln (σ )⎟ . (5.10)
⎜ 2σ 2 ⎟
i =1⎝ ⎠

The maximum occurs when the derivative is zero


79

Figure 5.25 (a)The Rayleigh parameter of the positional error for several different values of w. (b)
Variance of radius measurements for several different values of w.

N
∑ xi2
i 2N
− ) =0. (5.11)
σ ˆ3 σ

The resulting maximum likelihood estimator is

1 N 2
σ̂ = ∑ xi .
2N i
(5.12)

Because we know that there is a Rayleigh distribution, the standard deviation of the

positional error in circle measurements will be estimated using Equation 5.12.

The second experiment was designed to determine whether noise spread accounts for

the effect of w on the localizability of scanned circles. Figure 5.25a shows the maximum

likelihood estimate of the positional error. The noise spread accounts for most of the

effects of w, but when the noise spread is large the value of w is more significant. Figure

5.25b shows the variance in the measured circle size that results from the parameters in

this experiment. As can be seen the variance increases monotonically as the noise spread

increases and is not very dependent on the value of w until the noise spreads becomes

large.
80

Figure 5.26 (a)The Rayleigh parameter of the positional error for several different values of Θ. (b)
Variance of radius measurements for several different values of Θ.

Finally the third experiment shows the effect of Θ on the localizability of scanned

circles. Figure 5.26a shows the maximum likelihood estimate of the positional error

which results from the parameters in this experiment. The figure shows that when the

noise spread is small it accounts for the effects of Θ. However, when the noise spread is

large then the errors are larger when Θ is far from .5. This result is because the CSF has

to be linear in the noise spread region in order for noise spread to predict the effects of

noise. Figure 5.26b shows the variance in the measured circle size. As with the positional

error the error in radius measurements is predicted by noise spread unless the Θ is far

from .5 and the noise spread is large, which puts it outside the linearized noise spread

region.
81

6. CONCLUSIONS AND FUTURE WORK

This thesis shows the effect that noise has on bilevel scanned images. The amount of

edge noise in these images can be quantified by using noise spread. Initially, NS was

derived for scanned edges, and then it was generalized to arbitrary shapes. It was also

generalized to cases where noise levels vary. The noise spread was shown to be related

directly to the expected Hamming distance between a scanned object with and without

noise. It was also shown that while differences in phase affect the expected Hamming

distance between a character and a noiseless template, it is also true that the phase effects

are less significant when the noise spread is larger. The analysis assumed only that the

PSF was symmetrical and that the noise was Gaussian. In addition to showing that noise

spread is a good quantitative measure of noise in document images, it was also shown

that the noise spread predicts the localizability of scanned edges and circles.

This work consists of theory confirmed by simulations. Verifying this theory on real

scans is an area for future work. Using a grey level scan of a straight edge, the position

can be determined with subpixel accuracy. When the image is binarized black or white,

pixels on the wrong side of the located edge are noise. This means that the expected

Hamming distance of a straight edge can be determined. The grey level image can also be

used to determine the PSF width and the threshold level. The biggest difficulty is

determining how much additive noise is present so that the noise spread of the real scan

can be compared to the expected Hamming distance. As was discussed in Section 3.4 the

noise levels are likely to vary because of different amounts of noise on the black
82

foreground as compared to the white paper background. The noise level at the edge

boundary of the grey image is only predicted, it is not known directly. Because of this

uncertainty, while there is a very strong theoretical basis for noise spread, it is a very

difficult thing to prove definitively. Whether noise spread turns out to be a useful

theoretical concept will depend more on its usefulness in improving OCR than on

whether it is the most accurate model of noise in bilevel images.

One promising area of future work involves attempting to measure the noise in

bilevel images. Noise spread is very useful for generating synthetic scans with specified

amounts of noise. It is possible to generate images whose expected Hamming distance is

identical to the expected Hamming distance of real scans. However, if only the bilevel

scans are available, then it is more difficult to determine the Hamming distance. Since it

is noticeable when a bilevel edge has a large amount of noise, it may be possible to create

a pattern recognition system that can detect and quantify edge noise on bilevel images.

Inventive techniques for detecting noise in bilevel images can be tested using synthetic

scanned objects with specified noise spreads. If a technique is found that works on

synthetic scans it can be verified on real scans. Since the noise on bilevel images is

dependent on all of the degradation parameters, we could use a measure of noise to detect

spatial variation of degradation parameters which may result from uneven illumination.

Finally noise spread is a very useful property for testing the robustness of an OCR

system to noise. It has already been shown that simple computer vision tasks like

accurately localizing edges and circles are greatly affected by the noise spread. There is

no reason that similar methods could not be used to determine the effect of noise on OCR

features. Filters may be used to reduce the effect of noise on the features. Experiments
83

could determine how well these filters work under different amounts of noise spread.

Once a method to directly extract the noise spread from the bilevel image is developed, it

can be used to make filters work better.


84

REFERENCES

1. Prateek Sarkar, George Nagy, Jiangying Zhou, Daniel Lopresti, “Spatial


Sampling of Printed Patterns,” IEEE Transactions on Pattern Analysis and
Machine Intelligence, Volume 20, Number 3, March 1998, pp. 344-351.

2. Hok Sum Yam, “Estimating Degradation Model Parameters from Character


Images,” Master thesis, Boise State University, November 2004.

3. Henry S. Baird, “Document Image Defect Models,” Proc. IAPR Workshop on


Syntactic and Structural Pattern Recognition, Murry Hill, NJ, June 1990, pp.
13-15. Reprinted in H. S. Baird, H. Bunke, and K. Yamamoto (Eds.), Structured
Document Image Analysis, Springer Veralg: New York, 1992, pp. 546-556.

4. Elisa H. Barney Smith, “Optical Scanner Characterization Methods using


BilevelScans,” Ph.D. thesis, Rensselaer Polytechnic Institute, December 1998.

5. Elisa H. Barney Smith, “Characterization of Image Degradation Caused by


Scanning,” Pattern Recognition Letters, Volume 19, Number 13, 1998, pp.
1191-1197.

6. Gonzalez, Rafael C., and Richard E. Woods , Digital Image Processing, Second
Edition, Prentice Hall, Upper Saddle River, New Jersey, 2002, pp. 572-591.

7. J.F. Canny, “Finding Edges and Lines in Images,” MIT Artificial Intelligence
Laboratory, Cambridge MA, 1983.

8. Steven J. Gordon and Warren P. Seering, “Accuracy Issues in Measuring


Quantized Images of Straight-Line Features,” IEEE International Confernce on
Robotics and Automation, Volume 2, April 1986, pp. 931-936.

9. W. Gander, G.H. Golub, and R. Strebel, “Least-Squares Fitting of Circles and


Ellipses,” BIT, Volume 34, 1994, pp. 558-578.

10. Leo Dorst and Arnold W. M. Smeulders, “Discrete Representation of Straight


Lines,” IEEE Transactions on PatternAnalysis and Machine Intelligence, Volume
6, Number 4, July 1984, pp. 450-463.

11. L. Dorst and R. P. W. Duin, “Spirograph Theory: A Framework for Calculations


on Digitized Straight Lines,” IEEE Transactions on Pattern Analysis and Machine
Intelligence, Volume 6, Number 5, September 1984, pp. 632-639.
85

12. David I. Havelock, “Geometric Precision in Noise Free Digital Images,” IEEE
Trans. Pattern Analysis and Machine Intelligence, Volume 11, Number 10, Oct.
1989, pp. 1065-1075.

13. A.M. Bruckstein, L. O’Gorman, A. Orlitsky, “Design of Shapes for Precise Image
Registration.” Murray Hill, NJ, AT&T Bell Laboratories Technical
Memorandum, 1989.

14. A. Efrat and C. Gotsman, “Subpixel image registration using circular fiducials,”
International Journal of Computational Geometry and Applications, Volume 4,
Number 4, 1994, pp. 403-422.
86

APPENDIX A

Iso Curves for Cauchy and Gaussian PSF’s

∆/2
Θ
87

∆/2

∆/2
Θ
88

∆/2

∆/2
Θ
89

∆/2

∆/2
Θ
90

∆/2

∆/2
Θ
91

∆/2

∆/2
Θ
92

∆/2

∆/2
Θ
93

Θ
Θ
94

Θ
Θ
95

Θ
Θ
96

Θ
Θ
97

Θ
Θ
98

Θ
Θ
99

Θ
100

APPENDIX B

Code for Calculating ∆

%CalcDelta
%
% CalcDelta(OriginalStroke,ScannedStroke,w,theta,step,PSF_TYPE)
% This is a function that interpolates the value of Delta. Either
% OriginalStroke or ScannedStroke are an empty matrix which indicates
% which of the two is unknown.
%
% CALLS:
% gauss_cdf.m,cauchy_cdf.m
%
% RETURNS:
% Delta: This is the difference between the scanned stroke width
% and the original stroke width
% UnknownStroke: This is either the OriginalStroke or the ScannedStroke
% depending on which was an empty matrix
%
% PARAMETERS:
% OrignalStroke: Either the width of the stroke before scanning or an
% empty matrix
% ScannedStroke: Either the width of the stroke after scanning or an
% empty matrix
% w: Width of the PSF function
% theta: The level at which the scanned image is thresholded.
% PSF_TYPE: Either a gauss or cauchy this is used to determine Delta
% step: This is the step size that is used to interpolate Delta
%
% SYNTAX:
% [Delta,ScannedStroke]=CalcDelta(OriginalStroke,[],w,theta,step,PSF_TYPE)
% [Delta,OriginalStroke]=CalcDelta([],ScannedStroke,w,theta,step,PSF_TYPE)
%
% DEPENDENCIES:
% gauss_cdf.m
% cauchy_cdf.m
%
%Written by: Craig McGillivary Sept 21, 2005
function [Delta,UnknownStroke]=CalcDelta(OriginalStroke,ScannedStroke,w,...
theta,step,PSF_TYPE)
101

for i=1:length(w)
if isempty(OriginalStroke)
eval(['Deltac=min(-w(i)*' PSF_TYPE '_icdf(theta,0,1));'])
eval(['OriginalStrokeMin=min(-2*w(i)*' PSF_TYPE ...
'_icdf((1-theta)/2,0,1));'])
PossibleDelta=[(2*Deltac):step:(ScannedStroke-OriginalStrokeMin)];

eval(['G=' PSF_TYPE '_cdf((-PossibleDelta)/2,0,w(i))-' PSF_TYPE ...


'_cdf((-2*ScannedStroke+PossibleDelta)/2,0,w(i));'])
I=1:length(theta);
Delta(I,i)=(interp1(G,PossibleDelta,theta(I),'linear','extrap'))';

else
eval(['Deltamax=max(-2*w(i).*' PSF_TYPE '_icdf(theta,0,1));'])
eval(['Deltamin=max(-' num2str(OriginalStroke) ',min(2*w(i).*' ...
PSF_TYPE '_icdf((1-theta)/2,0,1)));'])
PossibleDelta=[(Deltamin):step:(Deltamax)];

eval(['G=' PSF_TYPE '_cdf(-PossibleDelta./(2*w(i)),0,1)-' PSF_TYPE ...


'_cdf((-2*OriginalStroke-PossibleDelta)./(2*w(i)),0,1);'])
I=find(theta<=max(G));
I2=find(theta>max(G));
if ~isempty(I)
Delta(I,i)=(interp1(G,PossibleDelta,theta(I),'linear','extrap'))';
end
Delta(I2,i)=-OriginalStroke;
end
end
if isempty(OriginalStroke)
UnknownStroke=ScannedStroke-Delta;
else
UnknownStroke=OriginalStroke+Delta;
end
102

APPENDIX C

Code for Calculating Ri

%CauchyCSFRadius
%
% CauchyCSFRadius(Rf,alpha,theta,tol)
% This is a function that calculates Ri for a Cauchy CSF
% CALLS:
% CauchyCSF - This is calculates the Circle Spread Function assuming
% Cauchy PSF
% cauchyicdf - This calculates the inverse of the Cauchy ESF
%
function R=CauchyCSFRadius(Rf,alpha,theta,tol)
%Add Stat_Tools directory satisfy dependencies.
addpath('M:\Document_Research\Code_Repository\Matlab_Code\Stat_Tools')

%Use inverse of Cauchy ESF to find minimum value for R


esf_inv = cauchy_icdf(theta,0,alpha);
Rmin=Rf+esf_inv;
if Rmin<0
Rmin=0;
end

%Find maximum of R
R=Rf;
while(true)
R=2*R;
[CSF]=CauchyCSF(Rf,alpha,R);
if CSF-theta>0
%Found maximum store it and break out of loop.
Rmax=R;
break;
else
%If CSF was less that theta make current R a new minimum
Rmin=R;
end
end
%Now do binary root finding use tol to determine when result is good enough
while(abs(CSF-theta)>tol)
R=(Rmin+Rmax)/2;
103

[CSF]=CauchyCSF(Rf,alpha,R);
if CSF-theta>0
Rmax=R;
else
Rmin=R;
end
end

Вам также может понравиться