MathGroup Archive 2005

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

Search the Archive

Re: Blurring with mathematica


Generate an image.

image = Table[Random[], {128}, {128}];
Show[Graphics[Raster[image]], AspectRatio -> 1];

Generate a Gaussian blurring kernel.

halfwindow = 5;
sdev = 2;
kernel = Table[Exp[-((i^2 + j^2)/(2*sdev^2))],
    {i, -halfwindow, halfwindow}, {j, -halfwindow, halfwindow}];
Show[Graphics[Raster[kernel]], AspectRatio -> 1];

Blur the image.

image2 = ListCorrelate[kernel, image];
image2 /= Max[image2];
Show[Graphics[Raster[image2]], AspectRatio -> 1];

If you want to blur with circular wraparound then use

ListCorrelate[kernel, image,
{{halfwindow + 1, halfwindow + 1},
{halfwindow + 1, halfwindow + 1}}];
Steve Luttrell

<V.Marinakis at damtp.cam.ac.uk> wrote in message 
news:cvrqhi$p5c$1 at smc.vnet.net...
> Hello everyone.
>
> I have an image which is stored as an 128 times 128
> matrix and I want to add gaussian blurring. Does anyone
> know how can this be done with mathematica?
>
> Best, Vangelis Marinakis.
> 



  • Prev by Date: Re: Exporting output cells to .eps
  • Next by Date: Re: Mathematica batch file
  • Previous by thread: Re: Blurring with mathematica
  • Next by thread: Mathematica batch file