1
$\begingroup$

I wrote a simple lowpass filter in python to run against lena. Now I'd like to add Gaussian noise to the lowpass filtered data and then run an inverse filter against the lowpass and try to get the original back (well, as close to original). I'm new to programming in python and not quite sure how to add noise and write the inverse.

import matplotlib.pyplot as plt
import numpy as np
import scipy.misc
from scipy import ndimage
import Image 

def plot(data, title):
    plot.i += 1
    plt.subplot(2,2,plot.i)
    plt.imshow(data)
    plt.gray()
    plt.title(title)
plot.i = 0

 # Load the data...
img = scipy.misc.lena()
data = np.array(img, dtype=float)
plot(data, 'Original')

#lowpass filter
n=5
kernel = kernel = np.ones((n,n))

plt.show()
$\endgroup$
  • $\begingroup$ This is really just a programming question, so it's not really on topic. Also, an inverse filter would not be a good choice, as there's no way to recover the frequency content that has been eliminated by the lowpass filter. Trying to do so by inverting the lowpass filter will result in very high gain in the lowpass's stopband, resulting in a large amount of noise enhancement. $\endgroup$ – Jason R Apr 11 '14 at 12:22

Your Answer

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

Browse other questions tagged or ask your own question.