#include <averager.h>
Inheritance diagram for EMAN::MinMaxAverager:
Public Member Functions | |
MinMaxAverager () | |
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. | |
virtual void | mult (const float &) |
Multiply the result image by some floating point constant This is useful when weighting the input images prior to calling add_image - a situation where it is likely you want to divide by the sum of the weights. | |
Static Public Member Functions | |
Averager * | NEW () |
Static Public Attributes | |
const string | NAME = "minmax" |
Private Attributes | |
int | max |
int | nimg |
It optionally makes a sigma image.
max | If set, will find the max value, otherwise finds min |
Definition at line 216 of file averager.h.
|
Definition at line 311 of file averager.cpp. References max. 00312 : nimg(0) 00313 { 00314 /*move max out of initializer list, since this max(0) is considered as a macro 00315 * in Visual Studio, which we defined somewhere else*/ 00316 max = 0; 00317 }
|
|
To add an image to the Averager. This image will be averaged in this function.
Implements EMAN::Averager. Definition at line 319 of file averager.cpp. References EMAN::EMData::copy(), get_name(), EMAN::EMData::get_value_at(), EMAN::EMData::get_xsize(), EMAN::EMData::get_ysize(), EMAN::EMData::get_zsize(), EMAN::EMUtil::is_same_size(), LOGERR, max, nimg, nx, ny, EMAN::EMData::set_value_at(), x, and y. 00320 { 00321 if (!image) { 00322 return; 00323 } 00324 00325 if (nimg >= 1 && !EMUtil::is_same_size(image, result)) { 00326 LOGERR("%sAverager can only process same-size Image", 00327 get_name().c_str()); 00328 return; 00329 } 00330 00331 nimg++; 00332 00333 int nx = image->get_xsize(); 00334 int ny = image->get_ysize(); 00335 int nz = image->get_zsize(); 00336 00337 if (nimg == 1) { 00338 result = image->copy(); 00339 max = params["max"]; 00340 return; 00341 } 00342 00343 for (int z=0; z<nz; z++) { 00344 for (int y=0; y<ny; y++) { 00345 for (int x=0; x<nx; x++) { 00346 if (result->get_value_at(x,y,z)>image->get_value_at(x,y,z)) 00347 { if (!max) result->set_value_at(x,y,z,image->get_value_at(x,y,z)); } 00348 else { if (max) result->set_value_at(x,y,z,image->get_value_at(x,y,z)); } 00349 } 00350 } 00351 } 00352 00353 }
|
|
Finish up the averaging and return the result.
Implements EMAN::Averager. Definition at line 355 of file averager.cpp. References nimg, EMAN::EMData::set_attr(), and EMAN::EMData::update(). 00356 { 00357 result->update(); 00358 result->set_attr("ptcl_repr",nimg); 00359 00360 if (result && nimg > 1) return result; 00361 00362 return NULL; 00363 }
|
|
Implements EMAN::Averager. Definition at line 229 of file averager.h. 00230 { 00231 return "Finds the minimum or maximum value in each pixel"; 00232 }
|
|
Get the Averager's name. Each Averager is identified by a unique name.
Implements EMAN::Averager. Definition at line 224 of file averager.h. Referenced by add_image(). 00225 {
00226 return NAME;
00227 }
|
|
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 239 of file averager.h. References EMAN::TypeDict::put(). 00240 { 00241 TypeDict d; 00242 d.put("max", EMObject::INT, "If set, will find the max value, otherwise finds min"); 00243 return d; 00244 }
|
|
Multiply the result image by some floating point constant This is useful when weighting the input images prior to calling add_image - a situation where it is likely you want to divide by the sum of the weights. Hence call mult after all of the weighted images have been added.
Reimplemented from EMAN::Averager. Definition at line 246 of file averager.h. 00246 { }
|
|
Definition at line 234 of file averager.h. 00235 { 00236 return new MinMaxAverager(); 00237 }
|
|
Definition at line 251 of file averager.h. Referenced by add_image(), and MinMaxAverager(). |
|
Definition at line 46 of file averager.cpp. |
|
Definition at line 252 of file averager.h. Referenced by add_image(), and finish(). |