Fetching images from other location

Hi,
I want to read in x number of images from a folder located in another folder using imread.
How do I do this?
I get error when I write;
base='/Users/..../folder/';
files = dir([base,'*.bmp']);
PictSize=size(imread([base,files(1).name],'bmp'));
My error message is:
??? Index exceeds matrix dimensions.
Error in ==> CalcLosses at 16
PictSize=size(imread([base,files(1).name],'bmp'));

Answers (1)

"files" probably came out empty.
Note: it would be better to use
files = dir( fullfile(base,'*.bmp') );
and then to check whether "files" came out empty.

3 Comments

Lizan
Lizan on 25 Sep 2012
Edited: Lizan on 25 Sep 2012
IT did .. so what could be wrong? I checked the location to "base" and its ok. Images are there.
Still I get,
files =
0x1 struct array with fields: name date bytes isdir datenum
Thanks!
Just want to add that if I am in the folder and write files = dir then I get
files =
51x1 ...
so somethings wrong. I have added the path directly from my mac "info" window so it should be right.
You don't have any files in that location. It might be a relative path since you forgot the drive letter. Maybe try adding a drive letter to get a full directory path and see what happens.
Lizan
Lizan on 25 Sep 2012
Edited: Lizan on 25 Sep 2012
I am working with MATLAB on my USB Passport .. it seems as if this was the problem because if I change the location of the files to the desktop (i.e. the computer) then it seems OK. But if I move the files to the USB again.. the error shows up again.
base = '/Volumes/MyPassport/images/'; vs. base='/Users/XXXXX/Desktop/images/';
Is there way for me to work on the files via my passport. Why is this not working?
Using a mac computer.

Sign in to comment.

Categories

Find more on Convert Image Type in Help Center and File Exchange

Tags

Asked:

on 8 Aug 2012

Community Treasure Hunt

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

Start Hunting!