Moving Average on Hyperspectral dataset [message #53154] |
Mon, 26 March 2007 16:03 |
rafaloos
Messages: 15 Registered: January 2006
|
Junior Member |
|
|
Hi, all ...
We are trying to do a moving average on our dataset. The dataset comes
from a Hyperspectral sensor and has 296 samples, 2000 lines and 492
bands.
We need to go through each pixel and do a moving average on the
spectral bands. So in the end we will have a dataset with the same
dimensions as the original but with smooth spectra. And because of the
moving average kernel size, we will have some empty bands at the
beginning and at the end.
Here is the code that we are using now ...
>>>> IMAGE = (296, 2000, 492)
--------------------------------------
Step = FIX(Kernel / 2)
FOR samples = 0 , 295 DO BEGIN
FOR lines = 0, 1999 DO BEGIN
FOR bands = Step, 491 - Step DO BEGIN
ARR_TEMP = MEAN(IMAGE[samples, lines,bands-Step:bands
+step])
IMAGE[samples, lines, bands] = ARR_TEMP
IMAGE[samples, lines, 0:step-1] = 0
IMAGE[samples, lines, bands-(Step):bands-1] =
0
ENDFOR
ENDFOR
ENDFOR
--------------------------------------
With the loops the code takes about 3 hours ... Is there a way to
speed it up ?
Thank you
|
|
|