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

static AveragerNEW ()

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


Constructor & Destructor Documentation

MinMaxAverager::MinMaxAverager (  ) 

Definition at line 297 of file averager.cpp.

References max.

Referenced by NEW().

00298         : nimg(0)
00299 {
00300         /*move max out of initializer list, since this max(0) is considered as a macro
00301          * in Visual Studio, which we defined somewhere else*/
00302         max = 0;
00303 }


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 305 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, EMAN::Averager::params, EMAN::EMData::set_value_at(), x, and y.

00306 {
00307         if (!image) {
00308                 return;
00309         }
00310 
00311         if (nimg >= 1 && !EMUtil::is_same_size(image, result)) {
00312                 LOGERR("%sAverager can only process same-size Image",
00313                            get_name().c_str());
00314                 return;
00315         }
00316 
00317         nimg++;
00318 
00319         int nx = image->get_xsize();
00320         int ny = image->get_ysize();
00321         int nz = image->get_zsize();
00322 
00323         if (nimg == 1) {
00324                 result = image->copy();
00325                 max = params["max"];
00326                 return;
00327         }
00328 
00329         for (int z=0; z<nz; z++) {
00330                 for (int y=0; y<ny; y++) {
00331                         for (int x=0; x<nx; x++) {
00332                                 if (result->get_value_at(x,y,z)>image->get_value_at(x,y,z))
00333                                         { if (!max) result->set_value_at(x,y,z,image->get_value_at(x,y,z)); }
00334                                 else { if (max) result->set_value_at(x,y,z,image->get_value_at(x,y,z)); }
00335                         }
00336                 }
00337         }
00338 
00339 }

EMData * MinMaxAverager::finish (  )  [virtual]

Finish up the averaging and return the result.

Returns:
The averaged image.

Implements EMAN::Averager.

Definition at line 341 of file averager.cpp.

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

00342 {
00343         result->update();
00344         if (result && nimg > 1) return result;
00345 
00346         return NULL;
00347 }

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

Referenced by add_image().

00223                 {
00224                         return "minmax";
00225                 }

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

Implements EMAN::Averager.

Definition at line 227 of file averager.h.

00228                 {
00229                         return "Finds the minimum or maximum value in each pixel";
00230                 }

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

Definition at line 232 of file averager.h.

References MinMaxAverager().

00233                 {
00234                         return new MinMaxAverager();
00235                 }

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

References EMAN::EMObject::INT, and EMAN::TypeDict::put().

00238                 {
00239                         TypeDict d;
00240                         d.put("max", EMObject::INT, "If set, will find the max value, otherwise finds min");
00241                         return d;
00242                 }

virtual void EMAN::MinMaxAverager::mult ( const float &  s  )  [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 244 of file averager.h.

00244 { }


Member Data Documentation

Definition at line 247 of file averager.h.

Referenced by add_image(), and MinMaxAverager().

Definition at line 248 of file averager.h.

Referenced by add_image(), and finish().


The documentation for this class was generated from the following files:

Generated on Sat Nov 21 02:20:15 2009 for EMAN2 by  doxygen 1.5.6