EMAN2
Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
EMAN::BoxStatProcessor Class Referenceabstract

BoxStatProcessor files are a kind of neighborhood processors. More...

#include <processor.h>

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

Public Member Functions

virtual void process_inplace (EMData *image)
 To process an image in-place. More...
 
virtual EMDataprocess (EMData *image)
 
TypeDict get_param_types () const
 Get processor parameter information in a dictionary. 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...
 
virtual void set_params (const Dict &new_params)
 Set the processor parameters using a key/value dictionary. More...
 
virtual string get_desc () const =0
 Get the descrition of this specific processor. More...
 

Static Public Member Functions

static string get_group_desc ()
 
- 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...
 

Protected Member Functions

virtual void process_pixel (float *pixel, const float *array, int n) const =0
 

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

Detailed Description

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

Parameters
radiusThe radius of the search box, default is 1 which results in a 3x3 box (3 = 2xradius + 1)

Definition at line 4479 of file processor.h.

Member Function Documentation

◆ get_group_desc()

static string EMAN::BoxStatProcessor::get_group_desc ( )
inlinestatic

Definition at line 4485 of file processor.h.

4486 {
4487 return "BoxStatProcessor files are real-space 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).";
4488 }

◆ get_param_types()

TypeDict EMAN::BoxStatProcessor::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.

Reimplemented in EMAN::PeakOnlyProcessor, and EMAN::BwMajorityProcessor.

Definition at line 4490 of file processor.h.

4491 {
4492 TypeDict d;
4493 d.put("radius", EMObject::INT, "The 'radius' of the (square/cube) search box, eg - 1 -> 3x3 box");
4494 d.put("xsize", EMObject::INT, "+- range on X axis, 0 uses the value only, 1 -> -1,0,+1, ...");
4495 d.put("ysize", EMObject::INT, "+- range on Y axis");
4496 d.put("zsize", EMObject::INT, "+- range on Z axis)");
4497 return d;
4498 }
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()

EMData * BoxStatProcessor::process ( EMData image)
virtual

Definition at line 2658 of file processor.cpp.

2659{
2660 if (!image) {
2661 LOGWARN("NULL Image");
2662 return NULL;
2663 }
2664
2665
2666 int nx = image->get_xsize();
2667 int ny = image->get_ysize();
2668 int nz = image->get_zsize();
2669
2670 int dx=1,dy=1,dz=1;
2671 if (params.has_key("radius")) dx=dy=dz=params["radius"];
2672 if (params.has_key("xsize")) dx=params["xsize"];
2673 if (params.has_key("ysize")) dy=params["ysize"];
2674 if (params.has_key("zsize")) dz=params["zsize"];
2675 if (nz==1) dz=0;
2676
2677 int matrix_size = (2*dx+1)*(2*dy+1)*(2*dz+1);
2678
2679 vector<float> array(matrix_size);
2680// image->process_inplace("normalize");
2681
2682 EMData *ret = image->copy_head();
2683
2684 // The old version of this code had a lot of hand optimizations, which likely weren't accomplishing much
2685 // This is much simpler, but relies on the compiler to optimize. May be some cost associated with the new
2686 // edge-mirroring policy which could be hand optomized if necessary
2687 for (int k=0; k<nz; k++) {
2688 for (int j=0; j<ny; j++) {
2689 for (int i=0; i<nx; i++) {
2690
2691 for (int kk=k-dz,s=0; kk<=k+dz; kk++) {
2692 for (int jj=j-dy; jj<=j+dy; jj++) {
2693 for (int ii=i-dx; ii<=i+dx; ii++,s++) {
2694 array[s]=image->get_value_at(MIRE(ii,nx),MIRE(jj,ny),MIRE(kk,nz));
2695 }
2696 }
2697 }
2698 float newv=image->get_value_at(i,j,k);
2699 process_pixel(&newv,array.data(),matrix_size);
2700 ret->set_value_at(i,j,k,newv);
2701 }
2702 }
2703 }
2704
2705 ret->update();
2706
2707 return ret;
2708}
virtual void process_pixel(float *pixel, const float *array, int n) const =0
bool has_key(const string &key) const
Ask the Dictionary if it as a particular key.
Definition: emobject.h:511
EMData stores an image's data and defines core image processing routines.
Definition: emdata.h:82
#define LOGWARN
Definition: log.h:53
int MIRE(int x, int nx)
Definition: processor.cpp:2656

References EMAN::Dict::has_key(), LOGWARN, MIRE(), EMAN::Processor::params, and process_pixel().

Referenced by process_inplace().

◆ process_inplace()

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.

Parameters
imageThe image to be processed.

Implements EMAN::Processor.

Definition at line 2649 of file processor.cpp.

2649 {
2650 EMData *cpy = process(image);
2651 memcpy(image->get_data(),cpy->get_data(),image->get_size()*sizeof(float));
2652 delete cpy;
2653}
virtual EMData * process(EMData *image)
Definition: processor.cpp:2658

References process().

◆ process_pixel()

virtual void EMAN::BoxStatProcessor::process_pixel ( float *  pixel,
const float *  array,
int  n 
) const
protectedpure virtual

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