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 304 of file averager.h.


Constructor & Destructor Documentation

AbsMaxMinAverager::AbsMaxMinAverager  ) 
 

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 }


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

EMData * AbsMaxMinAverager::finish  )  [virtual]
 

Finish up the averaging and return the result.

Returns:
The averaged image.

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 }

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.

Returns:
The Averager's name.

Implements EMAN::Averager.

Definition at line 312 of file averager.h.

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.

Returns:
A dictionary containing the parameter info.

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                 }

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

Definition at line 322 of file averager.h.

00323                 {
00324                         return new AbsMaxMinAverager();
00325                 }


Member Data Documentation

int EMAN::AbsMaxMinAverager::min [private]
 

Definition at line 337 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 338 of file averager.h.

Referenced by add_image(), and finish().


The documentation for this class was generated from the following files:
Generated on Fri Aug 10 16:36:52 2012 for EMAN2 by  doxygen 1.3.9.1