Re: Blurring with mathematica
- To: mathgroup at smc.vnet.net
- Subject: [mg54724] Re: Blurring with mathematica
- From: "Steve Luttrell" <steve_usenet at _removemefirst_luttrell.org.uk>
- Date: Mon, 28 Feb 2005 03:27:11 -0500 (EST)
- References: <cvrqhi$p5c$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
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.
>