Deblur an image using scikit-image

匆匆过客 提交于 2019-12-02 09:56:51

My best so far solution is:

import numpy as np
#import matplotlib.pyplot as plt
from scipy.misc import imfilter, imread
from skimage import color, data, restoration
from scipy.signal import convolve2d as conv2

def main():
  image = imread("/Users/gsamaras/Downloads/boat.tif")
  #plt.imshow(arr, cmap='gray')
  #plt.show()
  #blurred_arr = imfilter(arr, "blur")
  psf = np.ones((5, 5)) / 25
  image = conv2(image, psf, 'same')
  image += 0.1 * image.std() * np.random.standard_normal(image.shape)

  deconvolved = restoration.wiener(image, psf, 1, clip=False)
  #print deconvolved
  plt.imshow(deconvolved, cmap='gray')
  plt.show()
  #print image

if __name__ == "__main__":
    main()

Much smaller values in restoration.wiener() lead to images that appear like you have put a non-transparent overlay above it (like this). On the other hand as this value grows the image blurs more and more. A value near 1 seems to work best and deblur the image.

Worthnoting is the fact that the smaller this value (I mean the balance, the greater the image size is.


PS - I am open to new answers.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!