49
Master Thesis Face characterisation based on Gabor filters, Bayes Rule and AdaBoost

Master Thesis - deimURVdeim.urv.cat/~francesc.serratosa/2011_06_20_Abmnurul_Taluckder_MESISI_MasterThesis.pdfmaster’s course and, as well as, this thesis work successfully. I would

  • Upload
    others

  • View
    5

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Master Thesis - deimURVdeim.urv.cat/~francesc.serratosa/2011_06_20_Abmnurul_Taluckder_MESISI_MasterThesis.pdfmaster’s course and, as well as, this thesis work successfully. I would

Master Thesis

Face characterisation based on Gabor filters,

Bayes Rule and AdaBoost

Page 2: Master Thesis - deimURVdeim.urv.cat/~francesc.serratosa/2011_06_20_Abmnurul_Taluckder_MESISI_MasterThesis.pdfmaster’s course and, as well as, this thesis work successfully. I would
Page 3: Master Thesis - deimURVdeim.urv.cat/~francesc.serratosa/2011_06_20_Abmnurul_Taluckder_MESISI_MasterThesis.pdfmaster’s course and, as well as, this thesis work successfully. I would

UNIVERSITAT ROVIRA I VIRGILI

ESCOLA TECNICA SUPERIOR D’ENGINYERIA (ETSE)

Master’s thesis in Computer Security and Intelligent System

Face characterisation based on Gabor filters, Bayes Rule

and AdaBoost

Tarragona, 2011

A.B.M. NURUL AFSER TALUKDER

Supervisor: Dr. Francesc Serratosa

Research team: SSAI – Sensorial Systems Applied to the Industry

Page 4: Master Thesis - deimURVdeim.urv.cat/~francesc.serratosa/2011_06_20_Abmnurul_Taluckder_MESISI_MasterThesis.pdfmaster’s course and, as well as, this thesis work successfully. I would

Abstract

In the last two decades, a lot of research has been carried out related to face

identification and localisation. This research has produced a huge amount of papers

and several interesting methods. At the end, this effort has arrived to the society

through very different fields, such as, face localisation in low-cost cameras, security

systems, medical diagnosis, and so on.

The aim of this master thesis is to compare the most common methods used and find

some similarities in their performance. The methods studied in depth are the Bayes

Classifier and AdaBoost. We want to analyse in dept the behaviour of each method and

compare in which cases one of them outperforms the other one.

In general, AdaBoost has to outperform the Bayes Classifier since it has the capacity to

iterative weight the goodness of the samples. Nevertheless, it can fall to minimum

locals that depend on the features of the algorithm instead of the features of the data.

Several methods have been used to extract the features of faces given images. The most

common are Haar Filters and Gabor filters. In this master thesis, we aim to use Gabor

filters since they have a most solid mathematical basis.

Page 5: Master Thesis - deimURVdeim.urv.cat/~francesc.serratosa/2011_06_20_Abmnurul_Taluckder_MESISI_MasterThesis.pdfmaster’s course and, as well as, this thesis work successfully. I would

Acknowledgement

First of All I thank to the Greatest Almighty for making me able to complete my

master’s course and, as well as, this thesis work successfully.

I would like to express my appreciation to my advisor Prof. Dr. Francesc Serratosa

whose encouragement, supervision and support from the preliminary to the

concluding level enabled me to develop and understanding of the subject. Thanks

for giving me the opportunity to be a part of the SSAI.

I am indebted to the URV for the scholarship I obtained for the educational journey

to this University.

I dedicate this thesis to my parents who unremittingly supported me during my

years of study and for their love through all this long process. They made this work

possible.

Page 6: Master Thesis - deimURVdeim.urv.cat/~francesc.serratosa/2011_06_20_Abmnurul_Taluckder_MESISI_MasterThesis.pdfmaster’s course and, as well as, this thesis work successfully. I would

Table of Contents

List of Figures: .............................................................................................................................................. 7

Chapter 1: Introduction ............................................................................................................................ 9

Background ................................................................................................................................................ 9

Problem Description........................................................................................................................... 10

Chapter 2: Literature Review ............................................................................................................. 13

Gabor Filter ............................................................................................................................................. 13

Definition ............................................................................................................................................. 13

Elliptical Gabor Filter: .................................................................................................................... 14

Selection of filter parameters:.................................................................................................... 15

Learning Algorithm ............................................................................................................................. 16

Naive Bayes Classifier: ................................................................................................................... 17

AdaBoost .............................................................................................................................................. 19

Chapter 3: Methodology ........................................................................................................................ 23

Selection of filter parameters: ........................................................................................................ 23

The implementation of the Naïve Bayes Classifier: .............................................................. 24

Learning the most discriminant Gabor features by AdaBoost ........................................ 26

Chapter 4: Experimental Results ...................................................................................................... 29

Chapter 5: Conclusion ............................................................................................................................ 37

Appendix A: Terminology .................................................................................................................... 39

Appendix B: Sample codes ................................................................................................................... 41

Bibliography ............................................................................................................................................... 48

Page 7: Master Thesis - deimURVdeim.urv.cat/~francesc.serratosa/2011_06_20_Abmnurul_Taluckder_MESISI_MasterThesis.pdfmaster’s course and, as well as, this thesis work successfully. I would

7 | P a g e

List of Figures:

Figure 1: Process flow of the proposed work

Figure 2: Four types of rectangular Haar wavelet-like features. A feature is a scalar

calculated by summing up the pixels in the white region and subtracting those in the

dark region

Figure 3: Gabor filter composition for signal (a) sinusoid, (b) a Gaussian kernel, (c)

the corresponding Gabor filter

Figure 4: Implementation steps of Naïve Bayes Classifier

Figure 5: Implementation steps of AdaBoost algorithm

Figure 6: the AdaBoost algorithm

Figure 7: shows the process flow of the Naïve Bayes classifier

Figure 8: shows the probability calculation for construction weak learners

Figure 9: shows the 30 eye image dataset.

Figure 10: shows the 30 non eye image dataset.

Figure 11: shows sample test images set Figure 12: the first row shows the 2D outputs and the second row shows the surface plot of the EGF filter Figure 13: sample plot for probability of being eye (blue) and non-eye (red) for a filter Figure 14: shows the process and the classified output result of Naïve Bayes

Figure 15: the results of classifying the eyes in our face dataset using Naïve Bayes (a-

g) and AdaBoost classifier (h-n)

Figure 16: shows the final eye detection results of the face dataset

Page 8: Master Thesis - deimURVdeim.urv.cat/~francesc.serratosa/2011_06_20_Abmnurul_Taluckder_MESISI_MasterThesis.pdfmaster’s course and, as well as, this thesis work successfully. I would

8 | P a g e

Page 9: Master Thesis - deimURVdeim.urv.cat/~francesc.serratosa/2011_06_20_Abmnurul_Taluckder_MESISI_MasterThesis.pdfmaster’s course and, as well as, this thesis work successfully. I would

9 | P a g e

Chapter 1: Introduction

Image processing and computer vision are among the most heavily-researched fields in

computer science, and facial detection and recognition have each been extensively

explored. A wide variety of approaches drawing on many computer science and electrical

engineering disciplines have been applied to these two problems with varying success. In

the recent years, the advancement in the computer technology has put more emphasize on

this research field and the development of different face recognition and characterization

techniques both in 2D and 3D images. The need for this kind of technology in several

different areas keeps pushing the research forward every year. Most commonly used in

practice by law enforcement for human identification purposes, face recognition systems

can also be used in other different significant areas for controlling processes (e.g. an

industrial robot or an autonomous vehicle), detecting events (e.g. for visual surveillance),

organizing information (e.g. for indexing databases of images and image sequences),

modeling objects or environments (e.g. medical image analysis or topographical modeling),

interaction (e.g. as the input to a device for computer-human interaction).

Humans seem to recognize faces in cluttered scenes with relative ease, having the

ability to identify distorted images, coarsely quantized images, and faces with

occluded details. Machine recognition is much more daunting task. Face recognition is a

task so common to humans, that the individual does not even notice the extensive number

of times it is performed every day. Understanding the human mechanisms employed to

recognize faces constitute a challenge for psychologists and neural scientists. Although

