當前位置: 首頁>>代碼示例>>Python>>正文


Python filters.gaussian_laplace方法代碼示例

本文整理匯總了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)) 
開發者ID:neuropoly,項目名稱:spinalcordtoolbox,代碼行數:11,代碼來源:sct_maths.py

示例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) 
開發者ID:holzschu,項目名稱:Carnets,代碼行數:28,代碼來源:test_kernel_class.py

示例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 
開發者ID:Borda,項目名稱:pyImSegm,代碼行數:50,代碼來源:descriptors.py


注:本文中的scipy.ndimage.filters.gaussian_laplace方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。