comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: reading in a series of images
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: reading in a series of images [message #6660] Wed, 31 July 1996 00:00
Phil Partain is currently offline  Phil Partain
Messages: 1
Registered: July 1996
Junior Member
Salvador Borges wrote:
>
> I would like to read in a series of images from a file folder. the
> names of files would be serially incremented, like a01, a02 etc or
> odd/even increments like a01, a03 etc
>
> Is there an easy and efficient way to do this?
>
> Thanks,
>
> Salvador Borges


It is very easy to read a seies of files from a folder, especially when
they are serially incremented in a folder. This is the way I would do
it for a series of files like a01, a02, ...

file = FINDFILE('a*') This returns a string array of all the files
in the directory that fit under a*.

Check out what this returns. If the files are in numerical order in
this string array, then you can just loop over n_elements(file)-1 and
open and read each file. If the file names are not in numerical order
in the array 'file' then you must sort the files according to the
numbers in th filename:

nums = STRMID(file,1,2) This would extract '01' from 'a01'

nums = FIX(nums) Because the extracted '01' is a string,
this converts the nums array to integers.

file = file(SORT(nums)) Then we sort the 'file' array according to
the numerical order of nums.

Now you can loop over 'file' and open and read the data:

for i=0,n_elements(file)-1 do begin
OPENR,1,file(i)
read the data how you like
CLOSE,1
endfor

I hope this is close to what you were trying to do.

Phil Partain
Re: reading in a series of images [message #6662 is a reply to message #6660] Wed, 31 July 1996 00:00 Go to previous message
Walid is currently offline  Walid
Messages: 9
Registered: July 1996
Junior Member
Salvador Borges wrote:
>
> I would like to read in a series of images from a file folder. the
> names of files would be serially incremented, like a01, a02 etc or
> odd/even increments like a01, a03 etc
>
> Is there an easy and efficient way to do this?
>
> Thanks,
>
> Salvador Borges
Salvador Borges wrote:
>
> I would like to read in a series of images from a file folder. the
> names of files would be serially incremented, like a01, a02 etc or
> odd/even increments like a01, a03 etc
>
> Is there an easy and efficient way to do this?
>
> Thanks,
>
> Salvador Borges
Salvador,

Here is a simple method to do this (although I'm sure there are better
ways):

;define npts, nimages as number of data points, number of images
data=intarr(npts,npts,nimages)
image=intarr(npts,npts)
for i=0,nimages-1 do begin
openr,1,"filea"+strtrim(string(i),1)
readf,1,image
close,1
data(*,*,i)=image
endfor

Hope this helps,

Walid
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: changing colors
Next Topic: Re: ? - Putting text on TV output

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Fri Oct 10 14:48:39 PDT 2025

Total time taken to generate the page: 0.64033 seconds