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

Home » Public Forums » archive » How to find second minimum and maximum in 3D array?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
How to find second minimum and maximum in 3D array? [message #90353] Wed, 25 February 2015 12:01 Go to previous message
Harald Frey is currently offline  Harald Frey
Messages: 41
Registered: March 1997
Member
I have a time series of ~200 images with dimensions [X,Y]=[400,250]. My data is a UINTARR[200,400,250]. It is very easy to get the minimum and maximum for each pixel X,Y in my time series using

res=min(array,dimension=1,max=max_val)
IDL> help,res,max_val
RES FLOAT = Array[400, 250]
MAX_VAL FLOAT = Array[400, 250]

However, several pixels have 0 value or 65535 value and I want the second minimum and second maximum which are not 0 or 65535. I can do this in a for-loop, but is there a more clever and faster way?

min_array=uintarr(400,250)
max_array=uintarr(400,250)
for x=0,400-1 do begin
for y=0,300-1 do begin
good=where (array[*,x,y] gt 0 and array[*,x,y] lt 65535l)
res=min(array[good,x,y],dimension=1,max=max_val)
min_array[x,y]=res
max_array[x,y]=max_val
endfor
endfor

Thanks,
Harald Frey (UC Berkeley)
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: normal, relative and ellipse
Next Topic: Using Slither with Anaconda

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

Current Time: Wed Oct 08 13:58:51 PDT 2025

Total time taken to generate the page: 0.00254 seconds