Re: Help with ASSOC function [message #2397] |
Thu, 23 June 1994 11:18 |
ian
Messages: 26 Registered: February 1992
|
Junior Member |
|
|
Word has it that cce@dar.csiro.au may have said:
>
> Could someone please explain the reason for having to replace lines 7 and 9
> with those shown to get this .pro file to work. I am using a 512x512 BIL
> 2 channel image. What is the significance of the extra 0?
>
> pro dspim,name ; Line 01
> openr,1,name ; Line 02
> hdr = intarr(512) ; Line 03
> image = assoc(1,intarr(512,2,512,/nozero),1024) ; Line 04
> ch1 = bytarr(512,512) ; Line 05
> ch2 = bytarr(512,512) ; Line 06
> ch1(*,*) = bytscl(image(*,0,*),min=0,max=200) ; Line 07
> tv,ch1 ; Line 08
> ch2(*,*) = bytscl(image(*,1,*),min=0,max=200) ; Line 09
> tv,ch2 ; Line 10
> close,1 ; Line 11
> end ; Line 12
>
>
> % Compiled module: DSPIM.
> % Range illegal for record number in assoc var ref: IMAGE
> % Execution halted at DSPIM <dspim.pro( 7)> .
> % Called from $MAIN$ .
>
>
> If the above two lines replace their respective lines above everything works.
>
> ch1(*,*) = bytscl(image(*,0,*,0),min=0,max=200) ; Replace Line 07
> ch2(*,*) = bytscl(image(*,1,*,0),min=0,max=200) ; Replace Line 09
>
The problem is how you used ASSOC. ASSOC is used to declare that a file
is to be regarded as an array of arrays (usually). Your definition in
line 04 actually defined the whole file as an array of 512x2x512 arrays.
Thus, you need the last 0 to represent the "first" one of those.
As another example, say you had one typical AVIRIS scene (614 samples,
512 lines, 224 bands, 16-bit data, BIL). To use ASSOC you'd define:
IDL> image = assoc(1,intarr(614,224))
Then the third coordinate used in referencing it denotes the line.
Notice that there's no good way to get all of one band without getting
each line of said band at a time. That's the problem with using BIL or
BIP on hyperspectral data. But BIL and BIP are great for spectra. In
your case, since you only have the two bands, you can read the whole
file into IDL:
IDL> rawimg = intarr(512,2,512,/noz)
IDL> readu,1,rawimg
and then your lines 07 and 09 will work (using rawimg instead of image).
But if you don't want to read all that into memory, then you'll have to
use the replacement lines you mentioned.
+-Ian Novack (Particle Man and Comatose Reader)-----+-ian@gomez.jpl.nasa.gov--+
|"'Progress in ethics is the only cure for progress | Jet Propulsion Lab |
| in science.'" -- Freeman Dyson quoting Haldane | Pasadena, CA |
+--Disclaimer: Had this been an actual opinion, it would still be mine.-------+
|
|
|