本文簡要介紹 python 語言中 scipy.ndimage.rotate
的用法。
用法:
scipy.ndimage.rotate(input, angle, axes=(1, 0), reshape=True, output=None, order=3, mode='constant', cval=0.0, prefilter=True)#
旋轉數組。
數組在由軸參數給定的兩個軸定義的平麵中旋轉,使用請求順序的樣條插值。
- input: array_like
輸入數組。
- angle: 浮點數
以度為單位的旋轉角度。
- axes: 2 個整數的元組,可選
定義旋轉平麵的兩個軸。默認是前兩個軸。
- reshape: 布爾型,可選
如果 reshape 為真,則調整輸出形狀,以便輸入數組完全包含在輸出中。默認為真。
- output: 數組或數據類型,可選
放置輸出的數組,或返回數組的 dtype。默認情況下,將創建一個與輸入具有相同 dtype 的數組。
- order: 整數,可選
樣條插值的階數,默認為 3。階數必須在 0-5 範圍內。
- mode: {‘reflect’、‘grid-mirror’、‘constant’、‘grid-constant’、‘nearest’、‘mirror’、‘grid-wrap’、‘wrap’},可選
模式參數確定輸入數組如何擴展到其邊界之外。默認為‘constant’。每個有效值的行為如下(請參閱其他圖表和詳細信息邊界模式):
- ‘reflect’ (d c b a | a b c d | d c b a)
通過反射最後一個像素的邊來擴展輸入。此模式有時也稱為half-sample 對稱模式。
- ‘grid-mirror’
這是‘reflect’ 的同義詞。
- ‘constant’ (k k k k | a b c d |呸呸呸呸)
通過使用 cval 參數定義的相同常量值填充邊之外的所有值來擴展輸入。在輸入邊之外不執行插值。
- ‘grid-constant’ (k k k k | a b c d |呸呸呸呸)
通過使用 cval 參數定義的相同常量值填充邊之外的所有值來擴展輸入。插值也會發生在輸入範圍之外的樣本上。
- ‘nearest’ (啊啊啊啊| a b c d |嘀嘀嘀嘀)
通過複製最後一個像素來擴展輸入。
- ‘mirror’ (d c b | a b c d | c b a)
通過反射最後一個像素的中心來擴展輸入。此模式有時也稱為whole-sample 對稱模式。
- ‘grid-wrap’ (a b c d | a b c d | A B C D)
通過環繞到相對邊來擴展輸入。
- ‘wrap’ (d b c d | a b c d | b c a b)
輸入通過環繞到相反的邊來擴展,但是以某種方式使最後一個點和初始點完全重疊。在這種情況下,沒有很好地定義在重疊點將選擇哪個樣本。
- cval: 標量,可選
如果模式為‘constant’,則填充過去輸入邊的值。默認值為 0.0。
- prefilter: 布爾型,可選
確定輸入數組是否經過預過濾scipy.ndimage.spline_filter插值之前。默認為 True,這將創建一個臨時浮點數64過濾值數組 if訂單 > 1.如果將此設置為 False,則輸出會稍微模糊,如果訂單 > 1, 除非輸入是預過濾的,即它是調用的結果scipy.ndimage.spline_filter在原始輸入上。
- rotate: ndarray
旋轉的輸入。
參數 ::
返回 ::
注意:
對於complex-valued 輸入,此函數獨立旋轉實部和虛部。
例子:
>>> from scipy import ndimage, datasets >>> import matplotlib.pyplot as plt >>> fig = plt.figure(figsize=(10, 3)) >>> ax1, ax2, ax3 = fig.subplots(1, 3) >>> img = datasets.ascent() >>> img_45 = ndimage.rotate(img, 45, reshape=False) >>> full_img_45 = ndimage.rotate(img, 45, reshape=True) >>> ax1.imshow(img, cmap='gray') >>> ax1.set_axis_off() >>> ax2.imshow(img_45, cmap='gray') >>> ax2.set_axis_off() >>> ax3.imshow(full_img_45, cmap='gray') >>> ax3.set_axis_off() >>> fig.set_layout_engine('tight') >>> plt.show()
>>> print(img.shape) (512, 512) >>> print(img_45.shape) (512, 512) >>> print(full_img_45.shape) (724, 724)
相關用法
- Python SciPy ndimage.rank_filter用法及代碼示例
- Python SciPy ndimage.correlate用法及代碼示例
- Python SciPy ndimage.morphological_gradient用法及代碼示例
- Python SciPy ndimage.variance用法及代碼示例
- Python SciPy ndimage.correlate1d用法及代碼示例
- Python SciPy ndimage.binary_dilation用法及代碼示例
- Python SciPy ndimage.distance_transform_bf用法及代碼示例
- Python SciPy ndimage.find_objects用法及代碼示例
- Python SciPy ndimage.label用法及代碼示例
- Python SciPy ndimage.maximum_filter1d用法及代碼示例
- Python SciPy ndimage.iterate_structure用法及代碼示例
- Python SciPy ndimage.map_coordinates()用法及代碼示例
- Python SciPy ndimage.generic_laplace用法及代碼示例
- Python SciPy ndimage.generate_binary_structure用法及代碼示例
- Python SciPy ndimage.binary_opening用法及代碼示例
- Python SciPy ndimage.binary_fill_holes用法及代碼示例
- Python SciPy ndimage.maximum_filter用法及代碼示例
- Python SciPy ndimage.minimum_position用法及代碼示例
- Python SciPy ndimage.labeled_comprehension用法及代碼示例
- Python SciPy ndimage.grey_erosion用法及代碼示例
- Python SciPy ndimage.spline_filter用法及代碼示例
- Python SciPy ndimage.shift用法及代碼示例
- Python SciPy ndimage.distance_transform_cdt用法及代碼示例
- Python SciPy ndimage.minimum用法及代碼示例
- Python SciPy ndimage.fourier_uniform用法及代碼示例
注:本文由純淨天空篩選整理自scipy.org大神的英文原創作品 scipy.ndimage.rotate。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。