research in automated face recognition has been conducted since the 1960’s, it has only

recently caught the attention of the scientific community. Many face analysis and face

modeling techniques have progressed significantly in the last decade [18]. However, the

reliability of face recognition schemes still poses a great challenge to the scientific

community.

Background In the last two decades, a lot of research has been carried out related to face identification

and localization. This research has produced a huge amount of papers and several

interesting methods. The first methods were based on the 2D static and dynamic images.

Nevertheless, at the beginning of the current century, the third dimension contributes to

characterize faces in a better way and so, to increase the quality of the systems. Research

Page 10: Master Thesis - deimURVdeim.urv.cat/~francesc.serratosa/2011_06_20_Abmnurul_Taluckder_MESISI_MasterThesis.pdfmaster’s course and, as well as, this thesis work successfully. I would

10 | P a g e

activities in the face recognition domain have escalated due to its promising applications,

such as in building/store access control, suspect identification and surveillance. However, a

few can achieve a completely reliable performance due to the wide variations in the

appearance of a particular face with changes in pose, illumination, facial markup and facial

expression, especially when only one prototype face per person is stored.

Problem Description Face detection can be regarded as a more general case of facial feature localization. In facial

feature localization, the task is to find the locations of different facial feature i.e. eyes, nose,

mouth etc and extract the features form a set of images. The main target of this work is to

extract faces from the 2D images using Gabor Filter and for the initial part we considered to

extract eyes from a face. For accomplishing the initial target we have worked with our eye

database extracted from different images from a face database. In order to improve the

real-time and veracity performance of the eye location method, we have chosen the

Elliptical Gabor filter to convolute with the face image to highlight the eye region, which

can be exploited to segment the two pupil regions efficiently [1]. Comparing with other

algorithms, we have chosen this algorithm as it takes less input parameters and faster in

performance. Then we have implemented the Naïve Bayes Classifier and AdaBoost

classifier to classify the eyes from the non-eyes by these two classification methods from

the training set of eye and non-eye images and finally we tried to compare the results to

find out which classification method outperforms.

Figure 1: Process flow of the proposed work

Eye location plays an important role in the image normalization because eyes are the most

salient facial features, holding a comparatively fixed position on the face. The distance

between eyes is not easily influenced by the change of the face pose and expression. Also

the line of eye centre doesn’t bend when the face deflects. So normalizing the feature based

on eyes, the feature will have inflexibility to translation, rotation and scale [2]. As a result,

eye location usually is the first step in the face recognition system.

Eye and Non Eye

Dataset

Gabor Filter

Outputs

Naïve Bayes

Classifier

AdaBoost

Classifier

Compare the

classification

results

Page 11: Master Thesis - deimURVdeim.urv.cat/~francesc.serratosa/2011_06_20_Abmnurul_Taluckder_MESISI_MasterThesis.pdfmaster’s course and, as well as, this thesis work successfully. I would

11 | P a g e

There are different methods applied in the face detection techniques to extract the facial

features. Although many different algorithms exist to perform face detection, each has its

own weakness and strength. Some use flash tones, some use contours, and other are even

Figure 2: Four types of rectangular Haar wavelet-like features. A feature is a scalar calculated by

summing up the pixels in the white region and subtracting those in the dark region

more complex involving templates, neural networks, or filters. Among these techniques, we

have considered two of them and analyzed their features. One is the Haar classifiers,

devised by Viola and Jones [19], and the other is the Gabor filter.

The core basis for Haar classifier object detection is the Haar-like features. These features,

rather than using the intensity values of a pixel, use the change in contrast values between

adjacent rectangular groups of pixels. The contrast variances between the pixel groups are

used to determine relative light and dark areas. Two or three adjacent groups with a

relative contrast variance form a Haar-like feature. Haar like features, as shown in figure[2]

are used to detect image [20]. Haar features can easily be scaled by increasing or

decreasing the size of the pixel group being examined. This allows features to be used to

detect objects of various sizes.

Gabor Filter, named after Dennis Gabor, is a linear filter used in face detection. Frequency

and orientation representation of Gabor filters are similar to those of the human visual

system, and they have been found to be particularly appropriate for texture representation

and discrimination.

In our work, we have considered the Gabor filter to extract the eyes from the images as the

responses of this filter is much more efficient than the Haar like features to extract the eye

regions from the face. Another reason for choosing the Gabor filter is that there are a lot of

work done with the Haar like features and the AdaBoost classifier, but we would like to

implement the Gabor filter with the AdaBoost classifier and Naïve Bayes classifier.

In the chapter 2, we summarized the literature on Gabor filter, Naïve Bayes Classifier and

AdaBoost classification. In chapter 3, we defined the details methodology applied in our

work to implement the proposed algorithms. In chapter 4, we showed the experimental

results of our work and the comparison of the results of two classification algorithm.

Page 12: Master Thesis - deimURVdeim.urv.cat/~francesc.serratosa/2011_06_20_Abmnurul_Taluckder_MESISI_MasterThesis.pdfmaster’s course and, as well as, this thesis work successfully. I would

12 | P a g e

Finally, in chapter 5 concluding remarks are stated. Future works, which may follow this

study, are also presented.

Page 13: Master Thesis - deimURVdeim.urv.cat/~francesc.serratosa/2011_06_20_Abmnurul_Taluckder_MESISI_MasterThesis.pdfmaster’s course and, as well as, this thesis work successfully. I would

13 | P a g e

Chapter 2: Literature Review

This chapter deals with the basic concepts of different methodologies that are implemented

in this thesis work. After reading this chapter you can get the basic ideas of the Gabor filter

which is mostly used in face recognition process, and two different classification methods:

Naïve Bayes classification method and AdaBoost classification method. The face

recognition task is primarily a complex task to be achieved. This process that we have

followed to achieve this task are:

Extract the important features (i.e. eyes in our case) from the image using the Gabor

filtering technique.

Classify the images using the learning technique using the eye and non eye images

with Naïve Bayes Classification technique.

Then classify the images with another learning technique AdaBoost with the same

eye and non eye images.

Finally, compare the results of the two classification method and analyze the results

found in this two classification method.

Gabor Filter

Definition The Gabor filters started gaining popularity in the field of image processing in 1980 when

Gabor [14] first defined, and later extended to two dimensions by Daugman [15] showed

that the kernels exhibit many properties common to mammalian cortical simple cells.

Certain specific bands of frequency components can be extracted by adjusting the

orientation and center frequencies of the Gabor filter. They have enjoyed much attention in

the field of 2D face recognition and associated fields [16, 17] as researchers attempt to

Page 14: Master Thesis - deimURVdeim.urv.cat/~francesc.serratosa/2011_06_20_Abmnurul_Taluckder_MESISI_MasterThesis.pdfmaster’s course and, as well as, this thesis work successfully. I would

14 | P a g e

emulate and surpass the face recognition capabilities of human being. A Gabor filter is a

complex sinusoid modulated by a Gaussian function. This filter will therefore respond to

some frequency, but only in a localized part of the signal. This is illustrated in figure[3].

(a) (b) (c)

Figure 3: Gabor filter composition for signal (a) sinusoid, (b) a Gaussian kernel, (c) the

corresponding Gabor filter

There are some existing algorithms to locate eyes [2] [3-6]. Gabor filter has also been used

to this realm [7] locates eyes based on the GaborEye model and radial symmetry operator.

The work [8] uses Gabor and a genetic search algorithm to find eyes. Gabor filter and gray

projection are combined to locate eye in [9]. Although all these methods can locate eyes,

but they are not robust enough to illumination odds, face rotation, expression variation and

other problems. The shape of the eye contour is elliptical, so the elliptical filter is devised in

our work.

Elliptical Gabor Filter: The shape of Elliptical Gabor Filter likes an ellipse. Its form is similar to the Traditional

Gabor Filter (TGF), both of which are Gaussian functions modulated by the sine function.

The difference between them is the shape of the sine function. The elliptical Gabor Filter is

defined as follows:

Page 15: Master Thesis - deimURVdeim.urv.cat/~francesc.serratosa/2011_06_20_Abmnurul_Taluckder_MESISI_MasterThesis.pdfmaster’s course and, as well as, this thesis work successfully. I would

15 | P a g e

