[Insight-users] adding Gaussian noise to 2D image
Luis Ibanez
luis.ibanez at kitware.com
Thu Mar 12 09:44:32 EDT 2009
Hi Shoosh,
Convolving an image with a 2D Gaussian *will not* add a
Gaussian noise to the image.
On the contrary, it will reduce Noise from the image.
If what you need is to add noise to the image, what you want
to do is to use the generator of Gaussian Distributions:
Insight/Numerics/Statistics/itkGaussianDistribution.h
and do the following:
a) Iterate over all the pixels in your image
(using for example, the ImageRegionIterator)
b) For every pixel, call the method MersenerTwisterRandom
generator, in order to produce a random number from
a uniform distribution
c) Using the value from (b), pass it as argument to the
method InverseCDF() of the GaussianDistribution class.
This will convert the values from the uniform distribution
into values from a Gaussian Distribution.
d) Scale the value from (c) to the amplitude of noise that
you want to insert in your image
e) add the value from (d) to the current pixel
f) go to the next pixel.
Note that you could implement this quite easily by modifying the code
of the existing class:
itkRandomImageSource
if you insert the call to the GaussianDistribution::InverseCDF()
in lines 154 of the file
Insight/Code/BasicFilters/itkRandomImageSource.txx
You could then rename this modified filter
itkGaussianImageSource.txx
and submit it as a contribution to the Insight Journal :-)
http://wwww.insight-journal.org
so it can be included in the Toolkit later.
An alternative implementation could be like an actual
Image filter, that takes an input and produces an output.
This could be done by deriving your new filter from the
UnaryFunctorImageFilter, and packaging the random number
generator and GaussianDistribution in the Functor of that
filter.
Please let us know if you need help in implementing this filter.
Thanks
Luis
---------------------
shoosh moosh wrote:
> Hi,
> I need to add Gaussian noise to a 2D image by convolving the image with
> a Gaussian. Is this implemented as a filter in ITK? Also, is there a
> difference between Gaussian blurring and Gaussian smoothing filters.
> Thanks
>
>
>
> ------------------------------------------------------------------------
> What can you do with the new Windows Live? Find out
> <http://www.microsoft.com/windows/windowslive/default.aspx>
>
>
> ------------------------------------------------------------------------
>
> _____________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the ITK FAQ at: http://www.itk.org/Wiki/ITK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.itk.org/mailman/listinfo/insight-users
More information about the Insight-users
mailing list