EMAN2
Public Member Functions | Protected Member Functions | Protected Attributes
EMAN::AreaProcessor Class Reference

AreaProcessor use pixel values and coordinates of a real-space square area. More...

#include <processor.h>

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

List of all members.

Public Member Functions

 AreaProcessor ()
void process_inplace (EMData *image)
 To process an image in-place.
void set_params (const Dict &new_params)
 Set the processor parameters using a key/value dictionary.
TypeDict get_param_types () const
 Get processor parameter information in a dictionary.
string get_desc () const
 Get the descrition of this specific processor.

Protected Member Functions

virtual void process_pixel (float *pixel, float, float, float, float *area_matrix) const
virtual void create_kernel () const =0

Protected Attributes

int areasize
int matrix_size
float * kernel
int nx
int ny
int nz

Detailed Description

AreaProcessor use pixel values and coordinates of a real-space square area.

This is the base class. Specific AreaProcessor needs to implement function create_kernel().

Parameters:
areasizeThe width of the area to process (not radius)

Definition at line 3054 of file processor.h.


Constructor & Destructor Documentation

EMAN::AreaProcessor::AreaProcessor ( ) [inline]

Definition at line 3057 of file processor.h.

                               :areasize(0), kernel(0), nx(0), ny(0), nz(0)
                {
                }

Member Function Documentation

virtual void EMAN::AreaProcessor::create_kernel ( ) const [protected, pure virtual]
string EMAN::AreaProcessor::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.

Reimplemented in EMAN::LaplacianProcessor, and EMAN::ZeroConstantProcessor.

Definition at line 3076 of file processor.h.

                {
                        return "AreaProcessor use pixel values and coordinates of a real-space square area. This is the base class. Specific AreaProcessor needs to implement function create_kernel().";
                }
TypeDict EMAN::AreaProcessor::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 3069 of file processor.h.

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

                {
                        TypeDict d;
                        d.put("areasize", EMObject::INT, "The width of the area to process (not radius)");
                        return d;
                }
void AreaProcessor::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 1650 of file processor.cpp.

References areasize, create_kernel(), data, EMAN::EMData::get_data(), EMAN::EMData::get_xsize(), EMAN::EMData::get_ysize(), EMAN::EMData::get_zsize(), kernel, LOGWARN, matrix(), matrix_size, nx, ny, nz, process_pixel(), EMAN::EMData::update(), x, and y.

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

        float *data = image->get_data();

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

        int n = (areasize - 1) / 2;
        matrix_size = areasize * areasize;

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

        float *matrix = new float[matrix_size];
        kernel = new float[matrix_size];

        size_t cpysize = areasize * sizeof(float);
        size_t start = (nx * ny + nx + 1) * n;

        int xend = nx - n;
        int yend = ny - n;

        int zstart = n;
        int zend = nz - n;

        int zbox_start = 0;
        int zbox_end = areasize;

        if (nz == 1) {
                zstart = 0;
                zend = 1;
                zbox_end = 1;
        }

        size_t nsec = (size_t)nx * (size_t)ny;
        int box_nsec = areasize * areasize;

        create_kernel();

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

        size_t k;
        for (int z = zstart; z < zend; z++) {
                for (int y = n; y < yend; y++) {
                        for (int x = n; x < xend; x++) {

                                k = (size_t)z * nsec + y * nx + x;

                                for (int bz = zbox_start; bz < zbox_end; bz++) {
                                        for (int by = 0; by < areasize; by++) {
                                                memcpy(&matrix[(size_t)bz * box_nsec + by * areasize],
                                                           &data2[k - start + bz * nsec + by * nx], cpysize);
                                        }
                                }

                                process_pixel(&data[k], (float) x, (float) y, (float) z, matrix);
                        }
                }
        }

        if( matrix )
        {
                delete[]matrix;
                matrix = 0;
        }

        if( kernel )
        {
                delete[]kernel;
                kernel = 0;
        }
        image->update();
}
virtual void EMAN::AreaProcessor::process_pixel ( float *  pixel,
float  ,
float  ,
float  ,
float *  area_matrix 
) const [inline, protected, virtual]

Reimplemented in EMAN::ZeroConstantProcessor.

Definition at line 3082 of file processor.h.

References kernel, and matrix_size.

Referenced by process_inplace().

                {
                        for (int i = 0; i < matrix_size; i++)
                        {
                                *pixel += area_matrix[i] * kernel[i];
                        }
                }
void EMAN::AreaProcessor::set_params ( const Dict new_params) [inline, virtual]

Set the processor parameters using a key/value dictionary.

Parameters:
new_paramsA dictionary containing the new parameters.

Reimplemented from EMAN::Processor.

Definition at line 3063 of file processor.h.

References areasize, and EMAN::Processor::params.

                {
                        params = new_params;
                        areasize = params["areasize"];
                }

Member Data Documentation

float* EMAN::AreaProcessor::kernel [protected]

Definition at line 3093 of file processor.h.

Referenced by process_inplace(), and process_pixel().

int EMAN::AreaProcessor::nx [protected]

Definition at line 3095 of file processor.h.

Referenced by process_inplace().

int EMAN::AreaProcessor::ny [protected]

Definition at line 3096 of file processor.h.

Referenced by process_inplace().

int EMAN::AreaProcessor::nz [protected]

Definition at line 3097 of file processor.h.

Referenced by EMAN::LaplacianProcessor::create_kernel(), and process_inplace().


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