필터 지우기
필터 지우기

check if the picture exist within the database

조회 수: 2 (최근 30일)
Im@
Im@ 2015년 3월 19일
댓글: Im@ 2015년 3월 19일
hello I have read a database of images in matlab, I want to check if all the pictures exist before i run the program, what is the command to check ?
  댓글 수: 2
Konstantinos Sofos
Konstantinos Sofos 2015년 3월 19일
What do you mean by read? You have a list of all the names or you have read them by imread?
Im@
Im@ 2015년 3월 19일
I have read by imread

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

답변 (1개)

Konstantinos Sofos
Konstantinos Sofos 2015년 3월 19일
편집: Konstantinos Sofos 2015년 3월 19일
Hi,
you could use an exception catcher
Directory = fullfile ('C:','Users','Documents','MATLAB','image');
Images = dir(fullfile(Directory,'*.jpg'));
Names = {Images.name}';
for k=1: numel(Names)
try
I=imread(fullfile(Directory,Names{k}));
catch
error( ...)
end
end
Regards,
  댓글 수: 1
Im@
Im@ 2015년 3월 19일
for i=1:18 for j=1:3 for k=[37 100]
histowholeimage=[];
anger=[];
name=['anger\' num2str(i,'%04d') '_' num2str(j,'%2d') '\p_' num2str(k,'%03d') '.jpg'];
img=imread(name);% read the image
imshow(img)
pause
end
end
end
I have a databas, I read in this way but some of the images' name are not exist for example 31 is missed. before I load the program I have to search if all the images exists

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

Community Treasure Hunt

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

Start Hunting!

Translated by