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.
Note
You can also get pixel value information interactively using the Image Viewer app. For details, 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.
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