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
truesize
function to display the image without interpolation.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.
ImshowBorder
preference controls whether imshow
displays the figure window as larger than the image (leaving a border between the image axes and the edges of the figure), or the same size as the image (leaving no border). ImshowAxesVisible
preference controls whether imshow
displays images with the axes box and tick labels.ImshowTruesize
preference controls whether imshow
calls the truesize
function. This preference can be overridden for a single call to imshow
; see The truesize Function below for more details.TrueSizeWarning
preference controls whether you will receive a warning message if an image is too large for the screen. This example call to iptsetpref
resizes the figure window so that it fits tightly around displayed images.
iptsetpref('ImshowBorder', 'tight');
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
:
ImshowTruesize
preference to 'manual'
, meaning that truesize
will not be automatically called by imshow
.
iptsetpref('ImshowTruesize'
,'manual')
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.
imshow(X, map,'truesize')
For more information see the reference descriptions for imshow
and truesize
.
![]() | Displaying Multiple Images | Zooming in on a Region of an Image | ![]() |