Hi,
On Sat, 28 Jul 2006, Alain wrote:
> Smooth is currently not available in GDL. I am using Smooth quiet
> frequently. So I decided to rewrite it for GDL. The problem was to
> write a test suite to check how good was my draft
> (hope to submit it soon to GDL team !).
>
> One nice test is to check whether the SMOOTH operation is invariant by
> "rotation"
> (if fact a transposition). If A is the test signal, a square matrix,
> smooth(a,3) and transpose(smooth(transpose(a),3)) should be equal.
>
> With IDL, in 2D case, when we have NaN, I thinks somethings goes wrong
> when /Edge is set. It was reproduce on several computers at my lab.
> (IDL 5.5, 6.0, 6.1 and 6.2)
>
> a=REPLICATE(0.,9,9)
> a(4,4)=20.
> a(3,4)=!value.f_nan
> b=transpose(a)
>
> print, total(smooth(a,3,/nan)-transpose(smooth(b,3,/nan)))
> (should be Zero, OK !)
>
> print, total(smooth(a,3,/nan,/edge)-transpose(smooth(b,3,/nan,/edge )))
> I was expecting Zero, Not OK !
>
> What is your opinion ?
> Thank You
>
> Alain
>
> PS: I founded nothing about that in this newsgroup archive
>
smooth has a note in the reference guide:
Normally, two-dimensional floating-point arrays are smoothed in one pass.
If the EDGE_TRUNCATE keyword is specified for a two-dimensional
floating-point array, the result is obtained in two passes, first for all
of the rows, and second for all of the columns. Therefore, the results for
points in the interior of the array may differ slightly when the
EDGE_TRUNCATE keyword is set. This difference will be most pronounced if
the array contains NaN values.
smooth has other peculiarities, too:
IDL> print, smooth([1d20, 1, 1, 1], 3)
1.0000000e+20 3.3333333e+19 0.0000000 1.0000000
look at the third number: it should be the average of [1,1,1], but it
is zero. I guess this is because IDL does not do the summing for each
element, but uses a sliding window instead.
regards,
lajos
|