where (x’ , y’ ) = (x cos + y sin ,-x sin + y cos) and F is the spatial central frequency of

the filter in the frequency domain, g(x, y) is 2-D Gaussian envelope as follows:

where x and y are variances (scale factors) along x and y axes respectively. (x, y) is the

center of the receptive field in the spatial domain, θ is the rotation angle of the filter.

On the one hand the EGF embodies the orientation selectivity of the TGF; on the other hand

it matches the eye in shape. So the EGF can easily highlight the edge of eyelids.

When the frequency is appropriate, the horizontal EGF can stand out the eye region

efficiently wherever the image is frontal or rotating. So when designing the EGF, only three

parameters of x, y and F are took into account in this paper, which simplifies the filter to

some degree.

Selection of filter parameters:

Similar to Traditional Gabor Filter (TGF), this Elliptical Gabor filter can be configured to

have various shapes, bandwidths, center frequencies and orientations by adjusting certain

parameters. On the one hand the EGF embodies the orientation selectivity of the TGF; on

the other hand it matches the eye in shape. So the EGF can easily highlight the edge of

eyelids.

When the frequency is appropriate, the horizontal EGF can stand out the eye region

efficiently wherever the image is frontal or rotating. So when designing the EGF, only three

parameters of σx , σy and F are took into account in this paper, which simplifies the filter to

some degree.

The Gabor filter design is to choose a group of optimum parameters so as to enhance the

eye region. In general, the frequencies of the useful part in the signal to be processed are

not only. If using one frequency, the result will not be perfect. So a bank of filter with multi-

Page 16: Master Thesis - deimURVdeim.urv.cat/~francesc.serratosa/2011_06_20_Abmnurul_Taluckder_MESISI_MasterThesis.pdfmaster’s course and, as well as, this thesis work successfully. I would

16 | P a g e

frequency is adopted usually. When the basic frequency of signal is single and stable, a set

of optimal parameter (σx ,σy , F) can be determined to locate eyes.

The gray value of eyes changes more violently in the horizontal direction, including more

edge information. So the width of eyes is used as reference when designing the scale factor

of filter. In our work, in the training process we used eye images of 25x39 pixels. The width

of the eye portion W is about 28-33 pixels. In the scope of [-3σy, 3σy] , The energy that the

Gaussians possess is nearly to 99.7% [11]. In order to ensure that the band of Gabor filter

cover the whole eye width in horizontal direction, σy and W must satisfy the relation: σy / 6

= W . The ratio of the eye width W and eye height H is about 2.2:1, so it is 5σx /66 = W . Thus

the scale of the EGF is determined.

The research on the visual cells of the mammal shows that the spatial frequency bandwidth

in the receptive hold drops into 0.5-2.5 octave, no matter that the cell is simple or

complicate. According to the constraint condition:

Where is frequency bandwidth and {0.5, 2.5}. So the central frequency F [1/12σx ,

5/12σx].

Learning Algorithm

Face recognition is a multi-class problem; therefore we need to classify the images that are

most relevant to the successful recognition process. For this reason we have researched

different classification algorithm which better suffices our problem area. We have selected

two different types of classification algorithm; Naïve Bayes Classifier and the renowned

boosting algorithm AdaBoost. A face recognition system comprises two stages: training and

testing. In practical applications, the small number of available training face images and

complicated facial variations during the testing stage are the most difficult problems for

current face recognition systems.

Page 17: Master Thesis - deimURVdeim.urv.cat/~francesc.serratosa/2011_06_20_Abmnurul_Taluckder_MESISI_MasterThesis.pdfmaster’s course and, as well as, this thesis work successfully. I would

17 | P a g e

In our work, we have worked with two different types of learning algorithm to get the

classified output extracted from the Gabor filters. In the first approach, we have applied the

Naïve Bayes classifier algorithm and in the next approach, we have implemented the

AdaBoost.

Naive Bayes Classifier: A Bayes classifier is a simple probabilistic classifier based on applying Bayes' theorem

(from Bayesian statistics) with strong (naive) independence assumptions. A more

descriptive term for the underlying probability model would be "independent feature

model".

In simple terms, a naive Bayes classifier assumes that the presence (or absence) of a

particular feature of a class is unrelated to the presence (or absence) of any other feature.

For example, a fruit may be considered to be an apple if it is red, round, and about 4" in

diameter. Even if these features depend on each other or upon the existence of the other

features, a naive Bayes classifier considers all of these properties to independently

contribute to the probability that this fruit is an apple.

Depending on the precise nature of the probability model, naive Bayes classifiers can be

trained very efficiently in a supervised learning setting. In many practical applications,

parameter estimation for naive Bayes models uses the method of maximum likelihood; in

other words, one can work with the naive Bayes model without believing in Bayesian

probability or using any Bayesian methods. For more information a wiki definition of this

classifier can be referred [10].

An advantage of the naive Bayes classifier is that it requires a small amount of training data

to estimate the parameters (means and variances of the variables) necessary for

classification. Because independent variables are assumed, only the variances of the

variables for each class need to be determined and not the entire covariance matrix.

Page 18: Master Thesis - deimURVdeim.urv.cat/~francesc.serratosa/2011_06_20_Abmnurul_Taluckder_MESISI_MasterThesis.pdfmaster’s course and, as well as, this thesis work successfully. I would

18 | P a g e

The naive Bayes classifier combines this model with a decision rule. One common rule is to

pick the hypothesis that is most probable; this is known as the maximum a posteriori or

MAP decision rule. The corresponding classifier is the function classify defined as follows

(from Wikipedia):

Now this means, that for each possible class label, multiply together the conditional

probability of each feature, given the class label. This means, for us to implement the

classifier, all we need to do, is compute these individual conditional probabilities for each

label, for each feature, p(Fi | Cj), and multiply them together with the prior probability for

that label p(Cj). The label for which we get the largest product, is the label returned by the

classifier.

Figure 4: Implementation steps of Naïve Bayes Classifier

For the parameter estimation, our training data contains a continuous attribute that is the

output for different filters. We first segment the data in two classes; one class represents

the filter outputs given that they contains eyes and other class represents the filter outputs

for non-eye. And then compute the mean and variance of outputs of each class. Let μc be the

mean of the values in x associated with class c, and let be the variance of the values in x

associated with class c. Then, the probability of some value given a class, P(x = v | c), can be

computed by plugging v into the equation for a Normal distribution parameterized by μc

and . That is,

Face Database of

eye and non eye

images

EGF Filter

Naïve Bayes Classifier

Classified Output

Page 19: Master Thesis - deimURVdeim.urv.cat/~francesc.serratosa/2011_06_20_Abmnurul_Taluckder_MESISI_MasterThesis.pdfmaster’s course and, as well as, this thesis work successfully. I would

19 | P a g e

We have to calculate the probability for each of the class and then we have to compare the

product probability of each class whether the probability of eye or non-eye is greater or

not. If greater then we can classify as an eye and if not then it is a non-eye.

AdaBoost

A large number of experimental studies have shown that classifier combination can exploit

the discriminating power of individual feature sets and classifiers. With the success of

boosting in the application of face detection, boosting, as one of the most commonly used

methods of combining classifiers based on statistical resampling techniques, has shown

strong ability to resolve the two-class problem. In our work, classifying between eye and

non eye terms are used to describe whether two different images are from the same

subject, naturally, AdaBoost, a version of the boosting algorithm, is taken to solve this two-

class problem. Therefore we used AdaBoost for training the weak classifiers to build a

strong classifier.

AdaBoost, short for Adaptive Boosting, is a machine learning algorithm, formulated by Yoav

Freund and Robert Schapire [12]. AdaBoost is adaptive in the sense that subsequent

classifiers built are tweaked in favor of those instances misclassified by previous classifiers.

AdaBoost takes as input a training set S = (x1, y1),…..,(xm, ym) where each instance, xi, belongs

to a domain or instance space X, and each label yi belongs to a finite label space Y. Here we

will only focus on the binary case when Y = {-1, +1}.

Each round, m = 1,…,M, AdaBoost calls a given weak or base learning algorithm which

accepts as an input a sequence of training examples S along with a distribution or set of

weights over the training example, Wt(i). Given such an input the weak learner computes a

weak classifier, ht {-1, +1}. In general, ht has the form ht : X R. We interpret the sign of

ht(x) as the predicted label to be assigned to instance x. Once the weak classifier has been

Page 20: Master Thesis - deimURVdeim.urv.cat/~francesc.serratosa/2011_06_20_Abmnurul_Taluckder_MESISI_MasterThesis.pdfmaster’s course and, as well as, this thesis work successfully. I would

20 | P a g e

received, AdaBoost chooses a parameter t R that intuitively measures the importance

that it assigns to ht.

Figure 5: Implementation steps of AdaBoost algorithm

The idea of boosting is to use the weak learner to form a highly accurate prediction rule by

calling the weak learner repeatedly on different distributions over the training examples.

Initially, all weights are set equally, but each round the weights of incorrectly classified

examples are increased so that those observations that the previously classifier poorly

predicts receive greater weight on the next iteration. A generalized version of Freund and

Schapire’s AdaBoost algorithm [12] is shown in the figure[6].

Extracting

Gabor feature of

eye images

Extracting

Gabor feature of

non eye images

x = y

x != y

Positive sample

set. All samples

are +1.

Negative sample

set. All samples

are -1.

Ad

aBoost

A strong

classifier

Page 21: Master Thesis - deimURVdeim.urv.cat/~francesc.serratosa/2011_06_20_Abmnurul_Taluckder_MESISI_MasterThesis.pdfmaster’s course and, as well as, this thesis work successfully. I would

21 | P a g e

Figure 6: the AdaBoost algorithm

Page 22: Master Thesis - deimURVdeim.urv.cat/~francesc.serratosa/2011_06_20_Abmnurul_Taluckder_MESISI_MasterThesis.pdfmaster’s course and, as well as, this thesis work successfully. I would

22 | P a g e

Page 23: Master Thesis - deimURVdeim.urv.cat/~francesc.serratosa/2011_06_20_Abmnurul_Taluckder_MESISI_MasterThesis.pdfmaster’s course and, as well as, this thesis work successfully. I would

23 | P a g e

Chapter 3: Methodology

In this part of the paper, we will describe the process of implementing the aforementioned

basics for detecting the eyes from a face image. First we will define the selection procedure

of the parameters of the Gabor filter for getting the desired frequency to extract the eye in

the image. Then we will describe the process to implement the learning algorithms to

classify the eyes from the non eyes. We have used the Naïve Bayes classifier first then the

AdaBoost algorithm. In the following section, we will explain the detailed process for each

of the steps.

Selection of filter parameters: According to the defined selection procedure in chapter 2, we have selected our

parameters and a bank of frequencies for getting better outputs of the Gabor filter. Here in

our work we have selected 15 different frequencies to enhance the eye region. In general,

the frequencies of the useful part in the signal to be processed are not only. If using one

frequency, the result will not be perfect. So a bank of filter with multi-frequency is adopted

usually to get a better solution to get the eye regions separated from other images. The

bank of filter with 15 frequencies that we have chosen for our research work is:

[.145, .152, .155, .1583, .16, .164, .1681, .171, .1732, .175, .178, .1811, .183, .185, .187]

As we have mentioned earlier that we will use only three parameters for simplifying the

filtering process to some degree, we kept the other two parameters fixed and just changing

the frequencies. The value we have chosen for σx , σy are 2.3 and 5.0 respectively according

to the measurement that we have described. And we have considered the other parameter

theta = 0 that means that we are not considering the orientation to keep the work simple.

In figure 1, we can see the filter outputs in 2D and 3D views.

Page 24: Master Thesis - deimURVdeim.urv.cat/~francesc.serratosa/2011_06_20_Abmnurul_Taluckder_MESISI_MasterThesis.pdfmaster’s course and, as well as, this thesis work successfully. I would

24 | P a g e

After applying the EGF in the input images we tried to train our system with an eye

database and a non-eye database which we have further used to implement the Naïve

Bayes Classifier to classify an image containing a eye and non-eye. In the next section we

will first describe about the classifier and then give the details implementation of our

system.

The implementation of the Naïve Bayes Classifier:

In our work, we have a set of Gabor filter bank result for a set of training images. Now we

will try to classify a new input image using the Naïve classifier to identify the eye regions

using the supervised learning. For this, we have calculated the mean and standard

deviation for each of the Gabor filter outputs for both the eye and the non-eye training

sets. Now take a new image that we want to classify using the Naïve classifier. Calculate the

filter output of this image for each of the Gabor filters and then convolute the image with

the filter output. We have to calculate the probability for each of the outputs of the

convolution given eye and non-eye using the probability distribution function shown in the

naïve classifier definition. When we have got the probabilities for each of the class, we have

to calculate the probability product for the eye and for the non-eye. Now we want to

classify the eye and non-eye regions of the input image that we want to classify. For doing

this, we will compare the production result pixel by pixel and if the probability for a pixel

given eye is greater than or equal to the probability for the same pixel given non-eye, we

will change the value to 255 otherwise changes the value to 0. So the output of the

comparison will give us a binary image containing the values 0 or 255. It means that the

resulting image will be white in portions where the probability of being an eye is grater and

rest of the potions will be black. Form this resulting image we can easily classify the eye

regions of the input image based on the training set.

The process flow for the implementation of Naïve Bayes classifier using the Gabor filter

outputs for the eye and non eye images are shown in the figure. Here we have shown

graphically each phase of the process with the rectangular box and the flow.

Page 25: Master Thesis - deimURVdeim.urv.cat/~francesc.serratosa/2011_06_20_Abmnurul_Taluckder_MESISI_MasterThesis.pdfmaster’s course and, as well as, this thesis work successfully. I would

25 | P a g e

Figure 7: shows the process flow of the Naïve Bayes classifier

Extract Gabor filters

output G1-G15

Extract Gabor

filters output G1-G15

Resulting matrix of Convolution of each image with the filter output,

a 30x15 matrix.

Compute mean and

standard deviation for

each Gabor filter (,) for

eye images.

Compute mean and

standard deviation for

each Gabor filter (,) for

non eye images.

Resulting matrix of Convolution of each image with the filter output,

a 30x15 matrix.

a vector for mean

a vector for standard

deviation

a vector for mean

a vector for standard

deviation

Calculate the

Probability of eye Calculate the

Probability of non eye

Classified

Output

Page 26: Master Thesis - deimURVdeim.urv.cat/~francesc.serratosa/2011_06_20_Abmnurul_Taluckder_MESISI_MasterThesis.pdfmaster’s course and, as well as, this thesis work successfully. I would

26 | P a g e

Learning the most discriminant Gabor features by AdaBoost

In our work, we have the Gabor filtered images for both eyes and non eyes, and we have to

use the AdaBoost algorithm to classify the eye images from the non eye images. When we

will finish the boosting procedure, we will get the strong classifiers. For generating the

strong classifiers from the weak classifiers we have used the following procedures:

1. Initialize the yi values for the eyes as +1 and for non eyes as -1.

2. Initialize the weights W for eyes and non eyes as defined in the algorithm.

3. Iterate for each filter:

Calculate the weighted output for each eye images

Calculate the weighted output for each non eye images

Calculate the mean and standard deviation for eye and non eye

Iterate for all images:

o Calculate the probability given it is an eye

o Calculate the probability given it is a non eye

o If probability of being eye is greater than probability of being non eye,

we will tag hm as +1 and otherwise -1.

Calculate the error according to the algorithm.

If m >= 0.5 then stop

Calculate the m according to the algorithm.

Update the weights with the new m and hm and normalize the weight.

4. Finally calculate the strong classifier Hm.

Page 27: Master Thesis - deimURVdeim.urv.cat/~francesc.serratosa/2011_06_20_Abmnurul_Taluckder_MESISI_MasterThesis.pdfmaster’s course and, as well as, this thesis work successfully. I would

27 | P a g e

Now we have implemented the AdaBoost algorithm for building the strong classifiers from

the weak classifiers but before going to implement the learned strong classifier in our

further implementation we have tried to investigate the formula and results in each step of

the learning phase.

In our work, we have been using the weighted output for eyes and non eyes for calculating

the mean and standard deviation for eye and non eye. Then we have calculated the

probability of each images using the mean and standard deviation of eye which can be

expressed like P(I | Eye) and calculated the probability of each image using the mean and

standard deviation of non eye which can be expressed like P(I | Non Eye). We have used this

calculated probability for constructing the weak learners for implementation of AdaBoost.

The criteria we have used is that for an image if the P(I | Eye) greater than P(I | Non Eye) we

will consider it as a 1 and if not than -1. After finishing this step, we will get the desired

weak classifier for each image. The terminology can be described as the following figure[8].

Figure 8: shows the probability calculation for construction weak learners

When we have constructed the weak learners, the next step is to calculate the error for

each filter. For calculating the error as described in the algorithm, the formula will take into

consider the values those are poorly classified and in each step it will try to minimize the

Should be

greater

Should be

greater Eye Images

Non Eye

Images

P (I | Eye) P (I | Non Eye)

Page 28: Master Thesis - deimURVdeim.urv.cat/~francesc.serratosa/2011_06_20_Abmnurul_Taluckder_MESISI_MasterThesis.pdfmaster’s course and, as well as, this thesis work successfully. I would

28 | P a g e

error. In each step, if an image is misclassified i.e. [yi ≠ hm(xi)] it will be considered for

calculating the error and the total error is the sum of all the misclassified images. This error

is further used to calculate the m and for updating the weights. The aim of updating the

weights is to give larger weights wi(m) to the harder-to-classify examples (xi, yi) so that in

the next iteration more emphasis is placed on these examples.

When all the iterations have been completed, we get a sequence of best weak classifiers hm

and the best combining weights m which are then used to extract the eyes from full face

images.

Page 29: Master Thesis - deimURVdeim.urv.cat/~francesc.serratosa/2011_06_20_Abmnurul_Taluckder_MESISI_MasterThesis.pdfmaster’s course and, as well as, this thesis work successfully. I would

29 | P a g e

Chapter 4: Experimental Results

For implementing and testing the algorithms described in the previous sections, we have

used a face database containing 10 different subjects expressing 11 different facial

expressions, total (10x11) 110 face images. As we will concentrate our experiment to

extract the eyes from these images, we have collected different eye and non eye images

from this face database constructing a database of 30 eye images and 30 non eye images.

We have used this image database for implementing the Gabor filter on each of the images

and to train the system for Naïve Bayes and AdaBoost classification. When the training is

done, we have selected 10 different full face images from the original database to test the

system whether it can classify the eye regions properly. In this recognition system, we first

tried to use the images in the exact form but when we have found the result, it was a little

bit frustrating that the hair of the images is affecting the recognition procedure. Finally we

have extracted the face portion of the image to test the final system, and the results are

quite good in respect to the previous. In the figure[9,10,11], we can see the eye and non eye

images and also the test face images used in this work.

In the first step, we have tested the Gabor filter with the bank of parameters to test the

outputs. For each eye and non eye images, we have captured the 2D gray level image. We

have passed each image to the Gabor filter and get the filter output and also the convoluted

output of the image. In the figure[12], we can see some of the 2D output results and surface

plot of the EGF.

Figure 9: shows the 30 eye image dataset.

Page 30: Master Thesis - deimURVdeim.urv.cat/~francesc.serratosa/2011_06_20_Abmnurul_Taluckder_MESISI_MasterThesis.pdfmaster’s course and, as well as, this thesis work successfully. I would

30 | P a g e

Figure 10: shows the 30 non eye image dataset.

Figure 11: shows sample test images set

The outputs of the EGF are showing that the higher frequency is extracted from the center

of the eye. So when the frequency is appropriate, the horizontal EGF can stand out the eye

region efficiently. For this reason, we have chosen a bank of frequency and pass it to the

EGF to extract the eye regions efficiently.

After getting the filter output of all the images, we have applied the output images in Naïve

Bayes classification algorithm to classify the eyes and the non-eyes so that when we will

apply the algorithm to extract the eyes from the face, it can classify the eyes from other

parts of the image. In the Bayesian analysis, this belief is known as the prior probability.

Prior probabilities are based on previous experience, in this case the probability of being

an eye and non-eye, and often used to predict the outcomes. When we have formulated our

prior probability, we are now ready to classify a new image.

If we plot the probability of being an eye and the probability of being a non-eye, we can

understand that the less they overlap each other the more the classification is perfect. In

our work, we have tried to examine the outputs to find that how the classification

algorithm works for each of the filter. In the figure[13], the blue line shows the probability

of being eye P(I|Eye) and the red line shows the probability of non-eye P(I|NonEye). Here

we can see that the filter output differentiates the eye and non eye but cannot classify them

clearly. This probability outputs are the prior probability for eye and non eye images.

Page 31: Master Thesis - deimURVdeim.urv.cat/~francesc.serratosa/2011_06_20_Abmnurul_Taluckder_MESISI_MasterThesis.pdfmaster’s course and, as well as, this thesis work successfully. I would

31 | P a g e

Figure 12: the first row shows the 2D outputs and the second row shows the surface plot of the EGF filter

Now we will use this prior probability to classify an image and to do that we have passed

the test images to extract the eye portions from the non eye portions of the complete facial

image. In this process, we have used the mean () and standard deviation () for eyes and

non eyes to get the classified output of an image. From this two classified image, we

computed the difference and the result is the final classified output of the image. This

process is described with a sample image in figure[14].

Figure 13: sample plot for probability of being eye (blue) and non-eye (red) for a filter

Page 32: Master Thesis - deimURVdeim.urv.cat/~francesc.serratosa/2011_06_20_Abmnurul_Taluckder_MESISI_MasterThesis.pdfmaster’s course and, as well as, this thesis work successfully. I would

32 | P a g e

Figure 14: shows the process and the classified output result of Naïve Bayes

The next step of our work is to implement the AdaBoost algorithm so that we can do a

comparative research on the output of the two classification algorithm. For implementing

the AdaBoost algorithm, we have used the same Gabor filter outputs of the eye and non eye

images. According to the procedures described in the methodology section, we have started

with random weights and after each iteration, we have updated the weights increasing the

weights of the misclassified examples and decreasing the weights of correctly classified

examples. We have continued the process for each filter and after completing the iterations

we have got the m values. Finally, we calculated the strong classifier Hm which is a

Gabor

Filter

1

Gabor

Filter 2

Gabor

Filter 3

….

Gabor

Filter 15

P(Image|Eye) P(Image|NonEye

)

Final

Classified

Image

output

Page 33: Master Thesis - deimURVdeim.urv.cat/~francesc.serratosa/2011_06_20_Abmnurul_Taluckder_MESISI_MasterThesis.pdfmaster’s course and, as well as, this thesis work successfully. I would

33 | P a g e

weighted majority vote of the m weak hypothesis where m is the weight assigned to hm.

Schapire and Singer [21] showed how AdaBoost and its analysis can be extended to handle

weak hypotheses which output real-valued or confidence-rated predictions. That is, for

each images, the weak hypothesis hm outputs a prediction hm(x) R whose sign is the

predicted label (-1 or +1) and whose magnitude |hm(x)| gives a measure of “confidence” in

the prediction. And the strong classifier Hm contains the final measure of “confidence” of

each individual image set. In the following table, we have showed the final classification

label (+1 or -1) of eye images and non eye images.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

-1 1 -1 1 -1 -1 1 1 1 1 1 1 1 -1 1

16 17 18 19 20 21 22 23 24 25 26 27 28 29 30

1 1 1 -1 1 1 1 -1 1 1 1 1 -1 1 -1

Table 1: shows the Hm labels for eye images (+1-correctly classified, -1-misclassified)

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 1 -1 -1 -1

16 17 18 19 20 21 22 23 24 25 26 27 28 29 30

1 -1 -1 -1 -1 -1 -1 1 1 -1 -1 1 -1 -1 -1

Table 2: shows the Hm labels for non-eye images (-1-correctly classified, +1-misclassified)

Now we will try to illustrate and compare the obtained classification results using the two

algorithms. In the figure[15], we presented the final outputs of the Naïve Bayes and

AdaBoost classifier so that we can see the difference of the outputs of this two

classification.

In the figure, we can see the output of Naïve Bayes classifier in the first row and in the

second row the outputs of AdaBoost classifier. From the outputs, we can easily find that the

AdaBoost classification outputs are much more reliable and consistent than the Naïve

Bayes classification results.

Page 34: Master Thesis - deimURVdeim.urv.cat/~francesc.serratosa/2011_06_20_Abmnurul_Taluckder_MESISI_MasterThesis.pdfmaster’s course and, as well as, this thesis work successfully. I would

34 | P a g e

a b c d e f g

h i j k l m n

Figure 15: the results of classifying the eyes in our face dataset using Naïve Bayes (a-g) and

AdaBoost classifier (h-n)

The most basic theoretical property of AdaBoost concerns its ability to reduce the training

error. AdaBoost is adaptive in that it adapts to the error rates of the individual weak

hypothesis and efficiently converts a weak learning algorithm into a strong algorithm. On

the other hand, Naïve Bayes classification is based on the prior probability learning theory

and it tries to classify the problem according to the prior knowledge. Whereas AdaBoost

requires no prior knowledge about the weak learner and so can be flexibly combined with

any method for finding weak hypothesis. In nearly all of the resulting images, AdaBoost

performed as well or significantly better than the results of Naïve Bayes.

We can find that the Naïve Bayes results fails to significantly locate the eye positions form

our face dataset used for this experiment. The Elliptical Gabor filter tries to locate the eye

position in the face image and then we have used the filter results for classifying. But in

Naïve Bayes classifier gives the output where not only the eye positions but some other

portions of the face are extracted as well. The reason behind this problem is that it cannot

classify the eyes from the non eye regions of the face. We may get a better output from this

classification algorithm if we use more eyes and non eyes dataset for increasing the prior

knowledge of this classification method for accurately differentiate the eyes from non eye

regions.

Page 35: Master Thesis - deimURVdeim.urv.cat/~francesc.serratosa/2011_06_20_Abmnurul_Taluckder_MESISI_MasterThesis.pdfmaster’s course and, as well as, this thesis work successfully. I would

35 | P a g e

Figure 16: shows the final eye detection results of the face dataset

But AdaBoost algorithm is much efficient in this case as it can give us a better classification

result than naïve Bayes with the same dataset with less computational cost. In the resulting

images, we can see that the results of the AdaBoost are proficient in case of extracting the

eyes from the non eye regions of the image. A nice property of AdaBoost is its ability to

identify outlier i.e. examples that are either mislabeled in the training data, or which are

inherently ambiguous and hard to categorize. This ability helps this algorithm to

differentiate the eyes from the non eyes efficiently after each iteration. But Naïve Bayes

algorithm only depends on its prior knowledge i.e. the probability to classify the eyes from

the non eyes which make it less efficient in classifying the eyes from the non eyes.

The experimental result indicates that the classification by AdaBoost is much stronger than

the Naïve Bayes classifier when the classification dataset in limited which is the significant

finding of our work.

Finally, we have tried to locate the eye position from our face datasets so that we can prove

that our system finds the eye location successfully. The eye location is extracted based on

the results of the AdaBoost as we have seen that it can classify the eye positions robustly

than the Naïve Bayes algorithm. We note that when the image has some deflection, the

performance of our system deteriorates a bit, but the results are better. We have tested the

classification on 10 images from which the system can perform well in almost 7 images and

can locate the eye position successfully. In the figure [16], we can see the final result of the

system.

We also note that instead of some variations in the facial expressions, the system can

correctly locate the eye positions. It proves that our work is not affected by the variation of

Page 36: Master Thesis - deimURVdeim.urv.cat/~francesc.serratosa/2011_06_20_Abmnurul_Taluckder_MESISI_MasterThesis.pdfmaster’s course and, as well as, this thesis work successfully. I would

36 | P a g e

the facial expression as the eye positions remain fixed for different facial expression. So we

can see the system performs well to locate the eye positions successfully based on the

classification result.

Page 37: Master Thesis - deimURVdeim.urv.cat/~francesc.serratosa/2011_06_20_Abmnurul_Taluckder_MESISI_MasterThesis.pdfmaster’s course and, as well as, this thesis work successfully. I would

37 | P a g e

Chapter 5: Conclusion

The increase in complexity in consumer goods such as automobiles and home appliances

provides for a new market for technologies such as face recognition. Additionally, the

recent events in the world have spurred a public demand for security and safety in public

places; demands that could be partially met by deployment of these technologies.

The objectives of this thesis work were: To discuss and summarize the process of 2D facial

characterization using Gabor filter and some classification methods, to look at currently

available eye location recognition techniques based on 2D Gabor filter, to design and

develop a robust eye location detection system based on AdaBoost and Naïve Bayes

classification algorithm, and finally compare the results of the two classification algorithm

and extract the eye location based on the classification results.

In chapter 2 of this thesis presents a comprehensive literature overview of the Elliptical

Gabor filter (EGF), and two important classification algorithms i.e. Naïve Bayes and

AdaBoost satisfying the two first objectives.

The third objective of this thesis is satisfied by the work presented in chapter 3 by the

methodology for implementing the Gabor filter and other two classification algorithms

based on our eye and non eye dataset.

The last objective is satisfied by the work presented in chapter 4 showing the experimental

results based on the methodology described in the earlier chapter. While presenting the

results, we compared the two classification algorithms with their outputs and finally

concluded with the eye location extraction results from the face dataset.

As eye location extraction was one of our key ideas of this thesis work, we have

implemented a system based on the Gabor filter and two classification algorithms. Besides

this, we have presented the research work about the comparison of the Naïve Bayes and

AdaBoost algorithm. Finally, the system can locate eyes exactly and rapidly. Experiments

show that the performance of this system is robust against the variation of facial

expressions.

As an improvement and projected future work, we can consider the implementation of the

3D Gabor filters as well as 2D and implement the classification algorithms to check that

how much the classification works in case of 3D images. The third dimension contributes to

characterize faces in a better way and so, to increase the quality of the systems. Our

master’s thesis is the first step of a large project. The aim of it is to automatically recognize

Page 38: Master Thesis - deimURVdeim.urv.cat/~francesc.serratosa/2011_06_20_Abmnurul_Taluckder_MESISI_MasterThesis.pdfmaster’s course and, as well as, this thesis work successfully. I would

38 | P a g e

the probability of some illnesses in foetal that are 22 weeks aged. The features to be

analyzed from the foetal are extracted from 3D images captured inside the uterus. In this

first step, we concentrated to work with the 2D images and implement the classification

algorithms. In the next step, we will concentrate on the 3D images datasets to apply the 3D

Gabor filter as well as classification algorithms. And then continue the work for applying

the system for automatic recognition on the 3D images of the foetal that will significantly a

good work in the improvement of the integration of Information technology and medical

science.

Page 39: Master Thesis - deimURVdeim.urv.cat/~francesc.serratosa/2011_06_20_Abmnurul_Taluckder_MESISI_MasterThesis.pdfmaster’s course and, as well as, this thesis work successfully. I would

39 | P a g e

Appendix A: Terminology

AdaBoost: short form of Adaptive Boosting, is a machine learning algorithm.

Bandwidth: a measure of the width of a range of frequencies, measures in Hertz.

Bank of Filters: is an array of frequencies to use as the inputs for testing the filter results.

Bayesian Probability: one of the different interpretations of the concept of probability

and belongs to the category of evidential probabilities.

Boosting: a machine learning meta-algorithm for performing supervised learning.

Convolution: a mathematical operation on two functions f and g, producing a third

function that is typically viewed as a modified version of one of the original functions.

Covariance matrix: a matrix whose element in the i, j position is the covariance between

the i th and j th elements of a random vector.

Domain: is the set of entities over which certain variables of interest in some formal

treatment may range.

EGF: Elliptical Gabor Filter

Frequency (F): the number of occurrences of a repeating event per unit time.

Hypothesis: is a proposed explanation for a phenomenon.

Learning algorithm: a scientific discipline concerned with the design and development of

algorithms that allow computers to evolve behaviors based on empirical data, such as from

sensor data or databases.

Mean (): the expected value of a random variable, which is also called the population

mean.

Naïve Bayes classifier: a simple probabilistic classifier based on applying Bayes' theorem

with strong (naïve) independence assumption.

Page 40: Master Thesis - deimURVdeim.urv.cat/~francesc.serratosa/2011_06_20_Abmnurul_Taluckder_MESISI_MasterThesis.pdfmaster’s course and, as well as, this thesis work successfully. I would

40 | P a g e

Pixel: a single point in a raster image, or the smallest addressable screen element in a

display device.

Prior Probability: often called simply the prior, an uncertain quantity p is the probability

distribution that would express one’s uncertainty about p before the “data” is taken into

account.

Resampling: the process of estimating of the precision of sample statistics (medians,

variances, percentiles) by using subsets of available data or drawing randomly with

replacement from a set of data points.

Strong Learner: is a classifier that is arbitrarily well-correlated with the true classification.

TGF: Traditional Gabor Filter

Theta (): the rotation angle of the filter.

Variance (): a measure of how far the numbers lie from the mean (expected value).

Weak Learner: is defined to be a classifier which is only slightly correlated with the true

classification.

Page 41: Master Thesis - deimURVdeim.urv.cat/~francesc.serratosa/2011_06_20_Abmnurul_Taluckder_MESISI_MasterThesis.pdfmaster’s course and, as well as, this thesis work successfully. I would

41 | P a g e

Appendix B: Sample codes

EGF_fn.m

function [G, GABOUT] = EGF_fn(I,sx,sy,t,F)

if isa(I,'double')~=1 I=double(I); end

indexX = 1; for x=-12:12 indexY = 1; for y=-19:19 x1=x*cos(t)+y*sin(t); y1=-x*sin(t)+y*cos(t); G(indexX,indexY) = (1/(2*pi*sx*sy))*exp(-0.5*((x1^2/sx^2) +

(y1^2/sy^2)))*... exp(2*pi*j*F*(sqrt(x^2 + y^2))); indexY = indexY + 1; end indexX = indexX + 1; end

GABOUT=conv2(double(I),double(G),'same');

end

main.m

%setting the parameters for Elliptical Gabor Filter sx = 2.3; sy = 5.0; t = 0; f=[.145, .152,.155, .1583, .16, .164, .1681, .171 ,.1732, .175, .178,

.1811,.183,.185,.187];

load colormaps.mat

% Show the grayscale image colormap(grayscale);

matrixouteye = zeros(30,15); matrixoutnoneye = zeros(30,15);

%read images from the Images directory imagedir = 'eyes'; tifffiles = dir([imagedir '/*.jpg']);

Page 42: Master Thesis - deimURVdeim.urv.cat/~francesc.serratosa/2011_06_20_Abmnurul_Taluckder_MESISI_MasterThesis.pdfmaster’s course and, as well as, this thesis work successfully. I would

42 | P a g e

for k = 1:length(tifffiles) filename = [imagedir '/' tifffiles(k).name]; I = rgb2gray(imread(filename));

adjustedImage = imadjust(I, stretchlim(I),[]);

for i=1:length(f) [G,GABOUT] = EGF_fn(adjustedImage,sx,sy,t,f(i)); R= real(G);

%multiplying the GABOUT and image out = sum(sum(double(R) .* double(I)));

%saving the output in a matrix matrixouteye(k,i) = out;

end end

%read non eyes from the Images directory imagedir = 'noneyes'; tifffiles = dir([imagedir '/*.jpg']); for k = 1:length(tifffiles) filename = [imagedir '/' tifffiles(k).name]; I = rgb2gray(imread(filename));

for i=1:length(f) [G,GABOUT]= EGF_fn(I,sx,sy,t,f(i)); R= real(G);

%multiplying the GABOUT and image out = sum(sum(double(R) .* double(I)));

%saving the output in a matrix matrixoutnoneye(k,i) = out;

end end

%Display the output Matrix of eyes disp('The output Matrix of eyes'); disp(matrixouteye);

%Display the output Matrix of noneyes disp('The output Matrix of noneyes'); disp(matrixoutnoneye);

matrixout = [matrixouteye;matrixoutnoneye];

%calculating the mean of the output Matrix of eyes mean_eye = mean(matrixouteye); disp('The mean values of the output Matrix of eyes'); disp(mean_eye);

Page 43: Master Thesis - deimURVdeim.urv.cat/~francesc.serratosa/2011_06_20_Abmnurul_Taluckder_MESISI_MasterThesis.pdfmaster’s course and, as well as, this thesis work successfully. I would

43 | P a g e

%calculating the std of the output Matrix of eyes std_eye = std(matrixouteye); disp('The STD values of the output Matrix of eyes'); disp(std_eye);

%calculating the mean of the output Matrix of non eye mean_noneye = mean(matrixoutnoneye); disp('The mean values of the output Matrix of non eyes'); disp(mean_noneye);

%calculating the std of the output Matrix of non eyes std_noneye = std(matrixoutnoneye); disp('The STD values of the output Matrix of non eyes'); disp(std_noneye);

%This is the testing part of the Program to test whether %the trained system can classify a eye region or not

img = rgb2gray(imread('Images/10.jpg'));

outputEye = naiveclassify2(std_eye,mean_eye,f,double(img)); outputNonEye = naiveclassify2(std_noneye,mean_noneye,f,double(img));

%Now compare the two classifier values to detect eye or noneye THRE = 0.0; [x y] = size(img); classifiedOutput = []; diff = [];

for i= 1:x for j = 1:y diff(i,j)= outputEye(i,j)- outputNonEye(i,j); if(diff(i,j)>=THRE) classifiedOutput(i,j)= 255; else classifiedOutput(i,j)= 0; end end end

figure, imshow(classifiedOutput);

Page 44: Master Thesis - deimURVdeim.urv.cat/~francesc.serratosa/2011_06_20_Abmnurul_Taluckder_MESISI_MasterThesis.pdfmaster’s course and, as well as, this thesis work successfully. I would

44 | P a g e

naiveclassify.m

% this function calculates the class value given a new 128x128 sized % image to classify for a set of Gabor frequency, std and mean vlaues.

function output = naiveclassify(std, mean, f, I)

if isa(I,'double')~=1 I=double(I); end

sx = 2.3; sy = 5.0; t = 0; filterOutputs = [];

for i=1:length(f) [G,GABOUT] = EGF_fn(I,sx,sy,t,f(i)); R= real(G);

if(size(I)== size(double(R))) res = conv2(I,double(R), 'same'); [x y] = size(res); out = res(round(x/2),round(y/2)); else out = conv2(I,double(R), 'same'); end

value = normpdf(out,mean(i),std(i));

[x y] = size(value); minimum = min(min(value)); maximum = max(max(value)); for m = 1:x for n = 1:y norm = (value(m,n)-minimum)/(maximum - minimum); value(m,n) = norm * 255; end end

filterOutputs{i} = value; end

disp(filterOutputs);

[x y] = size(I); output = ones([x,y]); for i=1:length(filterOutputs) output = output.*filterOutputs{i}; end

end

Page 45: Master Thesis - deimURVdeim.urv.cat/~francesc.serratosa/2011_06_20_Abmnurul_Taluckder_MESISI_MasterThesis.pdfmaster’s course and, as well as, this thesis work successfully. I would

45 | P a g e

adaboost.m

%Adaboost Learning phase

%initializing the y=+1 for eyes and y=-1 for non eyes dataclass_eye = ones(length(matrixouteye),1).* 1 ; dataclass_noneye = ones(length(matrixoutnoneye),1).* -1; dataclass = [dataclass_eye;dataclass_noneye];

%initialize the alpha alpha =ones(1,length(f)).*(1/(length(matrixouteye)+length(matrixoutnoneye)));

%for storing the final values of alpha alpha_zero = 1/(length(matrixouteye)+length(matrixoutnoneye)); %for the first

iteration

%initializing weights for the eyes weight_eye = ones(length(dataclass_eye),1).*(1/(2*length(dataclass_eye)));

%initializing weights for the non eyes weight_noneye =

ones(length(dataclass_noneye),1).*(1/(2*length(dataclass_noneye)));

%initialize the weight matrix 69x1 weight_final = ones(length(dataclass),length(f)); weight = [weight_eye;weight_noneye];

%initializing the 69x15 matrix for storing the values of Hm for each filter Hm = zeros(length(weight),1); hm = zeros(length(dataclass),length(f));

