Image Processing Toolbox    

Setting the Preferences for imshow

The behavior of imshow is influenced in part by the current settings of the toolbox preferences. Depending on the arguments you specify and the current settings of the toolbox preferences, imshow may

All of these settings can be changed by using the iptsetpref function, and the truesize preference, in particular, can also be changed by setting the display_option parameter of imshow. This section describes how to set the toolbox preferences and how to use the display_option parameter.

When you display an image using the imshow function, MATLAB also sets the Handle Graphics figure, axes, and image properties, which control the way image data is interpreted. These settings are optimized for each image type. The specific properties set are described under the following sections:

Toolbox Preferences

The toolbox preferences affect the behavior of imshow for the duration of the current MATLAB session. You can change these settings at any time by using the iptsetpref function. To preserve your preference settings from one session to the next, make your settings in your startup.m file. These are the preferences that you may set.

This example call to iptsetpref resizes the figure window so that it fits tightly around displayed images.

To determine the current value of a preference, use the iptgetpref function.

For more information about toolbox preferences and the values they accept, see the reference entries for iptgetpref and iptsetpref.

The truesize Function

The truesize function assigns a single screen pixel to each image pixel, e.g., a 200-by-300 image will be 200 screen pixels in height and 300 screen pixels in width. This is generally the preferred way to display an image. In most situations, when the toolbox is operating under default behavior, imshow calls the truesize command automatically before displaying an image.

In some cases, you may not want imshow to automatically call truesize (for example, if you are working with a small image). If you display an image without calling truesize, the image displays at the default axis size. In such cases, MATLAB must use interpolation to determine the values for screen pixels that do not directly correspond to elements in the image matrix. (See Interpolation for more information.)

There are two ways to affect whether or not MATLAB will automatically call truesize:

  1. Set the preference for the current MATLAB session. This example sets the ImshowTruesize preference to 'manual', meaning that truesize will not be automatically called by imshow.
  2. Set the preference for a single imshow command by setting the display_option parameter. This example sets the display_option parameter to truesize, so that truesize is called for the image displayed, regardless of the current preference setting.

For more information see the reference descriptions for imshow and truesize.


 Displaying Multiple Images Zooming in on a Region of an Image