#include <processor.h>
Inheritance diagram for EMAN::AddNoiseProcessor:
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 | |
static Processor * | NEW () |
Static Public Attributes | |
static const string | NAME = "math.addnoise" |
Protected Member Functions | |
virtual float | get_sigma (EMData *) |
noise | noise factor used to generate Gaussian distribution random noise | |
seed | seed for random number generator |
Definition at line 4644 of file processor.h.
virtual string EMAN::AddNoiseProcessor::get_desc | ( | ) | const [inline, virtual] |
Get the descrition of this specific processor.
This function must be overwritten by a subclass.
Implements EMAN::Processor.
Reimplemented in EMAN::AddSigmaNoiseProcessor.
Definition at line 4667 of file processor.h.
04668 { 04669 return "add noise to an image, image multiply by noise then add a random value"; 04670 }
virtual string EMAN::AddNoiseProcessor::get_name | ( | ) | const [inline, virtual] |
Get the processor's name.
Each processor is identified by a unique name.
Implements EMAN::Processor.
Reimplemented in EMAN::AddSigmaNoiseProcessor.
Definition at line 4649 of file processor.h.
References NAME.
04650 { 04651 return NAME; 04652 }
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.
Reimplemented from EMAN::Processor.
Definition at line 4659 of file processor.h.
References EMAN::EMObject::FLOAT, EMAN::EMObject::INT, and EMAN::TypeDict::put().
04660 { 04661 TypeDict d; 04662 d.put("noise", EMObject::FLOAT, "noise factor used to generate Gaussian distribution random noise"); 04663 d.put("seed", EMObject::INT, "seed for random number generator"); 04664 return d; 04665 }
virtual float EMAN::AddNoiseProcessor::get_sigma | ( | EMData * | ) | [inline, protected, virtual] |
Reimplemented in EMAN::AddSigmaNoiseProcessor.
Definition at line 4675 of file processor.h.
Referenced by process_inplace().
static Processor* EMAN::AddNoiseProcessor::NEW | ( | ) | [inline, static] |
Reimplemented in EMAN::AddSigmaNoiseProcessor.
Definition at line 4654 of file processor.h.
04655 { 04656 return new AddNoiseProcessor(); 04657 }
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.
image | The image to be processed. |
Implements EMAN::Processor.
Definition at line 4491 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::Processor::params, EMAN::Randnum::set_seed(), and EMAN::EMData::update().
04492 { 04493 if (!image) { 04494 LOGWARN("NULL Image"); 04495 return; 04496 } 04497 04498 Randnum * randnum = Randnum::Instance(); 04499 if(params.has_key("seed")) { 04500 randnum->set_seed((int)params["seed"]); 04501 } 04502 04503 float addnoise = params["noise"]; 04504 addnoise *= get_sigma(image); 04505 float *dat = image->get_data(); 04506 04507 for (size_t j = 0; j < image->get_size(); ++j) { 04508 dat[j] += randnum->get_gauss_rand(addnoise, addnoise / 2); 04509 } 04510 04511 image->update(); 04512 }
const string AddNoiseProcessor::NAME = "math.addnoise" [static] |
Reimplemented in EMAN::AddSigmaNoiseProcessor.
Definition at line 4672 of file processor.h.
Referenced by get_name().