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

Home » Public Forums » archive » Re: max, mean, min of array
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: max, mean, min of array [message #28682] Mon, 07 January 2002 02:52 Go to next message
dinhnq is currently offline  dinhnq
Messages: 14
Registered: December 2001
Junior Member
Thank you all for your suggestions. Now it works.


Dinh Huong



Wayne Landsman <landsman@mpb.gsfc.nasa.gov> wrote in message news:<3C38AA76.69754BEC@mpb.gsfc.nasa.gov>...
> Dinh Huong wrote:
>
>> Dear Lists,
>>
>> I have an array of 400,400,10 contains 10 month T� of 400x400 pixel
>> area. I am trying to calculate min, max, mean T�for each pixel and
>> output is 400x400 image. How to solve this by IDL?
>> Any help will be appreciate,
>
> In IDL V5.5, if you have a 400 by 400 by 10 array, you can find the
> maximum over the 3rd dimension using the DIMENSION keyword.
>
> IDL> pixmax = max(array, dimen=3) ;Return a 400 x 400
> array
>
> In earlier versions of IDL you have to loop over each pixel, and (as
> David mentioned) Craig Markwardt's CMAPPLY will make sure that this
> looping is done as efficiently as possible.
>
> --Wayne
>
> P.S. While I am grateful to RSI for adding dimension-specific
> capabilities in V5.5 to MIN, MAX, FFT, and SMOOTH, I would still very
> much like to see the same capability added to MEDIAN. (The customer
> is never satisfied....)
Re: max, mean, min of array [message #28686 is a reply to message #28682] Sun, 06 January 2002 12:25 Go to previous messageGo to next message
Craig Markwardt is currently offline  Craig Markwardt
Messages: 1869
Registered: November 1996
Senior Member
David Fanning <david@dfanning.com> writes:

> Dinh Huong (dinhnq@yahoo.com) writes:
>
>> I have an array of 400,400,10 contains 10 month T� of 400x400 pixel
>> area. I am trying to calculate min, max, mean T�for each pixel and
>> output is 400x400 image. How to solve this by IDL?
>> Any help will be appreciate,
>
> I would hustle over to Craig Markwardt's web page
> and get ahold of his CMAPPLY program ASAP:
>
> http://cow.physics.wisc.edu/~craigm/idl/arrays.html

Which, unfortunately, still does 400x400 max/min calls, as Wayne
points out.

Craig

--
------------------------------------------------------------ --------------
Craig B. Markwardt, Ph.D. EMAIL: craigmnet@cow.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
------------------------------------------------------------ --------------
Re: max, mean, min of array [message #28687 is a reply to message #28686] Sun, 06 January 2002 11:50 Go to previous messageGo to next message
Wayne Landsman is currently offline  Wayne Landsman
Messages: 117
Registered: January 1997
Senior Member
Dinh Huong wrote:

> Dear Lists,
>
> I have an array of 400,400,10 contains 10 month T� of 400x400 pixel
> area. I am trying to calculate min, max, mean T�for each pixel and
> output is 400x400 image. How to solve this by IDL?
> Any help will be appreciate,

In IDL V5.5, if you have a 400 by 400 by 10 array, you can find the
maximum over the 3rd dimension using the DIMENSION keyword.

IDL> pixmax = max(array, dimen=3) ;Return a 400 x 400
array

In earlier versions of IDL you have to loop over each pixel, and (as
David mentioned) Craig Markwardt's CMAPPLY will make sure that this
looping is done as efficiently as possible.

--Wayne

P.S. While I am grateful to RSI for adding dimension-specific
capabilities in V5.5 to MIN, MAX, FFT, and SMOOTH, I would still very
much like to see the same capability added to MEDIAN. (The customer
is never satisfied....)
Re: max, mean, min of array [message #28689 is a reply to message #28687] Sun, 06 January 2002 07:42 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Dinh Huong (dinhnq@yahoo.com) writes:

> I have an array of 400,400,10 contains 10 month T� of 400x400 pixel
> area. I am trying to calculate min, max, mean T�for each pixel and
> output is 400x400 image. How to solve this by IDL?
> Any help will be appreciate,

I would hustle over to Craig Markwardt's web page
and get ahold of his CMAPPLY program ASAP:

http://cow.physics.wisc.edu/~craigm/idl/arrays.html

Cheers,

David
--
David W. Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438, E-mail: david@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
Re: max, mean, min of array [message #28924 is a reply to message #28687] Wed, 23 January 2002 07:04 Go to previous messageGo to next message
Alex Schuster is currently offline  Alex Schuster
Messages: 124
Registered: February 1997
Senior Member
Wayne Landsman wrote, a while ago:

> Dinh Huong wrote:

>> I have an array of 400,400,10 contains 10 month T� of 400x400 pixel
>> area. I am trying to calculate min, max, mean T�for each pixel and
>> output is 400x400 image. How to solve this by IDL?
>> Any help will be appreciate,
>
> In IDL V5.5, if you have a 400 by 400 by 10 array, you can find the
> maximum over the 3rd dimension using the DIMENSION keyword.
>
> IDL> pixmax = max(array, dimen=3) ;Return a 400 x 400 array
>
> In earlier versions of IDL you have to loop over each pixel, and (as
> David mentioned) Craig Markwardt's CMAPPLY will make sure that this
> looping is done as efficiently as possible.

It's possible without, um, with fewer loops:

zdim = (size( array, /dimension ))[2]
pixmin = ( pixmax = array[*,*,0] )
for i = 1, zdim-1 do begin
pixmax = pixmax > array[*,*,i]
pixmin = pixmin < array[*,*,i]
endfor
pixmean = total( array, 3 ) / zdim

Hey Craig, I think with this method you can get rid of your ho, hum
comment in cmapply.pro.

Alex
--
Alex Schuster Wonko@planet-interkom.de
alex@pet.mpin-koeln.mpg.de
Re: max, mean, min of array [message #29004 is a reply to message #28924] Thu, 24 January 2002 07:29 Go to previous message
Craig Markwardt is currently offline  Craig Markwardt
Messages: 1869
Registered: November 1996
Senior Member
Alex Schuster <Wonko@planet-interkom.de> writes:
> It's possible without, um, with fewer loops:
>
> zdim = (size( array, /dimension ))[2]
> pixmin = ( pixmax = array[*,*,0] )
> for i = 1, zdim-1 do begin
> pixmax = pixmax > array[*,*,i]
> pixmin = pixmin < array[*,*,i]
> endfor
> pixmean = total( array, 3 ) / zdim
>
> Hey Craig, I think with this method you can get rid of your ho, hum
> comment in cmapply.pro.

Very cool! I think I've been "outvectored" on this one.

Alex, I think *both* solutions should be possible. Consider the
following scenario: instead of a 400x400x12 array, how about a
2x2x1000000 array? Using your technique we would end up doing 1000000
iterations, but with mine it would only be 4.

Thus, the code should contain both solutions, and pick whichever one
takes fewer iterations.

Craig

--
------------------------------------------------------------ --------------
Craig B. Markwardt, Ph.D. EMAIL: craigmnet@cow.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
------------------------------------------------------------ --------------
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: Urgent object question
Next Topic: Urgent object question

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

Current Time: Wed Oct 08 15:26:20 PDT 2025

Total time taken to generate the page: 0.00621 seconds