Function File: [path, flag] = imgetfile ()
Function File: […] = imgetfile (options, …)

Open GUI dialogue to select image files.

The GUI dialogue opened is exactly the same as uigetfile but uses recognized image file formats as file filter. All other options from uigetfile are accepted.

The return value path is a string with the full filepath of the selected file. If the "MultiSelect" option is selected, then a cell array of strings is returned.

flag is a logical value, true if there was any issue with file selection such as the user closing or cancelling the dialogue with selecting a file. It has a value of false otherwise.

[filepath, flag] = imgetfile ();
if (flag)
  error ("A file must be selected");
endif

There is no guarantee that imread will be capable to read all files selected via this dialogue. Possible reasons for this are:

  • the filter uses all the extensions as obtained from imformats. This only means that a format with such extensions is registered, not necessarily that read or write support has been implemented;
  • the dialogue also has a "All files (*)" filter, so a user is actually able to select any file;
  • the file may be corrupt;
  • it is the file content, and not the file extension, that defines the file format. A file may have a file extension that is equal to an image file format and not actually be an image file.

The opposite is also true. imread is able to guess the file format even when the file extension is incorrect (or even in the absence of a file extension). A file that is filtered out may still be readable by imread or imfinfo.

See also: imformats, uigetfile.

Package: image