profile_line
-
skimage.measure.profile_line(img, src, dst, linewidth=1, order=1, mode='constant', cval=0.0)
[source] -
Return the intensity profile of an image measured along a scan line.
Parameters: img : numeric array, shape (M, N[, C])
The image, either grayscale (2D array) or multichannel (3D array, where the final axis contains the channel information).
src : 2-tuple of numeric scalar (float or int)
The start point of the scan line.
dst : 2-tuple of numeric scalar (float or int)
The end point of the scan line. The destination point is included in the profile, in constrast to standard numpy indexing.
linewidth : int, optional
Width of the scan, perpendicular to the line
order : int in {0, 1, 2, 3, 4, 5}, optional
The order of the spline interpolation to compute image values at non-integer coordinates. 0 means nearest-neighbor interpolation.
mode : {‘constant’, ‘nearest’, ‘reflect’, ‘mirror’, ‘wrap’}, optional
How to compute any values falling outside of the image.
cval : float, optional
If
mode
is ‘constant’, what constant value to use outside the image.Returns: return_value : array
The intensity profile along the scan line. The length of the profile is the ceil of the computed length of the scan line.
Examples
123456789101112>>> 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.
,
4.
])
The destination point is included in the profile, in contrast to standard numpy indexing. For example: >>> 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.])
Please login to continue.