Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

EMAN::AbsMaxMinAverager Class Reference

AbsMaxMinAverager averages a list of images to the maximum(or minimum of the absolute pixel value) It optionally makes a sigma image. More...

#include <averager.h>

Inheritance diagram for EMAN::AbsMaxMinAverager:

Inheritance graph
[legend]
Collaboration diagram for EMAN::AbsMaxMinAverager:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 AbsMaxMinAverager ()
void add_image (EMData *image)
 To add an image to the Averager.
EMDatafinish ()
 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

AveragerNEW ()

Static Public Attributes

const string NAME = "absmaxmin"

Private Attributes

int min
int nimg

Detailed Description

AbsMaxMinAverager averages a list of images to the maximum(or minimum of the absolute pixel value) It optionally makes a sigma image.

Parameters:
min If set, will find the min value, otherwise finds max

Definition at line 350 of file averager.h.


Constructor & Destructor Documentation

AbsMaxMinAverager::AbsMaxMinAverager  ) 
 

Definition at line 547 of file averager.cpp.

References min.

00547                                      : nimg(0)
00548 {
00549         /*move max out of initializer list, since this max(0) is considered as a macro
00550          * in Visual Studio, which we defined somewhere else*/
00551         min = 0;
00552 }


Member Function Documentation

void AbsMaxMinAverager::add_image EMData image  )  [virtual]
 

To add an image to the Averager.

This image will be averaged in this function.

Parameters:
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::EMData::get_xsize(), EMAN::EMData::get_ysize(), EMAN::EMData::get_zsize(), EMAN::EMUtil::is_same_size(), LOGERR, min, nimg, nx, and ny.

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.

Returns:
The averaged image.

Implements EMAN::Averager.

Definition at line 593 of file averager.cpp.

References nimg, 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.

Returns:
The Averager's name.

Implements EMAN::Averager.

Definition at line 358 of file averager.h.

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.

Returns:
A dictionary containing the parameter info.

Reimplemented from EMAN::Averager.

Definition at line 373 of file averager.h.

References 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                 }

Averager* EMAN::AbsMaxMinAverager::NEW  )  [inline, static]
 

Definition at line 368 of file averager.h.

00369                 {
00370                         return new AbsMaxMinAverager();
00371                 }


Member Data Documentation

int EMAN::AbsMaxMinAverager::min [private]
 

Definition at line 383 of file averager.h.

Referenced by AbsMaxMinAverager(), and add_image().

const string AbsMaxMinAverager::NAME = "absmaxmin" [static]
 

Definition at line 48 of file averager.cpp.

int EMAN::AbsMaxMinAverager::nimg [private]
 

Definition at line 384 of file averager.h.

Referenced by add_image(), and finish().


The documentation for this class was generated from the following files:
Generated on Tue Jun 11 13:41:54 2013 for EMAN2 by  doxygen 1.3.9.1