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

Home » Public Forums » archive » Technique to find maximum in 100x100 element moving box
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: Technique to find maximum in 100x100 element moving box [message #93766 is a reply to message #93765] Thu, 13 October 2016 10:58 Go to previous messageGo to previous message
Lajos Foldy is currently offline  Lajos Foldy
Messages: 176
Registered: December 2011
Senior Member
On Thursday, October 13, 2016 at 7:01:56 PM UTC+2, fawltyl...@gmail.com wrote:

> Try this:

Revised version, faster and without ifs:

pro test
nx=3200
ny=3248
m=100

m2=m/2
seed=123
data=randomu(seed,nx,ny)

tic
tmp1=transpose(data)
tmp2=fltarr(ny,nx,/nozero)
FOR i = 0, nx-1 DO BEGIN
FOR j = 0, m2 DO tmp2[j,i] = max(tmp1[0 :j+m2, i])
FOR j = m2+1, ny-m2-1 DO tmp2[j,i] = max(tmp1[j-m2:j+m2, i])
FOR j = ny-m2, ny-1 DO tmp2[j,i] = max(tmp1[j-m2:ny-1, i])
ENDFOR
tmp2=transpose(tmp2)
data_max=fltarr(nx,ny,/nozero)
FOR j = 0, ny-1 DO BEGIN
FOR i = 0, m2 DO data_max[i,j] = max(tmp2[0 :i+m2, j])
FOR i = m2+1, nx-m2-1 DO data_max[i,j] = max(tmp2[i-m2:i+m2, j])
FOR i = nx-m2, nx-1 DO data_max[i,j] = max(tmp2[i-m2:nx-1, j])
ENDFOR
toc

end


regards,
Lajos

ps: the i-50:i+50 subscript range has 101 elements, not 100.
[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: Structures and arrays of structures
Next Topic: repeated use of TVRD() gives different results

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

Current Time: Wed Oct 08 16:12:39 PDT 2025

Total time taken to generate the page: 0.00439 seconds