Main Content

Intensity Profile of Images

The intensity profile of an image is the set of intensity values taken from regularly spaced points along a line segment or multi-line path in an image. To create an intensity profile, use the improfile function. This function calculates and plots the intensity values along a line segment or a multi line path in an image. You define the line segment (or segments) by specifying their coordinates as input arguments or interactively using a mouse. For points that do not fall on the center of a pixel, the intensity values are interpolated. By default, improfile uses nearest-neighbor interpolation, but you can specify a different method. (For more information about specifying the interpolation method, see Resize an Image.) improfile works best with grayscale and truecolor images.

Create an Intensity Profile of an Image

This example shows how to create an intensity profile for an image interactively using improfile.

Read an image and display it.

I = fitsread("solarspectra.fts");
imshow(I,[]);

Create the intensity profile. Call improfile with no arguments. The cursor changes to cross-hairs when you move it over the displayed image. Using the mouse, specify line segments by clicking the endpoints. improfile draws a line between the endpoints. When you finish specifying the path, press Return. In the following figure, the line is shown in red.

improfile

Image that includes horizontal and vertical line features, with one vertical line highlighted in red

After you finish drawing the line over the image, improfile displays a plot of the data along the line. Notice how the peaks and valleys in the plot correspond to the light and dark bands in the image.

Image intensity versus distance in pixels along the highlighted red line

Create Intensity Profile of an RGB Image

This example shows how to plot the intensity values in an RGB image. For a single line segment, improfile plots the intensity values in a two-dimensional view. For a multi-line path, improfile plots the intensity values in a three-dimensional view.

Display an RGB image using imshow.

imshow("peppers.png")

Call improfile without any arguments and trace a line segment in the image interactively. In the figure, the black line indicates a line segment drawn from top to bottom. Double-click to end the line segment.

improfile

RGB image with a black line segment connecting two endpoints

The improfile function displays a plot of the intensity values along the line segment. The plot includes separate lines for the red, green, and blue intensities. In the plot, notice how low the blue values are at the beginning of the plot where the line traverses the orange pepper.

Intensity Values Along a Line Segment in an RGB Image

A plot of the intensity values of the red, green, and blue color channels as a function of distance along the line segment.

See Also

| |