b=importda​ta(input('​Enter path of image '))

조회 수: 2 (최근 30일)
Mangesh
Mangesh 2014년 8월 10일
댓글: Image Analyst 2014년 8월 10일
Sir, i have to call path of image from my drive and import this image by importdata and save as variable b.......please help me!

답변 (1개)

Geoff Hayes
Geoff Hayes 2014년 8월 10일
Mangesh - rather than using the input function, consider uigetfile instead. It is easier to get the user to choose the file using a GUI rather than trying to type in the path and name. For example, your above code could be rewritten as
% choose a file and define the extensions (more can be added in a similar fashion)
[filename, pathname] = uigetfile({'*.jpg;*.bmp;*.gif'},'Image File Chooser');
% if the cancel button is pressed, then filename is numeric (0)
if ischar(filename)
% we have a file name, so create the full path and file name string
pathToFile = fullfile(pathname, filename);
b = importdata(pathToFile);
end
Try the above and see what happens!
  댓글 수: 1
Image Analyst
Image Analyst 2014년 8월 10일
If it's really an image, use imread() instead of importdata().

댓글을 달려면 로그인하십시오.

카테고리

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

태그

아직 태그를 입력하지 않았습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by