当前位置: 首页>>代码示例>>Python>>正文


Python ndimage.maximum_filter方法代码示例

本文整理汇总了Python中scipy.ndimage.maximum_filter方法的典型用法代码示例。如果您正苦于以下问题:Python ndimage.maximum_filter方法的具体用法?Python ndimage.maximum_filter怎么用?Python ndimage.maximum_filter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在scipy.ndimage的用法示例。


在下文中一共展示了ndimage.maximum_filter方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_valid_origins

# 需要导入模块: from scipy import ndimage [as 别名]
# 或者: from scipy.ndimage import maximum_filter [as 别名]
def test_valid_origins():
    """Regression test for #1311."""
    func = lambda x: np.mean(x)
    data = np.array([1,2,3,4,5], dtype=np.float64)
    assert_raises(ValueError, sndi.generic_filter, data, func, size=3,
                  origin=2)
    func2 = lambda x, y: np.mean(x + y)
    assert_raises(ValueError, sndi.generic_filter1d, data, func,
                  filter_size=3, origin=2)
    assert_raises(ValueError, sndi.percentile_filter, data, 0.2, size=3,
                  origin=2)

    for filter in [sndi.uniform_filter, sndi.minimum_filter,
                   sndi.maximum_filter, sndi.maximum_filter1d,
                   sndi.median_filter, sndi.minimum_filter1d]:
        # This should work, since for size == 3, the valid range for origin is
        # -1 to 1.
        list(filter(data, 3, origin=-1))
        list(filter(data, 3, origin=1))
        # Just check this raises an error instead of silently accepting or
        # segfaulting.
        assert_raises(ValueError, filter, data, 3, origin=2) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:24,代码来源:test_filters.py

示例2: filter

# 需要导入模块: from scipy import ndimage [as 别名]
# 或者: from scipy.ndimage import maximum_filter [as 别名]
def filter(self, signal):
        """Filter a given signal with a choice of filter type (self.lres_filter).
        """
        signal = signal.copy()
        filter_size = [1, self.downsamp_t*2-1, self.downsamp_xz*2-1, self.downsamp_xz*2-1]

        if self.lres_filter == 'none' or (not self.lres_filter):
            output = signal
        elif self.lres_filter == 'gaussian':
            sigma = [0, int(self.downsamp_t/2), int(self.downsamp_xz/2), int(self.downsamp_xz/2)]
            output = ndimage.gaussian_filter(signal, sigma=sigma)
        elif self.lres_filter == 'uniform':
            output = ndimage.uniform_filter(signal, size=filter_size)
        elif self.lres_filter == 'median':
            output = ndimage.median_filter(signal, size=filter_size)
        elif self.lres_filter == 'maximum':
            output = ndimage.maximum_filter(signal, size=filter_size)
        else:
            raise NotImplementedError(
                "lres_filter must be one of none/gaussian/uniform/median/maximum")
        return output 
开发者ID:maxjiang93,项目名称:space_time_pde,代码行数:23,代码来源:dataloader_spacetime.py

示例3: build_part_with_score_fast

# 需要导入模块: from scipy import ndimage [as 别名]
# 或者: from scipy.ndimage import maximum_filter [as 别名]
def build_part_with_score_fast(score_threshold, local_max_radius, scores):
    parts = []
    num_keypoints = scores.shape[2]
    lmd = 2 * local_max_radius + 1

    # NOTE it seems faster to iterate over the keypoints and perform maximum_filter
    # on each subarray vs doing the op on the full score array with size=(lmd, lmd, 1)
    for keypoint_id in range(num_keypoints):
        kp_scores = scores[:, :, keypoint_id].copy()
        kp_scores[kp_scores < score_threshold] = 0.
        max_vals = ndi.maximum_filter(kp_scores, size=lmd, mode='constant')
        max_loc = np.logical_and(kp_scores == max_vals, kp_scores > 0)
        max_loc_idx = max_loc.nonzero()
        for y, x in zip(*max_loc_idx):
            parts.append((
                scores[y, x, keypoint_id],
                keypoint_id,
                np.array((y, x))
            ))

    return parts 
开发者ID:rwightman,项目名称:posenet-python,代码行数:23,代码来源:decode_multi.py

