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

static AveragerNEW ()

Static Public Attributes

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

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*/
        min = 0;
}

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:
imageThe 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, and EMAN::Averager::params.

{
        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();

        size_t imgsize = (size_t)nx*ny*nz;

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

        float * data     = result->get_data();
        float * src_data = image->get_data();

        for(size_t i=0; i<imgsize; ++i) {
                if(!min) {      //average to maximum by default
                        if (fabs(data[i]) < fabs(src_data[i])) data[i]=src_data[i];
                }
                else {  //average to minimum if set 'min'
                        if (fabs(data[i]) > fabs(src_data[i])) data[i]=src_data[i];
                }
        }
}
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::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::AbsMaxMinAverager::get_desc ( ) const [inline, virtual]

Implements EMAN::Averager.

Definition at line 363 of file averager.h.

                {
                        return "Average to maximum(or minimum if set parameter 'min' to non-zero) absolute value in each pixel";
                }
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.

References NAME.

Referenced by add_image().

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

                {
                        TypeDict d;
                        d.put("min", EMObject::INT, "If set, will average to minimum absolute value, by default average to max");
                        return d;
                }
static Averager* EMAN::AbsMaxMinAverager::NEW ( ) [inline, static]

Definition at line 368 of file averager.h.

References AbsMaxMinAverager().

                {
                        return new AbsMaxMinAverager();
                }

Member Data Documentation

Definition at line 383 of file averager.h.

Referenced by AbsMaxMinAverager(), and add_image().

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

Definition at line 380 of file averager.h.

Referenced by get_name().

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: