Image Pre-processing Using OpenCV Library on MORPH-II Face Database

11/16/2018
by   Benjamin Yip, et al.
UNCW
0

This paper outlines the steps taken toward pre-processing the 55,134 images of the MORPH-II non-commercial dataset. Following the introduction, section two begins with an overview of each step in the pre-processing pipeline. Section three expands upon each stage of the process and includes details on all calculations made, by providing the OpenCV functionality paired with each step. The last portion of this paper discusses the potential improvements to this pre-processing pipeline that became apparent in retrospect.

READ FULL TEXT VIEW PDF

Authors

page 1

page 2

page 3

page 5

11/04/2019

Human eye inspired log-polar pre-processing for neural networks

In this paper we draw inspiration from the human visual system, and pres...
03/02/2018

PRESISTANT: Learning based assistant for data pre-processing

Data pre-processing is one of the most time consuming and relevant steps...
08/13/2020

A Comprehensive Pipeline for Hotel Recommendation System

This paper addresses a comprehensive pipeline to build a hotel recommend...
09/08/2015

HEp-2 Cell Classification: The Role of Gaussian Scale Space Theory as A Pre-processing Approach

Indirect Immunofluorescence Imaging of Human Epithelial Type 2 (HEp-2) c...
02/26/2015

Concept for a CMOS Image Sensor Suited for Analog Image Pre-Processing

A concept for a novel CMOS image sensor suited for analog image pre-proc...
01/19/2017

Fast and Efficient Skin Detection for Facial Detection

In this paper, an efficient skin detection system is proposed. The algor...
11/17/2019

Countering Inconsistent Labelling by Google's Vision API for Rotated Images

Google's Vision API analyses images and provides a variety of output pre...
This week in AI

Get the week's most popular data science and artificial intelligence research sent straight to your inbox every Saturday.

1. Introduction

The MORPH data is one of the largest publicly available longitudinal face databases (Ricanek and Tesafaye, 2006)

. Since its first release in 2006, it has been cited by over 500 publications. Multiple versions of MORPH have been released, but for our face image analysis study, we use the 2008 MORPH-II non-commercial release. The MORPH-II dataset includes 55,134 mugshots with longitudinal spans taken between 2003 and late 2007. For each image, the following metadata is included: subject ID number, picture number, date of birth, date of arrest, race, gender, age, time since last arrest, and image filename. Because of its size, longitudinal span, and inclusion of relevant metadata, the MORPH-II dataset is widely utilized in the field of computer vision and pattern recognition, including a variety of race, gender, and age face imaging tasks.

(a) Variation in head tilt.
(b) Variation in camera distance.
(c) Variation in illumination.
(d) Variation in overall appearance.
Figure 1. Different types of variation present in the MORPH-II dataset.

However, despite the fairly standard format of police photography, many of the images vary greatly in terms of head-tilt, camera distance, and illumination. A great number of the images also contain large, empty backgrounds or excess occlusion that add a corresponding amount of noise to the data. This longitudinal dataset had an average of approximate 4 images per subject and some appearances varied greatly from one image to the next. Preliminary results showed women having an increased overall variation in their images due to changes in makeup and hairstyle. Figure 1 showcases some variety found during initial examination of the image dataset.

Consequently, the pre-processing step is crucial for the image analysis on the MORPH-II dataset. For our purposes, we utilized the Open Source Computer Vision 2 (OpenCV) library in Python to extract the face from each mugshot using the image vectors

(Bradski, 2000). The stages of this process are outlined in section 2.

2. Procedural Overview

This section provides a global description for the six stages of our pre-processing algorithm. The premise is to minimize image noise by the use of bounding boxes around necessary region of interest (ROI). Both Figures 2 and 3 are visual representations of each step and what is accomplished, from different prospects.

Initial face and eyes detection. Rotation. Face and eye re-detection. Cropping and scaling Pre-processed image.
Figure 2. Stages of the pre-processing pipeline with successful face and eye detection

Note: While the intermediate stages of the process in Figure 2 are shown with color images, all computer vision tasks were done only on the grayscale versions of each image (converted with OpenCV).

(a) Original image.
(b) Grayscale image.
(c)

Initial face detection.

(d) Eye detection.
(e) Rotation & re-detection.
(f) Cropping and scaling.
Figure 3. Face preprocessing pipeline with successful face and eye detection.

2.1. Grayscale

Research in computer vision showed converting images to grayscale increased the accuracy of locating the necessary facial features as it reduced the effect illumination variance had on the images. Doing so was the first introduction to the OpenCV library. For each image, we utilized the OpenCV function

where is the input image and represents the color channel for the output image. In our case we used . This results in the new image pixel value, , where , and , , represent Red, Green and Blue respectively. The values of , , , are from the original image pixel. Effects are shown in Figure 3(B).

2.2. Face Detection

The initial face detection step located and marked the position of a face within an image, which can be seen in Figure 3

(C). This eliminates backgrounds and hairstyles, which are image properties that are not useful for computer vision tasks. This procedure increased the accuracy of future detection steps. If a face was not successfully detected, the image was stored in a face not found (fnf) folder for manual detection later on. Both face and eye detection steps were accomplished using Haar-Feature based cascade classifiers from OpenCV. The function used was

where is the input image, is the scale factor at each image scale, and is the minimum amount of neighbors each candidate face rectangle should acquire.

Note that: Both face and eye detection were done using the the Haar-feature based Cascade Classifiers from OpenCV (the .xml files can be obtained from the OpenCV GitHub repository). For our purposes, we only had to adjust the parameters of the OpenCV detection function to locate the face in each image. Eye detection, however, required additional steps.

2.3. Eye Detection

We implemented a very similar algorithm for locating the eyes, illustrated in Figure 3(D). After the face is detected, the eyes are located within the region of interest (ROI) determined by the face (i.e. within the bounding box for the face), and the eye centers are computed as the center of the bounding box for each eye. The new domain and range of the image matrix come from the bounding box around a face that was found successfully. We then marked bounding boxes around each eye with the same Haar cascade function from OpenCV in section 2.2 with different parameter values to account for the smaller scope.

In many cases, wrinkles, shadows, and other facial blemishes were detected as eyes. To account for this, we implemented two conditions to eliminate as many of the incorrect eye detections as possible: if 1) the angle between eye centers was greater than fifteen degrees, or 2) the interocular distance (number of pixels between eye centers) was less than one fifth of the image width, the located features were discarded. Following the test of these conditions, a while loop conditioned on successful eye detection was used to refine the parameters of the detect function when eyes were not found. If this too proved unsuccessful, the image was stored for manual detection.

When both eyes were successfully found, figure 2(D), we captured the coordinate location of the right and left eye centers by calculating the center location of the new bounding boxes. These eye centers were crucial for future steps.

2.4. Rotation

Given successful eye-detection, the image is rotated based on the angle between the eye centers, as illustrated in Figure 3(E). Rotating the image began with the eye centers and . We added a conditional to ensure the left eye stored in was actually the left eye of the subject. was then calculated by subtracting the left eye from the right eye, , yielding the displacement between the eyes. We had to convert to the complex plane to allow use of the numpy angle function. was then a parameter used in the getRotationMatrix2D OpenCV function to create the necessary transformation matrix, M.

ΨΨΨΨΨcv2.getRotationMatrix2D(center, theta, scale)
ΨΨΨΨΨcenter = center of rotation source image
ΨΨΨΨΨscale = scale factor
ΨΨΨΨ

where, .

After the transformation matrix is calculated, it is applied to each pixel in the source image to produce the necessary rotated image. The OpenCV function warpAffine reconstructs the source image by producing the desired rotated image, dst:

ΨΨΨΨΨcv2.warpAffine(src, M, (column, row))
ΨΨΨΨ

2.5. Face and Eye Re-detection

Following rotation, the face and eyes are re-detected as above, as illustrated in Figures 2 and 3(E). Images with unsuccessfully detected faces were stored in a ”fnf_r” (face not found, rotated image) folder for manual detection later on. Images with undetected eyes were stored similarly, in a ”enf_r” (eyes not found, rotated image) folder.

2.6. Cropping and Scaling

After the eye centers were successfully re-located in the rotated image, a new bounding box for the face was determined based on the interocular distance. This step ultimately found the white bounding box in Figure 3(F) for the cropped image based on the interocular distance. Eye centers were relocated in the rotated image using the Haar cascade in section 2.3. The new eye center coordinates gave the interocular distance used for defining the height and width of the new bounding box. Finding the upper left corner of the box began with subtracting one interocular distance from the x-value midpoint of the eyes. The y-coordinate was calculated by adding four fifths times the interocular distance to the current eye height . [Note: 0.8 was chosen as the best option for capturing an appropriate region of the face]. The final bounding box was a slice of the rotated image with proportions 2:2.35 times the interocular distance.

The image was then cropped according to this frame and scaled down to 70 pixels tall by 60 pixels wide, using the following OpenCV function:

ΨΨΨΨΨcv2.resize(cropped_img, (60, 70))
ΨΨΨΨ

If an image could not be reduced to this size (i.e. something went wrong earlier on), it was stored in another folder for manual detection.

2.7. Manual Pre-processing

The images in which the face or eyes were not successfully detected were handled by manually clicking the eye centers of each subject. These new eye centers were then used for rotating the image and the rest of the pipeline followed suit. The images below in Figure 4 are examples of problem images that included errant detection.

Figure 4. Examples of problem images and errant detection

2.8. In Retrospect

When performing the manual eye-detection, the images were rotated based on the eye centers. However, we avoided re-clicking the eyes in the rotated image by simply applying the rotation matrix to the coordinates of the eye centers in the unrotated image. Had this been recognized in the original code, the face and eye re-detection step could have been skipped entirely. This would likely have drastically reduced run time and decreased the number of images necessitating manual eye detection.

3. Conclusion

When performing the manual eye-detection, the images were rotated based on the eye centers (as above). However, we avoided re-clicking the eyes in the rotated image by simply applying the rotation matrix to the coordinates of the eye centers in the unrotated image. Had this been recognized in the original code, the face and eye re-detection step could have been skipped entirely (effectively merging stages 2.3 and 2.4). This would likely have drastically reduced run time and decreased the number of images necessitating manual eye detection.

4. Acknowledgments

This material is based in part upon work supported by the National Science Foundation under Grant Numbers DMS-1659288. Any opinions, findings, conclusions, or recommendations expressed in this material are those of the author(s) and do not necessarily reflect the views of the National Science Foundation.

References

  • Bradski (2000) Bradski, G. (2000). The OpenCV Library. Dr. Dobb’s Journal of Software Tools.
  • Ricanek and Tesafaye (2006) Ricanek, K. and Tesafaye, T. (2006). Morph: A longitudinal image database of normal adult age-progression. In Automatic Face and Gesture Recognition, 2006. FGR 2006. 7th International Conference on, pages 341–345. IEEE.