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

Поділитися
Вставка
  • Опубліковано 11 лип 2024
  • #MedianFilter #OpenCV #NoiseReduction
    0:10 Definition of a Median filter
    0.49 Examples of Median filter
    1:37 Robust Median filter
    2:17 Median filter preserve edges.
    3:07 Salt and pepper noise
    4:27 Effect of kernel size
    5:42 Median filter on Gaussian noise
    6:05 Speckle noise
    6:32 Poisson Noise
    Github Code : github.com/Soft-illusion/Comp...
    In this video we discuss the Image Smoothing technique : Median filter
    Median filtering is a non-linear filtering technique which is useful to remove noise and preserve sharp features
    It is highly effective against salt and pepper noise.
    In this video we go through basics and implementation of median filter and at the end we have effect of median filter on different types of noises so watch till the end.
    If you want to use opencv function of median filter , kernel size should be positive odd int.
    The function cv.medianBlur() takes the median of all the pixels under the kernel area and the central element is replaced with this median value. This is highly effective against salt-and-pepper noise in an image. In median blurring, the central element is always replaced by some pixel value in the image. It reduces the noise effectively. Its kernel size should be a positive odd integer.
    We use the following example:
    Assume that we have an image with its top left px values.
    We convolute it with a median filter of size 3.
    So first we will sort the values and choose the central value in the list.
    In this case it is 30 so we will update the output image pixel value to be 30.
    Note: As kernel size in median filter is odd number. As kernel is always odd(N) so total elements will also be odd (NxN). The total elements in the sorted list will always be odd. So we just need to sort the list and choose (N^2+1)/2 th element.
    Now lets have a look at why is median filter robust.
    In this image assume we have 2 noisy pixels of 45 and 90.
    So if we convolute median filter we will remove the noise but if we use mean filter pixels values will have some effect of noise. Median filter is invariant with most of noise.
    Lets consider this particular image with and edge between 0 and 90.
    Now if we use kernel of size 3X3 first element will be 0 as there are 6 zeros
    And second element will be 90 as there are 6 90’s
    So the edge is preserved with same intersity.
    If you want to know about techniques to get output image size same as input image size refer our mean filter video by clicking on top right corner.
    For todays video, we take an example of input image. which is very sharp and without noise.
    In order to see effect of our filter we add 10% salt and pepper noise the the image.
    So here we choose 10 % of pixels and randomly gave them high intensity and low intensity.
    This image feels like original image if we implement 5X5 median filter.
    We can not see the different between original and this image because it is high resolution image but we loose some sharpness.
    However if we use a large kernel of size 101X101 we will slowly start losing small features in the image.
    Because our kernel is bigger than the feature like head of people or flags of temple.
    So small features are considered as noise and are removed by the median filter.
    We then see effect of median filter on a gaussian noise with mean zero and sigma 3.
    A fundamental problem in optical and digital holography is the presence of speckle noise in the image reconstruction process. Speckle noise can be generated by multiplying random pixel values with different pixels of an image.
    So median filter helps in reducing Speckle noise but not completely.
    The poisson noise is seen due to the statistical nature of electromagnetic waves. These sources are having random fluctuation of photons. Hence results in spatial and temporal randomness. This noise is also called as quantum (photon) noise or shot noise.
    If we have Poisson noise there is no effect on median filter.

КОМЕНТАРІ • 2

  • @alexstacey
    @alexstacey Рік тому +1

    this was helpful. well explained. thanks