Convolution of a Blockfunction with a Blockfunction


Mathematica 3.0 code:

First some initialization code and function definitions:

<<Calculus`DiracDelta`;
<<Graphics`Colors`;
$TextStyle = {FontFamily -> "Helvetica", FontSize -> 14};

animconvol[title_,rangef_,rangeg_]:=Module[{list,pn,t},
  list={};pn=10;
  conv[t_]:=Integrate[f[x] g[x-t],{x,-Infinity,Infinity}];
   Table[list=Append[list,{t,conv[t]}];
    p=Show[GraphicsArray[
    {{Plot[{f[x],g[x-t]+.01}, {x, -2, 3.5},
        PlotStyle->{{Black,Thickness[0.01]},{Green,Thickness[0.01]}},
        PlotRange->{{-2,3.5},rangef},
        Ticks->{Automatic,{.5,1}},
        AspectRatio->.3,
        DisplayFunction->Identity]},
     {ListPlot[list,
        PlotStyle->{Red,PointSize[.01]},
        PlotRange->{{-2,3.5},rangeg},
        Ticks->{Automatic,{.5,1}},
        AspectRatio->.3,
        DisplayFunction->Identity]}}],
      DisplayFunction->$DisplayFunction,
      PlotLabel->title];
  Display[StringJoin["c:/tmp/",title,ToString[pn++],".gif"],p,"GIF",
  ImageSize->{512,512}],
 {t,-1.51,2,.1}]];

Convolution of a block with a block

The code to make the graphics:

f[x_]:=UnitStep[x]+UnitStep[1-x]-1;
g[x_]:=UnitStep[x]+UnitStep[1-x]-1;
Plot[g[x], {x, -3, 3},PlotStyle->{Thickness[.01]}];
animconvol["Convolution of a block with a block",{-.1,1.1},{-.1,1.1}];


Convolution of a triangle with a block

f[x_]:=4x UnitStep[x]-8(x-1/2) UnitStep[x-1/2]+4(x-1) UnitStep[x-1];
Plot[f[x], {x, -3, 3},PlotStyle->{Thickness[.01]}];
animconvol["Convolution of a triangle with a block",{-.1,2.1},{-.1,1.1}];


Convolution of a spike with a Gaussian

Integrate[Exp[-x^2],{x,-Infinity,Infinity]}]
f[x_]:=20(UnitStep[x]+UnitStep[.05-x]-1) ;
g[x_]:=1/Sqrt[Pi] Exp[-x^2];
Plot[{f[x],g[x]},{x,-3,3},PlotRange->All,
  PlotStyle->{Thickness[.01]},PlotPoints->100];
animconvol["Convolution of a spike with a gaussian",{-.1,.8},{-.1,1.1}];


Edge detection

f[x_] := UnitStep[x + 1] - UnitStep[x] + (x - 1) UnitStep[x - 1] - 1;
  g[x_] := Evaluate[D[-Exp[-x^2/.02], x]/7];
  Plot[f[x],{x,-3,3}, PlotRange -> All, 
    PlotStyle -> {Thickness[.01]}, PlotPoints -> 100]; 
  Plot[g[x],{x,-3,3}, PlotRange -> All, 
    PlotStyle -> {Thickness[.01]}, PlotPoints -> 100];
animconvol["edge detection",{-1.1,1.1},{-.2,.2}];


Examples of different orientation tuned receptive field profiles in the human visual cortex

The filters come in all directions. They are shown here as a sequence of their orientations.


Bart M. ter Haar Romeny
August 1998