| Image Processing Toolbox | ![]() |
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 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, double, or logical. All other inputs and outputs are of class 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('flowers.tif'); c = [12 146 410]; r = [104 156 129]; pixels = impixel(RGB,c,r) pixels = 61 59 101 253 240 0 237 37 44
See Also
| imopen | improfile | ![]() |