用法:
cucim.skimage.measure.profile_line(image, src, dst, linewidth=1, order=None, mode=None, cval=0.0, *, reduce_func=<function mean>)
返回沿掃描線測量的圖像的強度分布。
- image:ndarray,形狀(M,N[,C])
圖像,灰度(2D 陣列)或多通道(3D 陣列,其中最後一個軸包含通道信息)。
- src:數組, 形狀 (2, )
掃描線起點的坐標。
- dst:數組, 形狀 (2, )
掃描線終點的坐標。與標準 numpy 索引相比,目標點是配置文件中的
included
。- linewidth:整數,可選
掃描的寬度,垂直於線
- order:{0, 1, 2, 3, 4, 5} 中的 int,可選
樣條插值的順序,如果 image.dtype 為 bool,則默認為 0,否則為 1。順序必須在 0-5 範圍內。有關詳細信息,請參閱
skimage.transform.warp
。- mode:{‘constant’, ‘nearest’, ‘reflect’, ‘mirror’, ‘wrap’},可選
如何計算圖像之外的任何值。
- cval:浮點數,可選
如果
mode
是‘constant’,在圖像外使用什麽常量值。- reduce_func:可調用的,可選的
當
linewidth
> 1 時,用於計算垂直於profile_line 方向的像素值聚合的函數。如果設置為None,將返回未歸約的數組。
- return_value:數組
沿掃描線的強度分布。輪廓的長度是計算出的掃描線長度的上限。
參數:
返回:
例子:
>>> import cupy as cp >>> x = cp.asarray([[1, 1, 1, 2, 2, 2]]) >>> img = cp.vstack([cp.zeros_like(x), x, x, x, cp.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., 4.])
與標準 numpy 索引相比,目標點包含在配置文件中。例如:
>>> profile_line(img, (1, 0), (1, 6)) # The final point is out of bounds array([1., 1., 1., 2., 2., 2., 0.]) >>> 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=cp.mean) array([0.66666667, 0.66666667, 0.66666667, 1.33333333]) >>> profile_line(img, (1, 0), (1, 3), linewidth=3, reduce_func=cp.max) array([1, 1, 1, 2]) >>> profile_line(img, (1, 0), (1, 3), linewidth=3, reduce_func=cp.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=cp.sqrt) array([[1. , 1. , 0. ], [1. , 1. , 0. ], [1. , 1. , 0. ], [1.41421356, 1.41421356, 0. ]])
相關用法
- Python cucim.skimage.measure.perimeter用法及代碼示例
- Python cucim.skimage.measure.label用法及代碼示例
- Python cucim.skimage.measure.moments_coords用法及代碼示例
- Python cucim.skimage.measure.moments_normalized用法及代碼示例
- Python cucim.skimage.measure.moments_central用法及代碼示例
- Python cucim.skimage.measure.moments_coords_central用法及代碼示例
- Python cucim.skimage.measure.regionprops用法及代碼示例
- Python cucim.skimage.measure.moments用法及代碼示例
- Python cucim.skimage.measure.centroid用法及代碼示例
- Python cucim.skimage.measure.moments_hu用法及代碼示例
- Python cucim.skimage.measure.regionprops_table用法及代碼示例
- Python cucim.skimage.measure.block_reduce用法及代碼示例
- Python cucim.skimage.morphology.dilation用法及代碼示例
- Python cucim.skimage.morphology.closing用法及代碼示例
- Python cucim.skimage.morphology.erosion用法及代碼示例
- Python cucim.skimage.morphology.white_tophat用法及代碼示例
- Python cucim.skimage.morphology.remove_small_holes用法及代碼示例
- Python cucim.skimage.morphology.black_tophat用法及代碼示例
- Python cucim.skimage.morphology.reconstruction用法及代碼示例
- Python cucim.skimage.morphology.remove_small_objects用法及代碼示例
注:本文由純淨天空篩選整理自rapids.ai大神的英文原創作品 cucim.skimage.measure.profile_line。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。