當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


Python skimage.transform.resize_local_mean用法及代碼示例

用法:

skimage.transform.resize_local_mean(image, output_shape, grid_mode=True, preserve_range=False, *, channel_axis=None)

使用局部均值/雙線性縮放調整數組大小。

參數

imagendarray

輸入圖像。如果這是多通道圖像,則應使用 channel_axis 指定通道對應的軸

output_shape可迭代的

生成的輸出圖像的大小。什麽時候channel_axis不是無,channel_axis應該從output_shape或者output_shape[channel_axis]必須匹配image.shape[channel_axis].如果長度為output_shape超過 image.ndim 額外的單例維度將被附加到輸入image如所須。

grid_mode布爾型,可選

定義image像素位置:如果為真,則假定像素位於網格交叉點,否則位於單元格中心。因此,例如,長度為 5 的一維信號在以下情況下被認為具有長度 4grid_mode為 False,但長度為 5 時grid_mode是真的。請參見以下視覺示例:

| pixel 1 | pixel 2 | pixel 3 | pixel 4 | pixel 5 |
     |<-------------------------------------->|
                        vs.
|<----------------------------------------------->|

上圖中箭頭的起點對應於每種模式下的坐標位置 0。

preserve_range布爾型,可選

是否保持原來的取值範圍。否則,輸入圖像將根據以下約定進行轉換img_as_float.另見https://scikit-image.org/docs/dev/user_guide/data_types.html

返回

resizedndarray

輸入的調整大小的版本。

注意

此方法有時稱為“area-based” 插值或“pixel mixing” 插值[1].什麽時候grid_mode為 True,相當於使用 OpenCV 的 resize withINTER_AREA插值模式。它通常用於圖像縮小。如果縮小因子是整數,那麽skimage.transform.downscale_local_mean應該是首選。

參考

1

http://entropymine.com/imageworsener/pixelmixing/

例子

>>> from skimage import data
>>> from skimage.transform import resize_local_mean
>>> image = data.camera()
>>> resize_local_mean(image, (100, 100)).shape
(100, 100)

相關用法


注:本文由純淨天空篩選整理自scikit-image.org大神的英文原創作品 skimage.transform.resize_local_mean。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。