有人能帮我计算高斯滤波器值吗?我看过其他相关的帖子,但找不到合适的解决方案。我有一个二维高斯方程:
def gauss2d(x,y,sigma):
return (1/(2*math.pi*math.pow(sigma,2)))*math.exp(-0.5*
(pow(x,2)+pow(y,2))/pow(sigma,2)) 我想知道如何计算具有离散值的3x3或5x5高斯滤波器的元素。
发布于 2020-02-11 00:23:31
此实现与应用规范化时略有不同,但这只是一件微不足道的事情。
def gaussian(sigma,Y,X):
kernel = np.zeros((Y,X))
ax = range(X) - np.floor(X/2)
ay = range(Y) - np.floor(Y/2)
xx,yy = np.meshgrid(ax,ay)
kernel = np.exp(-0.5 * (np.square(xx) + np.square(yy)))/np.square(sigma)
kernel = kernel/np.sum(kernel)
return kernel
print(np.sum(gaussian(0.3,5,5)))https://stackoverflow.com/questions/60148832
复制相似问题