示例4: local_nonmax_suppression

# 需要导入模块: from scipy import ndimage [as 别名]
# 或者: from scipy.ndimage import maximum_filter [as 别名]
def local_nonmax_suppression(filtered, suppression_masks, num_orients=16):
    """
    Apply oriented non-max suppression to the filters, so that only a single 
    orientated edge is active at a pixel. See Preproc for additional parameters.

    Parameters
    ----------
    filtered : numpy.ndarray
        Output of filtering the input image with the filter bank.
        Shape is (num feats, rows, columns).

    Returns
    -------
    localized : numpy.ndarray
        Result of oriented non-max suppression.
    """
    localized = np.zeros_like(filtered)
    cross_orient_max = filtered.max(0)
    filtered[filtered < 0] = 0
    for i, (layer, suppress_mask) in enumerate(zip(filtered, suppression_masks)):
        competitor_maxs = maximum_filter(layer, footprint=suppress_mask, mode='nearest')
        localized[i] = competitor_maxs <= layer
    localized[cross_orient_max > filtered] = 0
    return localized 
开发者ID:vicariousinc,项目名称:science_rcn,代码行数:26,代码来源:preproc.py

示例5: test_maximum_filter01

# 需要导入模块: from scipy import ndimage [as 别名]
# 或者: from scipy.ndimage import maximum_filter [as 别名]
def test_maximum_filter01(self):
        array = numpy.array([1, 2, 3, 4, 5])
        filter_shape = numpy.array([2])
        output = ndimage.maximum_filter(array, filter_shape)
        assert_array_almost_equal([1, 2, 3, 4, 5], output) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:7,代码来源:test_ndimage.py

示例6: non_max_suppression

# 需要导入模块: from scipy import ndimage [as 别名]
# 或者: from scipy.ndimage import maximum_filter [as 别名]
def non_max_suppression(plain, window_size=3, threshold=NMS_Threshold):
        under_threshold_indices = plain < threshold
        plain[under_threshold_indices] = 0
        return plain * (plain == maximum_filter(plain, footprint=np.ones((window_size, window_size)))) 
开发者ID:SrikanthVelpuri,项目名称:tf-pose,代码行数:6,代码来源:estimator.py

示例7: test_maximum_filter02

# 需要导入模块: from scipy import ndimage [as 别名]
# 或者: from scipy.ndimage import maximum_filter [as 别名]
def test_maximum_filter02(self):
        array = numpy.array([1, 2, 3, 4, 5])
        filter_shape = numpy.array([3])
        output = ndimage.maximum_filter(array, filter_shape)
        assert_array_almost_equal([2, 3, 4, 5, 5], output) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:7,代码来源:test_ndimage.py

示例8: test_maximum_filter03

# 需要导入模块: from scipy import ndimage [as 别名]
# 或者: from scipy.ndimage import maximum_filter [as 别名]
def test_maximum_filter03(self):
        array = numpy.array([3, 2, 5, 1, 4])
        filter_shape = numpy.array([2])
        output = ndimage.maximum_filter(array, filter_shape)
        assert_array_almost_equal([3, 3, 5, 5, 4], output) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:7,代码来源:test_ndimage.py

示例9: test_maximum_filter04

# 需要导入模块: from scipy import ndimage [as 别名]
# 或者: from scipy.ndimage import maximum_filter [as 别名]
def test_maximum_filter04(self):
        array = numpy.array([3, 2, 5, 1, 4])
        filter_shape = numpy.array([3])
        output = ndimage.maximum_filter(array, filter_shape)
        assert_array_almost_equal([3, 5, 5, 5, 4], output) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:7,代码来源:test_ndimage.py

示例10: test_maximum_filter05

# 需要导入模块: from scipy import ndimage [as 别名]
# 或者: from scipy.ndimage import maximum_filter [as 别名]
def test_maximum_filter05(self):
        array = numpy.array([[3, 2, 5, 1, 4],
                                [7, 6, 9, 3, 5],
                                [5, 8, 3, 7, 1]])
        filter_shape = numpy.array([2, 3])
        output = ndimage.maximum_filter(array, filter_shape)
        assert_array_almost_equal([[3, 5, 5, 5, 4],
                              [7, 9, 9, 9, 5],
                              [8, 9, 9, 9, 7]], output) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:11,代码来源:test_ndimage.py

