Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

EMAN::AddNoiseProcessor Class Reference

add noise to an image More...

#include <processor.h>

Inheritance diagram for EMAN::AddNoiseProcessor:

Inheritance graph
[legend]
Collaboration diagram for EMAN::AddNoiseProcessor:

Collaboration graph
[legend]
List of all members.

Public Member Functions

virtual void process_inplace (EMData *image)
 To process an image in-place.
virtual string get_name () const
 Get the processor's name.
virtual TypeDict get_param_types () const
 Get processor parameter information in a dictionary.
virtual string get_desc () const
 Get the descrition of this specific processor.

Static Public Member Functions

ProcessorNEW ()

Static Public Attributes

const string NAME = "math.addnoise"

Protected Member Functions

virtual float get_sigma (EMData *)

Detailed Description

add noise to an image

Parameters:
noise noise factor used to generate Gaussian distribution random noise
seed seed for random number generator

Definition at line 4472 of file processor.h.


Member Function Documentation

virtual string EMAN::AddNoiseProcessor::get_desc  )  const [inline, virtual]
 

Get the descrition of this specific processor.

This function must be overwritten by a subclass.

Returns:
The description of this processor.

Implements EMAN::Processor.

Reimplemented in EMAN::AddSigmaNoiseProcessor.

Definition at line 4495 of file processor.h.

04496                 {
04497                         return "add noise to an image, image multiply by noise then add a random value";
04498                 }

virtual string EMAN::AddNoiseProcessor::get_name  )  const [inline, virtual]
 

Get the processor's name.

Each processor is identified by a unique name.

Returns:
The processor's name.

Implements EMAN::Processor.

Reimplemented in EMAN::AddSigmaNoiseProcessor.

Definition at line 4477 of file processor.h.

04478                 {
04479                         return NAME;
04480                 }

virtual TypeDict EMAN::AddNoiseProcessor::get_param_types  )  const [inline, virtual]
 

Get processor parameter information in a dictionary.

Each parameter has one record in the dictionary. Each record contains its name, data-type, and description.

Returns:
A dictionary containing the parameter info.

Reimplemented from EMAN::Processor.

Definition at line 4487 of file processor.h.

References EMAN::TypeDict::put().

04488                 {
04489                         TypeDict d;
04490                         d.put("noise", EMObject::FLOAT, "noise factor used to generate Gaussian distribution random noise");
04491                         d.put("seed", EMObject::INT, "seed for random number generator");
04492                         return d;
04493                 }

virtual float EMAN::AddNoiseProcessor::get_sigma EMData  )  [inline, protected, virtual]
 

Reimplemented in EMAN::AddSigmaNoiseProcessor.

Definition at line 4503 of file processor.h.

Referenced by process_inplace().

04504                 {
04505                         return 1.0;
04506                 }

Processor* EMAN::AddNoiseProcessor::NEW  )  [inline, static]
 

Reimplemented in EMAN::AddSigmaNoiseProcessor.

Definition at line 4482 of file processor.h.

04483                 {
04484                         return new AddNoiseProcessor();
04485                 }

void AddNoiseProcessor::process_inplace EMData image  )  [virtual]
 

To process an image in-place.

For those processors which can only be processed out-of-place, override this function to just print out some error message to remind user call the out-of-place version.

Parameters:
image The image to be processed.

Implements EMAN::Processor.

Definition at line 4372 of file processor.cpp.

References EMAN::EMData::get_data(), EMAN::Randnum::get_gauss_rand(), get_sigma(), EMAN::EMData::get_size(), EMAN::Dict::has_key(), EMAN::Randnum::Instance(), LOGWARN, EMAN::Randnum::set_seed(), and EMAN::EMData::update().

04373 {
04374         if (!image) {
04375                 LOGWARN("NULL Image");
04376                 return;
04377         }
04378 
04379         Randnum * randnum = Randnum::Instance();
04380         if(params.has_key("seed")) {
04381                 randnum->set_seed((int)params["seed"]);
04382         }
04383 
04384         float addnoise = params["noise"];
04385         addnoise *= get_sigma(image);
04386         float *dat = image->get_data();
04387 
04388         for (size_t j = 0; j < image->get_size(); ++j) {
04389                 dat[j] += randnum->get_gauss_rand(addnoise, addnoise / 2);
04390         }
04391 
04392         image->update();
04393 }


Member Data Documentation

const string AddNoiseProcessor::NAME = "math.addnoise" [static]
 

Reimplemented in EMAN::AddSigmaNoiseProcessor.

Definition at line 156 of file processor.cpp.


The documentation for this class was generated from the following files:
Generated on Mon Mar 7 18:17:47 2011 for EMAN2 by  doxygen 1.3.9.1