During my undergraduate degree in systems engineering, I worked with a fellow student on a machine learning algorithm to detect faces in an image. The goal was to feed a photo with a face of a random person somewhere in the image to the algorithm and return the square and the position of the face in the image. The algorithm is based on singular value decomposition (SVD), which is used in applications such as least squares.
Using a similar approach to least square, we generate a “mean face” from a regression of greyscale faces from a dataset of 300, 68x56 px images. To do this, we use the algorithm \begin{equation} \tag{1} Q = \sum_{i = 1}^{k}{\sigma_i \bf{u_i} \bf{v_i^T}}, \end{equation} where \(\sigma_i\) is the i-th singular value, \(\bf{u_i}\) is the i-th column vector of matrix \(U\) and \(\bf{v_i^T}\) is the i-th row vector of the matrix \(V\) from the SVD. By using only the first couple of singular values (making \(k\) much smaller than the original set of singular values from our SVD), we are able to reduce the dimension of our image matrix. From this diminished form we can calculate the norm between the “mean face” matrix and the diminished matrix of the image we want to classify if there is a face in the image. From the test data, we then compute a threshold that defines whether the image is identified as a face or not (in our case, the threshold was set to \(\varepsilon = 14.0\) because all faces have a \(\varepsilon_{max}\) lower than \(12.329\) and the reference image without a face has a \(\varepsilon = 22.269\)). This application allows us to automatically classify whether an image contains a face or not.
Visualised “mean face”:

Norm of the test dataset of images containing a face and an example of a correctly classified image with a face:

With this application we are now able to find a face in a larger image using a kernel that scans the image and compares each section with the “mean face”. The section where the norm is minimal is given the highest probability of containing the face.
Skyline image where the face should be found:

Least square of each kernel scanning the skyline image:

Kernel identified as the cutout with the highest probability to contain a face:

Read the full report in german here