|
|
|
|
Re: Convolution, IDL & Numerical Recipes [message #32675 is a reply to message #32672] |
Thu, 31 October 2002 17:10   |
James Kuyper
Messages: 425 Registered: March 2000
|
Senior Member |
|
|
David Fanning wrote:
...
> Gonzales and Woods seem to suggest that "convolution" is a
> frequency domain concept, and can only be loosely applied in
> the linear spatial sense. Could this be part of the problem?
The convolution isn't specifically a frequency-domain concept. In fact,
as I'm usually seen it, the canonical definition is in the time domain.
cgh(t) is the convolution of g(t) and h(t) if:
cgh(t) = integral(g(tau)h(t-tau) d tau)
The importance of the frequency domain for convolutions is that it can
be proven that if G(f), H(f), and CGH(f) are the fourier transforms of
g(t), h(t), and cfg(t) respectively, then:
CGH(f) = G(f)*H(f)
If they'd been thinking in the frequency domain, there's no way they'd
have named it using a word that is closely related to "convoluted".
|
|
|
Re: Convolution, IDL & Numerical Recipes [message #32676 is a reply to message #32675] |
Thu, 31 October 2002 14:29   |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
JD Smith (jdsmith@as.arizona.edu) writes:
> Because IDL's convol() really does a correlation, not a convolution at
> all! In a true convolution, the kernel is reversed (rotated by 180
> degrees). You could try z=convol(a,reverse(k)) to get a true
> convolution for comparison.
Oddly enough, I finally bought a copy of the acclaimed
Digital Image Processing, 2nd Ed., by Gonzalez and Woods,
and was reading it last night! On page 116 of this excellent
book in the section entitled Basics of Spatial Filtering it
has this:
"The mechanics of spacial filtering ... consists simply
of moving the filter mask from point to point in an image.
At each point (x,y), the response of the filter at that
point is calculated using a predefined relationship. For
linear spacial filtering, the response is given by a sum
of the products of the filter coefficients and the corresponding
image pixels in the area spanned by the filter mask."
A couple of paragraphs later, they say this:
"For this reason, linear spatial filtering often is referred to
as 'convolving a mask with an image.' Similarly, filter masks
are sometimes called *convolution masks*. The term 'convolution
kernel' also is in common use."
In this sense, IDL CONVOL seems to do exactly what it is
asked to do, I.e., convolve a kernel with an image. In any case,
IDL's CONVOL gave me what I expected it to give me after reading
this portion of the text.
Gonzales and Woods seem to suggest that "convolution" is a
frequency domain concept, and can only be loosely applied in
the linear spatial sense. Could this be part of the problem?
I'm curious about this because I have been trying to
duplicate some of the results in the book (they apparently
use MatLab) and I am having rather more trouble than
I had hoped to. :-(
Cheers,
David
--
David W. Fanning, Ph.D.
Fanning Software Consulting, Inc.
Phone: 970-221-0438, E-mail: david@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
|
|
|
|
Re: Convolution, IDL & Numerical Recipes [message #32745 is a reply to message #32671] |
Mon, 04 November 2002 18:55  |
aceves
Messages: 4 Registered: October 2002
|
Junior Member |
|
|
"R.G. Stockwell" <sorry@noemail.now> wrote in message news:<3DC28954.7060605@noemail.now>...
>
> Perhaps you want to use the following keywords:
> Check out the help file to see the effects the keywords
> have on how the arrays line up to be convolved.
> (Note: you must explicitly set center=0, or else it defaults
> to 1)
>
> z=convol(a,k,center=0,edge_wrap=1)
>
> a 0 0 0 0 0 1 1 1 1 1 0 0 0 0 0 0
> k 1 0 0 0 0 0 0 0 0
>
> z 0 0 0 0 0 1 1 1 1 1 0 0 0 0 0 0
>
>
> Cheers,
> bob stockwell
Dear Bob...
It works well with the kernel [1,0,...]
But when I tried the actual examples of Numerical Recipes it did not
give me the same results:
a=[0,0,0,0,0,1,1,1,1,1,0,0,0,0,0,0]
k=[0,0,1,1,1,1,0,0,0]
z=convol(a,k,center=0,edge_wrap=1)
IDL> print,z
0 0 0 0 0 0 0 1 2
3 4 4 3 2 1 0
IDL>
With Numerical Recipes gives..
0 1 1 1 1 1 0 1 2 3 3 3 2 1 0 0
which seems ok!
Any other Idea? someone?
Thanks
|
|
|
|
Re: Convolution, IDL & Numerical Recipes [message #32768 is a reply to message #32671] |
Fri, 01 November 2002 06:53  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
R.G. Stockwell (sorry@noemail.now) writes:
> Perhaps you want to use the following keywords:
> Check out the help file to see the effects the keywords
> have on how the arrays line up to be convolved.
> (Note: you must explicitly set center=0, or else it defaults
> to 1)
Alright, now, can you give me the layman's definition
of the difference between spacial filtering (CENTER=1)
and convolution "in the strict mathematical sense"
(CENTER=0). Which would I use if I'm trying to make
a pretty image? :-)
Cheers,
David
P.S. Let's just say I'm open to some private mathematical
tutoring in exchange for some GREAT object-oriented
widget programs.
--
David W. Fanning, Ph.D.
Fanning Software Consulting, Inc.
Phone: 970-221-0438, E-mail: david@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
|
|
|