I'm trying to get rid of noise in the grayscale image. I tried the non-local-mean and Gaussian filter, but none of them give me good results. Is there any recommended algorithm I can use?

enter image description here

3 Answers

1
Mark Setchell On

Not sure what you are hoping for, but here each pixel is replaced by the mean of the surrounding 49x49 pixels just using ImageMagick in the Terminal:

convert noise.png -statistic mean 49x49 result.png

enter image description here

Here's the median of the surrounding 25x25 pixels:

convert noise.png -statistic median 25x25 result.png

enter image description here

1
fmw42 On

In Imagemagick, you can use the kuwahara non-linear edge preserving filter with different values (see https://en.wikipedia.org/wiki/Kuwahara_filter). Choose whichever looks best to you.

Input:

enter image description here

convert img.png -kuwahara 5 k5.png


enter image description here

convert img.png -kuwahara 9 k9.png


enter image description here

convert img.png -kuwahara 15 k15.png


enter image description here

convert img.png -kuwahara 25 k25.png


enter image description here

0
Meisam On

The best algorithm here depends on your desire, because the image is made by noise! and you have to define your output somehow (a binary image or a smooth one...)

Generally a simple median filter (5*5 kernel) is good for these situations.

You can also use this another method:

Pick a threshold value (with Otsu for example), and use a 5*5 kernel, in every 5*5 neighborhood compute the mean of values of the pixels, if it is below the threshold, choose the minimum value for all those pixels, and if it is higher than the threshold, substitute the maximum value of the neighborhood to all those 25 pixels. This job gives you a better contrast.