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

EMAN::NormalizeMaskProcessor Class Reference

Uses a 1/0 mask defining a region to use for the zero-normalization.if no_sigma is 1, standard deviation not modified. More...

#include <processor.h>

Inheritance diagram for EMAN::NormalizeMaskProcessor:

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

Collaboration graph
[legend]
List of all members.

Public Member Functions

string get_name () const
 Get the processor's name.
string get_desc () const
 Get the descrition of this specific processor.
TypeDict get_param_types () const
 Get processor parameter information in a dictionary.

Static Public Member Functions

ProcessorNEW ()

Static Public Attributes

const string NAME = "normalize.mask"

Protected Member Functions

float calc_sigma (EMData *image) const
float calc_mean (EMData *image) const

Detailed Description

Uses a 1/0 mask defining a region to use for the zero-normalization.if no_sigma is 1, standard deviation not modified.

Parameters:
mask the 1/0 mask defining a region to use for the zero-normalization
no_sigma if this flag is zero, only average under the mask will be substracted. set this flag to 1, standard deviation not modified

Definition at line 4210 of file processor.h.


Member Function Documentation

float NormalizeMaskProcessor::calc_mean EMData image  )  const [protected, virtual]
 

Implements EMAN::NormalizeProcessor.

Definition at line 3641 of file processor.cpp.

References data, EMAN::EMData::get_data(), EMAN::EMData::get_edge_mean(), EMAN::EMData::get_xsize(), EMAN::EMData::get_ysize(), EMAN::EMData::get_zsize(), ImageDimensionException, EMAN::EMUtil::is_same_size(), LOGERR, and LOGWARN.

03642 {
03643         if (!image) {
03644                 LOGWARN("NULL Image");
03645                 return 0;
03646         }
03647         EMData *mask = params["mask"];
03648 
03649         if (!EMUtil::is_same_size(mask, image)) {
03650                 LOGERR("normalize.maskProcessor: mask and image must be the same size");
03651                 throw ImageDimensionException("mask and image must be the same size");
03652         }
03653 
03654         float *data = image->get_data();
03655         float *mask_data = mask->get_data();
03656         size_t size = (size_t)image->get_xsize() * image->get_ysize() * image->get_zsize();
03657         double sum = 0;
03658         size_t n_norm = 0;
03659 
03660         for (size_t i = 0; i < size; ++i) {
03661                 if (mask_data[i] > 0.5f) {
03662                         sum += data[i];
03663                         n_norm++;
03664                 }
03665         }
03666 
03667         float mean = 0;
03668         if (n_norm == 0) {
03669                 mean = image->get_edge_mean();
03670         }
03671         else {
03672                 mean = (float) sum / n_norm;
03673         }
03674 
03675         return mean;
03676 }

float NormalizeMaskProcessor::calc_sigma EMData image  )  const [protected, virtual]
 

Reimplemented from EMAN::NormalizeProcessor.

Definition at line 3605 of file processor.cpp.

References data, EMAN::EMData::get_data(), EMAN::EMData::get_xsize(), EMAN::EMData::get_ysize(), EMAN::EMData::get_zsize(), ImageDimensionException, EMAN::EMUtil::is_same_size(), LOGERR, LOGWARN, and sqrt().

03606 {
03607         if (!image) {
03608                 LOGWARN("NULL Image");
03609                 return 0;
03610         }
03611         EMData *mask = params["mask"];
03612         int no_sigma = params["no_sigma"];
03613 
03614         if(no_sigma == 0) {
03615                 return 1;
03616         }
03617         else {
03618                 if (!EMUtil::is_same_size(mask, image)) {
03619                         LOGERR("normalize.maskProcessor: mask and image must be the same size");
03620                         throw ImageDimensionException("mask and image must be the same size");
03621                 }
03622 
03623                 float *data = image->get_data();
03624                 float *mask_data = mask->get_data();
03625                 size_t size = (size_t)image->get_xsize() * image->get_ysize() * image->get_zsize();
03626                 double sum = 0;
03627                 double sq2 = 0;
03628                 size_t n_norm = 0;
03629 
03630                 for (size_t i = 0; i < size; ++i) {
03631                         if (mask_data[i] > 0.5f) {
03632                                 sum += data[i];
03633                                 sq2 += data[i]*double (data[i]);
03634                                 n_norm++;
03635                         }
03636                 }
03637                 return sqrt(static_cast<float>((sq2 - sum * sum /n_norm)/(n_norm -1))) ;
03638         }
03639 }

string EMAN::NormalizeMaskProcessor::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.

Definition at line 4218 of file processor.h.

04219                 {
04220                         return "Uses a 1/0 mask defining a region to use for the zero-normalization.if no_sigma is 1, standard deviation not modified.";
04221                 }

string EMAN::NormalizeMaskProcessor::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.

Definition at line 4213 of file processor.h.

04214                 {
04215                         return NAME;
04216                 }

TypeDict EMAN::NormalizeMaskProcessor::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 4228 of file processor.h.

References EMAN::TypeDict::put().

04229                 {
04230                         TypeDict d;
04231                         d.put("mask", EMObject::EMDATA, "the 1/0 mask defining a region to use for the zero-normalization");
04232                         d.put("no_sigma", EMObject::INT, "if this flag is zero, only average under the mask will be substracted. set this flag to 1, standard deviation not modified");
04233                         return d;
04234                 }

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

Definition at line 4223 of file processor.h.

04224                 {
04225                         return new NormalizeMaskProcessor();
04226                 }


Member Data Documentation

const string NormalizeMaskProcessor::NAME = "normalize.mask" [static]
 

Definition at line 146 of file processor.cpp.


The documentation for this class was generated from the following files:
Generated on Fri Aug 10 16:37:52 2012 for EMAN2 by  doxygen 1.3.9.1