#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 | |
Averager * | NEW () |
Static Public Attributes | |
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.
|
Definition at line 468 of file averager.cpp. References min. 00468 : nimg(0) 00469 { 00470 /*move max out of initializer list, since this max(0) is considered as a macro 00471 * in Visual Studio, which we defined somewhere else*/ 00472 min = 0; 00473 }
|
|
To add an image to the Averager. This image will be averaged in this function.
Implements EMAN::Averager. Definition at line 475 of file averager.cpp. References EMAN::EMData::copy(), data, EMAN::EMData::get_data(), get_name(), EMAN::EMData::get_xsize(), EMAN::EMData::get_ysize(), EMAN::EMData::get_zsize(), EMAN::EMUtil::is_same_size(), LOGERR, min, nimg, nx, and ny. 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 }
|
|
Finish up the averaging and return the result.
Implements EMAN::Averager. Definition at line 514 of file averager.cpp. References nimg, 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 }
|
|
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 }
|
|
Get the Averager's name. Each Averager is identified by a unique name.
Implements EMAN::Averager. Definition at line 312 of file averager.h. Referenced by add_image(). 00313 {
00314 return NAME;
00315 }
|
|
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::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 }
|
|
Definition at line 322 of file averager.h. 00323 { 00324 return new AbsMaxMinAverager(); 00325 }
|
|
Definition at line 337 of file averager.h. Referenced by AbsMaxMinAverager(), and add_image(). |
|
Definition at line 48 of file averager.cpp. |
|
Definition at line 338 of file averager.h. Referenced by add_image(), and finish(). |