EMAN2
Public Member Functions | Static Public Member Functions | Protected Member Functions
EMAN::BoxStatProcessor Class Reference

BoxStatProcessor files are a kind of neighborhood processors. More...

#include <processor.h>

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

List of all members.

Public Member Functions

void process_inplace (EMData *image)
 To process an image in-place.
TypeDict get_param_types () const
 Get processor parameter information in a dictionary.

Static Public Member Functions

static string get_group_desc ()
 Get the description of this group of processors.

Protected Member Functions

virtual void process_pixel (float *pixel, const float *array, int n) const =0

Detailed Description

BoxStatProcessor files are a kind of neighborhood processors.

These processors compute every output pixel using information from a reduced region on the neighborhood of the input pixel. The classical form are the 3x3 processors. BoxStatProcessors could perform diverse tasks ranging from noise reduction, to differential , to mathematical morphology. BoxStatProcessor class is the base class. Specific BoxStatProcessor needs to define process_pixel(float *pixel, const float *array, int n).

Parameters:
radiusThe radius of the search box, default is 1 which results in a 3x3 box (3 = 2xradius + 1)

Definition at line 3173 of file processor.h.


Member Function Documentation

static string EMAN::BoxStatProcessor::get_group_desc ( ) [inline, static]

Get the description of this group of processors.

This function is defined in a parent class. It gives a introduction to a group of processors.

Returns:
The description of this group of processors.

Reimplemented from EMAN::Processor.

Definition at line 3178 of file processor.h.

                {
                        return "BoxStatProcessor files are a kind of neighborhood processors. These processors compute every output pixel using information from a reduced region on the neighborhood of the input pixel. The classical form are the 3x3 processors. BoxStatProcessors could perform diverse tasks ranging from noise reduction, to differential , to mathematical morphology. BoxStatProcessor class is the base class. Specific BoxStatProcessor needs to define process_pixel(float *pixel, const float *array, int n).";
                }
TypeDict EMAN::BoxStatProcessor::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.

Reimplemented in EMAN::PeakOnlyProcessor.

Definition at line 3183 of file processor.h.

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

                {
                        TypeDict d;
                        d.put("radius", EMObject::INT, "The radius of the search box, default is 1 which results in a 3x3 box (3 = 2xradius + 1)");
                        return d;
                }
void BoxStatProcessor::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 1756 of file processor.cpp.

References data, EMAN::EMData::get_data(), EMAN::EMData::get_xsize(), EMAN::EMData::get_ysize(), EMAN::EMData::get_zsize(), LOGWARN, nx, ny, EMAN::Processor::params, process_pixel(), EMAN::Dict::set_default(), and EMAN::EMData::update().

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

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

        int n = params.set_default("radius",1);
        int areasize = 2 * n + 1;

        int matrix_size = areasize * areasize;
        if (nz > 1) {
                matrix_size *= areasize;
        }

        float *array = new float[matrix_size];
//      image->process_inplace("normalize");

        float *data = image->get_data();
        size_t total_size = (size_t)nx * (size_t)ny * (size_t)nz;
        float *data2 = new float[total_size];
        memcpy(data2, data, total_size * sizeof(float));

        int z_begin = 0;
        int z_end = 1;
        int nzz=0;
        if (nz > 1) {
                z_begin = n;
                z_end = nz - n;
                nzz=n;
        }

        int nxy = nx * ny;

        for (int k = z_begin; k < z_end; k++) {
                size_t knxy = (size_t)k * nxy;

                for (int j = n; j < ny - n; j++) {
                        int jnx = j * nx;

                        for (int i = n; i < nx - n; i++) {
                                size_t s = 0;

                                for (int i2 = i - n; i2 <= i + n; i2++) {
                                        for (int j2 = j - n; j2 <= j + n; j2++) {
                                                for (int k2 = k - nzz; k2 <= k + nzz; k2++) {
                                                        array[s] = data2[i2 + j2 * nx + (size_t)k2 * nxy];
                                                        ++s;
                                                }
                                        }
                                }

                                process_pixel(&data[i + jnx + knxy], array, matrix_size);
                        }
                }
        }

        image->update();

        if( data2 )
        {
                delete[]data2;
                data2 = 0;
        }
}
virtual void EMAN::BoxStatProcessor::process_pixel ( float *  pixel,
const float *  array,
int  n 
) const [protected, pure virtual]

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