History of Object Detection -HAAR Features

Phani Ratan Yalamanchili
3 min readApr 18, 2022

--

The history of object detection starts with HAAR features, these are special wavelets having low-intensity and high-intensity waves over a period of time but in computer graphics we represent them as pixels ( 0 for white and 1 for black or vice versa)

There are two kinds of features one is the edges and the other one is lines, in simple terms, edges are nothing but a place in the image where the left portion is lighter and the right portion is darker and also if the upper portion is lighter and lower portion is darker it is treated as an edge and for line features the middle ones are darker and left and right ones are lighter, edges are mainly found on human images near eyebrows and face edges and lines are found near the nose and b/w the teeth and two lips here’s a small illustration

so the next question is, yes manually we can identify these features but how will the computer find these regions ?

so here is small example of how a HAAR feature looks like ideally in an image andpixel values of a small portion of an image.

so here the left matrix is our HAAR feature matrix and the right matrix is a portion of our image

so what we do is find the dark region pixel value sum and subtract from the light region pixel value sum and since we might get large values we will take mean

how do we find the dark and light pixels ?
ans : put your haar feature on your image portion all the pixel values which fall under your dark pixels are darker pixels of your image same applies to light area as well

so the equation is

(Σ (right pixel values )/no of right pixels — Σ(left pixel values )/no of left pixels)

(fun fact : the no of left and right pixels are always same )

here, so this comparison is called Viola-Jones algorithm, let us compute with our portion of the picture

x1 = (0.8+0.6+0.8+0.9+0.6+0.6+0.8+0.8)/8

x2 =(0.1+0.2+0.3+0.1+0.1+0.2+0.2+0.2)/8

x1-x2= 0.74 — 0.18 = 0.56

So it is not a HAAR feature, and it is not very close to either 0 or 1.

What does this practically mean?

The reason is very simple , for an ideal HAAR feature (i.e an edge) the equation throws a value of 1 as all are completely ones and zeros

So since we computed this for our real image we want to check like how near it is to 1 to be identified as an HAAR feature (i.e an edge )or how near it is to 0 to be identified as a HAAR feature (i.e a line).

if we find any portion of the image whose difference is very close to either 0 or 1 we can define it as an edge or line

--

--