本文整理汇总了Python中scipy.ndimage.filters.gaussian_laplace方法的典型用法代码示例。如果您正苦于以下问题:Python filters.gaussian_laplace方法的具体用法?Python filters.gaussian_laplace怎么用?Python filters.gaussian_laplace使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类scipy.ndimage.filters
的用法示例。
在下文中一共展示了filters.gaussian_laplace方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: laplacian
# 需要导入模块: from scipy.ndimage import filters [as 别名]
# 或者: from scipy.ndimage.filters import gaussian_laplace [as 别名]
def laplacian(data, sigmas):
"""
Apply Laplacian filter
"""
assert len(data.shape) == len(sigmas)
from scipy.ndimage.filters import gaussian_laplace
return gaussian_laplace(data.astype(float), sigmas)
# from scipy.ndimage.filters import laplace
# return laplace(data.astype(float))
示例2: test_scipy_filter_gaussian_laplace
# 需要导入模块: from scipy.ndimage import filters [as 别名]
# 或者: from scipy.ndimage.filters import gaussian_laplace [as 别名]
def test_scipy_filter_gaussian_laplace(self, width):
"""
Test RickerWavelet kernels against SciPy ndimage gaussian laplace filters.
"""
ricker_kernel_1D = RickerWavelet1DKernel(width)
ricker_kernel_2D = RickerWavelet2DKernel(width)
astropy_1D = convolve(delta_pulse_1D, ricker_kernel_1D, boundary='fill', normalize_kernel=False)
astropy_2D = convolve(delta_pulse_2D, ricker_kernel_2D, boundary='fill', normalize_kernel=False)
with pytest.raises(Exception) as exc:
astropy_1D = convolve(delta_pulse_1D, ricker_kernel_1D, boundary='fill', normalize_kernel=True)
assert 'sum is close to zero' in exc.value.args[0]
with pytest.raises(Exception) as exc:
astropy_2D = convolve(delta_pulse_2D, ricker_kernel_2D, boundary='fill', normalize_kernel=True)
assert 'sum is close to zero' in exc.value.args[0]
# The Laplace of Gaussian filter is an inverted Ricker Wavelet filter.
scipy_1D = -filters.gaussian_laplace(delta_pulse_1D, width)
scipy_2D = -filters.gaussian_laplace(delta_pulse_2D, width)
# There is a slight deviation in the normalization. They differ by a
# factor of ~1.0000284132604045. The reason is not known.
assert_almost_equal(astropy_1D, scipy_1D, decimal=5)
assert_almost_equal(astropy_2D, scipy_2D, decimal=5)
示例3: create_filter_bank_lm_2d
# 需要导入模块: from scipy.ndimage import filters [as 别名]
# 或者: from scipy.ndimage.filters import gaussian_laplace [as 别名]
def create_filter_bank_lm_2d(radius=16, sigmas=DEFAULT_FILTERS_SIGMAS,
nb_orient=8):
""" create filter bank with rotation, Gaussian, Laplace-Gaussian, ...
:param radius:
:param sigmas:
:param nb_orient:
:return np.ndarray<nb_samples, nb_features>, list(str):
>>> filters, names = create_filter_bank_lm_2d(6, SHORT_FILTERS_SIGMAS, 2)
>>> [f.shape for f in filters] # doctest: +NORMALIZE_WHITESPACE
[(2, 13, 13), (2, 13, 13), (1, 13, 13), (1, 13, 13), (1, 13, 13),
(2, 13, 13), (2, 13, 13), (1, 13, 13), (1, 13, 13), (1, 13, 13),
(2, 13, 13), (2, 13, 13), (1, 13, 13), (1, 13, 13), (1, 13, 13)]
>>> names # doctest: +NORMALIZE_WHITESPACE
['sigma1.4-edge', 'sigma1.4-bar',
'sigma1.4-Gauss', 'sigma1.4-GaussLap', 'sigma1.4-GaussLap2',
'sigma2.0-edge', 'sigma2.0-bar',
'sigma2.0-Gauss', 'sigma2.0-GaussLap', 'sigma2.0-GaussLap2',
'sigma4.0-edge', 'sigma4.0-bar',
'sigma4.0-Gauss', 'sigma4.0-GaussLap', 'sigma4.0-GaussLap2']
"""
logging.debug('creating Leung-Malik filter bank')
support = 2 * radius + 1
x, y = np.mgrid[-radius:radius + 1, radius:-radius - 1:-1]
org_pts = np.vstack([x.ravel(), y.ravel()])
a = np.zeros((support, support))
a[radius, radius] = 1
filters, names = [], []
for sigma in sigmas:
orient_edge, orient_bar = [], []
for orient in range(nb_orient):
# Not 2pi as filters have symmetry
angle = np.pi * orient / nb_orient
c, s = np.cos(angle), np.sin(angle)
rot_points = np.dot(np.array([[c, -s], [s, c]]), org_pts)
orient_edge.append(make_edge_filter2d(sigma, 1, rot_points, support))
orient_bar.append(make_edge_filter2d(sigma, 2, rot_points, support))
filters.append(np.asarray(orient_edge))
filters.append(np.asarray(orient_bar))
filters.append(gaussian_filter(a, sigma)[np.newaxis, :, :])
filters.append(gaussian_laplace(a, sigma)[np.newaxis, :, :])
filters.append(gaussian_laplace(a, sigma ** 2)[np.newaxis, :, :])
names += ['sigma%.1f-%s' % (sigma, n)
for n in ['edge', 'bar', 'Gauss', 'GaussLap', 'GaussLap2']]
return filters, names