用法:
skimage.measure.block_reduce(image, block_size=2, func=<function sum>, cval=0, func_kwargs=None)
通過將函數 func 應用於本地塊來對圖像進行下采樣。
例如,此函數對於最大和均值池很有用。
- image:ndarray
N維輸入圖像。
- block_size:數組 或 int
包含沿每個軸的下采樣整數因子的數組。默認 block_size 為 2。
- func:可調用的
用於計算每個本地塊的返回值的函數對象。這個函數必須實現一個
axis
範圍。主要函數是numpy.sum
,numpy.min
,numpy.max
,numpy.mean
和numpy.median
.也可以看看func_kwargs.- cval:浮點數
如果圖像不能完全被塊大小整除,則為常量填充值。
- func_kwargs:dict
傳遞給的關鍵字參數函數.對於將 dtype 參數傳遞給
np.mean
.接受輸入字典,例如:func_kwargs={'dtype': np.float16})
.
- image:ndarray
與輸入圖像具有相同維度的下采樣圖像。
參數:
返回:
例子:
>>> from skimage.measure import block_reduce >>> image = np.arange(3*3*4).reshape(3, 3, 4) >>> image array([[[ 0, 1, 2, 3], [ 4, 5, 6, 7], [ 8, 9, 10, 11]], [[12, 13, 14, 15], [16, 17, 18, 19], [20, 21, 22, 23]], [[24, 25, 26, 27], [28, 29, 30, 31], [32, 33, 34, 35]]]) >>> block_reduce(image, block_size=(3, 3, 1), func=np.mean) array([[[16., 17., 18., 19.]]]) >>> image_max1 = block_reduce(image, block_size=(1, 3, 4), func=np.max) >>> image_max1 array([[[11]], [[23]], [[35]]]) >>> image_max2 = block_reduce(image, block_size=(3, 1, 4), func=np.max) >>> image_max2 array([[[27], [31], [35]]])
相關用法
- Python skimage.measure.ransac用法及代碼示例
- Python skimage.measure.profile_line用法及代碼示例
- Python skimage.measure.perimeter_crofton用法及代碼示例
- Python skimage.measure.moments_hu用法及代碼示例
- Python skimage.measure.moments_coords_central用法及代碼示例
- Python skimage.measure.LineModelND用法及代碼示例
- Python skimage.measure.moments用法及代碼示例
- Python skimage.measure.shannon_entropy用法及代碼示例
- Python skimage.measure.moments_normalized用法及代碼示例
- Python skimage.measure.euler_number用法及代碼示例
- Python skimage.measure.perimeter用法及代碼示例
- Python skimage.measure.moments_central用法及代碼示例
- Python skimage.measure.EllipseModel用法及代碼示例
- Python skimage.measure.regionprops用法及代碼示例
- Python skimage.measure.find_contours用法及代碼示例
- Python skimage.measure.CircleModel用法及代碼示例
- Python skimage.measure.label用法及代碼示例
- Python skimage.measure.regionprops_table用法及代碼示例
- Python skimage.measure.moments_coords用法及代碼示例
- Python skimage.metrics.hausdorff_distance用法及代碼示例
注:本文由純淨天空篩選整理自scikit-image.org大神的英文原創作品 skimage.measure.block_reduce。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。