impixel - Pixel color values

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 syntax below, impixel displays the input image and waits for you to specify the pixels with the mouse.

P = impixel(I)
P = impixel(X,map)
P = impixel(RGB)

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 syntax.

P = impixel(I,c,r)
P = impixel(X,map,c,r)
P = impixel(RGB,c,r)

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,

[c,r,P] = impixel(...)

To specify a nondefault spatial coordinate system for the input image, use these syntax.

P = impixel(x,y,I,xi,yi)
P = impixel(x,y,X,map,xi,yi)
P = impixel(x,y,RGB,xi,yi)

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.

[xi,yi,P] = impixel(x,y,...)

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:

Examples

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

improfile

  


 © 1984-2008- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS