[Insight-users] Additive noise generator

Miller, James V (Research) millerjv at crd.ge.com
Mon Oct 4 10:26:52 EDT 2004


Gavin, 

First a few style issues. The "generator" variable in the
NormalVariateNoiseFunctor should be called m_Generator.  ITK style
guidelines
are to preface instance variables with "m_".  ITK style guidelines also
require method calls be prefaced with "this->".  So the constructor to the 
Functor should call this->SetSeed() instead of calling just SetSeed().

Now for a question on the formula for adding noise.  Your functions is 

	out = (float)input + m_Alpha * mid * generator->GetVariate() 

where "mid" is the middle of the "dynamic range".  Note that you use
NumericTraits<>::min() to determine the lower end of the dynamic range. 
NumericTraits<>::min() may not be what you want.  

	NumericTraits<float>::min() = 1.175494351e-38F   /* min positive
value */
	NumericTraits<short>::min() = -32768
	NumericTraits<unsigned short>::min = 0


Would it be cleaner just to allow the user to specify the mean and standard
deviation of the noise?  The mean could default to zero.  The standard
deviation
could default to one.

out = (float) input + m_Mean +
m_StandardDeviation*m_Generator->GetVariate();

Also, the c-style casts should probably be static_cast<>'s


Jim



-----Original Message-----
From: Gavin Baker [mailto:gavinb+xtk at cs.mu.OZ.AU]
Sent: Monday, October 04, 2004 1:34 AM
To: Insight Users
Subject: [Insight-users] Additive noise generator



Hello,

I've written a little ImageToImageFilter that I call
AdditiveGaussianNoiseImageFilter, which uses a gausian normal variate
generator to add noise to an image.

Just take your clean input image, plug this fella into your pipeline, and -
voila! - an image as noisy as your Mom will let you.

This is particularly useful for testing filters and so on.  You can set the
alpha parameter to adjust the noise strength, and specify the seed to ensure
deterministic/repeatable testing.

Can someone please have a look over it and send me some feedback.  It is a
pretty simple class, but probably needs some cleanup.  I'm not sure if it is
structured the best, being a derivative of ImageToImageFilter and nesting
the functor.  If it is any use, I would like to contribute it.

Cheerio -

  :: Gavin

-- 
Gavin Baker                                      Complex Systems Group
http://www.cs.mu.oz.au/~gavinb             The University of Melbourne


More information about the Insight-users mailing list