Re: Efficient Programing (reading multiband image) [message #4782 is a reply to message #4779] |
Thu, 27 July 1995 00:00  |
Liam Gumley
Messages: 473 Registered: November 1994
|
Senior Member |
|
|
dean@phobos.cira.colostate.edu wrote:
> I use the following code to read in an interleave (by pixel) raster image.
(stuff deleted)
> IImage = BYTarr(nchan,nx,ny)
As long as you know the image interleave format, you can read the whole
image in one hit. The interleave options available are
(1) Band interleaved - image dimensioned as ( pixels, lines, bands )
i.e. all pixels and lines for band 1; all pixels and lines for band 2; ....
(2) Line interleaved - image dimensioned as ( pixels, bands, lines )
i.e. all pixels for band 1, line 1; all pixels for band 2, line 1; ....
(3) Pixel interleaved - image dimensioned as ( bands, pixels, lines )
i.e. all bands for pixel 1, line 1; all bands for pixel 2, line 1; ....
(See IDL 4.0 Ref. Guide p. 1-927, paragraph 2)
You identified the image as pixel interleaved, so you can do the following:
openr, 1, 'image.dat'
image = bytarr( nchan, nx, ny )
readu, 1, image
close, 1
nchan = 0
tvscl, image( nchan, *, * )
If you are interested, I have a compound widget that lets you
interactively pick a data file and specify the data type, size, and interleave.
The data file is then read, and the contents returned in an array.
BYTE, INTEGER, LONG, and FLOAT data types are supported, and an image header offset
in bytes can be specified.
Cheers,
Liam.
liamg@ssec.wisc.edu
|
|
|