mirror of
https://github.com/wassname/scikit-image.git
synced 2026-07-05 20:16:04 +08:00
Rename block_* functions to local_*
This commit is contained in:
@@ -3,7 +3,7 @@ from ._regionprops import regionprops, perimeter
|
||||
from ._structural_similarity import structural_similarity
|
||||
from ._polygon import approximate_polygon, subdivide_polygon
|
||||
from .fit import LineModel, CircleModel, EllipseModel, ransac
|
||||
from .blocks import block_sum, block_median, block_mean, block_min, block_max
|
||||
from .local import local_sum, local_mean, local_median, local_min, local_max
|
||||
|
||||
|
||||
__all__ = ['find_contours',
|
||||
@@ -16,8 +16,8 @@ __all__ = ['find_contours',
|
||||
'CircleModel',
|
||||
'EllipseModel',
|
||||
'ransac',
|
||||
'block_sum',
|
||||
'block_mean',
|
||||
'block_median',
|
||||
'block_min',
|
||||
'block_max']
|
||||
'local_sum',
|
||||
'local_mean',
|
||||
'local_median',
|
||||
'local_min',
|
||||
'local_max']
|
||||
|
||||
@@ -2,7 +2,7 @@ import numpy as np
|
||||
from ..util.shape import view_as_blocks, _pad_asymmetric_zeros
|
||||
|
||||
|
||||
def _block_func(image, factors, func):
|
||||
def _local_func(image, factors, func):
|
||||
"""Down-sample image by applying function to local blocks.
|
||||
|
||||
Parameters
|
||||
@@ -45,7 +45,7 @@ def _block_func(image, factors, func):
|
||||
return out
|
||||
|
||||
|
||||
def block_sum(image, block_size):
|
||||
def local_sum(image, block_size):
|
||||
"""Sum elements in local blocks.
|
||||
|
||||
The image is padded with zeros if it is not perfectly divisible by integer
|
||||
@@ -75,10 +75,10 @@ def block_sum(image, block_size):
|
||||
[33, 27]])
|
||||
|
||||
"""
|
||||
return _block_func(image, block_size, np.sum)
|
||||
return _local_func(image, block_size, np.sum)
|
||||
|
||||
|
||||
def block_mean(image, block_size):
|
||||
def local_mean(image, block_size):
|
||||
"""Average elements in local blocks.
|
||||
|
||||
The image is padded with zeros if it is not perfectly divisible by integer
|
||||
@@ -108,10 +108,10 @@ def block_mean(image, block_size):
|
||||
[ 5.5, 4.5]])
|
||||
|
||||
"""
|
||||
return _block_func(image, block_size, np.mean)
|
||||
return _local_func(image, block_size, np.mean)
|
||||
|
||||
|
||||
def block_median(image, block_size):
|
||||
def local_median(image, block_size):
|
||||
"""Median element in local blocks.
|
||||
|
||||
The image is padded with zeros if it is not perfectly divisible by integer
|
||||
@@ -139,10 +139,10 @@ def block_median(image, block_size):
|
||||
array([[ 5.]])
|
||||
|
||||
"""
|
||||
return _block_func(image, block_size, np.median)
|
||||
return _local_func(image, block_size, np.median)
|
||||
|
||||
|
||||
def block_min(image, block_size):
|
||||
def local_min(image, block_size):
|
||||
"""Minimum element in local blocks.
|
||||
|
||||
The image is padded with zeros if it is not perfectly divisible by integer
|
||||
@@ -172,10 +172,10 @@ def block_min(image, block_size):
|
||||
[0, 0, 0]])
|
||||
|
||||
"""
|
||||
return _block_func(image, block_size, np.min)
|
||||
return _local_func(image, block_size, np.min)
|
||||
|
||||
|
||||
def block_max(image, block_size):
|
||||
def local_max(image, block_size):
|
||||
"""Maximum element in local blocks.
|
||||
|
||||
The image is padded with zeros if it is not perfectly divisible by integer
|
||||
@@ -205,4 +205,4 @@ def block_max(image, block_size):
|
||||
[12, 14]])
|
||||
|
||||
"""
|
||||
return _block_func(image, block_size, np.max)
|
||||
return _local_func(image, block_size, np.max)
|
||||
@@ -1,78 +1,78 @@
|
||||
import numpy as np
|
||||
from numpy.testing import assert_array_equal
|
||||
from skimage.measure import (block_sum, block_mean, block_median, block_min,
|
||||
block_max)
|
||||
from skimage.measure import (local_sum, local_mean, local_median, local_min,
|
||||
local_max)
|
||||
|
||||
|
||||
def test_block_sum():
|
||||
def test_local_sum():
|
||||
image1 = np.arange(4 * 6).reshape(4, 6)
|
||||
out1 = block_sum(image1, (2, 3))
|
||||
out1 = local_sum(image1, (2, 3))
|
||||
expected1 = np.array([[ 24, 42],
|
||||
[ 96, 114]])
|
||||
assert_array_equal(expected1, out1)
|
||||
|
||||
image2 = np.arange(5 * 8).reshape(5, 8)
|
||||
out2 = block_sum(image2, (3, 3))
|
||||
out2 = local_sum(image2, (3, 3))
|
||||
expected2 = np.array([[ 81, 108, 87],
|
||||
[174, 192, 138]])
|
||||
assert_array_equal(expected2, out2)
|
||||
|
||||
|
||||
def test_block_mean():
|
||||
def test_local_mean():
|
||||
image1 = np.arange(4 * 6).reshape(4, 6)
|
||||
out1 = block_mean(image1, (2, 3))
|
||||
out1 = local_mean(image1, (2, 3))
|
||||
expected1 = np.array([[ 4., 7.],
|
||||
[ 16., 19.]])
|
||||
assert_array_equal(expected1, out1)
|
||||
|
||||
image2 = np.arange(5 * 8).reshape(5, 8)
|
||||
out2 = block_mean(image2, (4, 5))
|
||||
out2 = local_mean(image2, (4, 5))
|
||||
expected2 = np.array([[14. , 10.8],
|
||||
[ 8.5, 5.7]])
|
||||
assert_array_equal(expected2, out2)
|
||||
|
||||
|
||||
def test_block_median():
|
||||
def test_local_median():
|
||||
image1 = np.arange(4 * 6).reshape(4, 6)
|
||||
out1 = block_median(image1, (2, 3))
|
||||
out1 = local_median(image1, (2, 3))
|
||||
expected1 = np.array([[ 4., 7.],
|
||||
[ 16., 19.]])
|
||||
assert_array_equal(expected1, out1)
|
||||
|
||||
image2 = np.arange(5 * 8).reshape(5, 8)
|
||||
out2 = block_median(image2, (4, 5))
|
||||
out2 = local_median(image2, (4, 5))
|
||||
expected2 = np.array([[ 14., 17.],
|
||||
[ 0., 0.]])
|
||||
assert_array_equal(expected2, out2)
|
||||
|
||||
image3 = np.array([[1, 5, 5, 5], [5, 5, 5, 1000]])
|
||||
out3 = block_median(image3, (2, 4))
|
||||
out3 = local_median(image3, (2, 4))
|
||||
assert_array_equal(5, out3)
|
||||
|
||||
|
||||
def test_block_min():
|
||||
def test_local_min():
|
||||
image1 = np.arange(4 * 6).reshape(4, 6)
|
||||
out1 = block_min(image1, (2, 3))
|
||||
out1 = local_min(image1, (2, 3))
|
||||
expected1 = np.array([[ 0, 3],
|
||||
[12, 15]])
|
||||
assert_array_equal(expected1, out1)
|
||||
|
||||
image2 = np.arange(5 * 8).reshape(5, 8)
|
||||
out2 = block_min(image2, (4, 5))
|
||||
out2 = local_min(image2, (4, 5))
|
||||
expected2 = np.array([[0, 0],
|
||||
[0, 0]])
|
||||
assert_array_equal(expected2, out2)
|
||||
|
||||
|
||||
def test_block_max():
|
||||
def test_local_max():
|
||||
image1 = np.arange(4 * 6).reshape(4, 6)
|
||||
out1 = block_max(image1, (2, 3))
|
||||
out1 = local_max(image1, (2, 3))
|
||||
expected1 = np.array([[ 8, 11],
|
||||
[20, 23]])
|
||||
assert_array_equal(expected1, out1)
|
||||
|
||||
image2 = np.arange(5 * 8).reshape(5, 8)
|
||||
out2 = block_max(image2, (4, 5))
|
||||
out2 = local_max(image2, (4, 5))
|
||||
expected2 = np.array([[28, 31],
|
||||
[36, 39]])
|
||||
assert_array_equal(expected2, out2)
|
||||
@@ -2,7 +2,7 @@ import numpy as np
|
||||
from scipy import ndimage
|
||||
|
||||
from ._geometric import warp, SimilarityTransform, AffineTransform
|
||||
from ..measure.blocks import _block_func
|
||||
from ..measure.local import _local_func
|
||||
|
||||
|
||||
def resize(image, output_shape, order=1, mode='constant', cval=0.):
|
||||
@@ -260,7 +260,7 @@ def downscale_local_mean(image, factors):
|
||||
[5.5, 4.5]])
|
||||
|
||||
"""
|
||||
return _block_func(image, factors, np.mean)
|
||||
return _local_func(image, factors, np.mean)
|
||||
|
||||
|
||||
def _swirl_mapping(xy, center, rotation, strength, radius):
|
||||
|
||||
Reference in New Issue
Block a user