#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 2984 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 2989 of file processor.h.
02990 { 02991 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)."; 02992 }
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 2994 of file processor.h.
References EMAN::EMObject::INT, and EMAN::TypeDict::put().
02995 { 02996 TypeDict d; 02997 d.put("radius", EMObject::INT, "The radius of the search box, default is 1 which results in a 3x3 box (3 = 2xradius + 1)"); 02998 return d; 02999 }
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 1740 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().
01741 { 01742 if (!image) { 01743 LOGWARN("NULL Image"); 01744 return; 01745 } 01746 01747 int nx = image->get_xsize(); 01748 int ny = image->get_ysize(); 01749 int nz = image->get_zsize(); 01750 01751 int n = params.set_default("radius",1); 01752 int areasize = 2 * n + 1; 01753 01754 int matrix_size = areasize * areasize; 01755 if (nz > 1) { 01756 matrix_size *= areasize; 01757 } 01758 01759 float *array = new float[matrix_size]; 01760 // image->process_inplace("normalize"); 01761 01762 float *data = image->get_data(); 01763 size_t total_size = (size_t)nx * (size_t)ny * (size_t)nz; 01764 float *data2 = new float[total_size]; 01765 memcpy(data2, data, total_size * sizeof(float)); 01766 01767 int z_begin = 0; 01768 int z_end = 1; 01769 int nzz=0; 01770 if (nz > 1) { 01771 z_begin = n; 01772 z_end = nz - n; 01773 nzz=n; 01774 } 01775 01776 int nxy = nx * ny; 01777 01778 for (int k = z_begin; k < z_end; k++) { 01779 size_t knxy = (size_t)k * nxy; 01780 01781 for (int j = n; j < ny - n; j++) { 01782 int jnx = j * nx; 01783 01784 for (int i = n; i < nx - n; i++) { 01785 size_t s = 0; 01786 01787 for (int i2 = i - n; i2 <= i + n; i2++) { 01788 for (int j2 = j - n; j2 <= j + n; j2++) { 01789 for (int k2 = k - nzz; k2 <= k + nzz; k2++) { 01790 array[s] = data2[i2 + j2 * nx + (size_t)k2 * nxy]; 01791 ++s; 01792 } 01793 } 01794 } 01795 01796 process_pixel(&data[i + jnx + knxy], array, matrix_size); 01797 } 01798 } 01799 } 01800 01801 image->update(); 01802 01803 if( data2 ) 01804 { 01805 delete[]data2; 01806 data2 = 0; 01807 } 01808 }
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().