#include <processor.h>
Inheritance diagram for EMAN::NormalizeProcessor:
Public Member Functions | |
void | process_inplace (EMData *image) |
To process an image in-place. | |
Static Public Member Functions | |
static string | get_group_desc () |
Get the description of this group of processors. | |
Protected Member Functions | |
virtual float | calc_sigma (EMData *image) const |
virtual float | calc_mean (EMData *image) const =0 |
Each specific normalization processor needs to define how to calculate mean and how to calculate sigma.
Definition at line 3936 of file processor.h.
virtual float EMAN::NormalizeProcessor::calc_mean | ( | EMData * | image | ) | const [protected, pure virtual] |
Implemented in EMAN::NormalizeUnitProcessor, EMAN::NormalizeUnitSumProcessor, EMAN::NormalizeStdProcessor, EMAN::NormalizeMaskProcessor, EMAN::NormalizeEdgeMeanProcessor, EMAN::NormalizeCircleMeanProcessor, EMAN::NormalizeLREdgeMeanProcessor, and EMAN::NormalizeMaxMinProcessor.
Referenced by process_inplace().
float NormalizeProcessor::calc_sigma | ( | EMData * | image | ) | const [protected, virtual] |
Reimplemented in EMAN::NormalizeUnitProcessor, EMAN::NormalizeUnitSumProcessor, EMAN::NormalizeMaskProcessor, and EMAN::NormalizeMaxMinProcessor.
Definition at line 3396 of file processor.cpp.
References EMAN::EMData::get_attr().
Referenced by process_inplace().
03397 { 03398 return image->get_attr("sigma"); 03399 }
static string EMAN::NormalizeProcessor::get_group_desc | ( | ) | [inline, static] |
Get the description of this group of processors.
This function is defined in a parent class. It gives a introduction to a group of processors.
Reimplemented from EMAN::Processor.
Definition at line 3941 of file processor.h.
03942 { 03943 return "Base class for normalization processors. Each specific normalization processor needs to define how to calculate mean and how to calculate sigma."; 03944 }
void NormalizeProcessor::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 3401 of file processor.cpp.
References calc_mean(), calc_sigma(), EMAN::EMData::get_data(), EMAN::EMData::get_xsize(), EMAN::EMData::get_ysize(), EMAN::EMData::get_zsize(), EMAN::Util::goodf(), EMAN::EMData::is_complex(), LOGWARN, mean(), and EMAN::EMData::update().
03402 { 03403 if (!image) { 03404 LOGWARN("cannot do normalization on NULL image"); 03405 return; 03406 } 03407 03408 if (image->is_complex()) { 03409 LOGWARN("cannot do normalization on complex image"); 03410 return; 03411 } 03412 03413 float sigma = calc_sigma(image); 03414 if (sigma == 0 || !Util::goodf(&sigma)) { 03415 LOGWARN("cannot do normalization on image with sigma = 0"); 03416 return; 03417 } 03418 03419 float mean = calc_mean(image); 03420 03421 size_t size = (size_t)image->get_xsize() * image->get_ysize() * image->get_zsize(); 03422 float *data = image->get_data(); 03423 03424 for (size_t i = 0; i < size; ++i) { 03425 data[i] = (data[i] - mean) / sigma; 03426 } 03427 03428 image->update(); 03429 }