Re: [question] on adding strings when reading file names [message #36955] |
Wed, 12 November 2003 17:39 |
tianyf_cn
Messages: 19 Registered: November 2002
|
Junior Member |
|
|
You can also get a file unit for each tiff file.
for i=1, count do begin
fname=frame+STRTRIM(i,2)+'.tif'
cmdstr='openr, lun'+STRTRIM(i,2)+', fname,/get_lun'
isok=execute(cmdstr)
...
endfor
Tian.
James Kuyper <kuyper@saicmodis.com> wrote in message news:<3FB27E89.A638E8A2@saicmodis.com>...
> Pepijn Kenter wrote:
> ...
>> filename=string(format='(%"frame%d.tif")', i)
>
> I'm a big fan of C, but a more IDLish way of doing the same thing would
> be:
>
> filename = 'frame'+STRTRIM(i,1)+'.tif'
|
|
|
|
Re: [question] on adding strings when reading file names [message #36961 is a reply to message #36960] |
Wed, 12 November 2003 10:09  |
Rick Towler
Messages: 821 Registered: August 1998
|
Senior Member |
|
|
"Pepijn Kenter" wrote...
> cmin wrote:
>> Hi,
>>
>> I am new to this IDL group.
>> I am trying to read multiple tiff images into my program.
>>
>> It was quite easy using C. But, since I am new to IDL, I am suffering.
> You can use c-style formats in IDL, the syntax is a bit awkward. Try
> something like this:
>
> for i = 1, 10 do begin
> filename=string(format='(%"frame%d.tif")', i)
> print, filename
>
> openr, lun, filename, /get_lun
> ; read stuff
> free_lun, lun ; close the file
> endfor
If you are reading uncompressed TIFF images I suggest using READ_TIFF()
instead of doing it the hard way:
for i = 1, 10 do begin
filename=string(format='(%"frame%d.tif")', i)
print, filename
imageData = READ_TIFF(filename)
endfor
-Rick
|
|
|
Re: [question] on adding strings when reading file names [message #36973 is a reply to message #36961] |
Tue, 11 November 2003 10:31  |
Pepijn Kenter
Messages: 31 Registered: April 2002
|
Member |
|
|
cmin wrote:
> Hi,
>
> I am new to this IDL group.
> I am trying to read multiple tiff images into my program.
>
> It was quite easy using C. But, since I am new to IDL, I am suffering.
>
> In C, it was something like the following:
> If I was reading frame0.tif, frame1.tif, frame2 ... frame9.tif
> I could run something like "read_frame frame%d.tif " and
> was able to read multiple frames.
>
> /********************
> read_frame.c
> ********************/
> int l, frames;
> char *ifile,ifile1[80];
> FILE *fpr;
>
> for(l=1;l<=9;l++){
> sprintf(ifile1,ifile,l);
> }
> if(!(fpr=fopen(ifile1,"r"))){
> printf("cannot open file: %s\n",ifile1);
> exit(1);
> }
> .....
>
>
> I would like to do a similar stuff using IDL, but not quite sure
> how to catenate the strings.
>
> I hope some one can give me some help.
>
> Thanx.
You can use c-style formats in IDL, the syntax is a bit awkward. Try
something like this:
for i = 1, 10 do begin
filename=string(format='(%"frame%d.tif")', i)
print, filename
openr, lun, filename, /get_lun
; read stuff
free_lun, lun ; close the file
endfor
Pepijn Kenter.
|
|
|