#include <processor.h>
Inheritance diagram for EMAN::GradientRemoverProcessor:
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 Processor * | NEW () |
Static Public Attributes | |
static const string | NAME = "math.lineargradientfix" |
Definition at line 3408 of file processor.h.
string EMAN::GradientRemoverProcessor::get_desc | ( | ) | const [inline, virtual] |
Get the descrition of this specific processor.
This function must be overwritten by a subclass.
Implements EMAN::Processor.
Definition at line 3422 of file processor.h.
string EMAN::GradientRemoverProcessor::get_name | ( | ) | const [inline, virtual] |
Get the processor's name.
Each processor is identified by a unique name.
Implements EMAN::Processor.
Definition at line 3413 of file processor.h.
References NAME.
Referenced by process_inplace().
03414 { 03415 return NAME; 03416 }
static Processor* EMAN::GradientRemoverProcessor::NEW | ( | ) | [inline, static] |
Definition at line 3417 of file processor.h.
03418 { 03419 return new GradientRemoverProcessor(); 03420 }
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.
image | The image to be processed. |
Implements EMAN::Processor.
Definition at line 2505 of file processor.cpp.
References b, EMAN::Util::calc_least_square_fit(), EMAN::EMData::get_data(), get_name(), EMAN::EMData::get_xsize(), EMAN::EMData::get_ysize(), EMAN::EMData::get_zsize(), ImageDimensionException, LOGERR, LOGWARN, and EMAN::EMData::update().
02506 { 02507 if (!image) { 02508 LOGWARN("NULL Image"); 02509 return; 02510 } 02511 02512 int nz = image->get_zsize(); 02513 if (nz > 1) { 02514 LOGERR("%s Processor doesn't support 3D model", get_name().c_str()); 02515 throw ImageDimensionException("3D model not supported"); 02516 } 02517 02518 int nx = image->get_xsize(); 02519 int ny = image->get_ysize(); 02520 float *dy = new float[ny]; 02521 float m = 0; 02522 float b = 0; 02523 float sum_y = 0; 02524 float *data = image->get_data(); 02525 02526 for (int i = 0; i < ny; i++) { 02527 Util::calc_least_square_fit(nx, 0, data + i * nx, &m, &b, false); 02528 dy[i] = b; 02529 sum_y += m; 02530 } 02531 02532 float mean_y = sum_y / ny; 02533 float sum_x = 0; 02534 Util::calc_least_square_fit(ny, 0, dy, &sum_x, &b, false); 02535 02536 for (int j = 0; j < ny; j++) { 02537 for (int i = 0; i < nx; i++) { 02538 data[i + j * nx] -= i * sum_x + j * mean_y + b; 02539 } 02540 } 02541 02542 image->update(); 02543 }
const string GradientRemoverProcessor::NAME = "math.lineargradientfix" [static] |