#include <processor.h>
Inheritance diagram for EMAN::NormalizeMaskProcessor:


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 | |
| Processor * | NEW () |
Static Public Attributes | |
| const string | NAME = "normalize.mask" |
Protected Member Functions | |
| float | calc_sigma (EMData *image) const |
| float | calc_mean (EMData *image) const |
| 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 4134 of file processor.h.
|
|
Implements EMAN::NormalizeProcessor. Definition at line 3546 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. 03547 {
03548 if (!image) {
03549 LOGWARN("NULL Image");
03550 return 0;
03551 }
03552 EMData *mask = params["mask"];
03553
03554 if (!EMUtil::is_same_size(mask, image)) {
03555 LOGERR("normalize.maskProcessor: mask and image must be the same size");
03556 throw ImageDimensionException("mask and image must be the same size");
03557 }
03558
03559 float *data = image->get_data();
03560 float *mask_data = mask->get_data();
03561 size_t size = (size_t)image->get_xsize() * image->get_ysize() * image->get_zsize();
03562 double sum = 0;
03563 size_t n_norm = 0;
03564
03565 for (size_t i = 0; i < size; ++i) {
03566 if (mask_data[i] > 0.5f) {
03567 sum += data[i];
03568 n_norm++;
03569 }
03570 }
03571
03572 float mean = 0;
03573 if (n_norm == 0) {
03574 mean = image->get_edge_mean();
03575 }
03576 else {
03577 mean = (float) sum / n_norm;
03578 }
03579
03580 return mean;
03581 }
|
|
|
Reimplemented from EMAN::NormalizeProcessor. Definition at line 3510 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(). 03511 {
03512 if (!image) {
03513 LOGWARN("NULL Image");
03514 return 0;
03515 }
03516 EMData *mask = params["mask"];
03517 int no_sigma = params["no_sigma"];
03518
03519 if(no_sigma == 0) {
03520 return 1;
03521 }
03522 else {
03523 if (!EMUtil::is_same_size(mask, image)) {
03524 LOGERR("normalize.maskProcessor: mask and image must be the same size");
03525 throw ImageDimensionException("mask and image must be the same size");
03526 }
03527
03528 float *data = image->get_data();
03529 float *mask_data = mask->get_data();
03530 size_t size = (size_t)image->get_xsize() * image->get_ysize() * image->get_zsize();
03531 double sum = 0;
03532 double sq2 = 0;
03533 size_t n_norm = 0;
03534
03535 for (size_t i = 0; i < size; ++i) {
03536 if (mask_data[i] > 0.5f) {
03537 sum += data[i];
03538 sq2 += data[i]*double (data[i]);
03539 n_norm++;
03540 }
03541 }
03542 return sqrt(static_cast<float>((sq2 - sum * sum /n_norm)/(n_norm -1))) ;
03543 }
03544 }
|
|
|
Get the descrition of this specific processor. This function must be overwritten by a subclass.
Implements EMAN::Processor. Definition at line 4142 of file processor.h. 04143 {
04144 return "Uses a 1/0 mask defining a region to use for the zero-normalization.if no_sigma is 1, standard deviation not modified.";
04145 }
|
|
|
Get the processor's name. Each processor is identified by a unique name.
Implements EMAN::Processor. Definition at line 4137 of file processor.h. 04138 {
04139 return NAME;
04140 }
|
|
|
Get processor parameter information in a dictionary. Each parameter has one record in the dictionary. Each record contains its name, data-type, and description.
Reimplemented from EMAN::Processor. Definition at line 4152 of file processor.h. References EMAN::TypeDict::put(). 04153 {
04154 TypeDict d;
04155 d.put("mask", EMObject::EMDATA, "the 1/0 mask defining a region to use for the zero-normalization");
04156 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");
04157 return d;
04158 }
|
|
|
Definition at line 4147 of file processor.h. 04148 {
04149 return new NormalizeMaskProcessor();
04150 }
|
|
|
Definition at line 151 of file processor.cpp. |
1.3.9.1