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

EMAN::MinMaxAverager Class Reference

ImageAverager averages a list of images. More...

#include <averager.h>

Inheritance diagram for EMAN::MinMaxAverager:

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

Collaboration graph
[legend]
List of all members.

Public Member Functions

 MinMaxAverager ()
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.
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

AveragerNEW ()

Static Public Attributes

const string NAME = "minmax"

Private Attributes

int max
int nimg

Detailed Description

ImageAverager averages a list of images.

It optionally makes a sigma image.

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

Definition at line 307 of file averager.h.


Constructor & Destructor Documentation

MinMaxAverager::MinMaxAverager  ) 
 

Definition at line 493 of file averager.cpp.

References max.

00494         : nimg(0)
00495 {
00496         /*move max out of initializer list, since this max(0) is considered as a macro
00497          * in Visual Studio, which we defined somewhere else*/
00498         max = 0;
00499 }


Member Function Documentation

void MinMaxAverager::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 501 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.

00502 {
00503         if (!image) {
00504                 return;
00505         }
00506 
00507         if (nimg >= 1 && !EMUtil::is_same_size(image, result)) {
00508                 LOGERR("%sAverager can only process same-size Image",
00509                            get_name().c_str());
00510                 return;
00511         }
00512 
00513         nimg++;
00514 
00515         int nx = image->get_xsize();
00516         int ny = image->get_ysize();
00517         int nz = image->get_zsize();
00518 
00519         if (nimg == 1) {
00520                 result = image->copy();
00521                 max = params["max"];
00522                 return;
00523         }
00524 
00525         for (int z=0; z<nz; z++) {
00526                 for (int y=0; y<ny; y++) {
00527                         for (int x=0; x<nx; x++) {
00528                                 if (result->get_value_at(x,y,z)>image->get_value_at(x,y,z))
00529                                         { if (!max) result->set_value_at(x,y,z,image->get_value_at(x,y,z)); }
00530                                 else { if (max) result->set_value_at(x,y,z,image->get_value_at(x,y,z)); }
00531                         }
00532                 }
00533         }
00534 
00535 }

EMData * MinMaxAverager::finish  )  [virtual]
 

Finish up the averaging and return the result.

Returns:
The averaged image.

Implements EMAN::Averager.

Definition at line 537 of file averager.cpp.

References nimg, EMAN::EMData::set_attr(), and EMAN::EMData::update().

00538 {
00539         result->update();
00540         result->set_attr("ptcl_repr",nimg);
00541         
00542         if (result && nimg > 1) return result;
00543 
00544         return NULL;
00545 }

string EMAN::MinMaxAverager::get_desc  )  const [inline, virtual]
 

Implements EMAN::Averager.

Definition at line 320 of file averager.h.

00321                 {
00322                         return "Finds the minimum or maximum value in each pixel";
00323                 }

string EMAN::MinMaxAverager::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 315 of file averager.h.

Referenced by add_image().

00316                 {
00317                         return NAME;
00318                 }

TypeDict EMAN::MinMaxAverager::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 330 of file averager.h.

References EMAN::TypeDict::put().

00331                 {
00332                         TypeDict d;
00333                         d.put("max", EMObject::INT, "If set, will find the max value, otherwise finds min");
00334                         return d;
00335                 }

virtual void EMAN::MinMaxAverager::mult const float &   )  [inline, virtual]
 

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.

Parameters:
s the scaling factor.
Exceptions:
NullPointerException if the EMData pointer (result) is NULL

Reimplemented from EMAN::Averager.

Definition at line 337 of file averager.h.

00337 { }

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

Definition at line 325 of file averager.h.

00326                 {
00327                         return new MinMaxAverager();
00328                 }


Member Data Documentation

int EMAN::MinMaxAverager::max [private]
 

Definition at line 342 of file averager.h.

Referenced by add_image(), and MinMaxAverager().

const string MinMaxAverager::NAME = "minmax" [static]
 

Definition at line 47 of file averager.cpp.

int EMAN::MinMaxAverager::nimg [private]
 

Definition at line 343 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:47:53 2013 for EMAN2 by  doxygen 1.3.9.1