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 (최근 30일)
이전 댓글 표시
filename = uigetfile('*.*', 'MultiSelect', 'on');
image = imread(filename);
axes(handles.axes1);
imshow(image);
guidata(hObject, handles);
set(handles.path,'string',image);
댓글 수: 1
Rik
2018년 1월 17일
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?
답변 (1개)
Jan
2018년 1월 17일
[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.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!