How mean filter in Image Processing works ? | Computer Vision | OpenCV | Image Smothing blur

Поділитися
Вставка
  • Опубліковано 22 січ 2022
  • #MeanFilter #OpenCV #NoiseReduction
    0:19 Definition of a mean filter.
    2:35 Calculations to implement Mean filter
    3:46 Improvements to vanilla Mean filter.
    4:14 Drawbacks of mean filter
    5:50 Results
    Github Code : github.com/Soft-illusion/Comp...
    In the video you will see that we place the kernel at top left corner of the image and multiply each element be the kernel value and sum all the outputs. After which we shift the kernel to left and do the same process. This is called the Vanilla version of Mean Convolution.
    We shift one pixel downwards and continue going to the right. You will notice that in the vanilla version reduction in dimension of image occurs. In the video the image reduces from 6X6 to 4X4
    Here is the simplified version of formula to calculate the reduction : (H - K + 1) X (W - K+1)
    So 3X3 kernel will reduce the dimension by 2
    Similarly , NXN kernel will reduce dimension by n-1
    There are also ways to keep the image size as same.
    Because it is easy to track the image if its size is not variable especially in deep learning. Here corner pixels will only have 4 elements to average. And edge elements will have 6 elements to average. Zeros cushion can also be added around the image. We can also repeat rows and columns around the image depending on the kernel size.
    Some drawbacks of mean filter inlcudes:
    1. A single pixel with a very unrepresentative value can significantly affect the mean value of all the pixels in its neighborhood. Some noisy pixel may affect neighbouring pixel values and we can see small patches of nun uniform colors in an image.
    2. When the filter neighborhood straddles an edge, the filter will interpolate new values for pixels on the edge and so will blur that edge. This may be a problem if sharp edges are required in the output. Due to interpolation we lose sharpness of edges. So we can mitigate these drawbacks with other filters.
    We finally see the implementation by seeing the example of an input image, which is very sharp and without noise. In order to see effect of our filter.. We generate gaussian noise of the same size as input image. We add the noise in our input image. In order to remove the noise we will use mean kernel that we learned. Now if we pass 3X3 kernel through this image you will see a new image. We see the effect of noise in the neighbouring pixels.
    So you can see here the zombie patches of different colors which was not present in original image . This is exactly what we saw in first drawbacks. Here we use a 39 X 39 kernel which reduced the noise but we lost lot of sharpness.
    This is our second drawback.
    Hence, we have a tradeoff between reduction of noise and losing sharpness.
    Hence, you can see the effect of decreasing smoothness and noise as we slowly increase kernel size.

КОМЕНТАРІ • 2

  • @amirbit2086
    @amirbit2086 Місяць тому

    Thanks
    What kind of mean filter is this that you implemented in this 6x6 image? bcz according to my knowledge there is at least 4 type of mean filter in spatial domain

  • @IshitaShahi
    @IshitaShahi 2 роки тому +1

    🙌🏻🙌🏻🙌🏻