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

static ProcessorNEW ()

Static Public Attributes

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


Member Function Documentation

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

Implements EMAN::NormalizeProcessor.

Definition at line 3579 of file processor.cpp.

References 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, LOGWARN, and EMAN::Processor::params.

03580 {
03581         if (!image) {
03582                 LOGWARN("NULL Image");
03583                 return 0;
03584         }
03585         EMData *mask = params["mask"];
03586 
03587         if (!EMUtil::is_same_size(mask, image)) {
03588                 LOGERR("normalize.maskProcessor: mask and image must be the same size");
03589                 throw ImageDimensionException("mask and image must be the same size");
03590         }
03591 
03592         float *data = image->get_data();
03593         float *mask_data = mask->get_data();
03594         size_t size = image->get_xsize() * image->get_ysize() * image->get_zsize();
03595         double sum = 0;
03596         size_t n_norm = 0;
03597 
03598         for (size_t i = 0; i < size; i++) {
03599                 if (mask_data[i] > 0.5f) {
03600                         sum += data[i];
03601                         n_norm++;
03602                 }
03603         }
03604 
03605         float mean = 0;
03606         if (n_norm == 0) {
03607                 mean = image->get_edge_mean();
03608         }
03609         else {
03610                 mean = (float) sum / n_norm;
03611         }
03612 
03613         return mean;
03614 }

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

Reimplemented from EMAN::NormalizeProcessor.

Definition at line 3543 of file processor.cpp.

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

03544 {
03545         if (!image) {
03546                 LOGWARN("NULL Image");
03547                 return 0;
03548         }
03549         EMData *mask = params["mask"];
03550         int no_sigma = params["no_sigma"];
03551 
03552         if(no_sigma == 0) {
03553                 return 1;
03554         }
03555         else {
03556                 if (!EMUtil::is_same_size(mask, image)) {
03557                         LOGERR("normalize.maskProcessor: mask and image must be the same size");
03558                         throw ImageDimensionException("mask and image must be the same size");
03559                 }
03560 
03561                 float *data = image->get_data();
03562                 float *mask_data = mask->get_data();
03563                 size_t size = image->get_xsize() * image->get_ysize() * image->get_zsize();
03564                 double sum = 0;
03565                 double sq2 = 0;
03566                 size_t n_norm = 0;
03567 
03568                 for (size_t i = 0; i < size; i++) {
03569                         if (mask_data[i] > 0.5f) {
03570                                 sum += data[i];
03571                                 sq2 += data[i]*double (data[i]);
03572                                 n_norm++;
03573                         }
03574                 }
03575                 return sqrt(static_cast<float>((sq2 - sum * sum /n_norm)/(n_norm -1))) ;
03576         }
03577 }

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

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

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

References NAME.

04175                 {
04176                         return NAME;
04177                 }

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

References EMAN::EMObject::EMDATA, EMAN::EMObject::INT, and EMAN::TypeDict::put().

04190                 {
04191                         TypeDict d;
04192                         d.put("mask", EMObject::EMDATA, "the 1/0 mask defining a region to use for the zero-normalization");
04193                         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");
04194                         return d;
04195                 }

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

Definition at line 4184 of file processor.h.

04185                 {
04186                         return new NormalizeMaskProcessor();
04187                 }


Member Data Documentation

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

Definition at line 4197 of file processor.h.

Referenced by get_name().


The documentation for this class was generated from the following files:
Generated on Mon Jul 19 13:07:01 2010 for EMAN2 by  doxygen 1.4.4