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


Python ndimage.minimum_filter方法代码示例

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


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

示例1: test_valid_origins

# 需要导入模块: from scipy import ndimage [as 别名]
# 或者: from scipy.ndimage import minimum_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: test_minimum_filter01

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

示例3: test_minimum_filter02

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

示例4: test_minimum_filter03

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

示例5: test_minimum_filter04

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

示例6: test_minimum_filter05

# 需要导入模块: from scipy import ndimage [as 别名]
# 或者: from scipy.ndimage import minimum_filter [as 别名]
def test_minimum_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.minimum_filter(array, filter_shape)
        assert_array_almost_equal([[2, 2, 1, 1, 1],
                              [2, 2, 1, 1, 1],
                              [5, 3, 3, 1, 1]], output) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:11,代码来源:test_ndimage.py

示例7: test_minimum_filter07

# 需要导入模块: from scipy import ndimage [as 别名]
# 或者: from scipy.ndimage import minimum_filter [as 别名]
def test_minimum_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.minimum_filter(array,
                                                 footprint=footprint)
        assert_array_almost_equal([[2, 2, 1, 1, 1],
                              [2, 3, 1, 3, 1],
                              [5, 5, 3, 3, 1]], output) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:12,代码来源:test_ndimage.py

示例8: test_minimum_filter08

# 需要导入模块: from scipy import ndimage [as 别名]
# 或者: from scipy.ndimage import minimum_filter [as 别名]
def test_minimum_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.minimum_filter(array,
                                       footprint=footprint, origin=-1)
        assert_array_almost_equal([[3, 1, 3, 1, 1],
                              [5, 3, 3, 1, 1],
                              [3, 3, 1, 1, 1]], output) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:12,代码来源:test_ndimage.py

示例9: test_minimum_filter09

# 需要导入模块: from scipy import ndimage [as 别名]
# 或者: from scipy.ndimage import minimum_filter [as 别名]
def test_minimum_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.minimum_filter(array,
                                  footprint=footprint, origin=[-1, 0])
        assert_array_almost_equal([[2, 3, 1, 3, 1],
                              [5, 5, 3, 3, 1],
                              [5, 3, 3, 1, 1]], output) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:12,代码来源:test_ndimage.py

示例10: test_minimum_filter05

# 需要导入模块: from scipy import ndimage [as 别名]
# 或者: from scipy.ndimage import minimum_filter [as 别名]
def test_minimum_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.minimum_filter(array, filter_shape)
        assert_array_almost_equal([[2, 2, 1, 1, 1],
                                   [2, 2, 1, 1, 1],
                                   [5, 3, 3, 1, 1]], output) 
开发者ID:Relph1119,项目名称:GraphicDesignPatternByPython,代码行数:11,代码来源:test_ndimage.py

示例11: test_minimum_filter07

# 需要导入模块: from scipy import ndimage [as 别名]
# 或者: from scipy.ndimage import minimum_filter [as 别名]
def test_minimum_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.minimum_filter(array, footprint=footprint)
        assert_array_almost_equal([[2, 2, 1, 1, 1],
                                   [2, 3, 1, 3, 1],
                                   [5, 5, 3, 3, 1]], output) 
开发者ID:Relph1119,项目名称:GraphicDesignPatternByPython,代码行数:11,代码来源:test_ndimage.py

示例12: test_minimum_filter08

# 需要导入模块: from scipy import ndimage [as 别名]
# 或者: from scipy.ndimage import minimum_filter [as 别名]
def test_minimum_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.minimum_filter(array, footprint=footprint, origin=-1)
        assert_array_almost_equal([[3, 1, 3, 1, 1],
                                   [5, 3, 3, 1, 1],
                                   [3, 3, 1, 1, 1]], output) 
开发者ID:Relph1119,项目名称:GraphicDesignPatternByPython,代码行数:11,代码来源:test_ndimage.py

示例13: test_minimum_filter09

# 需要导入模块: from scipy import ndimage [as 别名]
# 或者: from scipy.ndimage import minimum_filter [as 别名]
def test_minimum_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.minimum_filter(array, footprint=footprint,
                                        origin=[-1, 0])
        assert_array_almost_equal([[2, 3, 1, 3, 1],
                                   [5, 5, 3, 3, 1],
                                   [5, 3, 3, 1, 1]], output) 
开发者ID:Relph1119,项目名称:GraphicDesignPatternByPython,代码行数:12,代码来源:test_ndimage.py

示例14: test_multiple_modes

# 需要导入模块: from scipy import ndimage [as 别名]
# 或者: from scipy.ndimage import minimum_filter [as 别名]
def test_multiple_modes():
    # Test that the filters with multiple mode cababilities for different
    # dimensions give the same result as applying a single mode.
    arr = np.array([[1., 0., 0.],
                    [1., 1., 0.],
                    [0., 0., 0.]])

    mode1 = 'reflect'
    mode2 = ['reflect', 'reflect']

    assert_equal(sndi.gaussian_filter(arr, 1, mode=mode1),
                 sndi.gaussian_filter(arr, 1, mode=mode2))
    assert_equal(sndi.prewitt(arr, mode=mode1),
                 sndi.prewitt(arr, mode=mode2))
    assert_equal(sndi.sobel(arr, mode=mode1),
                 sndi.sobel(arr, mode=mode2))
    assert_equal(sndi.laplace(arr, mode=mode1),
                 sndi.laplace(arr, mode=mode2))
    assert_equal(sndi.gaussian_laplace(arr, 1, mode=mode1),
                 sndi.gaussian_laplace(arr, 1, mode=mode2))
    assert_equal(sndi.maximum_filter(arr, size=5, mode=mode1),
                 sndi.maximum_filter(arr, size=5, mode=mode2))
    assert_equal(sndi.minimum_filter(arr, size=5, mode=mode1),
                 sndi.minimum_filter(arr, size=5, mode=mode2))
    assert_equal(sndi.gaussian_gradient_magnitude(arr, 1, mode=mode1),
                 sndi.gaussian_gradient_magnitude(arr, 1, mode=mode2))
    assert_equal(sndi.uniform_filter(arr, 5, mode=mode1),
                 sndi.uniform_filter(arr, 5, mode=mode2)) 
开发者ID:Relph1119,项目名称:GraphicDesignPatternByPython,代码行数:30,代码来源:test_filters.py

示例15: test_minmax_filter

# 需要导入模块: from scipy import ndimage [as 别名]
# 或者: from scipy.ndimage import minimum_filter [as 别名]
def test_minmax_filter(self):
        d = np.random.randn(500, 500)
        os = np.empty([4] + list(d.shape))
        ot = np.empty_like(os)
        self.check_func_serial(4, sndi.maximum_filter, (d, 3), os)
        self.check_func_thread(4, sndi.maximum_filter, (d, 3), ot)
        assert_array_equal(os, ot)
        self.check_func_serial(4, sndi.minimum_filter, (d, 3), os)
        self.check_func_thread(4, sndi.minimum_filter, (d, 3), ot)
        assert_array_equal(os, ot) 
开发者ID:Relph1119,项目名称:GraphicDesignPatternByPython,代码行数:12,代码来源:test_filters.py


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