Re: Technique to find maximum in 100x100 element moving box [message #93765 is a reply to message #93761] |
Thu, 13 October 2016 10:01   |
Lajos Foldy
Messages: 176 Registered: December 2011
|
Senior Member |
|
|
On Thursday, October 13, 2016 at 5:02:14 PM UTC+2, Samantha Tushaus wrote:
> Interestingly, my method, the "dilute" method, and the no-ifs loop all take the same amount of time (63, 64, and 62 seconds, respectively).
Try this:
tmp1=transpose(data)
tmp2=fltarr(ny,nx,/nozero)
FOR i = 0, nx-1 DO BEGIN
FOR j = 0, ny-1 DO BEGIN
IF (j-m2) LT 0 THEN low_ind_j = 0 ELSE low_ind_j = j-m2
IF (j+m2) GT (ny-1) THEN hi_ind_j = ny-1 ELSE hi_ind_j = j+m2
tmp2[j,i] = max(tmp1[low_ind_j:hi_ind_j, i])
ENDFOR
ENDFOR
tmp2=transpose(tmp2)
data_max=fltarr(nx,ny,/nozero)
FOR j = 0, ny-1 DO BEGIN
FOR i = 0, nx-1 DO BEGIN
IF (i-m2) LT 0 THEN low_ind_i = 0 ELSE low_ind_i = i-m2
IF (i+m2) GT (nx-1) THEN hi_ind_i = nx-1 ELSE hi_ind_i = i+m2
data_max[i,j] = max(tmp2[low_ind_i:hi_ind_i,j])
ENDFOR
ENDFOR
regards,
Lajos
|
|
|