Image Processing Toolbox User's Guide Previous page   Next Page
impixel

Determine pixel color values

Syntax

Description

impixel returns the red, green, and blue color values of specified image pixels. In the syntaxes below, impixel displays the input image and waits for you to specify the pixels with the mouse.

If you omit the input arguments, impixel operates on the image in the current axes.

Use normal button clicks to select pixels. Press Backspace or Delete to remove the previously selected pixel. A shift-click, right-click, or double-click adds a final pixel and ends the selection; pressing Return finishes the selection without adding a pixel.

When you finish selecting pixels, impixel returns an m-by-3 matrix of RGB values in the supplied output argument. If you do not supply an output argument, impixel returns the matrix in ans.

You can also specify the pixels noninteractively, using these syntaxes.

r and c are equal-length vectors specifying the coordinates of the pixels whose RGB values are returned in P. The kth row of P contains the RGB values for the pixel (r(k),c(k)).

If you supply three output arguments, impixel returns the coordinates of the selected pixels. For example,

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. xi and yi are equal-length vectors specifying the spatial coordinates of the pixels whose RGB values are returned in P. If you supply three output arguments, impixel returns the coordinates of the selected pixels.

Class Support

The input image can be of class uint8, uint16, int16, single, double, or logical. All other inputs are of class double.

If the input is double, the output P is double. For all other input classes the output is single. The rest of the outputs are double.

Remarks

impixel works with indexed, intensity, and RGB images. impixel always returns pixel values as RGB triplets, regardless of the image type:

Example

See Also

improfile, pixval


Previous page  imoverviewpanel impixelinfo Next page

© 1994-2005 The MathWorks, Inc.