Image Denoising: Implementation
Test image:
Using box filter, the image gets blurred. It removes noise by reducing the intensity variance since the new distribution is closer to the mean.
A Gaussian filter is a linear filter. It's usually used to blur the image or to reduce noise. We reduce noise by reducing variance in pixel intensities, but now nearby pixels have a greater influence on blurring depending on the sigma.
We can see the difference between the original ground-truth image and the images after applying box, gaussian and median filters. Image gets blurred because the values are shifted towards the median. Thus, reducing variance of intensities.
Sigma = 12
Sigma = 22
Sigma = 32
From the above comparison, we can conclude that there is no particular formula or a mathematical derivation to decide the optimal sigma. It will depend on image factors like - the resolution of the image, the size of your objects in the image. Sigma controls how fat your kernel function is going to be. Higher the sigma values, wider the radius to blur away the images. Higher values of sigma would force you to use a larger kernel matrix to capture enough of the function's energy.
For your specific case, you want your kernel to be big enough to cover most of the object but not so large that it starts overlapping multiple neighboring objects at a time. Therefore, object separation is an important factor along with size.
Based on the results for each of the filters, we can say that we can use Median filter for ‘Salt and Pepper noise’. If you have a smooth surface with no texture which corresponds to a low frequency image, Gaussian filter would be the best to use. Box or Mean filter would be ideal to approx. gaussian and used widely in the rest of the use cases.
Box > Gaussian > Median
Box filter is the fastest, then comes gaussian and median at the bottom and slowest among them.
Test image:
Sample key:
We could observe the peak at (515, 28) and for rest of the keys we couldn’t observe a peak. The position of peak is the same position as of the key which validates that our function works correctly.