#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 | |
Processor * | NEW () |
Static Public Attributes | |
const string | NAME = "math.lineargradientfix" |
Definition at line 3628 of file processor.h.
|
Get the descrition of this specific processor. This function must be overwritten by a subclass.
Implements EMAN::Processor. Definition at line 3642 of file processor.h. 03643 { 03644 return "Gradient remover, does a rough plane fit to find linear gradients."; 03645 }
|
|
Get the processor's name. Each processor is identified by a unique name.
Implements EMAN::Processor. Definition at line 3633 of file processor.h. Referenced by process_inplace(). 03634 {
03635 return NAME;
03636 }
|
|
Definition at line 3637 of file processor.h. 03638 { 03639 return new GradientRemoverProcessor(); 03640 }
|
|
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.
Implements EMAN::Processor. Definition at line 2636 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(). 02637 { 02638 if (!image) { 02639 LOGWARN("NULL Image"); 02640 return; 02641 } 02642 02643 int nz = image->get_zsize(); 02644 if (nz > 1) { 02645 LOGERR("%s Processor doesn't support 3D model", get_name().c_str()); 02646 throw ImageDimensionException("3D model not supported"); 02647 } 02648 02649 int nx = image->get_xsize(); 02650 int ny = image->get_ysize(); 02651 float *dy = new float[ny]; 02652 float m = 0; 02653 float b = 0; 02654 float sum_y = 0; 02655 float *data = image->get_data(); 02656 02657 for (int i = 0; i < ny; i++) { 02658 Util::calc_least_square_fit(nx, 0, data + i * nx, &m, &b, false); 02659 dy[i] = b; 02660 sum_y += m; 02661 } 02662 02663 float mean_y = sum_y / ny; 02664 float sum_x = 0; 02665 Util::calc_least_square_fit(ny, 0, dy, &sum_x, &b, false); 02666 02667 for (int j = 0; j < ny; j++) { 02668 for (int i = 0; i < nx; i++) { 02669 data[i + j * nx] -= i * sum_x + j * mean_y + b; 02670 } 02671 } 02672 02673 image->update(); 02674 }
|
|
Definition at line 129 of file processor.cpp. |