Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File 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]
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

ProcessorNEW ()

Static Public Attributes

const string NAME = "math.lineargradientfix"

Detailed Description

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

Definition at line 3493 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 3507 of file processor.h.

03508                 {
03509                         return "Gradient remover, does a rough plane fit to find linear gradients.";
03510                 }

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

Referenced by process_inplace().

03499                 {
03500                         return NAME;
03501                 }

Processor* EMAN::GradientRemoverProcessor::NEW  )  [inline, static]
 

Definition at line 3502 of file processor.h.

03503                 {
03504                         return new GradientRemoverProcessor();
03505                 }

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:
image The image to be processed.

Implements EMAN::Processor.

Definition at line 2566 of file processor.cpp.

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

02567 {
02568         if (!image) {
02569                 LOGWARN("NULL Image");
02570                 return;
02571         }
02572 
02573         int nz = image->get_zsize();
02574         if (nz > 1) {
02575                 LOGERR("%s Processor doesn't support 3D model", get_name().c_str());
02576                 throw ImageDimensionException("3D model not supported");
02577         }
02578 
02579         int nx = image->get_xsize();
02580         int ny = image->get_ysize();
02581         float *dy = new float[ny];
02582         float m = 0;
02583         float b = 0;
02584         float sum_y = 0;
02585         float *data = image->get_data();
02586 
02587         for (int i = 0; i < ny; i++) {
02588                 Util::calc_least_square_fit(nx, 0, data + i * nx, &m, &b, false);
02589                 dy[i] = b;
02590                 sum_y += m;
02591         }
02592 
02593         float mean_y = sum_y / ny;
02594         float sum_x = 0;
02595         Util::calc_least_square_fit(ny, 0, dy, &sum_x, &b, false);
02596 
02597         for (int j = 0; j < ny; j++) {
02598                 for (int i = 0; i < nx; i++) {
02599                         data[i + j * nx] -= i * sum_x + j * mean_y + b;
02600                 }
02601         }
02602 
02603         image->update();
02604 }


Member Data Documentation

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

Definition at line 126 of file processor.cpp.


The documentation for this class was generated from the following files:
Generated on Thu Mar 10 23:00:04 2011 for EMAN2 by  doxygen 1.3.9.1