#include <processor.h>
Inheritance diagram for EMAN::AreaProcessor:
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 |
This is the base class. Specific AreaProcessor needs to implement function create_kernel().
areasize | The width of the area to process (not radius) |
Definition at line 2861 of file processor.h.
EMAN::AreaProcessor::AreaProcessor | ( | ) | [inline] |
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.
Implements EMAN::Processor.
Reimplemented in EMAN::LaplacianProcessor, and EMAN::ZeroConstantProcessor.
Definition at line 2883 of file processor.h.
02884 { 02885 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()."; 02886 }
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.
Reimplemented from EMAN::Processor.
Definition at line 2876 of file processor.h.
References EMAN::EMObject::INT, and EMAN::TypeDict::put().
02877 { 02878 TypeDict d; 02879 d.put("areasize", EMObject::INT, "The width of the area to process (not radius)"); 02880 return d; 02881 }
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.
image | The image to be processed. |
Implements EMAN::Processor.
Definition at line 1655 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.
01656 { 01657 if (!image) { 01658 LOGWARN("NULL Image"); 01659 return; 01660 } 01661 01662 float *data = image->get_data(); 01663 01664 nx = image->get_xsize(); 01665 ny = image->get_ysize(); 01666 nz = image->get_zsize(); 01667 01668 int n = (areasize - 1) / 2; 01669 matrix_size = areasize * areasize; 01670 01671 if (nz > 1) { 01672 matrix_size *= areasize; 01673 } 01674 01675 float *matrix = new float[matrix_size]; 01676 kernel = new float[matrix_size]; 01677 01678 int cpysize = areasize * (int) sizeof(float); 01679 int start = (nx * ny + nx + 1) * n; 01680 01681 int xend = nx - n; 01682 int yend = ny - n; 01683 01684 int zstart = n; 01685 int zend = nz - n; 01686 01687 int zbox_start = 0; 01688 int zbox_end = areasize; 01689 01690 if (nz == 1) { 01691 zstart = 0; 01692 zend = 1; 01693 zbox_end = 1; 01694 } 01695 01696 size_t nsec = (size_t)nx * (size_t)ny; 01697 int box_nsec = areasize * areasize; 01698 01699 create_kernel(); 01700 01701 size_t total_size = (size_t)nx * (size_t)ny * (size_t)nz; 01702 float *data2 = new float[total_size]; 01703 memcpy(data2, data, total_size * sizeof(float)); 01704 01705 size_t k; 01706 for (int z = zstart; z < zend; z++) { 01707 for (int y = n; y < yend; y++) { 01708 for (int x = n; x < xend; x++) { 01709 01710 k = z * nsec + y * nx + x; 01711 01712 for (int bz = zbox_start; bz < zbox_end; bz++) { 01713 for (int by = 0; by < areasize; by++) { 01714 memcpy(&matrix[bz * box_nsec + by * areasize], 01715 &data2[k - start + bz * nsec + by * nx], cpysize); 01716 } 01717 } 01718 01719 process_pixel(&data[k], (float) x, (float) y, (float) z, matrix); 01720 } 01721 } 01722 } 01723 01724 if( matrix ) 01725 { 01726 delete[]matrix; 01727 matrix = 0; 01728 } 01729 01730 if( kernel ) 01731 { 01732 delete[]kernel; 01733 kernel = 0; 01734 } 01735 image->update(); 01736 }
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 2889 of file processor.h.
References kernel, and matrix_size.
Referenced by process_inplace().
02890 { 02891 for (int i = 0; i < matrix_size; i++) 02892 { 02893 *pixel += area_matrix[i] * kernel[i]; 02894 } 02895 }
void EMAN::AreaProcessor::set_params | ( | const Dict & | new_params | ) | [inline, virtual] |
Set the processor parameters using a key/value dictionary.
new_params | A dictionary containing the new parameters. |
Reimplemented from EMAN::Processor.
Definition at line 2870 of file processor.h.
References areasize, and EMAN::Processor::params.
int EMAN::AreaProcessor::areasize [protected] |
Definition at line 2899 of file processor.h.
Referenced by EMAN::LaplacianProcessor::create_kernel(), process_inplace(), and set_params().
float* EMAN::AreaProcessor::kernel [protected] |
Definition at line 2901 of file processor.h.
Referenced by EMAN::LaplacianProcessor::create_kernel(), process_inplace(), and process_pixel().
int EMAN::AreaProcessor::matrix_size [protected] |
int EMAN::AreaProcessor::nx [protected] |
int EMAN::AreaProcessor::ny [protected] |
int EMAN::AreaProcessor::nz [protected] |
Definition at line 2904 of file processor.h.
Referenced by EMAN::LaplacianProcessor::create_kernel(), and process_inplace().