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

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

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:
radius The radius of the search box, default is 1 which results in a 3x3 box (3 = 2xradius + 1)

Definition at line 2939 of file processor.h.


Member Function Documentation

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

02945                 {
02946                         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).";
02947                 }

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

References EMAN::TypeDict::put().

02950                 {
02951                         TypeDict d;
02952                         d.put("radius", EMObject::INT, "The radius of the search box, default is 1 which results in a 3x3 box (3 = 2xradius + 1)");
02953                         return d;
02954                 }

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

Implements EMAN::Processor.

Definition at line 1664 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, process_pixel(), EMAN::Dict::set_default(), and EMAN::EMData::update().

01665 {
01666         if (!image) {
01667                 LOGWARN("NULL Image");
01668                 return;
01669         }
01670 
01671         int nx = image->get_xsize();
01672         int ny = image->get_ysize();
01673         int nz = image->get_zsize();
01674 
01675         int n = params.set_default("radius",1);
01676         int areasize = 2 * n + 1;
01677 
01678         int matrix_size = areasize * areasize;
01679         if (nz > 1) {
01680                 matrix_size *= areasize;
01681         }
01682 
01683         float *array = new float[matrix_size];
01684 //      image->process_inplace("normalize");
01685 
01686         float *data = image->get_data();
01687         size_t total_size = (size_t)nx * (size_t)ny * (size_t)nz;
01688         float *data2 = new float[total_size];
01689         memcpy(data2, data, total_size * sizeof(float));
01690 
01691         int z_begin = 0;
01692         int z_end = 1;
01693         int nzz=0;
01694         if (nz > 1) {
01695                 z_begin = n;
01696                 z_end = nz - n;
01697                 nzz=n;
01698         }
01699 
01700         int nxy = nx * ny;
01701 
01702         for (int k = z_begin; k < z_end; k++) {
01703                 size_t knxy = (size_t)k * nxy;
01704 
01705                 for (int j = n; j < ny - n; j++) {
01706                         int jnx = j * nx;
01707 
01708                         for (int i = n; i < nx - n; i++) {
01709                                 size_t s = 0;
01710 
01711                                 for (int i2 = i - n; i2 <= i + n; i2++) {
01712                                         for (int j2 = j - n; j2 <= j + n; j2++) {
01713                                                 for (int k2 = k - nzz; k2 <= k + nzz; k2++) {
01714                                                         array[s] = data2[i2 + j2 * nx + (size_t)k2 * nxy];
01715                                                         ++s;
01716                                                 }
01717                                         }
01718                                 }
01719 
01720                                 process_pixel(&data[i + jnx + knxy], array, matrix_size);
01721                         }
01722                 }
01723         }
01724 
01725         image->update();
01726 
01727         if( data2 )
01728         {
01729                 delete[]data2;
01730                 data2 = 0;
01731         }
01732 }

virtual void EMAN::BoxStatProcessor::process_pixel float *  pixel,
const float *  array,
int  n
const [protected, pure virtual]
 

Implemented in EMAN::BoxMedianProcessor, EMAN::BoxSigmaProcessor, EMAN::BoxMaxProcessor, EMAN::MinusPeakProcessor, and EMAN::PeakOnlyProcessor.

Referenced by process_inplace().


The documentation for this class was generated from the following files:
Generated on Thu Nov 17 12:46:08 2011 for EMAN2 by  doxygen 1.3.9.1