#include <processor.h>
Inheritance diagram for EMAN::BoxStatProcessor:
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 |
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).
radius | The radius of the search box, default is 1 which results in a 3x3 box (3 = 2xradius + 1) |
Definition at line 2905 of file processor.h.
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.
Reimplemented from EMAN::Processor.
Definition at line 2910 of file processor.h.
02911 { 02912 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)."; 02913 }
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.
Reimplemented from EMAN::Processor.
Reimplemented in EMAN::PeakOnlyProcessor.
Definition at line 2915 of file processor.h.
References EMAN::EMObject::INT, and EMAN::TypeDict::put().
02916 { 02917 TypeDict d; 02918 d.put("radius", EMObject::INT, "The radius of the search box, default is 1 which results in a 3x3 box (3 = 2xradius + 1)"); 02919 return d; 02920 }
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.
image | The image to be processed. |
Implements EMAN::Processor.
Definition at line 1701 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().
01702 { 01703 if (!image) { 01704 LOGWARN("NULL Image"); 01705 return; 01706 } 01707 01708 int nx = image->get_xsize(); 01709 int ny = image->get_ysize(); 01710 int nz = image->get_zsize(); 01711 01712 int n = params.set_default("radius",1); 01713 int areasize = 2 * n + 1; 01714 01715 int matrix_size = areasize * areasize; 01716 if (nz > 1) { 01717 matrix_size *= areasize; 01718 } 01719 01720 float *array = new float[matrix_size]; 01721 // image->process_inplace("normalize"); 01722 01723 float *data = image->get_data(); 01724 size_t total_size = (size_t)nx * (size_t)ny * (size_t)nz; 01725 float *data2 = new float[total_size]; 01726 memcpy(data2, data, total_size * sizeof(float)); 01727 01728 int z_begin = 0; 01729 int z_end = 1; 01730 int nzz=0; 01731 if (nz > 1) { 01732 z_begin = n; 01733 z_end = nz - n; 01734 nzz=n; 01735 } 01736 01737 int nxy = nx * ny; 01738 01739 for (int k = z_begin; k < z_end; k++) { 01740 size_t knxy = (size_t)k * nxy; 01741 01742 for (int j = n; j < ny - n; j++) { 01743 int jnx = j * nx; 01744 01745 for (int i = n; i < nx - n; i++) { 01746 size_t s = 0; 01747 01748 for (int i2 = i - n; i2 <= i + n; i2++) { 01749 for (int j2 = j - n; j2 <= j + n; j2++) { 01750 for (int k2 = k - nzz; k2 <= k + nzz; k2++) { 01751 array[s] = data2[i2 + j2 * nx + (size_t)k2 * nxy]; 01752 ++s; 01753 } 01754 } 01755 } 01756 01757 process_pixel(&data[i + jnx + knxy], array, matrix_size); 01758 } 01759 } 01760 } 01761 01762 image->update(); 01763 01764 if( data2 ) 01765 { 01766 delete[]data2; 01767 data2 = 0; 01768 } 01769 }
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().