comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Calculate the mean of many images
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Calculate the mean of many images [message #63649 is a reply to message #63648] Sun, 16 November 2008 10:30 Go to previous messageGo to previous message
Wasit.Weather is currently offline  Wasit.Weather
Messages: 62
Registered: February 2008
Member
On Nov 16, 2:54 am, Craig Markwardt <cbmarkwa...@gmail.com> wrote:
> On Nov 16, 1:16 am, Bulrush <Wasit.Weat...@gmail.com> wrote:
>
>> Hello,
>> I know this topic has been posted several times. But I could not find
>> my answer from these posted.
>> My issue is: I have many images 2 bands in each, one image is QA image
>> and the other one is data.
>> I need to calculate the mean of good pixels. Let's say QA image tells
>> me the location of good pixels, e.g. 1 for good pixels, and other for
>> bad. There are also NaN values. So, if the pixels are "good" in 7
>> images out of ten, then
>> (pixel1+pixel2...+Pixel7) /7
>
> I would loop over input images, and keep track of the cumulative sum
> of the number of valid pixels (NPIX), and the cumulative sum of the
> pixel values (SUM).  Something like the following.  Since there are
> only a few images, there will be very little overhead in the FOR-loop.
>
> Craig
>
> npix = 0 & sum = 0
> for i = 0, n_images-1 do begin
>   qa = ... the ith QA image ...
>   img = ... the ith image ...
>   mask = (qa EQ 1) AND (finite(img) EQ 1)
>
>   ;; Sum valid pixels
>   npix += mask
>   wh = where(mask, ct)
>   if ct GT 0 then sum(wh) += img(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)

Thanks for all the comments. I think Craig's method would work for me.
the Actual QA image contains more than one value, such as 0.00 (good
pixel), 1.000 (between good and band), 2.000 (cloud), 3.000(snow),
etc.
What does finite(img) EQ 1 mean here? Can I write this statement as
the following?

mask = (qa EQ 1.000 and qa EQ 0.000 ) AND (finite(img) EQ 1.000 &&
0.000)

Thanks
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: IDL and sqlite
Next Topic: A Simple IDL Manifesto

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Thu Oct 09 20:31:15 PDT 2025

Total time taken to generate the page: 1.44000 seconds