示例11: test_maximum_filter07

# 需要导入模块: from scipy import ndimage [as 别名]
# 或者: from scipy.ndimage import maximum_filter [as 别名]
def test_maximum_filter07(self):
        array = numpy.array([[3, 2, 5, 1, 4],
                                [7, 6, 9, 3, 5],
                                [5, 8, 3, 7, 1]])
        footprint = [[1, 0, 1], [1, 1, 0]]
        output = ndimage.maximum_filter(array,
                                                 footprint=footprint)
        assert_array_almost_equal([[3, 5, 5, 5, 4],
                              [7, 7, 9, 9, 5],
                              [7, 9, 8, 9, 7]], output) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:12,代码来源:test_ndimage.py

示例12: test_maximum_filter08

# 需要导入模块: from scipy import ndimage [as 别名]
# 或者: from scipy.ndimage import maximum_filter [as 别名]
def test_maximum_filter08(self):
        array = numpy.array([[3, 2, 5, 1, 4],
                                [7, 6, 9, 3, 5],
                                [5, 8, 3, 7, 1]])
        footprint = [[1, 0, 1], [1, 1, 0]]
        output = ndimage.maximum_filter(array,
                                      footprint=footprint, origin=-1)
        assert_array_almost_equal([[7, 9, 9, 5, 5],
                              [9, 8, 9, 7, 5],
                              [8, 8, 7, 7, 7]], output) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:12,代码来源:test_ndimage.py

示例13: test_maximum_filter09

# 需要导入模块: from scipy import ndimage [as 别名]
# 或者: from scipy.ndimage import maximum_filter [as 别名]
def test_maximum_filter09(self):
        array = numpy.array([[3, 2, 5, 1, 4],
                                [7, 6, 9, 3, 5],
                                [5, 8, 3, 7, 1]])
        footprint = [[1, 0, 1], [1, 1, 0]]
        output = ndimage.maximum_filter(array,
                                 footprint=footprint, origin=[-1, 0])
        assert_array_almost_equal([[7, 7, 9, 9, 5],
                              [7, 9, 8, 9, 7],
                              [8, 8, 8, 7, 7]], output) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:12,代码来源:test_ndimage.py

示例14: get_invalid_mask

# 需要导入模块: from scipy import ndimage [as 别名]
# 或者: from scipy.ndimage import maximum_filter [as 别名]
def get_invalid_mask(img, n, landmask_border):
    """
    Create mask of invalid pixels (land, cosatal, inf)

    Parameters
    ----------
    img : float ndarray
        input image
    n : Nansat
        input Nansat object
    landmask_border : int
        border around landmask

    Returns
    -------
    mask : 2D bool ndarray
        True where pixels are invalid
    """
    mask = np.isnan(img) + np.isinf(img)
    n.resize(1./landmask_border)
    try:
        wm = n.watermask()[1]
    except:
        print('Cannot add landmask')
    else:
        wm[wm > 2] = 2
        wmf = maximum_filter(wm, 3)
        wmz = zoom(wmf, (np.array(img.shape) / np.array(wm.shape)))
        mask[wmz == 2] = True

    n.undo()
    return mask 
开发者ID:nansencenter,项目名称:sea_ice_drift,代码行数:34,代码来源:lib.py

示例15: test_maximum_filter05

# 需要导入模块: from scipy import ndimage [as 别名]
# 或者: from scipy.ndimage import maximum_filter [as 别名]
def test_maximum_filter05(self):
        array = numpy.array([[3, 2, 5, 1, 4],
                             [7, 6, 9, 3, 5],
                             [5, 8, 3, 7, 1]])
        filter_shape = numpy.array([2, 3])
        output = ndimage.maximum_filter(array, filter_shape)
        assert_array_almost_equal([[3, 5, 5, 5, 4],
                                   [7, 9, 9, 9, 5],
                                   [8, 9, 9, 9, 7]], output) 
开发者ID:Relph1119,项目名称:GraphicDesignPatternByPython,代码行数:11,代码来源:test_ndimage.py


注:本文中的scipy.ndimage.maximum_filter方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。