Re: Does CONVOL convolute [message #34145] |
Tue, 25 February 2003 09:21  |
thompson
Messages: 584 Registered: August 1991
|
Senior Member |
|
|
condor@biosys.net (Big Bird) writes:
> David Fanning <david@dfanning.com> wrote in message news:<MPG.18c41ee199cd0d0b989afb@news.frii.com>...
>> Setting CENTER=1 or /CENTER is the same as leaving the CENTER
>> keyword off. (Don't ask!)
> Oy, I'll ask anyways: Who's grand idea was that?
>> If you want to perform convolution in
>> the "strictly mathematical" sense, you must explicitly set CENTER=0.
>> Is this what you were after:
>>
>> IDL> print,convol(tt,k, center=0)
>> 0.000000 0.000000 0.000000 0.000000 0.000000
>> 0.000000 0.000000 0.000000 0.000000 0.000000
>> 0.000000 0.000000 1.00000 0.000000 0.000000
>> 0.000000 0.000000 0.000000 0.000000 0.000000
>> 0.000000 0.000000 0.000000 0.000000 0.000000
> Huh? No, that isn't what I was after either.
> Maybe I'm thinking something completely wrong here somewhere but if my
> array is
> 1 0 0
> 0 0 0 ...
> 0 0 0
> .
> .
> and my convolution kernel is
> a b c
> d e f
> g h i
> then I would expect the convolution to be
> e f 0
> h i 0 ...
> 0 0 0
> .
> .
> At least for a symmetric kernel (I'd have to think about an
> unsymmetric one). ...
Actually, for an asymmetric kernel, the answer should be
e d 0
b a 0
0 0 0
What I usually do in this sort of situation is to embed my array within a
bigger array, to get around the edge effects within these IDL routines. Thus,
I would make my array
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 1 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
of which the center 3x3 portion is the real array. The convolution with the
kernal would then be
0 0 0 0 0 0 0
0 i h g 0 0 0
0 f e d 0 0 0
0 c b a 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
And taking the center 3x3 portion gives the expected answer.
William Thompson
|
|
|