#include <processor.h>
Inheritance diagram for EMAN::NormalizeRowProcessor:
Public Member Functions | |
string | get_name () const |
Get the processor's name. | |
string | get_desc () const |
Get the descrition of this specific processor. | |
void | process_inplace (EMData *image) |
To process an image in-place. | |
Static Public Member Functions | |
static Processor * | NEW () |
Static Public Attributes | |
static const string | NAME = "normalize.rows" |
Definition at line 4164 of file processor.h.
string EMAN::NormalizeRowProcessor::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 4177 of file processor.h.
string EMAN::NormalizeRowProcessor::get_name | ( | ) | const [inline, virtual] |
Get the processor's name.
Each processor is identified by a unique name.
Implements EMAN::Processor.
Definition at line 4167 of file processor.h.
References NAME.
04168 { 04169 return NAME; 04170 }
static Processor* EMAN::NormalizeRowProcessor::NEW | ( | ) | [inline, static] |
Definition at line 4172 of file processor.h.
04173 { 04174 return new NormalizeRowProcessor(); 04175 }
void NormalizeRowProcessor::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 3605 of file processor.cpp.
References EMAN::EMData::get_data(), EMAN::EMData::get_xsize(), EMAN::EMData::get_ysize(), EMAN::EMData::get_zsize(), LOGERR, LOGWARN, rdata, row_sum(), EMAN::EMData::update(), and x.
03606 { 03607 if (!image) { 03608 LOGWARN("NULL Image"); 03609 return; 03610 } 03611 03612 if (image->get_zsize() > 1) { 03613 LOGERR("row normalize only works for 2D image"); 03614 return; 03615 } 03616 03617 float *rdata = image->get_data(); 03618 int nx = image->get_xsize(); 03619 int ny = image->get_ysize(); 03620 03621 for (int y = 0; y < ny; y++) { 03622 double row_sum = 0; 03623 for (int x = 0; x < nx; x++) { 03624 row_sum += rdata[x + y * nx]; 03625 } 03626 03627 double row_mean = row_sum / nx; 03628 if (row_mean <= 0) { 03629 row_mean = 1; 03630 } 03631 03632 for (int x = 0; x < nx; x++) { 03633 rdata[x + y * nx] /= (float)row_mean; 03634 } 03635 } 03636 03637 image->update(); 03638 }
const string NormalizeRowProcessor::NAME = "normalize.rows" [static] |