Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

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


Constructor & Destructor Documentation

EMAN::AreaProcessor::AreaProcessor  )  [inline]
 

Definition at line 2870 of file processor.h.

References nx, and ny.

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


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

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

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

References EMAN::TypeDict::put().

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

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 1636 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.

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

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

Referenced by process_inplace().

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

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

02877                 {
02878                         params = new_params;
02879                         areasize = params["areasize"];
02880                 }


Member Data Documentation

int EMAN::AreaProcessor::areasize [protected]
 

Definition at line 2905 of file processor.h.

Referenced by process_inplace().

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

Definition at line 2907 of file processor.h.

Referenced by process_inplace().

int EMAN::AreaProcessor::matrix_size [protected]
 

Definition at line 2906 of file processor.h.

Referenced by process_inplace().

int EMAN::AreaProcessor::nx [protected]
 

Definition at line 2908 of file processor.h.

Referenced by process_inplace().

int EMAN::AreaProcessor::ny [protected]
 

Definition at line 2909 of file processor.h.

Referenced by process_inplace().

int EMAN::AreaProcessor::nz [protected]
 

Definition at line 2910 of file processor.h.

Referenced by process_inplace().


The documentation for this class was generated from the following files:
Generated on Tue Jun 11 13:48:38 2013 for EMAN2 by  doxygen 1.3.9.1