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

averages over cal_half_width, then sets the value in a local block More...

#include <processor.h>

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

List of all members.

Public Member Functions

void process_inplace (EMData *image)
 To process an image in-place.
string get_name () const
 Get the processor's name.
string get_desc () const
 Get the descrition of this specific processor.
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 = "eman1.filter.blockrange"

Detailed Description

averages over cal_half_width, then sets the value in a local block

Parameters:
cal_half_widthcal_half_width is dx/dy for calculating an average
fill_half_widthfill_half_width is dx/dy for fill/step

Definition at line 3418 of file processor.h.


Member Function Documentation

string EMAN::DiffBlockProcessor::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 3432 of file processor.h.

                {
                        return "averages over cal_half_width, then sets the value in a local block";
                }
string EMAN::DiffBlockProcessor::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 3423 of file processor.h.

References NAME.

Referenced by process_inplace().

                {
                        return NAME;
                }
TypeDict EMAN::DiffBlockProcessor::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 3437 of file processor.h.

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

                {
                        TypeDict d;
                        d.put("cal_half_width", EMObject::FLOAT, "cal_half_width is dx/dy for calculating an average");
                        d.put("fill_half_width", EMObject::FLOAT, "fill_half_width is dx/dy for fill/step");
                        return d;
                }
static Processor* EMAN::DiffBlockProcessor::NEW ( ) [inline, static]

Definition at line 3427 of file processor.h.

                {
                        return new DiffBlockProcessor();
                }
void DiffBlockProcessor::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 1826 of file processor.cpp.

References data, EMAN::EMData::get_data(), get_name(), EMAN::EMData::get_xsize(), EMAN::EMData::get_ysize(), EMAN::EMData::get_zsize(), ImageDimensionException, LOGERR, LOGWARN, mean(), nx, ny, EMAN::Processor::params, EMAN::EMData::update(), v0, x, and y.

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

        int nz = image->get_zsize();

        if (nz > 1) {
                LOGERR("%s Processor doesn't support 3D", get_name().c_str());
                throw ImageDimensionException("3D model not supported");
        }

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

        int v1 = params["cal_half_width"];
        int v2 = params["fill_half_width"];

        int v0 = v1 > v2 ? v1 : v2;

        if (v2 <= 0) {
                v2 = v1;
        }

        float *data = image->get_data();

        for (int y = v0; y <= ny - v0 - 1; y += v2) {
                for (int x = v0; x <= nx - v0 - 1; x += v2) {

                        float sum = 0;
                        for (int y1 = y - v1; y1 <= y + v1; y1++) {
                                for (int x1 = x - v1; x1 <= x + v1; x1++) {
                                        sum += data[x1 + y1 * nx];
                                }
                        }
                        float mean = sum / ((v1 * 2 + 1) * (v1 * 2 + 1));

                        for (int j = y - v2; j <= y + v2; j++) {
                                for (int i = x - v2; i <= x + v2; i++) {
                                        data[i + j * nx] = mean;
                                }
                        }
                }
        }

        image->update();
}

Member Data Documentation

const string DiffBlockProcessor::NAME = "eman1.filter.blockrange" [static]

Definition at line 3445 of file processor.h.

Referenced by get_name().


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