Re: 2D Convolution
- To: mathgroup at smc.vnet.net
- Subject: [mg76061] Re: 2D Convolution
- From: dh <dh at metrohm.ch>
- Date: Tue, 15 May 2007 05:04:58 -0400 (EDT)
- References: <f29389$m7p$1@smc.vnet.net>
Hi Mathieu, Note that the Gaussian and Hole covolution is symmetrical and can therefore done as a much simplier 1 dim problem. However, if you need 2dim, I would advice, due to computing time, to approximate the 2D convolution by a numerical approximation. Here is a small example: Hole[x_,y_]:=If[0.2<x^2+y^2,0,1]; Gaussian[x_,y_]:=Exp[-10(x^2+y^2)]; fun[x_/;NumericQ[x],y_]:= NIntegrate[Gaussian[x-xx,y-yy] Hole[xx,yy],{xx,-2.,2.},{yy,-2.,2.}] ; fun1=FunctionInterpolation[ fun[x,y] ,{x,-1.,1.},{y,-1.,1.}] hope this helps, Daniel Mathieu G wrote: > Hello, > I need your help on this problem please! > I would like to compute + plot a 2D convolution between a disk- or > square shaped hole, and a 2D Gaussian. > Here is where I am so far... > > > HoleSize = 300*^-9; (*Radius or side length*) > BeamRadius = 3.81*^-6; > > Gaussian2D[x_, y_] := Exp[-((x/BeamRadius)^2 + (y/BeamRadius)^2)/2]; > > (*Disk-shape hole*) > DHole = Disk[{0, 0}, HoleSize/2]; > > (*Square-shape hole*) > SHole = Rectangle[{-HoleSize/2, -HoleSize/2}, {HoleSize/2, > HoleSize/2}]; > > Plot3D[Gaussian2D[x, y], {x, -4 BeamRadius, > 4 BeamRadius}, {y, -4 BeamRadius, 4 BeamRadius}, > ColorFunction -> "Rainbow", PlotRange -> Full] > > Beam = Gaussian2D[{x, -5 BeamRadius, 5 BeamRadius}, {y, -5 BeamRadius, > 5 BeamRadius}]; > > (*Graphics3D[Beam] > Graphics[{Red,SHole,Orange,DHole},Frame->True]*) > > > Every advice welcome! > Thank you, > Mat' >