Services & Resources / Wolfram Forums
MathGroup Archive
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2005

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

Search the Archive

Re: Blurring with mathematica

  • To: mathgroup at
  • Subject: [mg54866] Re: Blurring with mathematica
  • From: "Steve Luttrell" <steve_usenet at>
  • Date: Fri, 4 Mar 2005 05:08:02 -0500 (EST)
  • References: <d060i3$ko6$>
  • Sender: owner-wri-mathgroup at

Your questions show that you are not having problems with Mathematica as 
such, but with basic mathematics itself. Maybe it would be a good idea to do 
some background reading.

Here are the answers to your questions anyway:

1) If you want to normalise the blurring kernel then use

(1/(2*Pi*sdev^2))*Exp[-((i^2 + j^2)/(2*sdev^2))]

There is a factor of 1/Sqrt[2 Pi sdev^2] for each of the 2 dimensions.

You can verify this is correct by integrating over the continuous-valued 
versions of i and j

Integrate[(1/(2*Pi*sdev^2))*Exp[-((i^2 + j^2)/(2*sdev^2))],
 {i, -Infinity, Infinity}, {j, -Infinity, Infinity},
  Assumptions -> Re[sdev^2] > 0]

to obtain 1.

However, the computations you want to do are over a discrete 2-dimensional 
grid, so if you want to normalise then you should make the appropriate 
changes (i.e use sums rather than integrals). Also have a look at my 
response to question (2) for the general approach to computing a 
normalisation factor.

2) The precise meaning of your question is not clear. However, it appears 
that you want to normalise a kernel so that its integral (or sum) over some 
domain is unity. The normalisation factor to put in the denominator is thus 
the integral (or sum) of the kernel that you started with, and which thus 
acts to cancel whatever (wrong) norm you had in the first place.

Steve Luttrell

<V.Marinakis at> wrote in message 
news:d060i3$ko6$1 at
> Dear all,
> I have some questions regarding the following email:
> 1) Shouldn't it be the factor (1/Sqrt[2 Pi sdev^2]) in the kernel?
> 2) What should I change in order to normalise the gaussian to an interval
> of 1;
> Best, Vangelis Marinakis.
> --------------------------------------------------------------------
> 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@[EMAIL PROTECTED]
>> wrote in message
> news:cvrqhi$p5c$1@[EMAIL PROTECTED]
>> 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: Precise bitmaps
  • Next by Date: Re: Rearranging a data array containing calendrical as well as data entries.
  • Previous by thread: Blurring with mathematica
  • Next by thread: Re: Notebook 'suddenly' does not talk to Kernel