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 4096 of file processor.h.


Member Function Documentation

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

Implements EMAN::NormalizeProcessor.

Definition at line 3518 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.

03519 {
03520         if (!image) {
03521                 LOGWARN("NULL Image");
03522                 return 0;
03523         }
03524         EMData *mask = params["mask"];
03525 
03526         if (!EMUtil::is_same_size(mask, image)) {
03527                 LOGERR("normalize.maskProcessor: mask and image must be the same size");
03528                 throw ImageDimensionException("mask and image must be the same size");
03529         }
03530 
03531         float *data = image->get_data();
03532         float *mask_data = mask->get_data();
03533         size_t size = (size_t)image->get_xsize() * image->get_ysize() * image->get_zsize();
03534         double sum = 0;
03535         size_t n_norm = 0;
03536 
03537         for (size_t i = 0; i < size; ++i) {
03538                 if (mask_data[i] > 0.5f) {
03539                         sum += data[i];
03540                         n_norm++;
03541                 }
03542         }
03543 
03544         float mean = 0;
03545         if (n_norm == 0) {
03546                 mean = image->get_edge_mean();
03547         }
03548         else {
03549                 mean = (float) sum / n_norm;
03550         }
03551 
03552         return mean;
03553 }

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

Reimplemented from EMAN::NormalizeProcessor.

Definition at line 3482 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().

03483 {
03484         if (!image) {
03485                 LOGWARN("NULL Image");
03486                 return 0;
03487         }
03488         EMData *mask = params["mask"];
03489         int no_sigma = params["no_sigma"];
03490 
03491         if(no_sigma == 0) {
03492                 return 1;
03493         }
03494         else {
03495                 if (!EMUtil::is_same_size(mask, image)) {
03496                         LOGERR("normalize.maskProcessor: mask and image must be the same size");
03497                         throw ImageDimensionException("mask and image must be the same size");
03498                 }
03499 
03500                 float *data = image->get_data();
03501                 float *mask_data = mask->get_data();
03502                 size_t size = (size_t)image->get_xsize() * image->get_ysize() * image->get_zsize();
03503                 double sum = 0;
03504                 double sq2 = 0;
03505                 size_t n_norm = 0;
03506 
03507                 for (size_t i = 0; i < size; ++i) {
03508                         if (mask_data[i] > 0.5f) {
03509                                 sum += data[i];
03510                                 sq2 += data[i]*double (data[i]);
03511                                 n_norm++;
03512                         }
03513                 }
03514                 return sqrt(static_cast<float>((sq2 - sum * sum /n_norm)/(n_norm -1))) ;
03515         }
03516 }

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 4104 of file processor.h.

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

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 4099 of file processor.h.

04100                 {
04101                         return NAME;
04102                 }

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 4114 of file processor.h.

References EMAN::TypeDict::put().

04115                 {
04116                         TypeDict d;
04117                         d.put("mask", EMObject::EMDATA, "the 1/0 mask defining a region to use for the zero-normalization");
04118                         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");
04119                         return d;
04120                 }

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

Definition at line 4109 of file processor.h.

04110                 {
04111                         return new NormalizeMaskProcessor();
04112                 }


Member Data Documentation

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

Definition at line 145 of file processor.cpp.


The documentation for this class was generated from the following files:
Generated on Mon May 2 13:30:28 2011 for EMAN2 by  doxygen 1.3.9.1