CVR-Lib last update 20 Sep 2009

cvr::noise Class Reference
[Non-linear filtering]

Class noise. More...

#include <cvrNoise.h>

Inheritance diagram for cvr::noise:

Inheritance graph
[legend]
Collaboration diagram for cvr::noise:

Collaboration graph
[legend]

List of all members.

Classes

class  parameters
 The parameters for the class noise. More...

Public Member Functions

 noise ()
 noise (const parameters &par)
 noise (const noise &other)
virtual ~noise ()
bool apply (fmatrix &srcdest) const
bool apply (dmatrix &srcdest) const
bool apply (imatrix &srcdest) const
bool apply (matrix< ubyte > &srcdest) const
bool apply (fvector &srcdest) const
bool apply (dvector &srcdest) const
bool apply (ivector &srcdest) const
bool apply (const fmatrix &src, fmatrix &dest) const
bool apply (const dmatrix &src, dmatrix &dest) const
bool apply (const imatrix &src, imatrix &dest) const
bool apply (const matrix< ubyte > &src, matrix< ubyte > &dest) const
bool apply (const fvector &src, fvector &dest) const
bool apply (const dvector &src, dvector &dest) const
bool apply (const ivector &src, ivector &dest) const
noisecopy (const noise &other)
noiseoperator= (const noise &other)
virtual const std::string & name () const
virtual noiseclone () const
virtual noisenewInstance () const
const parametersgetParameters () const
bool updateParameters ()
bool setNoiseGenerator (univariateContinuousDistribution &generator)
univariateContinuousDistributiongetNoiseGenerator ()

Protected Member Functions

parametersgetParameters ()

Protected Attributes

univariateContinuousDistributiongenerator_
uniformDiscreteDistribution uniform_


Detailed Description

Class noise.

This class is used to add noise to an image. In its default configuration gaussian white noise is added to all pixels of the image.

The random number generators provided to this class have to be continuous distributions, which means they generate floating point values. For the fixed point types, like int and ubyte, the normalization constants provided by cvr::typeInfo<T>::suggestedNorm() are multiplied to the values generated by the distribution, prior to the addition to the actual value of each matrix element.

You can indicate with the parameter coverage how much of the pixels do you want to be altered with noise, where the specific pixels chosen for modification (if less than 100%) are also taken randomly.

The following example uses noise to generate a sample image with different degrees of noise.

   #include "cvrViewer2D.h"
   #include "cvrMath.h"
   #include "cvrNoise.h"
   #include "cvrNormalDistribution.h"

   // ...

   channel chnl,chnl2,nchnl;
   viewer2D view("Original");

   noise noiser;

   // create a black background with a grey square on which a
   // white square lies.
   chnl.assign(100,100,0.0f);   // 100x100 with black
   chnl.fill(0.5f,20,20,79,79); // leave a border of 20
   chnl.fill(1.0f,40,40,59,59); // the white square

   // a large canvas to place 5x5 images like the channel just created
   chnl2.allocate(chnl.rows()*5,chnl.columns()*5);

   // use a normal distribution
   normalDistribution nd;
   normalDistribution::parameters ndp;

   for (int y=0;y<5;++y) {
     for (int x=0;x<5;++x) {
       ndp.sigma = (y*5 + x)/50.0;   // set the standard deviation
       nd.setParameters(ndp);        // into the normal distribution
       noiser.setNoiseGenerator(nd); // which has to be used

       noiser.apply(chnl,nchnl);     // add the noise

       // place the new noisy patch on the canvas
       chnl2.fill(nchnl,y*chnl.rows(),x*chnl.columns());
     }
   }

   // show the canvas
   view.show(chnl2);

See also:
noise::parameters.

Constructor & Destructor Documentation

cvr::noise::noise (  ) 

Default constructor.

cvr::noise::noise ( const parameters par  ) 

Construct a functor using the given parameters.

cvr::noise::noise ( const noise other  ) 

Copy constructor.

Parameters:
other the object to be copied

virtual cvr::noise::~noise (  )  [virtual]

Destructor.


Member Function Documentation

bool cvr::noise::apply ( const ivector src,
ivector dest 
) const

Operates on a copy of the given arguments.

Parameters:
src ivector with the source data.
dest ivector where the result will be left.
Returns:
true if apply successful or false otherwise.

bool cvr::noise::apply ( const dvector src,
dvector dest 
) const

Operates on a copy of the given arguments.

Parameters:
src dvector with the source data.
dest dvector where the result will be left.
Returns:
true if apply successful or false otherwise.

bool cvr::noise::apply ( const fvector src,
fvector dest 
) const

