| Image Processing Toolbox™ | ![]() |
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)
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 images and RGB images.
If you call improfile with one of these syntax, it operates interactively on the image in the current axes.
c = improfile c = improfile(n)
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 syntax.
c = improfile(I,xi,yi) c = improfile(I,xi,yi,n)
xi and yi are equal-length vectors specifying the spatial coordinates of the endpoints of the line segments.
You can use these syntax to return additional information.
[cx,cy,c] = improfile(...) [cx,cy,c,xi,yi] = improfile(...)
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 syntax.
[...] = improfile(x,y,I,xi,yi) [...] = improfile(x,y,I,xi,yi,n)
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 |
The input image can be uint8, uint16, int16, single, double, or logical. All other inputs and outputs must be double.
I = imread('liftingbody.png');
x = [19 427 416 77];
y = [96 462 37 33];
improfile(I,x,y),grid on;

interp2 in the MATLAB Function Reference
![]() | impositionrect | imputfile | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |