Image Deconvolution

285 Views Asked by At

to practice Wiener deconvolution, I'm trying to perform a simple deconvolution:

def div(img1 ,img2):
  res = np.zeros(img2.shape, dtype = 'complex_')
  for i in range (img2.shape[0]):
    for j  in range (img2.shape[0]):
      if (np.abs(img2[i][j]) > 0.001):
        res[i][j] = 1 / (img2[i][j])
      else:
        res[i][j] = 0.001
  return res

filtre = np.asarray([[1,1,1],
                     [1,1,1],
                     [1,1,1]]) * 1/9
filtre_freq = fft2(filtre)

v = signal.convolve(img, filtre)
F = div(1,(filtre_freq))
f = ifft2(F)

res = signal.convolve(v, f)

I am trying to compute the inverse filter in the frequency domain, pass it to the spatial domain and do the convolution with the inverse filter. On paper it's pretty simple, even if I have to manage the divisions by 0 without really knowing how to do it. But my results seem really inconsistent: enter image description here

If anyone can enlighten me on this ... Thanks in advance and have a great evening.

0

There are 0 best solutions below