#include <averager.h>
Inheritance diagram for EMAN::AbsMaxMinAverager:
Public Member Functions | |
AbsMaxMinAverager () | |
void | add_image (EMData *image) |
To add an image to the Averager. | |
EMData * | finish () |
Finish up the averaging and return the result. | |
string | get_name () const |
Get the Averager's name. | |
string | get_desc () const |
TypeDict | get_param_types () const |
Get Averager parameter information in a dictionary. | |
Static Public Member Functions | |
static Averager * | NEW () |
Static Public Attributes | |
static const string | NAME = "absmaxmin" |
Private Attributes | |
int | min |
int | nimg |
min | If set, will find the min value, otherwise finds max |
Definition at line 350 of file averager.h.
AbsMaxMinAverager::AbsMaxMinAverager | ( | ) |
void AbsMaxMinAverager::add_image | ( | EMData * | image | ) | [virtual] |
To add an image to the Averager.
This image will be averaged in this function.
image | The image to be averaged. |
Implements EMAN::Averager.
Definition at line 554 of file averager.cpp.
References EMAN::EMData::copy(), data, EMAN::EMData::get_data(), get_name(), EMAN::EMUtil::is_same_size(), LOGERR, min, nimg, EMAN::Averager::params, and EMAN::Averager::result.
00555 { 00556 if (!image) { 00557 return; 00558 } 00559 00560 if (nimg >= 1 && !EMUtil::is_same_size(image, result)) { 00561 LOGERR("%sAverager can only process same-size Image", 00562 get_name().c_str()); 00563 return; 00564 } 00565 00566 nimg++; 00567 00568 int nx = image->get_xsize(); 00569 int ny = image->get_ysize(); 00570 int nz = image->get_zsize(); 00571 00572 size_t imgsize = (size_t)nx*ny*nz; 00573 00574 if (nimg == 1) { 00575 result = image->copy(); 00576 min = params["min"]; 00577 return; 00578 } 00579 00580 float * data = result->get_data(); 00581 float * src_data = image->get_data(); 00582 00583 for(size_t i=0; i<imgsize; ++i) { 00584 if(!min) { //average to maximum by default 00585 if (fabs(data[i]) < fabs(src_data[i])) data[i]=src_data[i]; 00586 } 00587 else { //average to minimum if set 'min' 00588 if (fabs(data[i]) > fabs(src_data[i])) data[i]=src_data[i]; 00589 } 00590 } 00591 }
EMData * AbsMaxMinAverager::finish | ( | ) | [virtual] |
Finish up the averaging and return the result.
Implements EMAN::Averager.
Definition at line 593 of file averager.cpp.
References nimg, EMAN::Averager::result, EMAN::EMData::set_attr(), and EMAN::EMData::update().
00594 { 00595 result->update(); 00596 result->set_attr("ptcl_repr",nimg); 00597 00598 if (result && nimg > 1) return result; 00599 00600 return NULL; 00601 }
string EMAN::AbsMaxMinAverager::get_desc | ( | ) | const [inline, virtual] |
Implements EMAN::Averager.
Definition at line 363 of file averager.h.
00364 { 00365 return "Average to maximum(or minimum if set parameter 'min' to non-zero) absolute value in each pixel"; 00366 }
string EMAN::AbsMaxMinAverager::get_name | ( | ) | const [inline, virtual] |
Get the Averager's name.
Each Averager is identified by a unique name.
Implements EMAN::Averager.
Definition at line 358 of file averager.h.
References NAME.
Referenced by add_image().
00359 { 00360 return NAME; 00361 }
TypeDict EMAN::AbsMaxMinAverager::get_param_types | ( | ) | const [inline, virtual] |
Get Averager 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::Averager.
Definition at line 373 of file averager.h.
References EMAN::EMObject::INT, and EMAN::TypeDict::put().
00374 { 00375 TypeDict d; 00376 d.put("min", EMObject::INT, "If set, will average to minimum absolute value, by default average to max"); 00377 return d; 00378 }
static Averager* EMAN::AbsMaxMinAverager::NEW | ( | ) | [inline, static] |
Definition at line 368 of file averager.h.
References AbsMaxMinAverager().
00369 { 00370 return new AbsMaxMinAverager(); 00371 }
int EMAN::AbsMaxMinAverager::min [private] |
const string AbsMaxMinAverager::NAME = "absmaxmin" [static] |
int EMAN::AbsMaxMinAverager::nimg [private] |