'uigetimagefile' error in R2020a
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
FruitsLord
il 21 Lug 2020
Commentato: Image Analyst
il 21 Lug 2020
I have some old code files that used 'uigetimagefile' function. I knew they worked properly in R2018, R2019.
Today, when I tried to run those files on my new laptop with R2020a Update 4 installed. It complained about 'uigetimagefile' error immediately without poping up the file selection dialog:
>> uigetimagefile
Error using message/getString
Unable to load a message catalog 'mg:textedit'. Please check the file location and format.
Error in uigetimagefile (line 47)
dialogTitle = getString(message('mg:textedit:ImageInsertTtile'));
It wired as I didn't change any piece of the code and it stopped working.
So I tried to solve the problem by myself. It looks like the line 47 of uigetimagefile.m only sets the title of dialog. So I tried to modify that line using admin privilege to:
dialogTitle = 'Choose image file(s)';
Interestingly, the file selection window appeared and let me select an image file. However, as soon as I clicked the 'OK' button, another error appeared that prevented the function returning the selected file name to my code.
>> uigetimagefile
Unable to resolve the name GLUE2.Util.isValidImage.
Error in uigetimagefile (line 72)
elseif ~GLUE2.Util.isValidImage(filename)
I am stuck now. I cannot understand why the working code breaks in a newer release. Is the uigetimagefile function deprecated? Or is there anything missing in my new installation of Matlab?
0 Commenti
Risposta accettata
Image Analyst
il 21 Lug 2020
Yes, evidently it's deprecated and has now been removed. I'd use uigetfile():
% Have user browse for a file, from a specified "starting folder."
% For convenience in browsing, set a starting folder from which to browse.
startingFolder = pwd; % or 'C:\wherever';
if ~isfolder(startingFolder)
% If that folder doesn't exist, just start in the current folder.
startingFolder = pwd;
end
% Get the name of the file that the user wants to use.
defaultFileName = fullfile(startingFolder, '*.*'); % or *.png - whatever extension you want.
[baseFileName, folder] = uigetfile(defaultFileName, 'Select a file');
if baseFileName == 0
% User clicked the Cancel button.
return;
end
fullFileName = fullfile(folder, baseFileName)
Or even better, make a GUI and have a listbox where they user can simply click on the image they want.
2 Commenti
Image Analyst
il 21 Lug 2020
I'm sure it's in one of the release notes, but I don't blame you for not reading them all. I don't. But if you want to read all the release notes to discover and remember what functions were removed so you don't try to use them again, and it sounds like that's something you want to do, here they are : Release Notes
I can't guide you as to what year it's in, but you're welcome to look through them all.
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Startup and Shutdown in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!