#include <processor.h>


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 2761 of file processor.h.
| EMAN::AreaProcessor::AreaProcessor | ( | ) | [inline] |
| 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 1485 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.
01486 { 01487 if (!image) { 01488 LOGWARN("NULL Image"); 01489 return; 01490 } 01491 01492 float *data = image->get_data(); 01493 01494 nx = image->get_xsize(); 01495 ny = image->get_ysize(); 01496 nz = image->get_zsize(); 01497 01498 int n = (areasize - 1) / 2; 01499 matrix_size = areasize * areasize; 01500 01501 if (nz > 1) { 01502 matrix_size *= areasize; 01503 } 01504 01505 float *matrix = new float[matrix_size]; 01506 kernel = new float[matrix_size]; 01507 01508 int cpysize = areasize * (int) sizeof(float); 01509 int start = (nx * ny + nx + 1) * n; 01510 01511 int xend = nx - n; 01512 int yend = ny - n; 01513 01514 int zstart = n; 01515 int zend = nz - n; 01516 01517 int zbox_start = 0; 01518 int zbox_end = areasize; 01519 01520 if (nz == 1) { 01521 zstart = 0; 01522 zend = 1; 01523 zbox_end = 1; 01524 } 01525 01526 size_t nsec = (size_t)nx * (size_t)ny; 01527 int box_nsec = areasize * areasize; 01528 01529 create_kernel(); 01530 01531 size_t total_size = (size_t)nx * (size_t)ny * (size_t)nz; 01532 float *data2 = new float[total_size]; 01533 memcpy(data2, data, total_size * sizeof(float)); 01534 01535 size_t k; 01536 for (int z = zstart; z < zend; z++) { 01537 for (int y = n; y < yend; y++) { 01538 for (int x = n; x < xend; x++) { 01539 01540 k = z * nsec + y * nx + x; 01541 01542 for (int bz = zbox_start; bz < zbox_end; bz++) { 01543 for (int by = 0; by < areasize; by++) { 01544 memcpy(&matrix[bz * box_nsec + by * areasize], 01545 &data2[k - start + bz * nsec + by * nx], cpysize); 01546 } 01547 } 01548 01549 process_pixel(&data[k], (float) x, (float) y, (float) z, matrix); 01550 } 01551 } 01552 } 01553 01554 if( matrix ) 01555 { 01556 delete[]matrix; 01557 matrix = 0; 01558 } 01559 01560 if( kernel ) 01561 { 01562 delete[]kernel; 01563 kernel = 0; 01564 } 01565 image->update(); 01566 }
| 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 2770 of file processor.h.
References areasize, and EMAN::Processor::params.
| 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 2776 of file processor.h.
References EMAN::EMObject::INT, and EMAN::TypeDict::put().
02777 { 02778 TypeDict d; 02779 d.put("areasize", EMObject::INT, "The width of the area to process (not radius)"); 02780 return d; 02781 }
| 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 2783 of file processor.h.
02784 { 02785 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()."; 02786 }
| 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 2789 of file processor.h.
References kernel, and matrix_size.
Referenced by process_inplace().
02790 { 02791 for (int i = 0; i < matrix_size; i++) 02792 { 02793 *pixel += area_matrix[i] * kernel[i]; 02794 } 02795 }
| virtual void EMAN::AreaProcessor::create_kernel | ( | ) | const [protected, pure virtual] |
Implemented in EMAN::LaplacianProcessor, and EMAN::ZeroConstantProcessor.
Referenced by process_inplace().
int EMAN::AreaProcessor::areasize [protected] |
Definition at line 2799 of file processor.h.
Referenced by EMAN::LaplacianProcessor::create_kernel(), process_inplace(), and set_params().
int EMAN::AreaProcessor::matrix_size [protected] |
float* EMAN::AreaProcessor::kernel [protected] |
Definition at line 2801 of file processor.h.
Referenced by EMAN::LaplacianProcessor::create_kernel(), process_inplace(), and process_pixel().
int EMAN::AreaProcessor::nx [protected] |
int EMAN::AreaProcessor::ny [protected] |
int EMAN::AreaProcessor::nz [protected] |
Definition at line 2804 of file processor.h.
Referenced by EMAN::LaplacianProcessor::create_kernel(), and process_inplace().
1.5.6