用法:
skimage.measure.profile_line(image, src, dst, linewidth=1, order=None, mode='reflect', cval=0.0, *, reduce_func=<function mean>)
返回沿掃描線測量的圖像的強度分布。
- image:ndarray,形狀(M,N[,C])
圖像,灰度(2D 陣列)或多通道(3D 陣列,其中最後一個軸包含通道信息)。
- src:數組, 形狀 (2, )
掃描線起點的坐標。
- dst:數組, 形狀 (2, )
掃描線終點的坐標。與標準 numpy 索引相比,目標點包含在配置文件中。
- linewidth:int 可選
掃描的寬度,垂直於線
- order:int in {0, 1, 2, 3, 4, 5},可選
樣條插值的順序,如果 image.dtype 為 bool 則默認為 0,否則為 1。順序必須在 0-5 範圍內。有關詳細信息,請參閱
skimage.transform.warp
- mode:{‘constant’, ‘nearest’, ‘reflect’, ‘mirror’, ‘wrap’},可選
如何計算圖像之外的任何值。
- cval:浮點數,可選
如果模式是‘constant’,在圖像外使用什麽常量值。
- reduce_func:可調用的,可選的
當 linewidth > 1 時,用於計算垂直於profile_line 方向的像素值聚合的函數。如果設置為 None,將返回未歸約的數組。
- return_value:數組
沿掃描線的強度分布。輪廓的長度是計算出的掃描線長度的上限。
參數:
返回:
例子:
>>> x = np.array([[1, 1, 1, 2, 2, 2]]) >>> img = np.vstack([np.zeros_like(x), x, x, x, np.zeros_like(x)]) >>> img array([[0, 0, 0, 0, 0, 0], [1, 1, 1, 2, 2, 2], [1, 1, 1, 2, 2, 2], [1, 1, 1, 2, 2, 2], [0, 0, 0, 0, 0, 0]]) >>> profile_line(img, (2, 1), (2, 4)) array([1., 1., 2., 2.]) >>> profile_line(img, (1, 0), (1, 6), cval=4) array([1., 1., 1., 2., 2., 2., 2.])
與標準 numpy 索引相比,目標點包含在配置文件中。例如:
>>> profile_line(img, (1, 0), (1, 6)) # The final point is out of bounds array([1., 1., 1., 2., 2., 2., 2.]) >>> profile_line(img, (1, 0), (1, 5)) # This accesses the full first row array([1., 1., 1., 2., 2., 2.])
對於不同的 reduce_func 輸入:
>>> profile_line(img, (1, 0), (1, 3), linewidth=3, reduce_func=np.mean) array([0.66666667, 0.66666667, 0.66666667, 1.33333333]) >>> profile_line(img, (1, 0), (1, 3), linewidth=3, reduce_func=np.max) array([1, 1, 1, 2]) >>> profile_line(img, (1, 0), (1, 3), linewidth=3, reduce_func=np.sum) array([2, 2, 2, 4])
當reduce_func 為 None 或當reduce_func 單獨作用於每個像素值時,將返回未歸約的數組。
>>> profile_line(img, (1, 2), (4, 2), linewidth=3, order=0, ... reduce_func=None) array([[1, 1, 2], [1, 1, 2], [1, 1, 2], [0, 0, 0]]) >>> profile_line(img, (1, 0), (1, 3), linewidth=3, reduce_func=np.sqrt) array([[1. , 1. , 0. ], [1. , 1. , 0. ], [1. , 1. , 0. ], [1.41421356, 1.41421356, 0. ]])
相關用法
- Python skimage.measure.perimeter_crofton用法及代碼示例
- Python skimage.measure.perimeter用法及代碼示例
- Python skimage.measure.ransac用法及代碼示例
- Python skimage.measure.moments_hu用法及代碼示例
- Python skimage.measure.moments_coords_central用法及代碼示例
- Python skimage.measure.LineModelND用法及代碼示例
- Python skimage.measure.block_reduce用法及代碼示例
- Python skimage.measure.moments用法及代碼示例
- Python skimage.measure.shannon_entropy用法及代碼示例
- Python skimage.measure.moments_normalized用法及代碼示例
- Python skimage.measure.euler_number用法及代碼示例
- 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.profile_line。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。