Get Pixel Information in Image Viewer App

Determine Individual Pixel Values in Image Viewer

The Image Viewer displays information about the location and value of individual pixels in an image in the bottom left corner of the tool. (You can also obtain this information by opening a figure with imshow and then calling impixelinfo from the command line.) The pixel value and location information represent the pixel under the current location of the pointer. The Image Viewer updates this information as you move the pointer over the image.

For example, view an image in the Image Viewer.

imtool('moon.tif')

The following figure shows the Image Viewer with pixel location and value displayed in the Pixel Information tool. For more information, see Saving the Pixel Value and Location Information.

Saving the Pixel Value and Location Information

To save the pixel location and value information displayed, right-click a pixel in the image and choose the Copy pixel info option. The Image Viewer copies the x- and y-coordinates and the pixel value to the clipboard.

To paste this pixel information into the MATLAB® workspace or another application, right-click and select Paste from the context menu.

Determine Pixel Values in an Image Region

To view the values of pixels in a specific region of an image displayed in the Image Viewer, use the Pixel Region tool. The Pixel Region tool superimposes a rectangle, called the pixel region rectangle, over the image displayed in the Image Viewer. This rectangle defines the group of pixels that are displayed, in extreme close-up view, in the Pixel Region tool window. The following figure shows the Image Viewer with the Pixel Region tool. Note how the Pixel Region tool includes the value of each pixel in the display.

The following sections provide more information about using the Pixel Region tool.

Selecting a Region

  1. To start the Pixel Region tool, click the Pixel Region button in the Image Viewer toolbar or select the Pixel Region option from the Tools menu. (Another option is to open a figure using imshow and then call impixelregion from the command line.) The Image Viewer displays the pixel region rectangle in the center of the target image and opens the Pixel Region tool.

      Note   Scrolling the image can move the pixel region rectangle off the part of the image that is currently displayed. To bring the pixel region rectangle back to the center of the part of the image that is currently visible, click the Pixel Region button again. For help finding the Pixel Region tool in large images, see Determining the Location of the Pixel Region Rectangle.

  2. Using the mouse, position the pointer over the pixel region rectangle. The pointer changes to the fleur shape, .

  3. Click the left mouse button and drag the pixel region rectangle to any part of the image. As you move the pixel region rectangle over the image, the Pixel Region tool updates the pixel values displayed. You can also move the pixel region rectangle by moving the scroll bars in the Pixel Region tool window.

Customizing the View

To get a closer view of image pixels, use the zoom buttons on the Pixel Region tool toolbar. As you zoom in, the size of the pixels displayed in the Pixel Region tool increase and fewer pixels are visible. As you zoom out, the size of the pixels in the Pixel Region tool decrease and more pixels are visible. To change the number of pixels displayed in the tool, without changing the magnification, resize the Pixel Region tool using the mouse.

As you zoom in or out, note how the size of the pixel region rectangle changes according to the magnification. You can resize the pixel region rectangle using the mouse. Resizing the pixel region rectangle changes the magnification of pixels displayed in the Pixel Region tool.

If the magnification allows, the Pixel Region tool overlays each pixel with its numeric value. For RGB images, this information includes three numeric values, one for each band of the image. For indexed images, this information includes the index value and the associated RGB value. If you would rather not see the numeric values in the display, go to the Pixel Region tool Edit menu and clear the Superimpose Pixel Values option.

Determining the Location of the Pixel Region Rectangle

To determine the current location of the pixel region in the target image, you can use the pixel information given at the bottom of the tool. This information includes the x- and y-coordinates of pixels in the target image coordinate system. When you move the pixel region rectangle over the target image, the pixel information given at the bottom of the tool is not updated until you move the cursor back over the Pixel Region tool.

You can also retrieve the current position of the pixel region rectangle by selecting the Copy Position option from the Pixel Region tool Edit menu. This option copies the position information to the clipboard. The position information is a vector of the form [xmin ymin width height].

To paste this position vector into the MATLAB workspace or another application, right-click and select Paste from the context menu.

The following figure shows these components of the Pixel Region tool.

Printing the View of the Image in the Pixel Region Tool

You can print the view of the image displayed in the Pixel Region tool. Select the Print to Figure option from the Pixel Region tool File menu. See Print Images for more information.

Determine Image Display Range in Image Viewer

The Image Viewer provides information about the display range of pixels in a grayscale image. The display range is the value of the axes CLim property, which controls the mapping of image CData to the figure colormap. CLim is a two-element vector [cmin cmax] specifying the CData value to map to the first color in the colormap (cmin) and the CData value to map to the last color in the colormap (cmax). Data values in between are linearly scaled.

The Image Viewer displays this information in the Display Range tool at the bottom right corner of the window. The Image Viewer does not show the display range for indexed, truecolor, or binary images. (You can also obtain this information by opening a figure window with imshow and then calling imdisplayrange from the command line.)

For example, view an image in the Image Viewer.

imtool('moon.tif')

The following figure shows the Image Viewer displaying the image with display range information.

Was this topic helpful?