Re: Maximum value array resampling [message #45021 is a reply to message #45020] |
Fri, 05 August 2005 13:45   |
Richard French
Messages: 173 Registered: December 2000
|
Senior Member |
|
|
This works much better! I was being brain dead. Once you know the indices of
each of the four entries in each cell, you can do a direct compare. It took
7-8 seconds on my Powerbook G4 for a 4000 x 5000 image, compared to 40-45
seconds using loops:
nx=4000L
ny=5000L
; put in random values (this is the slow step!)
X=rebin(fix(1000*(randomu(seed,nx*ny))),nx,ny)
nx2=nx/2L
ny2=ny/2L
; get indices of upper left element of each 2x2 cell
l=rebin(nx*2#lindgen(ny2),nx2,ny2)+rebin(lindgen(nx2)#2,nx2, ny2)
; compare with indices of ul,ur, ll, lr of each 2x2 cell
print,'Start....'
T10=systime(1)
xfinal=x[l]>x[l+1]>x[l+nx]>x[l+nx+1]
print,'Time=',systime(1)-t10
t20=systime(1)
y=intarr(nx2,ny2)
for i=0,nx2-1 do x[i,*]=x[2*i,*] > x[2*i+1,*]
for i=0,ny2-1 do y[*,i]=x[0:nx2-1,2*i] > x[0:nx2-1,2*i+1]
print,'Time=',systime(1)-t20
print,max(abs(xfinal-y)) ; confirm that we get same result
end
~
|
|
|