#include <processor.h>
Inheritance diagram for EMAN::DiffBlockProcessor:
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. | |
TypeDict | get_param_types () const |
Get processor parameter information in a dictionary. | |
Static Public Member Functions | |
static Processor * | NEW () |
Static Public Attributes | |
static const string | NAME = "eman1.filter.blockrange" |
cal_half_width | cal_half_width is dx/dy for calculating an average | |
fill_half_width | fill_half_width is dx/dy for fill/step |
Definition at line 3184 of file processor.h.
string EMAN::DiffBlockProcessor::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 3198 of file processor.h.
string EMAN::DiffBlockProcessor::get_name | ( | ) | const [inline, virtual] |
Get the processor's name.
Each processor is identified by a unique name.
Implements EMAN::Processor.
Definition at line 3189 of file processor.h.
References NAME.
Referenced by process_inplace().
03190 { 03191 return NAME; 03192 }
TypeDict EMAN::DiffBlockProcessor::get_param_types | ( | ) | const [inline, virtual] |
Get processor parameter information in a dictionary.
Each parameter has one record in the dictionary. Each record contains its name, data-type, and description.
Reimplemented from EMAN::Processor.
Definition at line 3203 of file processor.h.
References EMAN::EMObject::FLOAT, and EMAN::TypeDict::put().
03204 { 03205 TypeDict d; 03206 d.put("cal_half_width", EMObject::FLOAT, "cal_half_width is dx/dy for calculating an average"); 03207 d.put("fill_half_width", EMObject::FLOAT, "fill_half_width is dx/dy for fill/step"); 03208 return d; 03209 }
static Processor* EMAN::DiffBlockProcessor::NEW | ( | ) | [inline, static] |
void DiffBlockProcessor::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 1734 of file processor.cpp.
References data, EMAN::EMData::get_data(), get_name(), EMAN::EMData::get_xsize(), EMAN::EMData::get_ysize(), EMAN::EMData::get_zsize(), ImageDimensionException, LOGERR, LOGWARN, mean(), nx, ny, EMAN::Processor::params, EMAN::EMData::update(), v0, x, and y.
01735 { 01736 if (!image) { 01737 LOGWARN("NULL Image"); 01738 return; 01739 } 01740 01741 int nz = image->get_zsize(); 01742 01743 if (nz > 1) { 01744 LOGERR("%s Processor doesn't support 3D", get_name().c_str()); 01745 throw ImageDimensionException("3D model not supported"); 01746 } 01747 01748 int nx = image->get_xsize(); 01749 int ny = image->get_ysize(); 01750 01751 int v1 = params["cal_half_width"]; 01752 int v2 = params["fill_half_width"]; 01753 01754 int v0 = v1 > v2 ? v1 : v2; 01755 01756 if (v2 <= 0) { 01757 v2 = v1; 01758 } 01759 01760 float *data = image->get_data(); 01761 01762 for (int y = v0; y <= ny - v0 - 1; y += v2) { 01763 for (int x = v0; x <= nx - v0 - 1; x += v2) { 01764 01765 float sum = 0; 01766 for (int y1 = y - v1; y1 <= y + v1; y1++) { 01767 for (int x1 = x - v1; x1 <= x + v1; x1++) { 01768 sum += data[x1 + y1 * nx]; 01769 } 01770 } 01771 float mean = sum / ((v1 * 2 + 1) * (v1 * 2 + 1)); 01772 01773 for (int j = y - v2; j <= y + v2; j++) { 01774 for (int i = x - v2; i <= x + v2; i++) { 01775 data[i + j * nx] = mean; 01776 } 01777 } 01778 } 01779 } 01780 01781 image->update(); 01782 }
const string DiffBlockProcessor::NAME = "eman1.filter.blockrange" [static] |