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:
areasize The width of the area to process (not radius)

Definition at line 2865 of file processor.h.


Constructor & Destructor Documentation

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

Definition at line 2868 of file processor.h.

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


Member Function Documentation

virtual void EMAN::AreaProcessor::create_kernel (  )  const [protected, pure virtual]

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

Referenced by process_inplace().

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 2887 of file processor.h.

02888                 {
02889                         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().";
02890                 }

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 2880 of file processor.h.

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

02881                 {
02882                         TypeDict d;
02883                         d.put("areasize", EMObject::INT, "The width of the area to process (not radius)");
02884                         return d;
02885                 }

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:
image The image to be processed.

Implements EMAN::Processor.

Definition at line 1634 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.

01635 {
01636         if (!image) {
01637                 LOGWARN("NULL Image");
01638                 return;
01639         }
01640 
01641         float *data = image->get_data();
01642 
01643         nx = image->get_xsize();
01644         ny = image->get_ysize();
01645         nz = image->get_zsize();
01646 
01647         int n = (areasize - 1) / 2;
01648         matrix_size = areasize * areasize;
01649 
01650         if (nz > 1) {
01651                 matrix_size *= areasize;
01652         }
01653 
01654         float *matrix = new float[matrix_size];
01655         kernel = new float[matrix_size];
01656 
01657         size_t cpysize = areasize * sizeof(float);
01658         size_t start = (nx * ny + nx + 1) * n;
01659 
01660         int xend = nx - n;
01661         int yend = ny - n;
01662 
01663         int zstart = n;
01664         int zend = nz - n;
01665 
01666         int zbox_start = 0;
01667         int zbox_end = areasize;
01668 
01669         if (nz == 1) {
01670                 zstart = 0;
01671                 zend = 1;
01672                 zbox_end = 1;
01673         }
01674 
01675         size_t nsec = (size_t)nx * (size_t)ny;
01676         int box_nsec = areasize * areasize;
01677 
01678         create_kernel();
01679 
01680         size_t total_size = (size_t)nx * (size_t)ny * (size_t)nz;
01681         float *data2 = new float[total_size];
01682         memcpy(data2, data, total_size * sizeof(float));
01683 
01684         size_t k;
01685         for (int z = zstart; z < zend; z++) {
01686                 for (int y = n; y < yend; y++) {
01687                         for (int x = n; x < xend; x++) {
01688 
01689                                 k = (size_t)z * nsec + y * nx + x;
01690 
01691                                 for (int bz = zbox_start; bz < zbox_end; bz++) {
01692                                         for (int by = 0; by < areasize; by++) {
01693                                                 memcpy(&matrix[(size_t)bz * box_nsec + by * areasize],
01694                                                            &data2[k - start + bz * nsec + by * nx], cpysize);
01695                                         }
01696                                 }
01697 
01698                                 process_pixel(&data[k], (float) x, (float) y, (float) z, matrix);
01699                         }
01700                 }
01701         }
01702 
01703         if( matrix )
01704         {
01705                 delete[]matrix;
01706                 matrix = 0;
01707         }
01708 
01709         if( kernel )
01710         {
01711                 delete[]kernel;
01712                 kernel = 0;
01713         }
01714         image->update();
01715 }

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 2893 of file processor.h.

References kernel, and matrix_size.

Referenced by process_inplace().

02894                 {
02895                         for (int i = 0; i < matrix_size; i++)
02896                         {
02897                                 *pixel += area_matrix[i] * kernel[i];
02898                         }
02899                 }

void EMAN::AreaProcessor::set_params ( const Dict new_params  )  [inline, virtual]

Set the processor parameters using a key/value dictionary.

Parameters:
new_params A dictionary containing the new parameters.

Reimplemented from EMAN::Processor.

Definition at line 2874 of file processor.h.

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

02875                 {
02876                         params = new_params;
02877                         areasize = params["areasize"];
02878                 }


Member Data Documentation

int EMAN::AreaProcessor::areasize [protected]

Definition at line 2903 of file processor.h.

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

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

Definition at line 2905 of file processor.h.

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

int EMAN::AreaProcessor::matrix_size [protected]

Definition at line 2904 of file processor.h.

Referenced by process_inplace(), and process_pixel().

int EMAN::AreaProcessor::nx [protected]

Definition at line 2906 of file processor.h.

Referenced by process_inplace().

int EMAN::AreaProcessor::ny [protected]

Definition at line 2907 of file processor.h.

Referenced by process_inplace().

int EMAN::AreaProcessor::nz [protected]

Definition at line 2908 of file processor.h.

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


The documentation for this class was generated from the following files:
Generated on Fri Aug 10 16:36:01 2012 for EMAN2 by  doxygen 1.4.7