EMAN2
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
EMAN::AreaProcessor Class Referenceabstract

AreaProcessor use pixel values and coordinates of a real-space square area. More...

#include <processor.h>

Inheritance diagram for EMAN::AreaProcessor:
Inheritance graph
[legend]
Collaboration diagram for EMAN::AreaProcessor:
Collaboration graph
[legend]

Public Member Functions

 AreaProcessor ()
 
void process_inplace (EMData *image)
 To process an image in-place. More...
 
void set_params (const Dict &new_params)
 Set the processor parameters using a key/value dictionary. More...
 
TypeDict get_param_types () const
 Get processor parameter information in a dictionary. More...
 
string get_desc () const
 Get the descrition of this specific processor. More...
 
- Public Member Functions inherited from EMAN::Processor
virtual ~Processor ()
 
virtual EMDataprocess (const EMData *const image)
 To proccess an image out-of-place. More...
 
virtual void process_list_inplace (vector< EMData * > &images)
 To process multiple images using the same algorithm. More...
 
virtual string get_name () const =0
 Get the processor's name. More...
 
virtual Dict get_params () const
 Get the processor parameters in a key/value dictionary. More...
 

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
 
- Protected Attributes inherited from EMAN::Processor
Dict params
 

Additional Inherited Members

- Public Types inherited from EMAN::Processor
enum  fourier_filter_types {
  TOP_HAT_LOW_PASS , TOP_HAT_HIGH_PASS , TOP_HAT_BAND_PASS , TOP_HOMOMORPHIC ,
  GAUSS_LOW_PASS , GAUSS_HIGH_PASS , GAUSS_BAND_PASS , GAUSS_INVERSE ,
  GAUSS_HOMOMORPHIC , BUTTERWORTH_LOW_PASS , BUTTERWORTH_HIGH_PASS , BUTTERWORTH_HOMOMORPHIC ,
  KAISER_I0 , KAISER_SINH , KAISER_I0_INVERSE , KAISER_SINH_INVERSE ,
  SHIFT , TANH_LOW_PASS , TANH_HIGH_PASS , TANH_HOMOMORPHIC ,
  TANH_BAND_PASS , RADIAL_TABLE , CTF_
}
 Fourier filter Processor type enum. More...
 
- Static Public Member Functions inherited from EMAN::Processor
static string get_group_desc ()
 Get the description of this group of processors. More...
 
static void EMFourierFilterInPlace (EMData *fimage, Dict params)
 Compute a Fourier-filter processed image in place. More...
 
static EMDataEMFourierFilter (EMData *fimage, Dict params)
 Compute a Fourier-processor processed image without altering the original image. More...
 

Detailed Description

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().

Parameters
areasizeThe width of the area to process (not radius)

Definition at line 4356 of file processor.h.

Constructor & Destructor Documentation

◆ AreaProcessor()

EMAN::AreaProcessor::AreaProcessor ( )
inline

Definition at line 4359 of file processor.h.

4359 :areasize(0), kernel(0), nx(0), ny(0), nz(0)
4360 {
4361 }

Member Function Documentation

◆ create_kernel()

virtual void EMAN::AreaProcessor::create_kernel ( ) const
protectedpure virtual

◆ get_desc()

string EMAN::AreaProcessor::get_desc ( ) const
inlinevirtual

Get the descrition of this specific processor.

This function must be overwritten by a subclass.

Returns
The description of this processor.

Implements EMAN::Processor.

Reimplemented in EMAN::LaplacianProcessor, and EMAN::ZeroConstantProcessor.

Definition at line 4378 of file processor.h.

4379 {
4380 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().";
4381 }

◆ get_param_types()

TypeDict EMAN::AreaProcessor::get_param_types ( ) const
inlinevirtual

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.

Definition at line 4371 of file processor.h.

4372 {
4373 TypeDict d;
4374 d.put("areasize", EMObject::INT, "The width of the area to process (not radius)");
4375 return d;
4376 }
TypeDict is a dictionary to store <string, EMObject::ObjectType> pair.
Definition: emobject.h:305
void put(const string &key, EMObject::ObjectType o, const string &desc="")
Definition: emobject.h:330

References EMAN::EMObject::INT, and EMAN::TypeDict::put().

◆ process_inplace()

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.

Parameters
imageThe image to be processed.

Implements EMAN::Processor.

Reimplemented in EMAN::LaplacianProcessor.

Definition at line 2482 of file processor.cpp.