p_eye = zeros(length(dataclass),length(f)); p_noneye = zeros(length(dataclass),length(f));

%forward inclusion phase of Adaboost algorithm for i= 1:length(f)

if(sum(weight,1) ~= 1.0000) z = sum(weight,1); weight = weight./z(ones(size(weight,1), 1), :); end

out_eye = matrixouteye(:,i).*weight(1:30,1); out_noneye = matrixoutnoneye(:,i).*weight(31:end,1); out = [out_eye;out_noneye];

%in each iteration we are calculating the mean and std for eye and %noneye mean_eye = mean(out_eye); std_eye = std(out_eye);

mean_noneye = mean(out_noneye); std_noneye = std(out_noneye);

for j=1:length(dataclass)

Page 46: Master Thesis - deimURVdeim.urv.cat/~francesc.serratosa/2011_06_20_Abmnurul_Taluckder_MESISI_MasterThesis.pdfmaster’s course and, as well as, this thesis work successfully. I would

46 | P a g e

p_eye(j,i) = normpdf(out(j,1),mean_eye,std_eye); p_noneye(j,i) = normpdf(out(j,1),mean_noneye,std_noneye);

if(j<=30) if(p_eye(j,i) >= p_noneye(j,i)) hm(j,i) = 1; else hm(j,i) = -1; end else if(p_eye(j,i) >= p_noneye(j,i)) hm(j,i) = -1; else hm(j,i) = 1; end end

end

err = sum(weight.*(sign(hm(:,i))~= dataclass(:))); if(err >= 0.5) alpha(1,i) = 0; else alpha(1,i) = log10((1-err)/err); end

for k=1:length(weight) res = dataclass(k,1)* alpha(1,i) * hm(k,i); weight(k,1) = weight(k,1) * exp(-res); end z = sum(weight); weight = weight./z; weight_final(:,i) = weight;

end

for i=1:length(dataclass) for j=1:length(f) Hm(i,1) = Hm(i,1) + alpha(1,j)*hm(i,j)/sum(alpha); end Hm(i,1) = sign(Hm(i,1)); end

%Testing with strong classifier filterOutputs = []; img = rgb2gray(imread('Images/2.jpg'));

if isa(I,'double')~=1 I=double(img); end

Page 47: Master Thesis - deimURVdeim.urv.cat/~francesc.serratosa/2011_06_20_Abmnurul_Taluckder_MESISI_MasterThesis.pdfmaster’s course and, as well as, this thesis work successfully. I would

47 | P a g e

for i=1:length(f) [G,GABOUT] = EGF_fn(I,sx,sy,t,f(i)); R= real(G);

out = conv2(I,double(R), 'same');

filterOutputs{i} = alpha(1,i).* out;

end

[x y] = size(I); output = zeros([x,y]); for i=1:length(filterOutputs) output = imadd(output,filterOutputs{i}); end

[m n] = size(output); max1= max(max(output));

[svals, idx ] = sort(output(:),'descend'); [II,JJ] = ind2sub([m,n],idx(2));

x = getcoord(max1, output);

if((x(1,2)-JJ)< 50) %find the another highest value which has the distance > 50) i=3; while(abs(x(1,2)-JJ)< 50 && i<=10) [II,JJ] = ind2sub([m,n],idx(i)); i = i+1; end end

image = MidpointCircle(img, 7, x(1,1),x(1,2), 0); image2 = MidpointCircle(image, 7, II,JJ, 0); figure,imshow(image2);

Page 48: Master Thesis - deimURVdeim.urv.cat/~francesc.serratosa/2011_06_20_Abmnurul_Taluckder_MESISI_MasterThesis.pdfmaster’s course and, as well as, this thesis work successfully. I would

48 | P a g e

Bibliography

[1] Yanfang Zhang, Nongliang Sun, Yang Gao, Maoyong Cao, “A new eye location method based on Ring Gabor Filter”. International Conference on Automation and Logistics Qingdao, China September 2008.

[2] Z. M. Hafed, M. D .Levine, “Face recognition using the discrete cosine transform,” .International Journal of Computer Vision, 2001, 43 (3): 167-188.

[3] H. Zhou, X. Geng. “Projection Functions for Eye Detection,” Pattern Recognition, No. 5, pp. 1049-1056, May 2004.

[4] Y. Ma, X. Ding, Z. Wang, N. Wang, “Robust Precise Eye Location under Probabilistic Framework,” Proc. 6th IEEE Int’l Conf. on Automatic faceand Gesture Recognition (FGR’04), pp.339-344, May 2004.

[5] Z. Niu, S. Shan, S. Yan. X. Chen and W. Gao, “2D Cascaded Adaboost for Eye Location,” 18th Int’1 Conf. on Pattern Recognition,Vol.2,pp.1216-1219, Aug, 2006.

[6] L. Yuille, D. S. Cohen, and P. W. Hallinan, "Feature Extraction from Faces using Deformable Templates," in IEEE Proc. of Computer Visionand Pattern Recognition(CVPR 1989),pp.104-109,Washington,DC,June 1989.

[7] Peng Yang, Bo Du, Shiguang Shan, Wen Gao, “A Novel Pupil Localization Method Based On Gaboreye Model And Radial Symmetry Operator,” Proc. Of ICIP 2004, pp.67-70, 2004.

[8] Lim R, M.J.T.Reinders, Thiang, “Facial landmark detection using a Gabor filter representation and a genetic search algorithm,” In: Proceeding , seminar of intelligent technology and its applications.

[9] Song Li, Danghui Liu, Lansun Shen, “Eye Location Using Gabor Transform”, Measurement and Control Techniques, 2006, 25(5): 27-29.

[10] http://en.wikipedia.org/wiki/Naive_Bayes_classifier

[11] M. A. Webster, R. L. De Valois, “Relationship between spatial frequency and orientation tuning of striate cortex cells,” Journal of the Optical Society of America, 1985, 2(7): 1124-1132.

[12] Yoav Freund, Robert E. Schapire. "A Decision-Theoretic Generalization of on-Line Learning and an Application to Boosting", 1995

[13] Michael J. Jones and Paul Viola. “Face Recognition Using Boosted Local Features”, MERL Technical Reports. TR 2003-25, April 2003. [14] D. Gabor, Theory of communication, IEEE 93 (1946), 429-457.

Page 49: Master Thesis - deimURVdeim.urv.cat/~francesc.serratosa/2011_06_20_Abmnurul_Taluckder_MESISI_MasterThesis.pdfmaster’s course and, as well as, this thesis work successfully. I would

49 | P a g e

[15] J. Daugman. Uncertainty relation for resolution in space, spatial frequency and

orientation optimized by two-dimensinak visuak cortical filters. Journal of the Optical

Society of America A, 2(7): 1160-1169, 1985.

[16] B. Duc, S. Fischer, and J. Bigun, “Face authentication with gabor information on

deformable graphs,” IEEE Transactions on Image Processing, vol. 8, no. 4, pp. 504–516,

April 1999.

[17] C Liu and H. Wechsler, “Independent Component Analysis of Gabor Features for Face

Recognition,” IEEE Transactions. Neural Networks, vol. 14, no. 4, pp. 919–928, 2003.

[18] X. He, S. Yan, Y. Hu, P. Niyogi, and H. Zhang. Face recognition using Laplacianfaces. IEEE

Transactions on Pattern Analysis and Machine Intelligence, 27(3):328–340, 2005.

[19] Viola, P. and Jones, M. Rapid object detection using boosted cascade of simple features.

IEEE Conference on Computer Vision and Pattern Recognition, 2001.

[20] Open Computer Vision Library Reference Manual. Intel Corporation, USA, 2001.

[21] Robert E. Schapire and Yoram Singer. Improved boosting algorithms using confidence-rated predictions. In Proceedings of the Eleventh Annual Conference on Computational Learning Theory, pages 80–91, 1998. To appear, Machine Learning. [22] S. Z. Li & A. K. Jain (Eds.), “Handbook of Face Recognition”, Springer (chap 1, 2,3)

[23] A.K. Jain, P. Fkynn & A.A. Ross, “handbook of Biometrics”, Springer (chap. 3)