Gender Classification Using OpenCV and Feature Extraction
Gender Classification Using OpenCV and Feature Extraction
net/publication/349551329
CITATION READS
1 758
3 authors, including:
All content following this page was uploaded by Dibyendu Saha on 24 February 2021.
Abstract - Face detection [1] is not an easy task for steps. Firstly, giving a common gray filter to the image to
machines like it is for humans. The machines need to be detect facial features. To detect the skin regions from the facial
trained thoroughly with many data, because the machines image, the proposed algorithm coverts the image to YCbCr [7]
cannot understand by its own. When we the humans look colour space from RGB.The next step is detecting the face
at someone’s face, we may decode much information about from the scattered pieces and hence dividing the face into 3
the person just by looking at the face such as gender, age parts as nose, forehead and eyes, mouth and jaw. These pieces
and sometimes behavior or calmness also. Our brain is also are hence used to detect the male or female classifications and
trained for recognizing gender from a face. The aim of this finally the detected image in the image database is used to the
project is to appropriately train the machine using face recognizer to test it with the image it has been trained.
algorithms so that it can identify and detect the differences
between male and female faces. The pixel and the data of II. LITERATURE REVIEW
the image are together known as the picture element. It is
Our paper deals with the agenda to classify the gender of a
the compact most element of an image. Both the processes
person using the features from the photo. This technology is
face recognition and face detection, mainly deal with the
pushed with greater accuracy in the paper so as to make
pixels and their respective picture elements. The attributes
computers much more user friendly and for security purposes
of the image or based upon the features extracted [2] from
also. Shervin EMAMI1 in his paper Facial Recognition using
each image can be used for the face recognition.
OpenCV has found a way to recognize a face and match with
Keywords: Gender Classification, OpenCV, Face Detection, the face in the database using OpenCV, but has not pushed the
Image, Feature Extraction. limits to classify the gender of the face hence recognized.
Object detection using Haar-cascade Classifier by Sander Soo
I. INTRODUCTION and Rapid Object Detection using a Boosted Cascade of
Simple Features by Paul Viola has found ways to detect the
The prevailing prominent feature in machine learning [3] object from a still image or from live streaming respectively.
and computer vision system [4] is the human face. Gender, The object thus detected is used to detect the face and thus
age, ethnicity, etc are the various information’s conveyed by recognizing it. The process of object detection is done by Haar
the human face. Sectors like biometric authentication [5] and Cascade classifier algorithm.
intelligent human computer interface [6] applies face
information. It is also used in law enforcement identifications, In this paper, the face is first preprocessed in which the
banking authentication, security system access and also face is divided into 3 parts- forehead, nose and below nose.
personal identification. According to neurophysiologist David Features or characteristics are extracted from them and hence
Hubel and Torstel Wiesel, there are specialized nerve cells in checked with the ones in the database. Also a common light
our brain which responds to specific local characteristics of a filter is given to the pictures which remove the extra
scene like lines, angles, edges and movements. The visual illumination and effects from it. The features hence extracted
cortex combines these information sources to combine them are also checked for gender classification. Unlike the other
into one frame or pattern. Automatic face recognition deals papers, this paper extracts features from the face after dividing
with deracinating those meaningful pieces and merging them it into 3 parts. This process of preprocessing is done by Haar
into one picture. The main concern for gender classification is cascade classifier and OpenCV.
detecting skin region and hence selecting colour space is
required. This whole process can be classified into three major
OpenCV [8] (open source computer vision library) is a The real world is a complicated illuminated environment
software library used for machine learning. It focuses on for which the eradication of non standard illumination is
processing any image fetched from real time. It increases the necessary. The lighting condition hampers the accuracy of the
use of machine learning or perception of machines in skin colour which complicates the face recognition and gender
commercial products. It can be used for any kind of image discrimination process. The environment creates a yellow
related processes, such as: detect faces, differentiate human biased colour or effect into the image. Contradicting the earlier
movements, track moving objects, find alike images from researches the present research shows that the skin colour
database, recognize scenery and differentiate them with other depends non-linearly on the luminance of the environment. In
situations. It was initially made in C interface, which makes it the process of lowering the environment luminance, takes into
easily available, making it having a wider range of customers account each pixel at a time. If the value of luma (non linear
or users. But, using it in C had some disadvantages like: more gamma corrected luminance) of each pixel is into any kind of
lines of code, more probability of errors. To eradicate these extremes the chrominance value is adjusted using top 5% of
problems it was summed up with C++ leading to less memory luma as reference white. The images which are taken in
leaks. But in this case providing wrappers are becoming a varying colors with different brightness can be restored to
difficult task as compared to C code. So, most of the wrappers natural lights using the light compensation (LC) algorithm [12]
of other languages are deficit of the features present in the as used in the paper.
recent updates.
The algorithm can be stated as follows:
3.2 Haar features
//template equation
The haar features [9] are used for extracting features from
the face to be trained. During the process of face detection, Ȓ = 𝛾0 + 𝛾1 𝛽1 + 𝛾2 𝛽2 + 𝛾3 𝛽3 + 𝛾4 𝛽4 + 𝜖𝑖
each face may have a huge number of features. The features
The object created by face recognition has Face
with low number of sub features or iterations are used to train
Recognizer [13] train for training the machine and Face
the classifier. This process can be done rapidly using Adaboost
Recognizer predict for recognizing the face. The detect Multi
algorithm [10]. For the features, the number of iterations
Scale [14] function in OpenCV uses the viola-Jones algorithm
contained in it can be calculated. Amongst all the features, the
for detecting faces on images. The above process is done by
one with the lowest iterations is needed and hence it is used to
train the classifier with haar features. The features hence segmenting the face into different parts from which features
achieved from the face the used to train and also modified to are to be extracted to check for similarity with the trained
produce the template. image.
The haar features are depicted as rectangular blocks, as The face detector studies each of the images and classifies
described in Viola’s paper [11]. The paper described that the it as face or not a face, coming from any image or video. In the
black areas of the rectangular boxes depicts a group of pixels, process of classifying the image, it assumes a fixed scale. The
classifier divides the face into smaller scales to search for the
which describes the features. This paper also describes that the
black areas and the white areas sums up the total block. That is, image. On detecting a face the face detector creates a sub
the black areas subtract the full block to achieve the uncolored image such that the face comes in the middle with appropriate
scale.
areas.
This promotes a better hit rate in the basic set of haar 4.2 Face Detection
features. There haar features are not exactly the haar ones but The face detection process comprises of steps like
the ones that are similar to the haar, which in turn are used to detecting the image, extracting the features, forming face
train the classifier and to extract the features. The rectangular image template, comparing the templates, declaring the
boxes may have more than one group of black groups. These matching template with the image. High pixel density and
black areas depict each sub feature under each feature. A block
resolution is accommodated to the real time image using any
having only one partition is one feature block, whereas the one
type of image sensor. This process can also be done by can
ones having two partitions are 2 features block and so on.
also be done by real time Ethernet connectivity. The real time
image is divided on smaller image parts and then simpler a two dimension Gussion [20]. The formula for space domain
patterns are searched onto it. Gabor wavelength is given below:
separating hyper plane. A hyper plane separates the input 995 images, has been taken into account, wherein the male
which is mapped on to high dimensional feature space, in case faces are indexed as +1 and the female ones as -1.
of linearly non-separable data. Kernels efficiently perform the
work of high dimensional projection into the space. For a set of 5.1 Results
training samples 𝑥𝑖 and their respective values of decision, TABLE 4.1.1
𝑦𝑖 ∈ −1, 1 , the best separating hyper plane calculated by Details of the mixed Database
the equation 𝑤 𝑇 𝑥 + 𝑏 is found out by SVM[23], which Database No. of male face No. of female face
increases the difference between the classes. images images
CMU PIE 66 56
The main task training SVM is to solve the following AR 156 168
Indian Face 150 132
quadratic equation:
Chinese Face 80 62
𝐿 FERET 79 62
1
min 𝐿 = 𝑎𝑖 𝑎𝑗 𝑦𝑖 𝑦𝑗 𝐾 𝑥𝑖 , 𝑥𝑗 − 𝑎𝑖 Total (995) 515 480
2 𝑖,𝑗 𝑖=1
TABLE 4.1.2
Subjected to- Comparison results of different algorithms
Male Female
Methods Detection Rate Detection Rate
0 ≤ 𝑎𝑖 , ≤ 𝐶, 𝑎𝑖 𝑦𝑖 = 0 (%) (%)
𝑖
Neural Network 62.31 65.2
Threshold Adaboost 75.26 72.45
Where, C signifies the penalty parameter [24] and K is LUT Adaboost 75.78 76.71
kernel function [25]. Mean Adaboost 71.84 73.23
LSVM 78.2 75.8
The problem can be stated as the input data which are SVM+Pol 86.72 84.51
projected to a higher dimensional plane where they are again SVM+RBF 87 85.5
separated using parallel hyper planes. The polynomial kernel Our data 87.6 85.9
function used for this problem is given below. TABLE 4.1.3
Gender Classification Result with different frequencies
𝑝
𝐾 𝑥𝑖 , 𝑥𝑗 = 1 + 𝑥𝑖𝑇 𝑥𝑗 Frequency Male Female
0.1~0.4 76.12% 78.5%
And the radial basis function is given by- 0.1~1.0 89.5% 87.9%
automatically detect face from the image. But this method, [13] Fast Face Detection with Multi-Scale Window Search
detect the face area automatically within the color image and Free from Image Resizing Using SGI Features,
also detect the gender of the face. It can be concluded that the Masayuki Miyama
experimental results of that the proposed method is much [14] A Real generalization of discrete AdaBoost, Richard
better in terms of varied circumstance. The proposed solution Nock
can be used for surveillance system, forensic applications, [15] Omni directional face detection based on Real
access control, face recognition problems etc. Finally, we Adaboost, Chang Huang
conclude that there is still room for improvement in gender [16] An efficient gentle Adaboost based approach for
classification methods. Mammograms classification, NezhaHamdi
[17] Additive logistic regression: a statistical view of
REFERENCES boosting, Jerome Friedman
[18] A Review Paper on Gabor Filter Algorithm & Its
[1] Face detection and its applications, Mrs. Sunita Roy1
Applications, Neelu Arora
[2] A Comparative Study of Feature Extraction Methods
[19] Gaussian Probability Density Functions: Properties
in Images Classification, Seyyid Ahmed Medjahed
and Error Characterization, Maria Isabel Ribeiro
[3] Machine Learning Algorithms: A Review, AyonDey
[20] An efficient Radix-two Algorithm to compute the 2D
[4] Various Biometric Authentication Techniques: A
Fourier Transform, D. CHIKOUCHE
Review, J BiomBiostat
[21] Object detection using Haar-cascade Classifier,
[5] Human-Computer Interaction in Smart Environments,
Sander Soo
GianlucaParavati
[22] Data classification using Support Vector Machine,
[6] Comparison between YCbCr Color Space and
Durgesh Srivastava
CIELab Color Space for Skin Color Segmentation,
[23] A Practical Guide to Support Vector Classification,
Amanpreet, Kaur
Chih-Wei Hsu
[7] Facial Recognition using OpenCV, Shervin EMAMI1
[24] A Comparison Study of Kernel Functions in the
[8] Object detection using Haar-cascade Classifier,
Support Vector Machine and Its Application for
Sander Soo
Termite Detection, Muhammad Achirul Nanda
[9] Explaining AdaBoost, Robert E. Schapire
[25] Efficient Sampling of SAT Solutions for Testing,
[10] Rapid Object Detection using a Boosted Cascade of
Rafael Dutra
Simple Features, Paul Viola
[26] The CMU Pose, Illumination, and Expression
[11] Light compensation, Chih-Fong Chang
Database, Terence Sim
[12] Face Recognition, Wei-Lun Chao
[27] Introduction to Augmented Reality, R. Silva
[28] The FERET evaluation methodology for face
recognition algorithms, P. Jonathon Phillips
Dibyendu Saha, Anisha Banik, Koushik Bhattacharyya, “Gender Classification using OpenCV and Feature Extraction”
Published in International Research Journal of Innovations in Engineering and Technology - IRJIET, Volume 4, Issue 4, pp
36-40, April 2020.
*******