Main Content

Manage Display Preferences

You can control how Image Processing Toolbox™ displays images either by using preferences or by using function name-value arguments. Preferences control the default display settings of all images for imshow and the Image Tool (imtool). You can also use name-value arguments, in functions such as imshow, to override default preferences for individual images.

This page shows you how to use preferences and name-value arguments to control how images display.

Retrieve Toolbox Preferences

Retrieve the current preference values using one of these options:

  • Interactively — Use the Preferences window. To access the window, on the Home tab, in the Environment section, click Preferences button Preferences. You can also open the Preferences window from the Image Tool (imtool), under File > Preferences.

  • Programmatically — Use the iptgetpref function. For example, this code retrieves the value of the ImtoolInitialMagnification preference.

    iptgetpref("ImtoolInitialMagnification")
    ans =
    
       100

Set Toolbox Preferences

Set Image Processing Toolbox preferences using one of these options:

  • Interactively — Use the Preferences window. To access the window, on the Home tab, in the Environment section, click Preferences button Preferences. You can also open the Preferences window from the Image Tool (imtool), under File > Preferences.

    Note

    In MATLAB® Online™, access the imshow display settings in the Preferences window under MATLAB > Image Display. (since R2023a)

  • Programmatically — Use the iptsetpref function. For example, this code specifies that, by default, imshow resize the figure window tightly around displayed images.

    iptsetpref("ImshowBorder","tight");

For a complete list of toolbox preferences, see the iptsetpref reference page.

Control Image Display Using Preferences and Name-Value Arguments

This example shows how to control image magnification in the Image Tool using preferences versus name-value arguments. Image Processing Toolbox preferences set the default display behavior for a function. You can use name-value arguments to override the default preference for individual images.

Display Image Using Factory Default

The imtool function opens images in the Image Tool. By default, the app displays images at the magnification specified by the ImtoolInitialMagnification preference. The original default value is 100, meaning the app loads images at 100% magnification.

imtool("peppers.png")

Peppers image displayed at 100% magnification

Update Default Using Preferences

To display images at 80% magnification by default, update the ImtoolInitialMagnification value by using the Preferences window or the iptsetpref function. Note that the Image Tool now displays images at 80% magnification by default.

iptsetpref("ImtoolInitialMagnification",80);
imtool("peppers.png")

Peppers image displayed at 80% magnification

Override Preference Using Name-Value Argument

To display a single image at 50% magnification, without changing the default value, include the InitialMagnification name-value argument when you call imtool. You do not need to update the ImtoolInitialMagnification preference.

imtool("peppers.png",InitialMagnification=50)

Peppers image displayed at 50% magnification

See Also

| |