Azzera filtri
Azzera filtri

I have some problem about showing path of a picture in guide! how can i do this? Please help me! thank you very much!

1 visualizzazione (ultimi 30 giorni)
filename = uigetfile('*.*', 'MultiSelect', 'on');
image = imread(filename);
axes(handles.axes1);
imshow(image);
guidata(hObject, handles);
set(handles.path,'string',image);
  1 Commento
Rik
Rik il 17 Gen 2018
image is not a string, it is an image. Also, if you are selecting multiple images, what should this code do? And what if non-image files are selected?

Accedi per commentare.

Risposte (1)

Jan
Jan il 17 Gen 2018
[filename, filepath] = uigetfile('*.*', 'MultiSelect', 'on');
if isequal(filename, 0)
disp('User aborted file choosing');
return;
end
% Due to "MultipSelect" filename can be a string or cell string.
% Make it a cell string in every case:
filename = cellstr(filename);
for k = 1:numel(filename)
% Append the folder:
file = fullfile(filepath, filename{k});
img = imread(file);
imshow(img, 'Parent', handles.axes1);
set(handles.path,'string', file); % Not "image"
end
"guidata(hObject, handles)" is not useful, if you did not change the handles struct.
Note that the shown code would overwrite the image for each selected file. If 'MultiSelect' should be useful, you have to use different axes to display the images.

Categorie

Scopri di più su Images 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!

Translated by