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:
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.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 = (fft_row + fft_row)/2 # Replace with values from either side fft_row = (fft_row + fft_row)/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.