How to get random image from specific folder in matlab ?

I have set of image in one folder. From that I want to get only one image from this folder. You can get one image by any feature or any logic or non logic..

 채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2014년 5월 4일
편집: Azzi Abdelmalek 2014년 5월 4일
d='Yourfolder';
f=dir([d '\*.jpg']);
n=numel(f);
idx=randi(n);
im=imread(f(idx).name);
imshow(im)

댓글 수: 2

I am using Matlab 2012 and got this type of error.. Thanks for your reply...
Error using randi First input must be a positive scalar integer value IMAX, or two integer values [IMIN IMAX] with IMIN less than or equal to IMAX.
Error in One_image (line 11) idx=randi(n);
Azzi Abdelmalek
Azzi Abdelmalek 2014년 5월 4일
편집: Azzi Abdelmalek 2014년 5월 4일
This is because your folder is empty, I mean it doesn't contain jpg files

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

추가 답변 (0개)

질문:

2014년 5월 4일

편집:

2014년 5월 4일

Community Treasure Hunt

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

Start Hunting!

Translated by