Operates on a copy of the given arguments.

Parameters:
src fvector with the source data.
dest fvector where the result will be left.
Returns:
true if apply successful or false otherwise.

bool cvr::noise::apply ( const matrix< ubyte > &  src,
matrix< ubyte > &  dest 
) const [virtual]

Operates on a copy of the given arguments.

Parameters:
src matrix<ubyte> with the source data.
dest matrix<ubyte> where the result will be left.
Returns:
true if apply successful or false otherwise.

Implements cvr::matrixProcessingInterface< ubyte >.

bool cvr::noise::apply ( const imatrix src,
imatrix dest 
) const

Operates on a copy of the given arguments.

Parameters:
src imatrix with the source data.
dest imatrix where the result will be left.
Returns:
true if apply successful or false otherwise.

bool cvr::noise::apply ( const dmatrix src,
dmatrix dest 
) const

Operates on a copy of the given arguments.

Parameters:
src dmatrix with the source data.
dest dmatrix where the result will be left.
Returns:
true if apply successful or false otherwise.

bool cvr::noise::apply ( const fmatrix src,
fmatrix dest 
) const [virtual]

Operates on a copy of the given arguments.

Parameters:
src fmatrix with the source data.
dest fmatrix where the result will be left.
Returns:
true if apply successful or false otherwise.

Implements cvr::matrixProcessingInterface< float >.

bool cvr::noise::apply ( ivector srcdest  )  const

Operates on the given argument.

Parameters:
srcdest ivector with the source data. The result will be left here too.
Returns:
true if apply successful or false otherwise.

bool cvr::noise::apply ( dvector srcdest  )  const

Operates on the given argument.

Parameters:
srcdest dvector with the source data. The result will be left here too.
Returns:
true if apply successful or false otherwise.

bool cvr::noise::apply ( fvector srcdest  )  const

Operates on the given argument.

Parameters:
srcdest fvector with the source data. The result will be left here too.
Returns:
true if apply successful or false otherwise.

bool cvr::noise::apply ( matrix< ubyte > &  srcdest  )  const [virtual]

Operates on the given argument.

Parameters:
srcdest matrix<ubyte> with the source data. The result will be left here too.
Returns:
true if apply successful or false otherwise.

Implements cvr::matrixProcessingInterface< ubyte >.

bool cvr::noise::apply ( imatrix srcdest  )  const

Operates on the given argument.

Parameters:
srcdest imatrix with the source data. The result will be left here too.
Returns:
true if apply successful or false otherwise.

bool cvr::noise::apply ( dmatrix srcdest  )  const

Operates on the given argument.

Parameters:
srcdest dmatrix with the source data. The result will be left here too.
Returns:
true if apply successful or false otherwise.

bool cvr::noise::apply ( fmatrix srcdest  )  const [virtual]

Operates on the given argument.

Parameters:
srcdest fmatrix with the source data. The result will be left here too.
Returns:
true if apply successful or false otherwise.

Implements cvr::matrixProcessingInterface< float >.

virtual noise* cvr::noise::clone (  )  const [virtual]

Returns a pointer to a clone of this functor.

Implements cvr::functor.

noise& cvr::noise::copy ( const noise other  ) 

Copy data of "other" functor.

Parameters:
other the functor to be copied
Returns:
a reference to this functor object

univariateContinuousDistribution* cvr::noise::getNoiseGenerator (  ) 

Get the random number generator to be used.

The default value is a normalDistribution with zero mean and a standard deviation of 0.25.

parameters& cvr::noise::getParameters (  )  [protected]

Returns used parameters.

Reimplemented from cvr::parametersManager.

const parameters& cvr::noise::getParameters (  )  const

Returns used parameters.

Reimplemented from cvr::parametersManager.

virtual const std::string& cvr::noise::name (  )  const [virtual]

Returns the complete name of the functor class.

Implements cvr::functor.

virtual noise* cvr::noise::newInstance (  )  const [virtual]

Returns a pointer to a new instance of this functor.

Implements cvr::functor.

noise& cvr::noise::operator= ( const noise other  ) 

Alias for copy member.

Parameters:
other the functor to be copied
Returns:
a reference to this functor object

bool cvr::noise::setNoiseGenerator ( univariateContinuousDistribution generator  ) 

Set the random number generator to be used.

bool cvr::noise::updateParameters (  )  [virtual]

Update parameters when new set is given.

Reimplemented from cvr::parametersManager.


Member Data Documentation

The noise generator.

The generator for the coordinates.


The documentation for this class was generated from the following file:

Generated on Sun Sep 20 22:09:00 2009 for CVR-Lib by Doxygen 1.5.8