EMAN2
Public Member Functions | Static Public Member Functions | Static Public Attributes | Private Attributes
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 ()

Static Public Attributes

static 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:
maxIf 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.

Referenced by NEW().

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

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

{
        if (!image) {
                return;
        }

        if (nimg >= 1 && !EMUtil::is_same_size(image, result)) {
                LOGERR("%sAverager can only process same-size Image",
                           get_name().c_str());
                return;
        }

        nimg++;

        int nx = image->get_xsize();
        int ny = image->get_ysize();
        int nz = image->get_zsize();

        if (nimg == 1) {
                result = image->copy();
                max = params["max"];
                return;
        }

        for (int z=0; z<nz; z++) {
                for (int y=0; y<ny; y++) {
                        for (int x=0; x<nx; x++) {
                                if (result->get_value_at(x,y,z)>image->get_value_at(x,y,z))
                                        { if (!max) result->set_value_at(x,y,z,image->get_value_at(x,y,z)); }
                                else { if (max) result->set_value_at(x,y,z,image->get_value_at(x,y,z)); }
                        }
                }
        }

}
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::Averager::result, EMAN::EMData::set_attr(), and EMAN::EMData::update().

{
        result->update();
        result->set_attr("ptcl_repr",nimg);
        
        if (result && nimg > 1) return result;

        return NULL;
}
string EMAN::MinMaxAverager::get_desc ( ) const [inline, virtual]

Implements EMAN::Averager.

Definition at line 320 of file averager.h.

                {
                        return "Finds the minimum or maximum value in each pixel";
                }
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.

References NAME.

Referenced by add_image().

                {
                        return NAME;
                }
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::EMObject::INT, and EMAN::TypeDict::put().

                {
                        TypeDict d;
                        d.put("max", EMObject::INT, "If set, will find the max value, otherwise finds min");
                        return d;
                }
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:
sthe scaling factor.
Exceptions:
NullPointerExceptionif the EMData pointer (result) is NULL

Reimplemented from EMAN::Averager.

Definition at line 337 of file averager.h.

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

Definition at line 325 of file averager.h.

References MinMaxAverager().

                {
                        return new MinMaxAverager();
                }

Member Data Documentation

Definition at line 342 of file averager.h.

Referenced by add_image(), and MinMaxAverager().

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

Definition at line 339 of file averager.h.

Referenced by get_name().

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: