Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2007
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2007

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: 2D Convolution

  • To: mathgroup at smc.vnet.net
  • Subject: [mg76154] Re: 2D Convolution
  • From: Joseph Gwinn <joegwinn at comcast.net>
  • Date: Thu, 17 May 2007 05:50:27 -0400 (EDT)
  • References: <f29389$m7p$1@smc.vnet.net> 29bbo$ppn$11smccvnee.neee <f2emb3$2qn$1@smc.vnet.net>

In article <f2emb3$2qn$1 at smc.vnet.net>, CKWong <CKWong.P at gmail.com> 
wrote:

> You need to re-define your Convolve like this:
> 
> Convolve[f_, g_, x_?NumberQ, y_?NumberQ] := NIntegrate[f[
>     xPrime, yPrime] *g[x - xPrime,
>   y - yPrime], {xPrime, -=A1=DB, =A1=DB}, {yPrime, -=A1=DB, =A1=DB}]
> 
> When calling Convolve, remember to place the kernel as the first
> function, e.g.,
> 
> Convolve[Gaussian2D, SHole, 0, 0]
> 
> You can plot the convolution like this:
> 
> Plot3D[Convolve[Gaussian2D, SHole, x, y] // Evaluate, {x, -HoleSize,
>       HoleSize}, {y, -HoleSize, HoleSize}]
> 
> However, this scheme is too slow for the round hole, for which case,
> it's better to switch to polar coordinates so that the angular part
> can be integrated by hand.

An alternative is to implement convolution using 2D Fourier and 
InverseFourier.  This may be faster, at least for large kernels and/or 
strange hole shapes.

Joe Gwinn


  • Prev by Date: how save newly created palette?
  • Next by Date: Re: Re: Re: Where is the Mathematica
  • Previous by thread: Re: 2D Convolution
  • Next by thread: Re: 2D Convolution