Image Processing Toolbox User's Guide |
Compute pixel-value cross-sections along line segments
Syntax
c = improfile
c = improfile(n)
c = improfile(I,xi,yi)
c = improfile(I,xi,yi,n)
[cx,cy,c] = improfile(...)
[cx,cy,c,xi,yi] = improfile(...)
[...] = improfile(x,y,I,xi,yi)
[...] = improfile(x,y,I,xi,yi,n)
[...] = improfile(...,method
)
Description
improfile
computes the intensity values along a line or a multiline path in an image. improfile selects equally spaced points along the path you specify, and then uses interpolation to find the intensity value for each point. improfile
works with grayscale intensity images and RGB images.
If you call improfile
with one of these syntaxes, it operates interactively on the image in the current axes.
n
specifies the number of points to compute the intensity value for. If you do not provide this argument, improfile
chooses a value for n
, roughly equal to the number of pixels the path traverses.
You specify the line or path using the mouse, by clicking points in the image. Press Backspace or Delete to remove the previously selected point. A shift-click, right-click, or double-click adds a final point and ends the selection; pressing Return finishes the selection without adding a point. When you finish selecting points, improfile
returns the interpolated data values in c
. c
is an n
-by-1 vector if the input is a grayscale intensity image, or an n
-by-1-by-3 array if the input is an RGB image.
If you omit the output argument, improfile
displays a plot of the computed intensity values. If the specified path consists of a single line segment, improfile
creates a two-dimensional plot of intensity values versus the distance along the line segment; if the path consists of two or more line segments, improfile
creates a three-dimensional plot of the intensity values versus their x- and y-coordinates.
You can also specify the path noninteractively, using these syntaxes.
xi
and yi
are equal-length vectors specifying the spatial coordinates of the endpoints of the line segments.
You can use these syntaxes to return additional information.
cx
and cy
are vectors of length n
, containing the spatial coordinates of the points at which the intensity values are computed.
To specify a nondefault spatial coordinate system for the input image, use these syntaxes.
x
and y
are two-element vectors specifying the image XData
and YData
.
[...] = improfile(...,method)
uses the specified interpolation method. method
is a string that can have one of these values. The default value is enclosed in braces ({}
).
Value |
Description |
{'nearest'} |
Nearest-neighbor interpolation |
'bilinear' |
Bilinear interpolation |
'bicubic' |
Bicubic interpolation |
Class Support
The input image can be uint8
, uint16
, int16
, single
, double
, or logical
. All other inputs and outputs must be double
.
Example
See Also
interp2
in the MATLAB Function Reference
impositionrect | imread |
© 1994-2005 The MathWorks, Inc.