# Noise Reduction - noisy lines

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?

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

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

plt.figure(1)
plt.imshow(noisy, cmap='gray')
plt.title('Original')


and then checking the peaks in the frequency domain:

fft_x = np.abs(np.fft.fft(noisy[10,:] - np.mean(noisy[10,:])))
plt.plot(fft_x)
print(np.argmax(fft_x[0:800]))
print(np.argmax(fft_x))


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.figure(2)
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.

• You wouldn’t get a shadow if you did this with a 2D FFT. Jun 25 at 14:25
• @CrisLuengo interesting! Care to explain why? I don’t see it.
– Peter K.
Jun 25 at 20:40
• 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. Jun 25 at 21:15
• 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. Jun 25 at 21:18
• @CrisLuengo Cool! Got it. Thanks for the explanation.
– Peter K.
Jun 25 at 22:05