【问题标题】:Is `sigma` expressed in the units of pixel for `gaussian_filter`?`sigma` 是否以`gaussian_filter` 的像素单位表示?
【发布时间】:2018-08-22 01:43:41
【问题描述】:

我正在查看scipy.ndimage.gaussian_filter,但无法理解sigma 的含义。 sigma= n 是否意味着n 是像素数,因此n 内的区域在一个点的所有边上的像素数对平均贡献最大?

【问题讨论】:

  • 你见过stackoverflow.com/questions/25216382/gaussian-filter-in-scipy>吗?
  • @taront 很好,如果sigma 以像素为单位表示,我无法解释。可能是我错过了什么。

标签: python scipy filtering gaussianblur


【解决方案1】:

是的,是的。从 SciPy 的高斯核为 computed 的复杂(无双关语)方式来看,这并不明显,但这是一个经验验证:我将高斯与一个向量 a 进行卷积,该向量具有单个条目 1,获得卷积核。然后以通常的方式E[X**2] - E[X]**2 计算方差,其中 X 显然以像素为单位 (np.arange(len(a)))。

from scipy.ndimage.filters import gaussian_filter
import numpy as np
a = np.zeros((100,))
x = np.arange(len(a))
a[len(a)//2] = 1
for sigma in range(3, 10):
    kernel = gaussian_filter(a, sigma)
    var = np.sum(x**2*kernel) - np.sum(x*kernel)**2
    print("Given sigma {}, empiric value {}".format(sigma, np.sqrt(var)))

输出:

Given sigma 3, empiric value 2.999207360674749
Given sigma 4, empiric value 3.9987184940057614
Given sigma 5, empiric value 4.998211402871647
Given sigma 6, empiric value 5.997694984501222
Given sigma 7, empiric value 6.997173172490447
Given sigma 8, empiric value 7.996647965992465
Given sigma 9, empiric value 8.99612048649375

【讨论】:

    猜你喜欢
    • 2014-11-03
    • 1970-01-01
    • 1970-01-01
    • 2018-04-16
    • 2021-04-19
    • 2011-01-25
    • 2015-04-12
    • 1970-01-01
    • 2011-11-02
    相关资源
    最近更新 更多