EMAN2
Public Member Functions | Static Public Member Functions | Static Public Attributes
EMAN::SmartMaskProcessor Class Reference

Smart mask processor. More...

#include <processor.h>

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

List of all members.

Public Member Functions

virtual void process_inplace (EMData *image)
 To process an image in-place.
virtual string get_name () const
 Get the processor's name.
virtual string get_desc () const
 Get the descrition of this specific processor.
virtual TypeDict get_param_types () const
 Get processor parameter information in a dictionary.

Static Public Member Functions

static ProcessorNEW ()

Static Public Attributes

static const string NAME = "mask.smart"

Detailed Description

Smart mask processor.

Parameters:
maskmask value

Definition at line 6192 of file processor.h.


Member Function Documentation

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

Get the descrition of this specific processor.

This function must be overwritten by a subclass.

Returns:
The description of this processor.

Implements EMAN::Processor.

Definition at line 6207 of file processor.h.

                {
                        return "Smart mask processor.";
                }
virtual string EMAN::SmartMaskProcessor::get_name ( ) const [inline, virtual]

Get the processor's name.

Each processor is identified by a unique name.

Returns:
The processor's name.

Implements EMAN::Processor.

Definition at line 6197 of file processor.h.

References NAME.

                {
                        return NAME;
                }
virtual TypeDict EMAN::SmartMaskProcessor::get_param_types ( ) const [inline, virtual]

Get processor 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::Processor.

Definition at line 6212 of file processor.h.

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

                {
                        TypeDict d;
                        d.put("mask", EMObject::FLOAT, "mask value");
                        return d;
                }
static Processor* EMAN::SmartMaskProcessor::NEW ( ) [inline, static]

Definition at line 6202 of file processor.h.

                {
                        return new SmartMaskProcessor();
                }
void SmartMaskProcessor::process_inplace ( EMData image) [virtual]

To process an image in-place.

For those processors which can only be processed out-of-place, override this function to just print out some error message to remind user call the out-of-place version.

Parameters:
imageThe image to be processed.

Implements EMAN::Processor.

Definition at line 6755 of file processor.cpp.

References EMAN::EMData::get_data(), EMAN::EMData::get_xsize(), EMAN::EMData::get_ysize(), EMAN::EMData::get_zsize(), LOGWARN, nx, ny, EMAN::Processor::params, sqrt(), EMAN::Util::square(), and EMAN::EMData::update().

{
        if (!image) {
                LOGWARN("NULL Image");
                return;
        }

        float mask = params["mask"];

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

        float *dat = image->get_data();
        double sma = 0;
        size_t smn = 0;
        float r = 0.0f;
        for (int k = 0; k < nz; ++k) {
                for (int j = 0; j < ny; ++j) {
                        for (int i = 0; i < nx; ++i, ++dat) {
                                r =
                                        sqrt((float) Util::square(i - nx / 2) + Util::square(j - ny / 2) +
                                                 Util::square(k - nz / 2));
                                if (r > mask - 1.5f && r < mask - 0.5f) {
                                        sma += *dat;
                                        smn++;
                                }
                        }
                }
        }

        float smask = (float) (sma / smn);
        image->update();

        dat = image->get_data();
        for (int k = 0; k < nz; ++k) {
                for (int j = 0; j < ny; ++j) {
                        for (int i = 0; i < nx; ++i, ++dat) {
                                r =
                                        sqrt((float) Util::square(i - nx / 2) + Util::square(j - ny / 2) +
                                                 Util::square(k - nz / 2));
                                if (r > mask - .5) {
                                        *dat = 0;
                                }
                                else {
                                        *dat -= smask;
                                }
                        }
                }
        }

        image->update();
}

Member Data Documentation

const string SmartMaskProcessor::NAME = "mask.smart" [static]

Definition at line 6219 of file processor.h.

Referenced by get_name().


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