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

Home » Public Forums » archive » Re: Maximum value array resampling
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: Maximum value array resampling [message #45190 is a reply to message #45102] Mon, 15 August 2005 11:13 Go to previous message
JD Smith is currently offline  JD Smith
Messages: 850
Registered: December 1999
Senior Member
>
> Just to clarify things, your 8/8/05 routine above is essentially
> identical to the revised routine I posted on 8/5/05 (see below), and I was
> referring to this new routine when I said it was faster than what you had
> posted. I had also posted a lame rebinning approach to the problem
> previously, and I think that is the one you used when you found such poor
> performance.

Sorry about that Dick... looks very similar (except of course for
reform vs #). Here's a version which can do max or min, and any box
size (not just 2x2). Keep in mind that for arrays which are not
multiples of the box size, the edges will be lost. Another
interesting question is how to do a sliding box max/min efficiently,
ala MEDIAN.

JD

;; BOX_MAX: Compute local maximum (or minimum. with /MIN) box
;; downsampling, with box size boxx, boxy (default 2,2). Pre-computed
;; INDS may be passed.
;; JD Smith (c) 2005.
function box_max,array,boxx,boxy,INDS=inds, MIN=min
if n_elements(boxx) eq 0 then boxx=2
if n_elements(boxy) eq 0 then boxy=2
min=keyword_set(min)
d=size(array,/DIMENSIONS)
nx=d[0] & ny=d[1]

if n_elements(inds) eq 0 then begin
nx_out=nx/boxx & ny_out=ny/boxy
inds=rebin(lindgen(nx_out)*boxx,nx_out,ny_out,/SAMPLE)+ $
rebin(transpose(lindgen(ny_out)*boxy*nx),nx_out,ny_out,/SAMP LE)
endif

ret=array[inds]
for i=0L,boxx-1L do begin
for j=0L,boxy-1L do begin
if i eq 0 && j eq 0 then continue
if min then ret <= array[inds+i+j*nx] else ret >= array[inds+i+j*nx]
endfor
endfor

return,ret
end
[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
Read Message
Previous Topic: Re: Dynamic array of an Object as class member variable.
Next Topic: New Tabbing Functionality in IDL 6.2

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

Current Time: Fri Oct 10 00:59:29 PDT 2025

Total time taken to generate the page: 0.88112 seconds