Image Processing Toolbox User's Guide |
Syntax
P = impixel(I) P = impixel(X,map) P = impixel(RGB) P = impixel(I,c,r) P = impixel(X,map,c,r) P = impixel(RGB,c,r) [c,r,P] = impixel(...) P = impixel(x,y,I,xi,yi) P = impixel(x,y,X,map,xi,yi) P = impixel(x,y,RGB,xi,yi) [xi,yi,P] = impixel(x,y,...)
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 k
th 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:
impixel
returns the actual data for the pixel. The values are either uint8
integers or double
floating-point numbers, depending on the class of the image array.
impixel
returns the RGB triplet stored in the row of the colormap that the pixel value points to. The values are double
floating-point numbers.
impixel
returns the intensity value as an RGB triplet, where R=G=B. The values are either uint8
integers or double
floating-point numbers, depending on the class of the image array.
Example
RGB = imread('peppers.png'); c = [12 146 410]; r = [104 156 129]; pixels = impixel(RGB,c,r) pixels = 62 34 63 166 54 60 59 28 47
See Also
imoverviewpanel | impixelinfo |
© 1994-2005 The MathWorks, Inc.