All human faces share some similarities. If you look at a photograph showing a person’s face, you will see, for example, that the eye region is darker than the bridge of the nose. The cheeks are also brighter than the eye region. We can use these properties to help us understand if an image contains a human face.
A simple way to find out which region is lighter or darker is to sum up the pixel values of both regions and comparing them. The sum of pixel values in the darker region will be smaller than the sum of pixels in the lighter region. This can be accomplished using Haar-like features.
A Haar-like feature is represented by taking a rectangular part of an image and dividing that rectangle into multiple parts. They are often visualized as black and white adjacent rectangles.
00:38 Remember: lower values represent a darker pixel, while higher ones represent a brighter pixel. So if a specific subregion’s pixels add up to a low number, it’s a dark subregion. If it’s a high number, it’s bright.
01:22 The first two are used to detect edges within a picture, the third one here detects vertical lines, and the fourth one detects horizontal features. If our images were pure black and white, then these Haar-like features would be able to identify where lines and edges are perfectly. But like I said, these features are ideal.
02:24 This contrast is called the feature’s value, and it’s what lets us determine if what the feature represents—like an edge, a line, or a facial feature—exists at this location in the image. To calculate this value, we take the average of the white pixels and subtract from them the average of the black pixels.
02:46 If we get a result that is close to 255, then we’ve got a strong contrast, and this feature is likely to represent the feature we are looking for. It’s telling us that whatever it represents—like an edge or a line—it most likely exists within this region.
03:36 Because the face has so many distinct areas in terms of brightness, Haar-like features work great here. The only problem is this pixel summing has to be calculated for many different subregions of the image at once, and that becomes computationally expensive—aka slow.
Become a Member to join the conversation.