2483{
2484 if (!image) {
2485 LOGWARN("NULL Image");
2486 return;
2487 }
2488
2489 float *data = image->get_data();
2490
2491 nx = image->get_xsize();
2492 ny = image->get_ysize();
2493 nz = image->get_zsize();
2494
2495 int n = (areasize - 1) / 2;
2497
2498 if (nz > 1) {
2500 }
2501
2502 float *matrix = new float[matrix_size];
2503 kernel = new float[matrix_size];
2504
2505 size_t cpysize = areasize * sizeof(float);
2506 size_t start = (nx * ny + nx + 1) * n;
2507
2508 int xend = nx - n;
2509 int yend = ny - n;
2510
2511 int zstart = n;
2512 int zend = nz - n;
2513
2514 int zbox_start = 0;
2515 int zbox_end = areasize;
2516
2517 if (nz == 1) {
2518 zstart = 0;
2519 zend = 1;
2520 zbox_end = 1;
2521 }
2522
2523 size_t nsec = (size_t)nx * (size_t)ny;
2524 int box_nsec = areasize * areasize;
2525
2526 create_kernel();
2527
2528 size_t total_size = (size_t)nx * (size_t)ny * (size_t)nz;
2529 float *data2 = new float[total_size];
2530 memcpy(data2, data, total_size * sizeof(float));
2531
2532 size_t k;
2533 for (int z = zstart; z < zend; z++) {
2534 for (int y = n; y < yend; y++) {
2535 for (int x = n; x < xend; x++) {
2536
2537 k = (size_t)z * nsec + y * nx + x;
2538
2539 for (int bz = zbox_start; bz < zbox_end; bz++) {
2540 for (int by = 0; by < areasize; by++) {
2541 memcpy(&matrix[(size_t)bz * box_nsec + by * areasize],
2542 &data2[k - start + bz * nsec + by * nx], cpysize);
2543 }
2544 }
2545
2546 process_pixel(&data[k], (float) x, (float) y, (float) z, matrix);
2547 }
2548 }
2549 }
2550
2551 if( matrix )
2552 {
2553 delete[]matrix;
2554 matrix = 0;
2555 }
2556
2557 if( kernel )
2558 {
2559 delete[]kernel;
2560 kernel = 0;
2561 }
2562 image->update();
2563}
virtual void create_kernel() const =0
virtual void process_pixel(float *pixel, float, float, float, float *area_matrix) const
Definition: processor.h:4384
#define LOGWARN
Definition: log.h:53
#define y(i, j)
Definition: projector.cpp:1516
#define x(i)
Definition: projector.cpp:1517

References areasize, create_kernel(), kernel, LOGWARN, matrix_size, nx, ny, nz, process_pixel(), x, and y.

◆ process_pixel()

virtual void EMAN::AreaProcessor::process_pixel ( float *  pixel,
float  ,
float  ,
float  ,
float *  area_matrix 
) const
inlineprotectedvirtual

Reimplemented in EMAN::ZeroConstantProcessor.

Definition at line 4384 of file processor.h.

4385 {
4386 for (int i = 0; i < matrix_size; i++)
4387 {
4388 *pixel += area_matrix[i] * kernel[i];
4389 }
4390 }

References kernel, and matrix_size.

Referenced by process_inplace().

◆ set_params()

void EMAN::AreaProcessor::set_params ( const Dict new_params)
inlinevirtual

Set the processor parameters using a key/value dictionary.

Parameters
new_paramsA dictionary containing the new parameters.

Reimplemented from EMAN::Processor.

Definition at line 4365 of file processor.h.

4366 {
4367 params = new_params;
4368 areasize = params["areasize"];
4369 }

References areasize, and EMAN::Processor::params.

Member Data Documentation

◆ areasize

int EMAN::AreaProcessor::areasize
protected

◆ kernel

float* EMAN::AreaProcessor::kernel
protected

◆ matrix_size

int EMAN::AreaProcessor::matrix_size
protected

Definition at line 4395 of file processor.h.

Referenced by process_inplace(), and process_pixel().

◆ nx

int EMAN::AreaProcessor::nx
protected

Definition at line 4397 of file processor.h.

Referenced by process_inplace().

◆ ny

int EMAN::AreaProcessor::ny
protected

Definition at line 4398 of file processor.h.

Referenced by process_inplace().

◆ nz

int EMAN::AreaProcessor::nz
protected

Definition at line 4399 of file processor.h.

Referenced by EMAN::LaplacianProcessor::create_kernel(), and process_inplace().


The documentation for this class was generated from the following files: