Implementing Gaussian Blur - How to calculate convolution matrix (kernel)

后端 未结 7 2038
予麋鹿
予麋鹿 2020-12-22 21:14

My question is very close to this question: How do I gaussian blur an image without using any in-built gaussian functions?

The answer to this question is very good,

7条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-22 21:57

    OK, a late answer but in case of...

    Using the @moooeeeep answer, but with numpy;

    import numpy as np
    radius = 3
    sigma = radius/2.
    
    k = np.arange(2*radius +1)
    row = np.exp( -(((k - radius)/(sigma))**2)/2.)
    col = row.transpose()
    out = np.outer(row, col)
    out = out/np.sum(out)
    for line in out:
        print(["%.3f" % x for x in line])
    

    Just a bit less of lines.

提交回复
热议问题