YTread Logo
YTread Logo

Computer Vision - Haar-Features

Apr 07, 2024
In the last lecture we talked about the Viola Jones algorithm and how to detect a human face in an image and we came to the conclusion that the algorithm will look for the most relevant

features

, such as the eyes, the left eye, the right eye. nose, lips, forehead, eyebrows and something like that, so these are the most relevant

features

as far as human faces are concerned and the good question is how to detect these features and the answer is hard waves or hard features, so the hard wavelet is a sequence of rescaled squares. shaped functions is very similar to Fourier analysis was proposed by a Hungarian mathematician named Hart in 1909 because of the way these features are very similar to convolutional kernels so basically this is the theory behind convolutional neural networks that read the With the help of these kernels the most relevant features can be detected, so the approach is approximately the same.
computer vision   haar features
Its features are the features relevant to face detection. Let's assign a physical characteristic to each important feature of a human face. Well, for example, there are edge features and lines. features, so what exactly does it mean that for example for edge features there are black and white pixels? Well, of course, in real images like this there are no completely white or completely black pixels because it is a grayscale image, each pixel has a value from 0. up to 255, so there are no completely white and completely black images, but let's consider the ideal case where there is a white region of pixels and a black region of pixels.
computer vision   haar features

More Interesting Facts About,

computer vision haar features...

Well, there is a horizontal version and a vertical version, but as you can see, it's about the same in The feeling that it's going to detect edges, so let's try to look for edges when it comes to this image, as you can see, for example, the eyebrow contains darker pixels and the forehead just above the eyebrow contains brighter pixels. Well, this is very, very. similar to this edge feature brighter pixels darker pixels well we can use line features that can detect lines quite effectively for example we can have brighter pixels than darker pixels than brighter pixels again this is the vertical version this is the horizontal version by the way The opposite can happen, so instead of white, black, white, we can work with black, white, black, so the darkest pixels, the brightest pixels and the darkest pixels again, for example, as far as this image goes, you can see that these are dark pixels and then brighter pixels than dark pixels again. it's very, very similar to the characteristics of the line black pixels white pixels black pixels okay so we have the nose as you can see this region of the nose contains brighter pixels and these regions right next to the nose contain darker pixels , so black white black again, so we are able to map complete features to the most relevant features of the human face and why it is important because the algorithm will detect human faces based on the most relevant features eyes, eyebrows, nose, lips , etc., so our features are extremely important and extremely powerful method to detect the most relevant features.
computer vision   haar features
Okay, let's talk a little bit about the concrete calculation so we can assign a pixel intensity to each pixel. If we are dealing with grayscale images, these values ​​are within the range 0 and 255. In this case, we are going to represent white pixels with zero and black pixels with one, so these are the pixel intensities. Okay, this is the pixel intensity of the ideal heart feature when we deal with white pixels and black pixels exclusively, of course, in real life scenarios. These values ​​are not exclusively zeros and ones because we're dealing with grayscale images, but something like this, so zero point one is a very bright pixel. 0.3 is a little darker. 0.6 is even darker and as you can see 0.9 is almost black.
computer vision   haar features
Okay, then we can. detect these are brighter pixels, these are darker pixels, so what we have to do. Viola Jones' algorithm is going to compare how close the real scenario is to the ideal case, so somehow we have to compare these pixel intensities with these pixel intensities, so we only have to summarize the intensities of the white pixels, so let's summarize these values ​​and calculate the average, let's calculate the sum of the black pixels and calculate the average and the Delta, which is the difference of the dark intensities - the white intensities so you can see the I is the pixel intensity of a given pixel, okay, we just have to sum them up as far as the dark pixels are concerned, i.e. 0.6 plus 0.8 plus 0.8 plus 0.6, so we just have to add these numbers and calculate the average . that is why we have to multiply it by 1 divided by n where n is the number of pixels in the given region.
Well, in this case we have eight values. Well, minus the average of the brightest pixel intensities. What about this data value for the ideal heart characteristic? We just have to calculate the average of the dark region, okay, we just have to add ones and divide it by eight so that the average is one. Here for the brightest pixels, the average will be zero, so one minus zero is one, so the data value. It's going to be one for the heart's ideal feature. What's up with this real life scenario? We just have to calculate the intensities of the dark pixels and the intensities of the white pixels.
Therefore, 0.74 is the average for dark pixels; 0.18, which is the average of the brightest pixels. will be 0.56, so the closer the value is to 1, the more likely we have found a heart feature and we will never get zeros or ones because we are dealing with real images, so if you take a look at this image , there are no 0. or 1 pixel intensities because there are no completely white and completely black pixels. Well, maybe it's roughly black pixels here, but anyway we're usually dealing with values ​​like this and the closer the value is to 1, the more likely we've found a heart feature.
What do we have to do? We just have to calculate these deltas and if the Delta is very close to 1 we can conclude that we have found a match in the sense that we have found a certain characteristic of the heart, so, for example, We have found an eyebrow, we have found a nose, we have found lips, etc., this is how we can detect the most relevant features in a given image. Well, in the next lecture we will talk about how to improve these calculations. because as you can see we have to sum the values ​​inside a rectangle, so maybe we can come up with a smaller algorithm to make the approach as fast as possible.
Thanks for watching.

If you have any copyright issue, please Contact