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

Gradient remover, does a rough plane fit to find linear gradients. More...

#include <processor.h>

Inheritance diagram for EMAN::GradientRemoverProcessor:
Inheritance graph
[legend]
Collaboration diagram for EMAN::GradientRemoverProcessor:
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...
 
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...
 
virtual TypeDict get_param_types () const
 Get processor parameter information in a 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 = "math.lineargradientfix"
 

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

Gradient remover, does a rough plane fit to find linear gradients.

Definition at line 5173 of file processor.h.

Member Function Documentation

◆ get_desc()

string EMAN::GradientRemoverProcessor::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 5187 of file processor.h.

5188 {
5189 return "Gradient remover, does a rough plane fit to find linear gradients.";
5190 }

◆ get_name()

string EMAN::GradientRemoverProcessor::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 5178 of file processor.h.

5179 {
5180 return NAME;
5181 }
static const string NAME
Definition: processor.h:5192

References NAME.

Referenced by process_inplace().

◆ NEW()

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

Definition at line 5182 of file processor.h.

5183 {
5184 return new GradientRemoverProcessor();
5185 }
Gradient remover, does a rough plane fit to find linear gradients.
Definition: processor.h:5174

◆ process_inplace()

void GradientRemoverProcessor::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 3582 of file processor.cpp.

3583{
3584 if (!image) {
3585 LOGWARN("NULL Image");
3586 return;
3587 }
3588
3589 int nz = image->get_zsize();
3590 if (nz > 1) {
3591 LOGERR("%s Processor doesn't support 3D model", get_name().c_str());
3592 throw ImageDimensionException("3D model not supported");
3593 }
3594
3595 int nx = image->get_xsize();
3596 int ny = image->get_ysize();
3597 float *dy = new float[ny];
3598 float m = 0;
3599 float b = 0;
3600 float sum_y = 0;
3601 float *data = image->get_data();
3602
3603 for (int i = 0; i < ny; i++) {
3604 Util::calc_least_square_fit(nx, 0, data + i * nx, &m, &b, false);
3605 dy[i] = b;
3606 sum_y += m;
3607 }
3608
3609 float mean_y = sum_y / ny;
3610 float sum_x = 0;
3611 Util::calc_least_square_fit(ny, 0, dy, &sum_x, &b, false);
3612
3613 for (int j = 0; j < ny; j++) {
3614 for (int i = 0; i < nx; i++) {
3615 data[i + j * nx] -= i * sum_x + j * mean_y + b;
3616 }
3617 }
3618
3619 image->update();
3620}
string get_name() const
Get the processor's name.
Definition: processor.h:5178
static void calc_least_square_fit(size_t nitems, const float *data_x, const float *data_y, float *p_slope, float *p_intercept, bool ignore_zero, float absmax=0)
calculate the least square fit value.
Definition: util.cpp:538
#define ImageDimensionException(desc)
Definition: exception.h:166
#define LOGWARN
Definition: log.h:53
#define LOGERR
Definition: log.h:51

References EMAN::Util::calc_least_square_fit(), get_name(), ImageDimensionException, LOGERR, and LOGWARN.

Member Data Documentation

◆ NAME

const string GradientRemoverProcessor::NAME = "math.lineargradientfix"
static

Definition at line 5192 of file processor.h.

Referenced by get_name().


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