the noisy image

I'm trying to reduce the noise in this photo. What type of filters/techniques should I use to cancel out the noise? I've tried using box filter and Gaussian filter to blur out some of the noise, but i had no luck getting satisfying results. Any suggestions?


1 Answer 1


I just used the method suggested in this older DSP.SE post and it seems to work:

Denoised version of image

I did this manually by first loading the image:

import numpy as np
import scipy.signal as signal
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
import scipy.ndimage as ndimage

noisy = mpimg.imread('Q83584.jpg')
plt.imshow(noisy, cmap='gray')

and then checking the peaks in the frequency domain:

fft_x = np.abs(np.fft.fft(noisy[10,:] - np.mean(noisy[10,:])))

and then replacing these peaks with the average of the values on either side:

filtered_image = np.zeros(noisy.shape)
for row in np.arange(801):
    fft_row = np.fft.fft(noisy[row,:])
    fft_row[19] = (fft_row[18] + fft_row[20])/2 # Replace with values from either side
    fft_row[1582] = (fft_row[1581] + fft_row[1583])/2 # Replace with values from either side
    filtered_image[row,:] = np.real(np.fft.ifft(fft_row))
plt.imshow(filtered_image, cmap='gray')
plt.title('Attempt at removal')
plt.imsave('Q83584_filtered.jpg', filtered_image, cmap='gray')

This could easily be improved to automagically grab the peak (and its mirror), but I'll leave that as an exercise for the reader.

Another thing I'll leave to the reader is dealing with what seems to be some aliasing / shadowing in the resulting image. I suspect it's because of the simple replacement I did and not zero padding the FFT lengths.

  • $\begingroup$ You wouldn’t get a shadow if you did this with a 2D FFT. $\endgroup$ Jun 25 at 14:25
  • $\begingroup$ @CrisLuengo interesting! Care to explain why? I don’t see it. $\endgroup$
    – Peter K.
    Jun 25 at 20:40
  • $\begingroup$ You are removing all frequencies that have a specific horizontal component. This is all sinusoidal waves where the horizontal distance between peaks is your selected value. Including a horizontal wave (vertical bars). The buildings are formed by many of these horizontal waves. By removing one of these components, you created this shadow effect. It is basically an echo of the buildings that appeared because you removed frequency components that are not part of the diagonal bar pattern you intended to remove. $\endgroup$ Jun 25 at 21:15
  • $\begingroup$ In short, instead of removing only, say, (4,3) Hz, you removed all (4,x) Hz, for all values of x, including (4,0) Hz, which would be part of what forms those buildings. $\endgroup$ Jun 25 at 21:18
  • $\begingroup$ @CrisLuengo Cool! Got it. Thanks for the explanation. $\endgroup$
    – Peter K.
    Jun 25 at 22:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.