Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Reading a sequence of images with complex filenames

Subject: Reading a sequence of images with complex filenames

From: James

Date: 4 Dec, 2009 12:04:01

Message: 1 of 2

Hi everyone,

I'm trying to use imread to read in a series of bmps for processing, that are in a format like so:

_0000(z=0.010).bmp
_0001(z=0.178).bmp
_0002(z=0.267).bmp
_0003(z=0.301).bmp
...etc.

It's the first bit of the filename (0001, etc) that defines the order of the bmps, the second bit(z=#.###) is causing me trouble. There is no guarantee that the number increases by the same amount each time. Basically, I just want to specify the order of the bmps by the first bit of the file and ignore the rest (except the information that tells imread it's an image, which I assume is the '.bmp'). I've got this:

for i=1:9
   image = imread(['_000',num2str(i-1),'(z=*.***).bmp']);
end

...where I'm hoping that some kind of * wildcard exists! Obviously, this doesn't work, but it illustrates what I want. Any help would be greatly appreciated!

Subject: Reading a sequence of images with complex filenames

From: Adam Aitkenhead

Date: 11 Dec, 2009 15:19:21

Message: 2 of 2

The following should work:

filelist = dir(['_000*.bmp']);
for loopA=1:9
  filename = filelist(loopA).name;
  image = imread(filename);
end

Hope this helps.
Adam

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us