#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 3587 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 3601 of file processor.h. 03602 { 03603 return "Gradient remover, does a rough plane fit to find linear gradients."; 03604 }
|
|
Get the processor's name. Each processor is identified by a unique name.
Implements EMAN::Processor. Definition at line 3592 of file processor.h. Referenced by process_inplace(). 03593 {
03594 return NAME;
03595 }
|
|
Definition at line 3596 of file processor.h. 03597 { 03598 return new GradientRemoverProcessor(); 03599 }
|
|
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 2625 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(). 02626 { 02627 if (!image) { 02628 LOGWARN("NULL Image"); 02629 return; 02630 } 02631 02632 int nz = image->get_zsize(); 02633 if (nz > 1) { 02634 LOGERR("%s Processor doesn't support 3D model", get_name().c_str()); 02635 throw ImageDimensionException("3D model not supported"); 02636 } 02637 02638 int nx = image->get_xsize(); 02639 int ny = image->get_ysize(); 02640 float *dy = new float[ny]; 02641 float m = 0; 02642 float b = 0; 02643 float sum_y = 0; 02644 float *data = image->get_data(); 02645 02646 for (int i = 0; i < ny; i++) { 02647 Util::calc_least_square_fit(nx, 0, data + i * nx, &m, &b, false); 02648 dy[i] = b; 02649 sum_y += m; 02650 } 02651 02652 float mean_y = sum_y / ny; 02653 float sum_x = 0; 02654 Util::calc_least_square_fit(ny, 0, dy, &sum_x, &b, false); 02655 02656 for (int j = 0; j < ny; j++) { 02657 for (int i = 0; i < nx; i++) { 02658 data[i + j * nx] -= i * sum_x + j * mean_y + b; 02659 } 02660 } 02661 02662 image->update(); 02663 }
|
|
Definition at line 134 of file processor.cpp. |