Re: Multi bands mean [message #58658] |
Fri, 08 February 2008 09:44 |
jujo
Messages: 8 Registered: May 2007
|
Junior Member |
|
|
Hi David,
Your tip worked fine!
Thanks a lot!
Best,
Jurandir
On 8 fev, 15:15, David Fanning <n...@dfanning.com> wrote:
> David Fanning writes:
>>> mean_image=total(multi_bands_image, 3, /nan) / total(finite(a),3)
>
>> Whoops! Of course, a is the "universal variable", and in
>> your case will be equal to multi_bands_image. :-)
>
> Whoops! Whoops! (I'm trying to get ready for an international
> trip here...)
>
> I *think* TOTAL will cast the finite array, which is
> a byte array, into floats, but you better make sure of that.
> I don't have time to. :-)
>
> 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.")
|
|
|
Re: Multi bands mean [message #58660 is a reply to message #58658] |
Fri, 08 February 2008 09:15  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
David Fanning writes:
>> mean_image=total(multi_bands_image, 3, /nan) / total(finite(a),3)
>
> Whoops! Of course, a is the "universal variable", and in
> your case will be equal to multi_bands_image. :-)
Whoops! Whoops! (I'm trying to get ready for an international
trip here...)
I *think* TOTAL will cast the finite array, which is
a byte array, into floats, but you better make sure of that.
I don't have time to. :-)
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.")
|
|
|
Re: Multi bands mean [message #58661 is a reply to message #58660] |
Fri, 08 February 2008 09:09  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
David Fanning writes:
> mean_image=total(multi_bands_image, 3, /nan) / total(finite(a),3)
Whoops! Of course, a is the "universal variable", and in
your case will be equal to multi_bands_image. :-)
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.")
|
|
|
Re: Multi bands mean [message #58662 is a reply to message #58661] |
Fri, 08 February 2008 09:05  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
jujo@argentina.com writes:
> I have a multi-bands image. I need to calculate the mean value of each
> pixel, considering all the bands. It can be easily done using:
>
> mean_image=total(multi_bands_image, 3) / number of bands
>
> However, I have some nan values, which have to be discarded before the
> calculation. I can do that:
>
> mean_image=total(multi_bands_image, 3, /nan) / number of bands
>
> However, if I do that, the nan values become zeros and the average
> includes them. How can I do to calculate the mean without considering
> nan values?
Seems to me you want this:
mean_image=total(multi_bands_image, 3, /nan) / total(finite(a),3)
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.")
|
|
|