
6 Images, Arrays, and Matrices
Listing 1.1: Reading and displaying a multispectral image in ENVI/IDL.
1 PRO E X1_1
2
3 envi_select , ti tle = ’ Ch oose mul tispec tral i mage ’, $
4 fid = fid , dims = dims , pos = pos
5 IF ( fid EQ -1) THEN BEGI N
6 PRINT , ’ canc elled ’
7 RETU RN
8 ENDIF
9
10 envi _file_ query , fid , fname = fnam e
11
12 ; i mage dimension s
13 cols = dims [2] - dims [1]+ 1
14 rows = dims [4] - dims [3]+ 1
15 band s = n_el ements ( pos )
16
17 ; BSQ array
18 mage = fltarr ( cols , rows , band s )
19
20 FOR i =0 , bands -1 DO im age [* ,* , i ] = $
21 envi_get_da ta ( fid = fid , dims =dims , pos = pos [ i])
22
23 ; disp lay fir st band
24 w