EMAN2
Public Member Functions | Static Public Member Functions | Static Public Attributes
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]

List of all members.

Public Member Functions

void process_inplace (EMData *image)
 To process an image in-place.
string get_name () const
 Get the processor's name.
string get_desc () const
 Get the descrition of this specific processor.

Static Public Member Functions

static ProcessorNEW ()

Static Public Attributes

static const string NAME = "math.lineargradientfix"

Detailed Description

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

Definition at line 3817 of file processor.h.


Member Function Documentation

string EMAN::GradientRemoverProcessor::get_desc ( ) const [inline, virtual]

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 3831 of file processor.h.

                {
                        return "Gradient remover, does a rough plane fit to find linear gradients.";
                }
string EMAN::GradientRemoverProcessor::get_name ( ) const [inline, virtual]

Get the processor's name.

Each processor is identified by a unique name.

Returns:
The processor's name.

Implements EMAN::Processor.

Definition at line 3822 of file processor.h.

References NAME.

                {
                        return NAME;
                }
static Processor* EMAN::GradientRemoverProcessor::NEW ( ) [inline, static]

Definition at line 3826 of file processor.h.

                {
                        return new GradientRemoverProcessor();
                }
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 2652 of file processor.cpp.

References b, EMAN::Util::calc_least_square_fit(), EMAN::EMData::get_data(), EMAN::CutoffBlockProcessor::get_name(), EMAN::EMData::get_xsize(), EMAN::EMData::get_ysize(), EMAN::EMData::get_zsize(), ImageDimensionException, LOGERR, LOGWARN, nx, ny, and EMAN::EMData::update().

{
        if (!image) {
                LOGWARN("NULL Image");
                return;
        }

        int nz = image->get_zsize();
        if (nz > 1) {
                LOGERR("%s Processor doesn't support 3D model", get_name().c_str());
                throw ImageDimensionException("3D model not supported");
        }

        int nx = image->get_xsize();
        int ny = image->get_ysize();
        float *dy = new float[ny];
        float m = 0;
        float b = 0;
        float sum_y = 0;
        float *data = image->get_data();

        for (int i = 0; i < ny; i++) {
                Util::calc_least_square_fit(nx, 0, data + i * nx, &m, &b, false);
                dy[i] = b;
                sum_y += m;
        }

        float mean_y = sum_y / ny;
        float sum_x = 0;
        Util::calc_least_square_fit(ny, 0, dy, &sum_x, &b, false);

        for (int j = 0; j < ny; j++) {
                for (int i = 0; i < nx; i++) {
                        data[i + j * nx] -= i * sum_x + j * mean_y + b;
                }
        }

        image->update();
}

Member Data Documentation

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

Definition at line 3836 of file processor.h.

Referenced by get_name().


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