필터 지우기
필터 지우기

how to get file name when i take a image file from imgetfile

조회 수: 3 (최근 30일)
Vish
Vish 2016년 2월 16일
편집: Vish 2016년 2월 17일
i want only file name of my image file which i take from imgetfile. as i want to save the file name and data i collected/processed on that particular image file.
  댓글 수: 1
Vish
Vish 2016년 2월 17일
function getImage_Callback(hObject, eventdata, handles)
[f,p]=uigetfile('*.jpg');
oi=imread(strcat(p,f)); %getting Original Image;
imshow(oi)
function getImage_Callback(hObject, eventdata, handles)
%now i want to use variable f in this function how can i use it??
if true
% code
end

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

답변 (1개)

MHN
MHN 2016년 2월 17일
편집: MHN 2016년 2월 17일
One easy way is to write a code for that ! (assumption: there is no dot (.) in the name of the image)
IMPORTANT NOTE : if you are using Windows, you have to change '/' to '\'.
[filename, user_canceled] = imgetfile;
if user_canceled==0
L = filename=='/';
m = find(L==1,1,'last');
L = filename=='.';
n = find(L==1,1,'last');
str = filename(m+1:n-1)
end
  댓글 수: 2
MHN
MHN 2016년 2월 17일
편집: MHN 2016년 2월 17일
You can use the following code to make sure it works for Windows or other OSs :
[filename, user_canceled] = imgetfile;
if user_canceled==0
if ispc
L = filename=='\';
else
L = filename=='/';
end
m = find(L==1,1,'last');
L = filename=='.';
n = find(L==1,1,'last');
str = filename(m+1:n-1)
end
Vish
Vish 2016년 2월 17일
편집: Vish 2016년 2월 17일
u can also use uigetfile() which return filename and its path. here we dont need imgetfile to get im file use
uigetfile('*.jpg');

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

카테고리

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