Re: Calculate the mean of many images [message #63639 is a reply to message #63635] |
Sun, 16 November 2008 16:35   |
Wasit.Weather
Messages: 62 Registered: February 2008
|
Member |
|
|
On Nov 16, 3:04 pm, David Fanning <n...@dfanning.com> wrote:
> Bulrush writes:
>> Thank you. I just run the code, but it always reporting syntax error
>> for sum(wh) +=3D img(wh), for the brackets.
>
> I think that is a hold-over from Craig's days as the King
> of IDL 4.0. ;-)
>
> Cheers,
>
> David
>
> --
> David Fanning, Ph.D.
> Fanning Software Consulting, Inc.
> Coyote's Guide to IDL Programming:http://www.dfanning.com/
> Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Seems like I got lost between the codes. the mean I got with avg[wh]
is all zero. Here is my code. Thanks for your help.
FOR K = 0, images-1 DO BEGIN
ENVI_OPEN_FILE, files[K], r_fid=files_fid
ENVI_FILE_QUERY, files_fid, ......
pos = lindgen(nb)
; get the data
Data = ENVI_GET_DATA(fid=files_fid, dims=dims, pos=pos[0])
QA = ENVI_GET_DATA(fid=files_fid, dims=dims, pos=pos[1])
mask = (QA EQ 0.00) AND (finite(Data) EQ 1) OR (QA EQ 1.00) AND
(finite(Data) EQ 1)
; Sum Valid Pixels
npix += mask
wh = where(mask, ct)
if ct GT 0 then sum[wh] += Data[wh]
EndFor
; Positions where there are good pixels
qa_avg = (npix GT 0)
wh = where(qa_avg EQ 1)
; Compute average for valid pixels
avg = sum*0
avg[wh] = sum[wh] / npix[wh]
I am also wondering what does += means?
Thank you!!!1
|
|
|