필터 지우기
필터 지우기

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
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
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.

카테고리

Help CenterFile Exchange에서 Images에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by