How To Sharpen an image in OpenCV

后端 未结 3 1727
悲&欢浪女
悲&欢浪女 2021-01-06 13:40

A basic Google search finds this SO question and what appears to be an excellent answer. When I try, however, it has absolutely no effect on sharpening my blurred image.

相关标签:
3条回答
  • 2021-01-06 13:42

    For future readers, the code does work it was just that my image was so blurry, the above code had no visible effect!

    0 讨论(0)
  • 2021-01-06 13:44

    I think fft deconvolution should be interesting for you: http://web.archive.org/web/20160420171504/http://www.nist.gov/lispix/imlab/FFT/deblur.html

    But this algorithm userful if you know blur kernel. If not, then you should google for blind deconvolution algorithm.

    0 讨论(0)
  • 2021-01-06 13:52

    In order to make it work for a proper image you can check out both the following approches. I did the coding using OpenCV 3.0.0:

    import cv2
    
    x = 'Columbia river.jpg'
    img = cv2.imread(x, 1)
    cv2.imshow("Original",img)
    

    #---Approach 1---
    #---Sharpening filter----
    kernel = np.array([[-1,-1,-1], [-1,9,-1], [-1,-1,-1]])
    im = cv2.filter2D(img, -1, kernel)
    cv2.imshow("Sharpening",im)
    

    #---Approach 2---
    aw = cv2.addWeighted(img, 4, cv2.blur(img, (30, 30)), -4, 128)
    cv2.imshow("Add_weighted", aw)
    

    0 讨论(0)
提交回复
热议问题