EMAN2
Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
EMAN::CutoffBlockProcessor Class Reference

Block processor, val1 is dx/dy, val2 is lp freq cutoff in pixels. More...

#include <processor.h>

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

Public Member Functions

void process_inplace (EMData *image)
 To process an image in-place. More...
 
string get_name () const
 Get the processor's name. 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 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...
 

Static Public Member Functions

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

Static Public Attributes

static const string NAME = "eman1.filter.blockcutoff"
 

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

Block processor, val1 is dx/dy, val2 is lp freq cutoff in pixels.

Mystery processor.

Parameters
value1val1 is dx/dy
value2val2 is lowpass freq cutoff in pixels

Definition at line 4809 of file processor.h.

Member Function Documentation

◆ get_desc()

string EMAN::CutoffBlockProcessor::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.

Definition at line 4831 of file processor.h.

4832 {
4833 return "Block processor, val1 is dx/dy, val2 is lp freq cutoff in pixels. Mystery processor.";
4834 }

◆ get_name()

string EMAN::CutoffBlockProcessor::get_name ( ) const
inlinevirtual

Get the processor's name.

Each processor is identified by a unique name.

Returns
The processor's name.

Implements EMAN::Processor.

Definition at line 4814 of file processor.h.

4815 {
4816 return NAME;
4817 }
static const string NAME
Definition: processor.h:4836

References NAME.

Referenced by process_inplace().

◆ get_param_types()

TypeDict EMAN::CutoffBlockProcessor::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 4823 of file processor.h.

4824 {
4825 TypeDict d;
4826 d.put("value1", EMObject::FLOAT, "val1 is dx/dy");
4827 d.put("value2", EMObject::FLOAT, "val2 is lowpass freq cutoff in pixels");
4828 return d;
4829 }
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::FLOAT, and EMAN::TypeDict::put().

◆ NEW()

static Processor * EMAN::CutoffBlockProcessor::NEW ( )
inlinestatic

Definition at line 4818 of file processor.h.

4819 {
4820 return new CutoffBlockProcessor();
4821 }
Block processor, val1 is dx/dy, val2 is lp freq cutoff in pixels.
Definition: processor.h:4810

◆ process_inplace()

void CutoffBlockProcessor::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 2761 of file processor.cpp.

2762{
2763 if (!image) {
2764 LOGWARN("NULL Image");
2765 return;
2766 }
2767 int nz = image->get_zsize();
2768
2769 if (nz > 1) {
2770 LOGERR("%s Processor doesn't support 3D", get_name().c_str());
2771 throw ImageDimensionException("3D model not supported");
2772 }
2773
2774 int nx = image->get_xsize();
2775 int ny = image->get_ysize();
2776
2777 float value1 = params["value1"];
2778 float value2 = params["value2"];
2779
2780 int v1 = (int) value1;
2781 int v2 = (int) value2;
2782 if (v2 > v1 / 2) {
2783 LOGERR("invalid value2 '%f' in CutoffBlockProcessor", value2);
2784 return;
2785 }
2786
2787 if (v2 <= 0) {
2788 v2 = v1;
2789 }
2790
2791 float *data = image->get_data();
2792 int y = 0, x = 0;
2793 for (y = 0; y <= ny - v1; y += v1) {
2794 for (x = 0; x <= nx - v1; x += v1) {
2795
2796 EMData *clip = image->get_clip(Region(x, y, v1, v1));
2797 EMData *fft = clip->do_fft();
2798
2799 float *fft_data = fft->get_data();
2800 float sum = 0;
2801 int nitems = 0;
2802
2803 for (int i = -v2; i < v2; i++) {
2804 for (int j = 0; j < v2; j++) {
2805 if (j == 0 && i == 0) {
2806 continue;
2807 }
2808
2809 if (hypot(j, i) < value2) {
2810 int t = j * 2 + (i + v1 / 2) * (v1 + 2);
2811 sum += (fft_data[t] * fft_data[t] + fft_data[t + 1] * fft_data[t + 1]);
2812 nitems++;
2813 }
2814 }
2815 }
2816
2817 if( clip )
2818 {
2819 delete clip;
2820 clip = 0;
2821 }
2822
2823 float mean = sum / nitems;
2824
2825 for (int i = y; i < y + v1; i++) {
2826 for (int j = x; j < x + v1; j++) {
2827 data[i * nx + j] = mean;
2828 }
2829 }
2830 }
2831 }
2832
2833 memset(&data[y * nx], 0, (ny - y) * nx * sizeof(float));
2834
2835 for (int i = 0; i < ny; i++) {
2836 memset(&data[i * nx + x], 0, (nx - x) * sizeof(float));
2837 }
2838
2839 image->update();
2840}
string get_name() const
Get the processor's name.
Definition: processor.h:4814
EMData stores an image's data and defines core image processing routines.
Definition: emdata.h:82
EMData * get_clip(const Region &area, const float fill=0) const
Get an inclusive clip.
Definition: emdata.cpp:592
Region defines a 2D or 3D rectangular region specified by its origin coordinates and all edges' sizes...
Definition: geometry.h:497
#define ImageDimensionException(desc)
Definition: exception.h:166
#define LOGWARN
Definition: log.h:53
#define LOGERR
Definition: log.h:51
#define y(i, j)
Definition: projector.cpp:1516
#define x(i)
Definition: projector.cpp:1517

References EMAN::EMData::get_clip(), get_name(), ImageDimensionException, LOGERR, LOGWARN, EMAN::Processor::params, x, and y.

Member Data Documentation

◆ NAME

const string CutoffBlockProcessor::NAME = "eman1.filter.blockcutoff"
static

Definition at line 4836 of file processor.h.

Referenced by get_name().


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