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


Member Function Documentation

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

Implements EMAN::NormalizeProcessor.

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

03488 {
03489         if (!image) {
03490                 LOGWARN("NULL Image");
03491                 return 0;
03492         }
03493         EMData *mask = params["mask"];
03494 
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         size_t n_norm = 0;
03505 
03506         for (size_t i = 0; i < size; ++i) {
03507                 if (mask_data[i] > 0.5f) {
03508                         sum += data[i];
03509                         n_norm++;
03510                 }
03511         }
03512 
03513         float mean = 0;
03514         if (n_norm == 0) {
03515                 mean = image->get_edge_mean();
03516         }
03517         else {
03518                 mean = (float) sum / n_norm;
03519         }
03520 
03521         return mean;
03522 }

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

Reimplemented from EMAN::NormalizeProcessor.

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

03452 {
03453         if (!image) {
03454                 LOGWARN("NULL Image");
03455                 return 0;
03456         }
03457         EMData *mask = params["mask"];
03458         int no_sigma = params["no_sigma"];
03459 
03460         if(no_sigma == 0) {
03461                 return 1;
03462         }
03463         else {
03464                 if (!EMUtil::is_same_size(mask, image)) {
03465                         LOGERR("normalize.maskProcessor: mask and image must be the same size");
03466                         throw ImageDimensionException("mask and image must be the same size");
03467                 }
03468 
03469                 float *data = image->get_data();
03470                 float *mask_data = mask->get_data();
03471                 size_t size = (size_t)image->get_xsize() * image->get_ysize() * image->get_zsize();
03472                 double sum = 0;
03473                 double sq2 = 0;
03474                 size_t n_norm = 0;
03475 
03476                 for (size_t i = 0; i < size; ++i) {
03477                         if (mask_data[i] > 0.5f) {
03478                                 sum += data[i];
03479                                 sq2 += data[i]*double (data[i]);
03480                                 n_norm++;
03481                         }
03482                 }
03483                 return sqrt(static_cast<float>((sq2 - sum * sum /n_norm)/(n_norm -1))) ;
03484         }
03485 }

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

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

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

04044                 {
04045                         return NAME;
04046                 }

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

References EMAN::TypeDict::put().

04059                 {
04060                         TypeDict d;
04061                         d.put("mask", EMObject::EMDATA, "the 1/0 mask defining a region to use for the zero-normalization");
04062                         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");
04063                         return d;
04064                 }

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

Definition at line 4053 of file processor.h.

04054                 {
04055                         return new NormalizeMaskProcessor();
04056                 }


Member Data Documentation

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

Definition at line 143 of file processor.cpp.


The documentation for this class was generated from the following files:
Generated on Mon Mar 7 18:17:42 2011 for EMAN2 by  doxygen 1.3.9.1