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


Member Function Documentation

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

Implements EMAN::NormalizeProcessor.

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

03473 {
03474         if (!image) {
03475                 LOGWARN("NULL Image");
03476                 return 0;
03477         }
03478         EMData *mask = params["mask"];
03479 
03480         if (!EMUtil::is_same_size(mask, image)) {
03481                 LOGERR("normalize.maskProcessor: mask and image must be the same size");
03482                 throw ImageDimensionException("mask and image must be the same size");
03483         }
03484 
03485         float *data = image->get_data();
03486         float *mask_data = mask->get_data();
03487         size_t size = image->get_xsize() * image->get_ysize() * image->get_zsize();
03488         double sum = 0;
03489         size_t n_norm = 0;
03490 
03491         for (size_t i = 0; i < size; i++) {
03492                 if (mask_data[i] > 0.5f) {
03493                         sum += data[i];
03494                         n_norm++;
03495                 }
03496         }
03497 
03498         float mean = 0;
03499         if (n_norm == 0) {
03500                 mean = image->get_edge_mean();
03501         }
03502         else {
03503                 mean = (float) sum / n_norm;
03504         }
03505 
03506         return mean;
03507 }

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

Reimplemented from EMAN::NormalizeProcessor.

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

03437 {
03438         if (!image) {
03439                 LOGWARN("NULL Image");
03440                 return 0;
03441         }
03442         EMData *mask = params["mask"];
03443         int no_sigma = params["no_sigma"];
03444 
03445         if(no_sigma == 0) {
03446                 return 1;
03447         }
03448         else {
03449                 if (!EMUtil::is_same_size(mask, image)) {
03450                         LOGERR("normalize.maskProcessor: mask and image must be the same size");
03451                         throw ImageDimensionException("mask and image must be the same size");
03452                 }
03453 
03454                 float *data = image->get_data();
03455                 float *mask_data = mask->get_data();
03456                 size_t size = image->get_xsize() * image->get_ysize() * image->get_zsize();
03457                 double sum = 0;
03458                 double sq2 = 0;
03459                 size_t n_norm = 0;
03460 
03461                 for (size_t i = 0; i < size; i++) {
03462                         if (mask_data[i] > 0.5f) {
03463                                 sum += data[i];
03464                                 sq2 += data[i]*double (data[i]);
03465                                 n_norm++;
03466                         }
03467                 }
03468                 return sqrt(static_cast<float>((sq2 - sum * sum /n_norm)/(n_norm -1))) ;
03469         }
03470 }

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

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

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

References NAME.

04135                 {
04136                         return NAME;
04137                 }

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

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

04150                 {
04151                         TypeDict d;
04152                         d.put("mask", EMObject::EMDATA, "the 1/0 mask defining a region to use for the zero-normalization");
04153                         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");
04154                         return d;
04155                 }

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

Definition at line 4144 of file processor.h.

04145                 {
04146                         return new NormalizeMaskProcessor();
04147                 }


Member Data Documentation

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

Definition at line 4157 of file processor.h.

Referenced by get_name().


The documentation for this class was generated from the following files:
Generated on Tue May 25 17:37:26 2010 for EMAN2 by  doxygen 1.4.4