#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 304 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 475 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.
00476 { 00477 if (!image) { 00478 return; 00479 } 00480 00481 if (nimg >= 1 && !EMUtil::is_same_size(image, result)) { 00482 LOGERR("%sAverager can only process same-size Image", 00483 get_name().c_str()); 00484 return; 00485 } 00486 00487 nimg++; 00488 00489 int nx = image->get_xsize(); 00490 int ny = image->get_ysize(); 00491 int nz = image->get_zsize(); 00492 00493 size_t imgsize = (size_t)nx*ny*nz; 00494 00495 if (nimg == 1) { 00496 result = image->copy(); 00497 min = params["min"]; 00498 return; 00499 } 00500 00501 float * data = result->get_data(); 00502 float * src_data = image->get_data(); 00503 00504 for(size_t i=0; i<imgsize; ++i) { 00505 if(!min) { //average to maximum by default 00506 if (fabs(data[i]) < fabs(src_data[i])) data[i]=src_data[i]; 00507 } 00508 else { //average to minimum if set 'min' 00509 if (fabs(data[i]) > fabs(src_data[i])) data[i]=src_data[i]; 00510 } 00511 } 00512 }
EMData * AbsMaxMinAverager::finish | ( | ) | [virtual] |
Finish up the averaging and return the result.
Implements EMAN::Averager.
Definition at line 514 of file averager.cpp.
References nimg, EMAN::Averager::result, EMAN::EMData::set_attr(), and EMAN::EMData::update().
00515 { 00516 result->update(); 00517 result->set_attr("ptcl_repr",nimg); 00518 00519 if (result && nimg > 1) return result; 00520 00521 return NULL; 00522 }
string EMAN::AbsMaxMinAverager::get_desc | ( | ) | const [inline, virtual] |
Implements EMAN::Averager.
Definition at line 317 of file averager.h.
00318 { 00319 return "Average to maximum(or minimum if set parameter 'min' to non-zero) absolute value in each pixel"; 00320 }
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 312 of file averager.h.
References NAME.
Referenced by add_image().
00313 { 00314 return NAME; 00315 }
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 327 of file averager.h.
References EMAN::EMObject::INT, and EMAN::TypeDict::put().
00328 { 00329 TypeDict d; 00330 d.put("min", EMObject::INT, "If set, will average to minimum absolute value, by default average to max"); 00331 return d; 00332 }
static Averager* EMAN::AbsMaxMinAverager::NEW | ( | ) | [inline, static] |
Definition at line 322 of file averager.h.
References AbsMaxMinAverager().
00323 { 00324 return new AbsMaxMinAverager(); 00325 }
int EMAN::AbsMaxMinAverager::min [private] |
const string AbsMaxMinAverager::NAME = "absmaxmin" [static] |
int EMAN::AbsMaxMinAverager::nimg [private] |