Professional Documents
Culture Documents
on
MASTER OF TECHNOLOGY
in
CERTIFICATE
This is to certify that the project report entitled “GENDER RECOGNITION FROM
FACES USING FUZZY CLUSTERING AND NEAREST NEIGHBOR
CLASSIFIER” is a bonafide work done by M. MYTRI MADHURYA
(14FE1D5814) under my guidance and submitted in partial fulfilment of the
requirements for the award of the degree of Master of Technology in COMPUTER
SCIENCE AND ENGINEERING from JAWAHARLAL NEHRU
TECHNOLOGICAL UNIVERSITY, KAKINADA. The work embodied in this
project report is not submitted to any University or Institution for the award of any
Degree or Diploma.
External Examiner
ACKNOWLEDGEMENT
While bringing out this project to its final form, I came across a number of
people whose contributions in various ways helped my field of explore and they deserve
special thanks. It is a pleasure to convey my gratitude to all of them.
I’m thankful to our beloved Principal Dr. K. Phaneendra Kumar for providing
great support in completing my project and giving the opportunity of doing the project.
At the same time I feel elated to thank our beloved Head of the
Department Mr. N. Ratna Kanth for inspiring all the way and arranging all the facilities and
resources needed for project. I profoundly convey thanks towards services rendered by him.
I’m thankful to our project Coordinator Mr. B. Balvinder Singh for supporting
in all the way to complete the project. His efforts in this respect are beyond the preview of
the acknowledgement.
This project presented here in the work accomplished under the enviable and
scholarly guidance of Mr. K. Vivek for his significant suggestion and help in every
aspect to accomplish the project work.
I also place my floral gratitude to the other teaching staff and lab technicians for
their constant support and advice throughout the project. I extend my thanks to non-
teaching staff for their assistantship during the project.
Last but not least I thank everyone who directly or indirectly helped me during the
successful completion of my project.
M. Mytri Madhurya
(14FE1D5814)
DECLARATION
M. Mytri Madhurya
(14FE1D5814)
ABSTRACT
The gender classification has attracted much attention in psychological
literature, relatively few machine vision methods have been proposed. However it has
been extensively studied in the context of surveillance applications and biometrics.
This project is mainly concern with offline gender classification using purely image
processing technique which using a database that was included in the system. The
way of doing this is by extracting the differences between male and female facial
features. Obviously the classification base on a single feature is not adequate since
humans share many facial properties even within different gender group. In the
existing systems, the feature extraction techniques like Principal component analysis,
Local binary patterns which worked on geometric methods. A geometric method does
not provide the accurate results.
Gender recognition is a standout amongst the most difficult issues in
computer vision. Facial gender identification of neonates and children is also known
as an extremely demanding issue for human spectators. This study propounds a novel
gender grouping technique using frontal facial pictures of individuals. The proposed
approach utilizes fuzzy clustering techniques and nearest neighbor, respectively, for
feature extraction and classification steps. Nearest neighbor can also apply to extract
the most suitable features from images as well as reducing the dimensionality of data.
The extracted components are then used to allocate the new pictures to proper classes
male or female in view of fuzzy clustering. The computational time and exactness of
the proposed method are examined together and the importance of the preferred
approach estimated to most of the other known competing methods is proved, chiefly
for younger faces. Experimental results indicate the significant classification
accuracies which have been gathered from FERET databases. Meanwhile, the
proposed algorithm is relatively easy; its computational time is viable and often less
than the other state-of-art gender classification methods.
i
TABLE OF CONTENTS
TOPIC PAGE NO
ABSTRACT i
List of Figures ii
1. INTRODUCTION 1 - 10
1.3 Applications 10
2. LITERATURE SURVEY 11 - 21
4. IMPLEMNTATION 31 - 56
4.3 Tools 33
5. TESTING 57 - 61
5.1 Testing 57
REFERENCES 68
PUBLISHED PAPER 69
LIST OF FIGURES PAGE NO
ii
Figure 6.4 Cluster Formations 64
iii
Gender Recognition from Faces using Fuzzy Clustering and Nearest Neighbor Classifier
CHAPTER 1
INTRODUCTION
1.1 Introduction to Gender recognition
This project is about gender recognition for classification based on the
frontal facial images. The classification using the frontal still facial image is not easy.
It is difficult mostly because of the inherent variability of the image formation process
in terms of image quality, images size, lighting condition, the angle of image and
photometry, geometry, and/or occlusion, change, and disguise. A successful gender
classification method has many potential applications such as human identification,
security system, smart human computer interface, computer vision approaches for
monitoring people, passive demographic data collection, etc. The interest on gender
recognition are discussed about the techniques that appearance based methods, that is
will learn the differential boundary between gender for male and female classes from
example images, without extracting any geometrical features such as distances, face
shape, face genetics and etc. Hopefully, in the 21st century now, there is a new system
that can implement or develop for solutions to similar face tasks as well.
The face is one of the most important biometric features of the human
beings and normally used as identification. Each person has their own innate face and
mostly a different face. As a human, to recognize the different faces without any
difficulty is more easily but it become difficulty to the system to recognize the human
faces. Face recognition is an active research area, and they can be used in wide range
applications such as surveillance and security, telecommunication and digital
libraries, human-computer intelligent interaction, and smart environment. Yet, it is a
challenging task to design and develop a robust computer system for face
identification thus classifies the gender of the human.
But, nowadays, the lack of automated face recognition systems is
especially apparent when compared to our own innate face recognition ability. Human
can perform face recognition, which is an extremely complex visual task, almost
instantaneously and our own recognition ability is far better and robust than any
computers can hope to be. Beside, a human also can recognize a familiar individual
under very adverse lighting conditions, from varying angles or viewpoints.
In the research for determination of features, such as, gender, race,
expression of a person, using facial features goes back to 1960s; it is only very
1
Gender Recognition from Faces using Fuzzy Clustering and Nearest Neighbor Classifier
recently that acceptable results have been obtained. However, face recognition system
is still an area of active research since a completely successful approach or model has
not been proposed to solve the face recognition problem. For the next generation
surveillance systems are expected to take human frontal face as input pattern and
extract useful information such as gender information, emotion, race or age
information from the human face that soon it also can be used for the security system
or more than that.
Gender classification was first perceived as an issue in psychophysical
studies, which focuses on the efforts of understanding human visual processing
and identifying key features used to categorize between male and female
individuals. Research has shown that the disparity between facial masculinity and
femininity can be utilized to improve performances of face recognition
applications in biometrics, human-computer interaction, surveillance, and
computer vision. However, in a real-world environment, the challenge is how to deal
with the facial image being affected by the variance in factors such as illumination,
pose, facial expression, occlusion, background information and noise. This is then
also the challenge to the development of a robust face-based gender classification
system that has high classification accuracy and real-time performance.
This is then also the challenge to the development of a robust face-based
gender classification system that has high classification accuracy and real-time
performance. The conventional approach applied in face recognition, including face-
based gender recognition, typically involves the stages of image acquisition and
processing, dimensionality reduction, feature extraction, and classification, in that
order. Prior knowledge of the application domain is required to determine the best
feature extractor to design. In addition, the performance of the recognition system
is highly dependent on the type of classifier chosen, which is in turn
dependent on the feature extraction method applied. It is difficult to find a classifier
that combines best with the chosen feature extractor such that an optimal
classification performance is achieved. Any changes to the problem domain require a
complete re-design of the system.
2
Gender Recognition from Faces using Fuzzy Clustering and Nearest Neighbor Classifier
1.2.1.1 IMAGE:
The word image is also used in the broader sense of any two-dimensional figure
such as a map, a graph, a pie chart, or an abstract painting. In this wider sense, images
can also be rendered manually, such as by drawing, painting, carving, rendered
automatically by printing or computer graphics technology, or developed by a
combination of methods, especially in a pseudo-photograph.
An image is a rectangular grid of pixels. It has a definite height and a definite width
counted in pixels. Each pixel is square and has a fixed size on a given display.
However different computer monitors may use different sized pixels. The pixels that
constitute an image are ordered as a grid (columns and rows); each pixel consists of
numbers representing magnitudes of brightness and color.
3
Gender Recognition from Faces using Fuzzy Clustering and Nearest Neighbor Classifier
Each pixel has a color. The color is a 32-bit integer. The first eight bits
determine the redness of the pixel, the next eight bits the greenness, the next eight bits
the blueness, and the remaining eight bits the transparency of the pixel.
Image file size is expressed as the number of bytes that increases with the
number of pixels composing an image, and the color depth of the pixels. The greater
the number of rows and columns, the greater the image resolution, and the larger the
file. Also, each pixel of an image increases in size when its color depth increases, an
8-bit pixel (1 byte) stores 256 colors, a 24-bit pixel (3 bytes) stores 16 million colors,
the latter known as true color.
4
Gender Recognition from Faces using Fuzzy Clustering and Nearest Neighbor Classifier
occupy 36,000,000 bytes of memory, a great amount of digital storage for one image,
given that cameras must record and store many images to be practical. Faced with
large file sizes, both within the camera and a storage disc, image file formats were
developed to store such large images.
5
Gender Recognition from Faces using Fuzzy Clustering and Nearest Neighbor Classifier
Image Acquisition:
Image Enhancement:
6
Gender Recognition from Faces using Fuzzy Clustering and Nearest Neighbor Classifier
Image restoration is an area that also deals with improving the appearance of
an image. However, unlike enhancement, which is subjective, image restoration is
objective, in the sense that restoration techniques tend to be based on mathematical or
probabilistic models of image degradation.
7
Gender Recognition from Faces using Fuzzy Clustering and Nearest Neighbor Classifier
Digital image is defined as a two dimensional function f(x, y), where x and y
are spatial (plane) coordinates, and the amplitude of f at any pair of coordinates (x,
y) is called intensity or grey level of the image at that point. The field of digital image
8
Gender Recognition from Faces using Fuzzy Clustering and Nearest Neighbor Classifier
Fuzzy clustering:
The central idea in fuzzy clustering is the non-unique partitioning of the data into a
collection of clusters. The data points are assigned membership values for each of the
clusters and fuzzy clustering algorithm allow the clusters to grow into their natural
shapes. The fuzzy clustering algorithms can be divided into two types 1) Classical
fuzzy clustering algorithms 2) Shape based fuzzy clustering algorithms. Classical
fuzzy clustering algorithms can be divided into three types.1) The Fuzzy C-Means
algorithm 2) The Gustafson-Kessel algorithm 3) The Gath-Geva algorithm. Shape
based fuzzy clustering algorithm can be divided into 1) Circular shape based
clustering algorithm 2) Elliptical shape based clustering algorithm 3) Generic shape
based clustering algorithm. In this paper, represent a review on fuzzy c means, and
extended version of fcm such as pcm, fpcm and their advantages and disadvantages of
real time applications.
9
Gender Recognition from Faces using Fuzzy Clustering and Nearest Neighbor Classifier
1.4 Applications
Gender recognition is important because it finds its strong applications in fields of
• Authentication
• India’s UID (Unique Identification Authority of India) project that store face images.
10
Gender Recognition from Faces using Fuzzy Clustering and Nearest Neighbor Classifier
CHAPTER 2
LITERATURE SURVEY
2) Geometric methods are slow and complex and not providing an optimal result.
11
Gender Recognition from Faces using Fuzzy Clustering and Nearest Neighbor Classifier
[2] Hyun- Chul Kim, Daijin Kim: Gender Classification with Bayesian Kernel
Methods
Method: The EM-EP algorithm to learn Gaussian process classifiers for gender
classification. We expect that GPCs with the EM-EP algorithm work better than
SVMs with the cross validation and provide better hyper parameters for the kernels of
SVMs. In the experiments the hyper parameters obtained by GPC with the EM-EP
algorithm were even more suitable for SVMs than the ones obtained by cross
validation. GPCs worked better than SVMs and provided kernel hyper parameters to
make SVMs work better. We used Gaussian kernels in this paper.
Gaussian kernels do not seem to be ideal for image data since they do not
capture correlations between pixels. If we invent more proper kernels for face images,
we might improve the performance. It would also be interesting to perform
experiments on a larger face dataset.
Advantages
2. SVMs worked better than other classifiers such as ensemble of RBF networks,
classical RBF networks
Issues:
12
Gender Recognition from Faces using Fuzzy Clustering and Nearest Neighbor Classifier
[4] “Gender Recognition from Faces Using Bandlet and Local Binary Patterns”
In this paper, multi-scale bandlet and local binary pattern (LBP) based method for
gender recognition from faces is proposed. Bandlet is one of the multi-resolution
techniques that can adapt the orientation of the edges of the face images, and thereby
can better capture the texture of a face image. After extracting bandlet coefficients
from face images at different scales, LBP is applied to create a histogram, which is
used as the feature to a minimum distance classifier. The experiments are performed
using FERET gray scale face database, and the highest accuracy of 99.13% is
obtained with the proposed method.
Advantages
Better performance of the local binary pattern operator over other texture descriptors
is its tolerance to monotonic gray-scale changes.
Additional advantages are the computational efficiency of the LBP operator and that
no gray-scale normalization is needed prior to applying the LBP operator to the face
image.
Limitations
[5] “Gender classification from face images based using Weber’s local descript
Gender Recognition from Face Pictures with Native WLD Descriptor and Neural
Network Approach”
13
Gender Recognition from Faces using Fuzzy Clustering and Nearest Neighbor Classifier
Advantages
Low complexity
Limitations
Automatic facial feature extraction is one of the most important and attempted
problems in computer vision. It is a necessary step in face recognition, facial image
compression. There are many methods have been proposed in the literature for the
facial feature extraction task. However, all of them have still disadvantage such as not
complete reflection about face structure, face texture. Therefore, a combination of
different feature extraction methods which can integrate the complementary
information should lead to improve the efficiency of feature extraction stage. In this
paper we describe a methodology for improving the efficiency of feature extraction
stage based on the association of two methods: geometric feature based method and
Independent Component Analysis (ICA) method.
Comparison of two methods of facial feature extraction: geometric feature
based method combined with PCA method (called GPCA) versus geometric feature
based method combined with ICA method (called GICA) on CalTech dataset has
demonstrated the efficiency of GICA method. Our results show that GICA achieved
good performance 80% compared to 88% of GPCA method. Furthermore, we
compare two methods mentioned above on our dataset, with performance of GICA
being 80% better 82% of GPCA method. The experiment results have confirmed the
benefits of the association geometric feature based method and ICA method in facial
feature extraction.
Limitations
1. Less accurate of features description because of whole image consideration
2. Poor edge detection and texture representation
14
Gender Recognition from Faces using Fuzzy Clustering and Nearest Neighbor Classifier
Drawbacks
Poor discriminatory power
jk , lm = jl , km
15
Gender Recognition from Faces using Fuzzy Clustering and Nearest Neighbor Classifier
Drawbacks
Hierarchical classifiers
As errors in the first layer will propagate to the following steps, the accuracy
of the orientation classification is important for the whole problem. One source of
error is the boundary effect of hard assignment. For a face whose orientation lies on
the boundary of two categories, it is unreasonable to simply put it into one of them.
Therefore, we estimate the confidence that one face falls in each orientation category.
After obtaining the results from the gender classifiers in the following stage, we
compute the weighted-sum using the orientation confidence. In this paper, we use the
approach proposed by Huang and Shao for face pose classification.
Symmetric trick
Human faces are bilaterally symmetrical. There may be some special characteristics
on someone’s face which could be the decisive evidence to recognize a certain person.
But in the area of gender classification, the special characteristics are not so
16
Gender Recognition from Faces using Fuzzy Clustering and Nearest Neighbor Classifier
important. Thus, whether the characteristic is on the left cheek or right would not
affect the result of gender classification. In most cases, the face images are exactly
bilaterally symmetrical. We can identify a person in an image as a man or a women
according to the geometric measurements of the face and organs, the position of the
facial components, the style of hair, the texture of the skin, and many other details on
the face. A symmetric process will do no harm to the feature extraction of all the
above information. In fact, we cannot know if the face in the following image is
originally facing left or right.
The bilateral symmetry of the human face is one reason for us to select the
yaw rotation from the three possibilities. Because the space of the problem can be cut
to a half if we turn all the faces which face right to face left by a horizontal flip. If we
just take one of the other two rotations, the flip would not work. The limitation of the
facial symmetric trick is that we can only handle the various situations brought by the
yaw rotation but not all three possible rotations of the human face. The performance
also depends on the accuracy of the classification to tell wether the face is turned
toward left or right. Fortunately, this is an easy task (See Sect. 6.4). Suppose we just
consider the yaw rotation of the human face and all the faces are now facing left.
The feature space is obviously a half of the original one. As a result, the
scales of training data in the expert classifiers of the hierarchical framework increase
a lot and the number of the classes into which the first layer is going to classify is also
reduced to a half. Combination of facial component classifiers Even in the same
orientation category, the alignment of facial components is still a problem that cannot
be ignored when using holistic features. Thus, Takimoto et al. extracted the features
around the eyes and mouth to bypass the complexity of different facial component
17
Gender Recognition from Faces using Fuzzy Clustering and Nearest Neighbor Classifier
We adopt the active shape model (ASM), a statistical model of the shape of
a deformable object, to get the locations of eyes, nose, mouth, and chin, and then cut a
rectangle of facial components out of the facial image. SVMs with probabilistic
outputs are trained based on each facial component in a certain angle category (See
Fig. 3.2). There are many strategies for combination of classifiers. The strategies are
mainly divided into two approaches. One is to use the probabilistic outputs of the
classifiers as input to get the result according to some optimized rules. The other
receives the feature vectors which are the input of the individual classifiers in the
former approach and trains a classifier with all this information. Both of them achieve
better performance than the individual classifier does.
18
Gender Recognition from Faces using Fuzzy Clustering and Nearest Neighbor Classifier
The detected edges match the subjective criterion elegantly since WLD
depends on the perceived luminance difference. For example, as shown in (2), WLD
preserves the differences ( 00 s v ) between its neighbors and a centre pixel.
Sometimes 00 s v may be quite large. But if 00 s v / 01 s v is smaller than a noticeable
threshold, there is not a noticeable edge. In contrast, 00 s v may be quite small. But if
00 s v / 01 s v is larger than a noticeable threshold, there is a noticeable edge. In Fig.
5, we show some filtered images produced by WLD, from which one could conclude
that a WLD extracts the edges of images perfectly even with heavy noise.
Furthermore, the results of texture analysis show that much of the is discriminative
texture information is contained in high spatial frequencies such as edges. Thus, the
WLD works well to obtain a powerful feature for textures. WLD is robust to noise
appearing in a given image. Specifically, a WLD reduces the influence of noise, as it
is similar to the smoothing in image processing. As shown in Figure a differential
excitation is computed by a sum of its p-neighbor differences to a current pixel. Thus,
it reduces the influence of noisy pixels. Moreover, the sum of its p-neighbor
differences is further divided by the intensity of the current pixel, which also
decreases the influence of noise in an image. WLD has been developed to reduce the
effects of illumination change. On the one hand, it computes the differences 00 s v
between its neighbors and a current pixel. Thus, a brightness change in which a
constant is added to each image pixel will not affect the differences values. On the
other hand, WLD performs the division between the differences 00 s v and 01 s v .
Thus, a change in image contrast in which each pixel value is multiplied by a constant
19
Gender Recognition from Faces using Fuzzy Clustering and Nearest Neighbor Classifier
will multiply differences by the same constant, and this contrast change will be
cancelled by the division. Therefore, the descriptor is robust to changes in
illumination. Furthermore, regrouping the differential excitation and orientation into a
2D histogram and then weighting the different frequency segments can improve
further the performance of the WLD descriptor.
For LBP, it computes the intensity differences between the centre pixel
xc and its neighbors in the first stage, and the responses of each neighbor are
thresholded at zero and are then concatenated to a binary string in the second stage.
Each binary string corresponding to each pixel is then used to compute a histogram
feature in the last stage. For SIFT, it computes the gradient magnitude and orientation
at each image sample point in a region around the keypoint location in the first stage.
The orientations are quantized to 8 dominant ones in the second stage. For the third
stage, the gradient magnitudes are weighted by a Gaussian window, and then
accumulated into orientation histograms by summarizing the contents over denoted
sub-regions.
Although WLD also computes the difference between the centre pixel xc
and its neighbors like LBP in the first stage, these differences are added together and
then divided by the centre pixel xc to obtain the differential excitation like the Weber
fraction. Different from LBP, WLD uses the gradient orientations to describe the
direction of edges. The gradient orientations are then quantized to 8 dominant
orientations in the second stage. Different from SIFT, we use the differential
excitation but not the weighted gradient to compute the histogram. Moreover,
differential excitations are not accumulated over denoted sub-regions around the
keypoint location. In contrast, we compute the frequency of the occurrence of
differential excitations for each bin of the histogram, the weighted object is the
20
Gender Recognition from Faces using Fuzzy Clustering and Nearest Neighbor Classifier
frequency of each bin, and the weights are computed according to the recognition
performance based on the statistics, not weighting the values of gradients in terms of
the distances between the neighbours and the keypoint, as does SIFT. Furthermore,
we also compare the time complexity of WLD with LBP and SIFT theoretically.
Given an image in m×n, the time complexity for WLD is very low. It is as follows:
OWLD = C1m ,n , ,
where C1 is a constant. We use C1 for the computation of each pixel in WLD through
several additions, divisions and filtering with an arctangent function. Likewise, the
time complexity for LBP is also very simple:
OLBP = C 2 mn ,
where C2 is also a constant. We use C2 for the computation of each pixel in LBP
through several additions. However, the time complexity for SIFT is a little
complicated
Drawbacks
21
Gender Recognition from Faces using Fuzzy Clustering and Nearest Neighbor Classifier
CHAPTER 3
22
Gender Recognition from Faces using Fuzzy Clustering and Nearest Neighbor Classifier
The overall approach for gender detection block diagram is shown in Fig 3.1
Face Image
Preprocessing
Feature Extraction
Computation Classifier
Database Verification
Display Output
23
Gender Recognition from Faces using Fuzzy Clustering and Nearest Neighbor Classifier
• Good detection - the algorithm used must point out as many real images as
possible.
• Minimal response - a given edge must mark only once in a possible way; the
noise, if any, in an image should not create false detection of an edge.
• Good localization - the marked edges should always be nearer to the real
image.
• Lighting compensation we adjust the locations of the lights to change the
lighting condition. The total energy of an image is the sum of the squares of
the intensity values.
3. Lapalacian of Gaussian Filter
Lapalacian of Gaussian Filter is used to filter noise before edge detection. This
method combines Gaussian filtering with the Laplacian for edge detection.
In Laplacian of Gaussian edge detection there are mainly three steps:
• Filtering
• Enhancement
• Detection
The LoG is a bandpass filter; we can therefore fold the spectrum of the image
(after low pass filtering) without loss of information, which is equivalent to reducing
the resolution.
The Laplacian of an image highlights regions of rapid intensity change and is
therefore often used for edge detection The Laplacian is often applied to an image that
has first been smoothed with something approximating a Gaussian smoothing filter in
order to reduce its sensitivity to noise. The operator normally takes a single graylevel
image as input and produces another graylevel image as output.
The Laplacian L(x,y) of an image with pixel intensity values I(x,y) is given by:
2I 2I
L ( x, y )
x 2 y 2
24
Gender Recognition from Faces using Fuzzy Clustering and Nearest Neighbor Classifier
4. Facial region extraction: we adopt the face detection method. The method for
detecting and extracting the facial features in a gray-level image is divided into two
stages. First, the possible human eye regions are detected by testing all the valley
regions in an image. A pair of eye candidates is selected by means of the genetic
algorithm to form a possible face candidate. In our method, a square block is used to
represent the detected face region.
Computation
Compute the Euclidean distance matrix between pairs of feature vectors in the
training,
3. Collect the class labels of the patterns located in the closest neighborhood of the
pattern,
Gender classification method using frontal facial images of people. The proposed
approach employs nearest neighbor classifier (NN) and fuzzy clustering technique,
respectively, for feature extraction and classification steps.
Fuzzy Clustering
FCM is a data clustering algorithm in which each data point associated with cluster
through a membership degree. This technique divides a group of N data points into r
fuzzy groups and finds a cluster center in each group, such that a cost of function of a
dissimilarity measure is minimized. Fuzzy clustering algorithm is used to reduce the
misclassified faces by excluding or modifying the low membership face images.
25
Gender Recognition from Faces using Fuzzy Clustering and Nearest Neighbor Classifier
Advantages
Fuzzy clustering approach outperforms the other methods for the datasets considered.
• Sensitivity variations in illumination and facial expression reduced
substantially.
• Fuzzy sets can efficiently manage the vagueness and ambiguity of face
images degraded by poor illumination component.
So far, many techniques have been proposed that can be used as a distinct
feature from facial images, which are given to binary classifier. The feature extraction
techniques are mainly based on geometric and appearance. Geometric features are
mainly based on distance between eyes, eye to ear, face length and face width; these
features are used by machine to classify a face image based on gender. Another
approach is appearance based approach that uses whole face image containing
thousands of pixels which is reduced to handful number of pixels by dimensionally
reduction schemes. For this image is transformed into other domain and features are
selected from that domain.
Clustering
26
Gender Recognition from Faces using Fuzzy Clustering and Nearest Neighbor Classifier
The central idea in fuzzy clustering is the non-unique partitioning of the data
into a collection of clusters. The data points are assigned membership values for each
of the clusters and fuzzy clustering algorithm allow the clusters to grow into their
natural shapes [3]. The fuzzy clustering algorithms can be divided into two types 1)
Classical fuzzy clustering algorithms 2) Shape based fuzzy clustering algorithms.
Classical fuzzy clustering algorithms can be divided into three types.1) The Fuzzy C-
Means algorithm 2) The Gustafson-Kessel algorithm 3) The Gath-Geva algorithm.
Shape based fuzzy clustering algorithm can be divided into 1) Circular shape based
clustering algorithm 2) Elliptical shape based clustering algorithm 3) Generic shape
based clustering algorithm. In this paper, represent a review on fuzzy c means, and
extended version of fcm such as pcm, fpcm and their advantages and disadvantages of
real time applications.
Fuzzy clustering is a class of algorithms for cluster analysis in which the allocation
of data points to clusters is not "hard" (all-or-nothing) but "fuzzy" in the same sense as fuzzy
logic. Data clustering is the process of dividing data elements into classes or clusters so that
items in the same class are as similar as possible, and items in different classes are as
dissimilar as possible. Depending on the nature of the data and the purpose for which
clustering is being used, different measures of similarity may be used to place items into
classes, where the similarity measure controls how the clusters are formed.
Some examples of measures that can be used as in clustering include distance,
connectivity, and intensity. In hard clustering, data is divided into distinct clusters, where
each data element belongs to exactly one cluster. In fuzzy clustering (also referred to as soft
clustering), data elements can belong to more than one cluster, and associated with each
element is a set of membership levels. These indicate the strength of the association between
that data element and a particular cluster.
Fuzzy clustering is a process of assigning these membership levels, and then using
them to assign data elements to one or more clusters. In fuzzy c-means clustering, each point
has a degree of belonging to clusters, as in fuzzy logic, rather than belonging completely to
just one cluster. Thus, points on the edge of a cluster, may be in the cluster to a lesser degree
than points in the center of cluster.
Ck
w ( x) x
x k
m
w ( x)
x k
m
27
Gender Recognition from Faces using Fuzzy Clustering and Nearest Neighbor Classifier
Any point x has a set of coefficients giving the degree of being in the kth cluster wk(x).
With fuzzy c-means, the centroid of a cluster is the mean of all points, weighted by their
degree of belonging to the cluster:
The degree of belonging, wk(x), is related inversely to the distance from x
to the cluster center as calculated on the previous pass. It also depends on a
parameter m that controls how much weight is given to the closest center.
The algorithm employs fuzzy partitioning such that a given data point can belong
to several groups with a degree specified by membership grades between 0 and 2.
Gender recognition has been an active research topic since the early nineties.
There have been several advances in the past few years in terms of face detection and
tracking, feature extraction mechanisms and the related machine learning techniques.
28
Gender Recognition from Faces using Fuzzy Clustering and Nearest Neighbor Classifier
Face recognition has drawn the attention of researchers in fields from image analysis
and processing, computer vision, to psychology and security [1]. In spite of more than
fifteen years of extensive re-search, large number of papers published in journals and
conferences dedicated to this area, we still cannot claim that automatic face
recognition is comparable to human performance [2]. The difficulty of automatic face
recognition is due to various effects like aging, facial expressions, occlusions, lighting
and viewpoint changes induced by body movement [3].
A successful face recognition mythology depends heavily on the particular
choice of the features, observation reduction and classification method. In this paper
four algorithms have introduced, modified and combined to enhance the face
recognition and detection [4]. The features are extracted using Fourier-Gabor filter
and selected by generalizing signal to noise equation. Modified fuzzy clustering
algorithm is used to reduce the misclassified faces by excluding or modifying the low
membership faces. Furthermore a new non-linear kernel is used to kernel the least
square method and the wild dog pack optimization is implemented to find the optimal
parameters. The suggested method is implemented by using four datasets: AT & T
database of faces (ATT), Indian Face Database (IFD), Faces95 from Essex university
database and Yale face database (Yale)
Feature Extraction and Selection There are several methods have been used to
extract the features from the face images, one among the best methods is Fourier-
Gabor filter which is introduced in [8]. Therefore the same method will be used in this
study to extract the features from the face images. However different size, orientation
and scale values are adopted in this study. The main steps are as following:
1) Resize the images to 40 × 40
2) Transform the images to frequency domain by applying Fourier transform in
Equation (3)
3) Use Equation (4) to prepare 8 Gabor filters for orientation and 10 filters for scaling.
Thus 80 different filters will be constructed
4) Multiply the result matrix in step 2 by each matrix in step 3.
5) Resize each matrix in step 4 as one row
6) construct the feature vector for each face by concatenation all the rows in step 5.
29
Gender Recognition from Faces using Fuzzy Clustering and Nearest Neighbor Classifier
Feature Extraction,
Face Detection Normalization
Decision
KNN Classifier
Male/Female
30
Gender Recognition from Faces using Fuzzy Clustering and Nearest Neighbor Classifier
CHAPTER 4
IMPLEMENTATION
4.1 Functional Requirements
System Configuration:
1. Test Image
2. Face Detection
3. Normalization
4. Features Extraction
5. Classification
6. Decision making
31
Gender Recognition from Faces using Fuzzy Clustering and Nearest Neighbor Classifier
Test Image
Test image is nothing but an input image that to be compared with database
images for classification or authentication.
Normalization
Removing the unwanted distortions which acquired from the input face images
Feature Extraction
Calculate the similar features of the given image by comparing the pixel
values and group them to form a cluster by using Fuzzy clustering.
Classification
The k-NN classifier is used to classify the different face images. The
Euclidean distance between the testing image feature and the training image
feature and a distance matrix is created.
In the distance matrix first k values are considered as and majority label of the
k value is considered as the correct label of the given testing image.
Detection
32
Gender Recognition from Faces using Fuzzy Clustering and Nearest Neighbor Classifier
4.3 Tools
MATLAB
Algorithm development
The name MATLAB stands for matrix laboratory. MATLAB was originally written
to provide easy access to matrix software developed by the LINPACK and EISPACK
projects. Today, MATLAB uses software developed by the LAPACK and ARPACK
projects, which together represent the state-of-the-art in software for matrix
computation.
MATLAB has evolved over a period of years with input from many
users. In university environments, it is the standard instructional tool for introductory
and advanced courses in mathematics, engineering, and science. In industry,
MATLAB is the tool of choice for high-productivity research, development, and
analysis.
33
Gender Recognition from Faces using Fuzzy Clustering and Nearest Neighbor Classifier
Development Environment. This is the set of tools and facilities that help you use
MATLAB functions and files. Many of these tools are graphical user interfaces. It
includes the MATLAB desktop and Command Window, a command history, and
browsers for viewing help, the workspace, files, and the search path.
The MATLAB Application Program Interface (API). This is a library that allows
you to write C and FORTRAN programs that interact with MATLAB. It include
34
Gender Recognition from Faces using Fuzzy Clustering and Nearest Neighbor Classifier
facilities for calling routines from MATLAB (dynamic linking), calling MATLAB as
a computational engine, and for reading and writing MAT-files.
Introduction
This chapter provides a brief introduction to starting and quitting MATLAB, and
the tools and functions that help you to work with MATLAB variables and files. For
more information about the topics covered here, see the corresponding topics under
Development Environment in the MATLAB documentation, which is available online
as well as in print.
Starting MATLAB
After starting MATLAB, the MATLAB desktop opens - see MATLAB Desktop.
You can change the directory in which MATLAB starts, define startup options
including running a script upon startup, and reduce startup time in some situations.
Quitting MATLAB
To end your MATLAB session, select Exit MATLAB from the File menu in
the desktop, or type quit in the Command Window. To execute specified functions
each time MATLAB quits, such as saving the workspace, you can create and run a
finish.m script.
MATLAB Desktop
35
Gender Recognition from Faces using Fuzzy Clustering and Nearest Neighbor Classifier
The first time MATLAB starts, the desktop appears as shown in the
following illustration, although your Launch Pad may contain different entries.
You can change the way your desktop looks by opening, closing,
moving, and resizing the tools in it. You can also move tools outside of the desktop or
return them back inside the desktop (docking). All the desktop tools provide common
features such as context menus and keyboard shortcuts.
Desktop Tools
Workspace Browser
Array Editor
Editor/Debugger
Command Window
Command History
Launch Pad
Help Browser
36
Gender Recognition from Faces using Fuzzy Clustering and Nearest Neighbor Classifier
Command Window Use the Command Window to enter variables and run functions
and M-files.
Command History
Lines you enter in the Command Window are logged in the Command
History window. In the Command History, you can view previously used functions,
and copy and execute selected lines. To save the input and output from a MATLAB
session to a file, use the diary function.
Launch Pad
Help Browser
Use the Help browser to search and view documentation for all your Math
Works products. The Help browser is a Web browser integrated into the MATLAB
desktop that displays HTML documents.
To open the Help browser, click the help button in the toolbar, or type help
browser in the Command Window. The Help browser consists of two panes, the Help
Navigator, which you use to find information, and the display pane, where you view
the information.
Help Navigator
37
Gender Recognition from Faces using Fuzzy Clustering and Nearest Neighbor Classifier
Product filter: Set the filter to show documentation only for the products you
specify.
Contents tab: View the titles and tables of contents of documentation for your
products.
Index tab: Find specific index entries (selected keywords) in the MathWorks
documentation for your products.
Search tab: Look for a specific phrase in the documentation. To get help for a
specific function, set the Search type to Function Name.
Display Pane
After finding documentation using the Help Navigator, view it in the display
pane. While viewing the documentation, you can:
Browse to other pages - Use the arrows at the tops and bottoms of the pages, or use
the back and forward buttons in the toolbar.
Find a term in the page - Type a term in the Find in page field in the toolbar and
click Go.
Other features available in the display pane are: copying information, evaluating a
selection, and viewing Web pages.
MATLAB file operations use the current directory and the search path as
reference points. Any file you want to run must either be in the current directory or on
the search path
38
Gender Recognition from Faces using Fuzzy Clustering and Nearest Neighbor Classifier
Search Path
To determine how to execute functions you call, MATLAB uses a search path
to find M-files and other MATLAB-related files, which are organized in directories
on your file system. Any file you want to run in MATLAB must reside in the current
directory or in a directory that is on the search path. By default, the files supplied with
MATLAB and MathWorks toolboxes are included in the search path.
To view the workspace and information about each variable, use the
Workspace browser, or use the functions.
To delete variables from the workspace, select the variable and select Delete
from the Edit menu. Alternatively, use the clear function.
Array Editor
Editor/Debugger
Use the Editor/Debugger to create and debug M-files, which are programs you
write to run MATLAB functions. The Editor/Debugger provides a graphical user
interface for basic text editing, as well as for M-file debugging.
You can use any text editor to create M-files, such as Emacs, and can
use preferences (accessible from the desktop File menu) to specify that editor as the
default. If you use another editor, you can still use the MATLAB Editor/Debugger for
debugging, or you can use debugging functions, such as dbstop, which sets a
breakpoint.
39
Gender Recognition from Faces using Fuzzy Clustering and Nearest Neighbor Classifier
MANIPULATING MATRICES
Entering Matrices
The best way for you to get started with MATLAB is to learn how to handle
matrices. Start MATLAB and follow along with each example.
Start by entering Dürer's matrix as a list of its elements. You have only to follow a
few basic conventions:
A=
16 3 2 13
5 10 11 8
9 6 7 12
4 15 14 1
40
Gender Recognition from Faces using Fuzzy Clustering and Nearest Neighbor Classifier
This exactly matches the numbers in the engraving. Once you have entered the
matrix, it is automatically remembered in the MATLAB workspace. You can refer to
it simply as A.
Variables
MATLAB does not require any type declarations or dimension statements. When
MATLAB encounters a new variable name, it automatically creates the variable and
allocates the appropriate amount of storage. If the variable already exists, MATLAB
changes its contents and, if necessary, allocates new storage. For example,
num_students = 25
Creates a 1-by-1 matrix named num_students and stores the value 25 in its single
element.
+ Addition
- Subtraction
* Multiplication
/ Division
41
Gender Recognition from Faces using Fuzzy Clustering and Nearest Neighbor Classifier
^ Power
Functions
type
help specfun
help elmat
Some of the functions, like sqrt and sin, are built-in. They are part of
the MATLAB core so they are very efficient, but the computational details are not
readily accessible. Other functions, like gamma and sin, are implemented in M-files.
You can see the code and even modify it if you want.
Figure
Figures are the windows that contain the GUI you design with the Layout
Editor. See the description of figure properties for information on what figure
characteristics you can control.
GUI
42
Gender Recognition from Faces using Fuzzy Clustering and Nearest Neighbor Classifier
A graphical user interface (GUI) is a user interface built with graphical objects,
such as buttons, text fields, sliders, and menus. In general, these objects already have
meanings to most computer users. For example, when you move a slider, a value
changes; when you press an OK button, your settings are applied and the dialog box is
dismissed. Of course, to leverage this built-in familiarity, you must be consistent in
how you use the various GUI-building components.
Applications that provide GUIs are generally easier to learn and use since
the person using the application does not need to know what commands are available
or how they work. The action that results from a particular user action can be made
clear by the design of the interface.
The sections that follow describe how to create GUIs with MATLAB. This
includes laying out the components, programming them to do specific things in
response to user actions, and saving and launching the GUI; in other words, the
mechanics of creating GUIs. This documentation does not attempt to cover the "art"
of good user interface design, which is an entire field unto itself. Topics covered in
this section include:
43
Gender Recognition from Faces using Fuzzy Clustering and Nearest Neighbor Classifier
GUI. This M-file provides a framework for the implementation of the callbacks - the
functions that execute when users activate components in the GUI.
While it is possible to write an M-file that contains all the commands to lay
out a GUI, it is easier to use GUIDE to lay out the components interactively and to
generate two files that save and launch the GUI:
A FIG-file - contains a complete description of the GUI figure and all of its
children (uicontrols and axes), as well as the values of all object properties.
An M-file - contains the functions that launch and control the GUI and the
Note that the application M-file does not contain the code that lays out
the uicontrols; this information is saved in the FIG-file.
44
Gender Recognition from Faces using Fuzzy Clustering and Nearest Neighbor Classifier
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
45
Gender Recognition from Faces using Fuzzy Clustering and Nearest Neighbor Classifier
% --- Outputs from this function are returned to the command line.
function varargout = main_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
if isequal(file,0)
46
Gender Recognition from Faces using Fuzzy Clustering and Nearest Neighbor Classifier
if size(inp,3)>1
inp = rgb2gray(inp);
end
axes(handles.axes2);
imshow(inp);
title('Test Image Gray Scale Part');
end
%handles.inp=inp;
for i = 1:size(BB,1)
J = imcrop(img,BB(i,:));
end
imwrite(J,'Croped.jpg');
axes(handles.axes3);
imshow(J);
Freg = double(J);
%axes(handles.axes3);
%imshow(Freg,[]);
%title('Face Detection');
handles.Freg=Freg;
guidata(hObject, handles);
47
Gender Recognition from Faces using Fuzzy Clustering and Nearest Neighbor Classifier
%%%%%%%%%%%%%%%%%%%%%%%%%%%
fuzzycmeans(rgb2gray(imread('Croped.jpg')),2,10)
48
Gender Recognition from Faces using Fuzzy Clustering and Nearest Neighbor Classifier
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
k='male/test/';
Im1=rgb2gray(imread(strcat(k,data)));
t1=imread(strcat(k,data));
for i=301:312
kk=strcat(num2str(i),'.jpg');
% Im1 = rgb2gray(imresize(imread('input.jpg'),[256 384]));
Im2 = rgb2gray(imread(strcat(k,kk)));
t2=imread(strcat(k,kk));
if(t1==t2)
msgbox('Male');
end
% convert images to type double (range from from 0 to 1 instead of from 0 to 255)
Im1 = im2double(Im1);
Im2 = im2double(Im2);
end
end
49
Gender Recognition from Faces using Fuzzy Clustering and Nearest Neighbor Classifier
function [recognized_img]=facerecog(datapath,testimg)
% In this part of function, we align a set of face images (the training set x1, x2, ... ,
xM )
%
% This means we reshape all 2D images of the training database
% into 1D column vectors. Then, it puts these 1D column vectors in a row to
% construct 2D matrix 'X'.
%
%
% datapath - path of the data images used for training
% X - A 2D matrix, containing all 1D image vectors.
% Suppose all P images in the training database
% have the same size of MxN. So the length of 1D
% column vectors is MxN and 'X' will be a (MxN)xP 2D
matrix.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%
X = [];
for i = 1 : imgcount
str = strcat(datapath,'\',int2str(i),'.jpg');
img = imread(str);
img = rgb2gray(img);
[r c] = size(img);
temp = reshape(img',r*c,1); %% Reshaping 2D images into 1D image vectors
%% here img' is used because reshape(A,M,N) function reads the
matrix A columnwise
%% where as an image matrix is constructed with first N pixels as
first row,next N in second row so on
X = [X temp]; %% X,the image matrix with columnsgetting added for
each image
50
Gender Recognition from Faces using Fuzzy Clustering and Nearest Neighbor Classifier
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Now we calculate m, A and eigenfaces.The descriptions are below :
%
% m - (MxN)x1 Mean of the training images
% A - (MxN)xP Matrix of image vectors after each vector getting
subtracted from the mean vector m
% eigenfaces - (MxN)xP' P' Eigenvectors of Covariance matrix (C) of
training database X
% where P' is the number of eigenvalues of C that best represent
the feature set
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%% calculating A matrix, i.e. after subtraction of all image vectors from
the mean image vector %%%%%%
A = [];
for i=1 : imgcount
temp = double(X(:,i)) - m;
A = [A temp];
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% CALCULATION
OF EIGENFACES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%
%%% we know that for a MxN matrix, the maximum number of non-zero
eigenvalues that its covariance matrix can have
%%% is min[M-1,N-1]. As the number of dimensions (pixels) of each image vector
is very high compared to number of
%%% test images here, so number of non-zero eigenvalues of C will be maximum P-
1 (P being the number of test images)
%%% if we calculate eigenvalues & eigenvectors of C = A*A' , then it will be very
time consuming as well as memory.
%%% so we calculate eigenvalues & eigenvectors of L = A'*A , whose eigenvectors
will be linearly related to eigenvectors of C.
%%% these eigenvectors being calculated from non-zero eigenvalues of C, will
represent the best feature sets.
51
Gender Recognition from Faces using Fuzzy Clustering and Nearest Neighbor Classifier
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
L= A' * A;
[V,D]=eig(L); %% V : eigenvector matrix D : eigenvalue matrix
%%%% again we use Kaiser's rule here to find how many Principal Components
(eigenvectors) to be taken
%%%% if corresponding eigenvalue is greater than 1, then the eigenvector will be
chosen for creating eigenface
L_eig_vec = [];
for i = 1 : size(V,2)
if( D(i,i) > 1 )
L_eig_vec = [L_eig_vec V(:,i)];
end
end
%In this part of recognition, we compare two faces by projecting the images into
facespace and
% measuring the Euclidean distance between them.
%
% recogimg - the recognized image name
% testimg - the path of test image
% m - mean image vector
% A - mean subtracted image vector matrix
% eigenfaces - eigenfaces that are calculated from eigenface function
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%
%%%%%%% finding the projection of each image vector on the facespace (where
the eigenfaces are the co-ordinates or dimensions) %%%%%
test_image = imread(testimg);
test_image = test_image(:,:,1);
[r c] = size(test_image);
52
Gender Recognition from Faces using Fuzzy Clustering and Nearest Neighbor Classifier
%%%%% calculating & comparing the euclidian distance of all projected trained
images from the projected test image %%%%%
euclide_dist = [ ];
for i=1 : size(eigenfaces,2)
temp = (norm(projtestimg-projectimg(:,i)))^2;
euclide_dist = [euclide_dist temp];
end
[euclide_dist_min recognized_index] = min(euclide_dist);
recognized_img = strcat(int2str(recognized_index),'.jpg');
function image_out = smooth_gaussian(img,order,sig)
img2 = img;
for i=1:floor(order/2)
[h,w] = size(img2);
f = gauss2d(order,sig);
image_out = conv2(img2,f,'valid');
function f = gauss2d(order,sig)
f=0;
i=0;
j=0;
for x = -fix(order/2):1:fix(order/2)
j=j+1;
i=0;
for y = -fix(order/2):1:fix(order/2)
i=i+1;
f(i,j) = 1/2/pi*exp(-((x^2+y^2)/(2*sig^2)));
end
end
53
Gender Recognition from Faces using Fuzzy Clustering and Nearest Neighbor Classifier
f = f / sum(sum(f));
function[Ifc,CI] = fuzzycmeans(I,k,Tn)
I=double(I);
[H,W]=size(I);
Icm = zeros(H,W);
IC = [];
for i=1:k
IC=cat(3,IC,I);
end
cc = randi(250,1,k);
TFcm=0;
%-----------------------------------------------------------------
while(TFcm<Tn)
c=[];
R = [];
tmp = [];
P = [];
D=zeros(H,W,1);
for i=1:k
U=repmat(cc(i),H,W);
c=cat(3,c,U);
end
for i=1:k
r=repmat(0.000001,H,W);
R=cat(3,R,r);
end
distance=IC-c;
distance=distance.*distance+R;
dS=1./distance;
for i=1:k
D = D + dS(:,:,i);
end
for i=1:k
dist(:,:,i)=distance(:,:,i).*D;
Q(:,:,i)=1./dist(:,:,i);
end
54
Gender Recognition from Faces using Fuzzy Clustering and Nearest Neighbor Classifier
for i=1:k
CI(i)=sum(sum(Q(:,:,i).*Q(:,:,i).*I))/sum(sum(Q(:,:,i).*Q(:,:,i)));
end
for i=1:k
tmp = cat(3,tmp,abs(cc(i)-CI(i))/cc(i));
end
for i=1:k
P = cat(3,P,Q(:,:,i));
end
for i=1:H
for j=1:W
for l=1:k
if max(P(i,j,:))==Q(i,j,l)
Icm(i,j)=l;
end
end
end
end
%------------------------------------------------------------------
if max(tmp)<0.0001
break;
else
cc = CI; %updating cluster centers
end
%----------------------------------------
Ifc=uint8(Icm);
TFcm=TFcm+1;
end
function result = knnclassification(testsamplesX,samplesX, samplesY, Knn,type)
55
Gender Recognition from Faces using Fuzzy Clustering and Nearest Neighbor Classifier
L = length(samplesY);
Uc = unique(samplesY);
if (L < Knn),
error('You specified more neighbors than there are points.')
end
N = size(testsamplesX, 1);
result = zeros(N,1);
switch type
case '2norm'
for i = 1:N,
dist = sum((samplesX - ones(L,1)*testsamplesX(i,:)).^2,2);
[m, indices] = sort(dist);
n = hist(samplesY(indices(1:Knn)), Uc);
[m, best] = max(n);
result(i) = Uc(best);
end
case '1norm'
for i = 1:N,
dist = sum(abs(samplesX - ones(L,1)*testsamplesX(i,:)),2);
[m, indices] = sort(dist);
n = hist(samplesY(indices(1:Knn)), Uc);
[m, best] = max(n);
result(i) = Uc(best);
end
case 'match'
for i = 1:N,
dist = sum(samplesX == ones(L,1)*testsamplesX(i,:),2);
[m, indices] = sort(dist);
n = hist(samplesY(indices(1:Knn)), Uc);
[m, best] = max(n);
result(i) = Uc(best);
end
otherwise
error('Unknown measure function');
end
56
Gender Recognition from Faces using Fuzzy Clustering and Nearest Neighbor Classifier
CHAPTER 5
TESTING
5.1 TESTING
Testing is the process of evaluating a system or its component(s) with the intent to
find that whether it satisfies the specified requirements or not. This activity results in
the actual, expected and difference between their results. In simple words testing is
executing a system in order to identify any gaps, errors or missing requirements in
contrary to the actual desire or requirements.
Unit testing involves the design of test cases that validate that the internal
program logic is functioning properly, and that program inputs produce valid outputs.
All decision branches and internal code flow should be validated. It is the testing of
individual software units of the application .it is done after the completion of an
individual unit before integration. This is a structural testing, that relies on knowledge
of its construction and is invasive. Unit tests perform basic tests at component level
and test a specific business process, application, and/or system configuration. Unit
tests ensure that each unique path of a business process performs accurately to the
documented specifications and contains clearly defined inputs and expected results.
57
Gender Recognition from Faces using Fuzzy Clustering and Nearest Neighbor Classifier
Functional tests provide systematic demonstrations that functions tested are available
as specified by the business and technical requirements, system documentation, and
user manuals. Functional testing is centered on the following items:
System testing ensures that the entire integrated software system meets requirements.
It tests a configuration to ensure known and predictable results. An example of system
testing is the configuration oriented system integration test. System testing is based on
process descriptions and flows, emphasizing pre-driven process links and integration
points.
White box testing is the detailed investigation of internal logic and structure of the
code. White box testing on an application, the tester needs to possess knowledge of
58
Gender Recognition from Faces using Fuzzy Clustering and Nearest Neighbor Classifier
the internal working of the code. The tester needs to have a look inside the source
code and find out which unit/chunk of the code is behaving inappropriately.
Advantages:
As the tester has knowledge of the source code, it becomes very easy to find out
which type of data can help in testing the application effectively.
Disadvantages:
Due to the fact that a skilled tester is needed to perform white box testing, the
costs are increased.
Sometimes it is impossible to look into every nook and corner to find out
hidden errors
The technique of testing without having any knowledge of the interior workings of the
application is Black Box testing. The tester is oblivious to the system architecture and
does not have access to the source code. Typically, when performing a black box test,
a tester will interact with the system’s user interface by providing inputs and
examining outputs without knowing how and where the inputs are worked upon.
Advantages:
Disadvantages:
Limited Coverage since only a selected number of test scenarios are actually
performed.
Inefficient testing, due to the fact that the tester only has limited knowledge
59
Gender Recognition from Faces using Fuzzy Clustering and Nearest Neighbor Classifier
about an application.
Unit Testing:
Unit testing is usually conducted as part of a combined code and unit test phase of
the software lifecycle, although it is not uncommon for coding and unit testing to be
conducted as two distinct phases.
Field testing will be performed manually and functional tests will be written in
detail.
Test Objectives
Features to Be Tested
Test Results: All the test cases mentioned above passed successfully. No defects
encountered.
Acceptance Testing
User Acceptance Testing is a critical phase of any project and requires significant
participation by the end user. It also ensures that the system meets the functional
requirements.
Test Results: All the test cases mentioned above passed successfully. No defects
encountered.
60
Gender Recognition from Faces using Fuzzy Clustering and Nearest Neighbor Classifier
61
Gender Recognition from Faces using Fuzzy Clustering and Nearest Neighbor Classifier
CHAPTER 6
RESULTS
1. This is the first GUI that appears when we execute the project in Matlab. It consists
of 3axex components in which input image, grayscale image, and facial part of input
image are displayed simultaneously. It also consists of six push buttons Browse, Face
Detection, Clustering Feature Extraction ,Classified Image, Detect. On clicking each
button performs corresponding action.
2. After browsing and selecting image program is written such that it automatically
converts input image to scale 256*256 and converts to gray scale. It is displayed in
second axis automatically.
62
Gender Recognition from Faces using Fuzzy Clustering and Nearest Neighbor Classifier
3. After converting to gray scale, face in the input image is found out using
facefind.dll is Face Detection button is pressed.
63
Gender Recognition from Faces using Fuzzy Clustering and Nearest Neighbor Classifier
4. Calculate the similar features of the given image by comparing the pixel values and
group them to form a cluster.
64
Gender Recognition from Faces using Fuzzy Clustering and Nearest Neighbor Classifier
5. Creating an array vector and compare the test image with the predefined values.
Determine K value using test set and report the performance on the test set.
Once the features are extracted ,these features are fed to K-NN classifier, it performs
classification mechanism on comparing to database image’s properties classifies
whether male/female
65
Gender Recognition from Faces using Fuzzy Clustering and Nearest Neighbor Classifier
66
Gender Recognition from Faces using Fuzzy Clustering and Nearest Neighbor Classifier
CHAPTER 7
A future study will be to reduce the feature dimension of the proposed method
in an intelligent way.
67
Gender Recognition from Faces using Fuzzy Clustering and Nearest Neighbor Classifier
REFERENCES
[1] Golomb B., Lawrence D., Sejnowski T.: Sexnet: a neural network
identifies sex from human faces. In: Advances in Neural Information Processing
Systems, pp. 572–577. Morgan Kaufmann, San Mateo (1991)
[2] Tamura S.H., Kawai, Mitsumoto H.: Male/female identification from 8 9 6 very
low resolution face images by neural network. Pattern Recognit. 29, 331–335 (1996)
[3] Gutta, S., Weschler, H., Phillips, P.J.: Gender and ethnic classificationof human
faces using hybrid classifiers. In: Proceedingsof IEEE International Conference on
Automatic Face and Gesture Recognition, pp. 194–199 (1998)
[4] Wu B., Ai H., Huang C.: LUT-based Adaboost for gender classification. AVBPA
2688, 104–110 (2003)
[5] Moghaddam B., Yang M.H.: Gender classification with support vector
machines. In: IEEE Trans. PAMI 24, 707–711 (2002)
[6] Baluja S., Rowley H.A.: Boosting sex identification performance. Int. J. Comput.
Vis. 71, 111–119 (2007)
[7] Do, T.T.; Le, T.H., Facial Feature Extraction Using Geometric Feature and
Independent Component Analysis.
Springer-Verlag Berlin, Heidelberg . 2009, p. 231-241. ISBN 978-3- 642-01714-8.
[8] Omaia, A; Poel, J.K; Batista, L.V. 2D-DCT Distance Based Face
Recognition Using a Reduced Number of Coefficients. Computer Graphics and
Image Processing (SIBGRAPI). 2009, p. 291 - 298. ISSN 1550-1834.
[9] A. Golom, D. T. Lawrence, and T. J. Sejnowski, ―SEXNET: A neural network
identifies gender from human faces‖, Advances in Neural Information Processing
Systems, pp. 572-577, 1991
[10] B. Moghaddam and M.-H.Yang, ―Gender classification with support vector
machines‖ Proc. IEEE International Conference on Automatic Face and Gesture
Recognition, pp. 306-311, March 2000.
[11] M. Nakano, F. Yasukata and M. Fukumi, ―Age and gender classification
from face images using neural networks‖ Proc. of Signal and Image Processing,
2004.
68
Gender Recognition from Faces using Fuzzy Clustering and Nearest Neighbor Classifier
PUBLISHED PAPER
The paper with title “GENDER RECOGNITION FROM FACES USING FUZZY
CLUSETRING AND NEAREST NEIGHBOR CLASSIFIER” was published in
International Journal of Innovative Research in Computer and Communication
Engineering in October 2016.
69