This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

Pixel Values

To determine the values of one or more pixels in an image and return the values in a variable, use the impixel function. You can specify the pixels by passing their coordinates as input arguments or you can select the pixels interactively using a mouse. impixel returns the value of specified pixels in a variable in the MATLAB® workspace.

Note

You can also get pixel value information interactively using the Image Tool -- see Get Pixel Information in Image Viewer App.

Determine Values of Individual Pixels in Images

This example shows how to use impixel interactively to get pixel values.

Display an image.

imshow canoe.tif

Call impixel. When called with no input arguments, impixel associates itself with the image in the current axes.

pixel_values = impixel

Select the points you want to examine in the image by clicking the mouse. impixel places a star at each point you select.

imshow canoe.tif

When you are finished selecting points, press Return. impixel returns the pixel values in an n-by-3 array, where n is the number of points you selected. impixel removes the stars used to indicate selected points.

pixel_values =
0.1294    0.1294    0.1294
0.5176         0         0
0.7765    0.6118    0.4196