#include <processor.h>
Inheritance diagram for EMAN::DirectionalSumProcessor:
Public Member Functions | ||||
virtual string | get_name () const | |||
Get the processor's name. | ||||
virtual EMData * | process (const EMData *const image) | |||
| ||||
virtual void | process_inplace (EMData *image) | |||
| ||||
virtual TypeDict | get_param_types () const | |||
Get processor parameter information in a dictionary. | ||||
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 = "misc.directional_sum" |
direction | The direction of the sum, either x,y or z |
Definition at line 5439 of file processor.h.
string EMAN::DirectionalSumProcessor::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 5471 of file processor.h.
05472 { 05473 return "Calculates the projection of the image along one of the axial directions, either x, y or z"; 05474 }
virtual string EMAN::DirectionalSumProcessor::get_name | ( | ) | const [inline, virtual] |
Get the processor's name.
Each processor is identified by a unique name.
Implements EMAN::Processor.
Definition at line 5442 of file processor.h.
References NAME.
05443 { 05444 return NAME; 05445 }
virtual TypeDict EMAN::DirectionalSumProcessor::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 5464 of file processor.h.
References EMAN::TypeDict::put(), and EMAN::EMObject::STRING.
05465 { 05466 TypeDict d; 05467 d.put("direction", EMObject::STRING,"The direction of the sum, either x,y or z"); 05468 return d; 05469 }
static Processor* EMAN::DirectionalSumProcessor::NEW | ( | ) | [inline, static] |
Definition at line 5447 of file processor.h.
05448 { 05449 return new DirectionalSumProcessor(); 05450 }
InvalidParameterException | raised if the direction parameter is not "x", "y" or "z" |
Reimplemented from EMAN::Processor.
Definition at line 6561 of file processor.cpp.
References EMAN::EMData::get_data(), EMAN::EMData::get_value_at(), EMAN::EMData::get_xsize(), EMAN::EMData::get_ysize(), EMAN::EMData::get_zsize(), InvalidParameterException, EMAN::Processor::params, EMAN::Dict::set_default(), EMAN::EMData::set_size(), EMAN::EMData::set_value_at(), EMAN::EMData::to_zero(), EMAN::EMData::update(), and v.
06561 { 06562 string dir = params.set_default("direction", ""); 06563 if ( dir == "" || ( dir != "x" && dir != "y" && dir != "z" ) ) 06564 throw InvalidParameterException("The direction parameter must be either x, y, or z"); 06565 06566 int nx = image->get_xsize(); 06567 int ny = image->get_ysize(); 06568 int nz = image->get_zsize(); 06569 06570 // compress one of the dimensions 06571 if ( dir == "x" ) nx = 1; 06572 else if ( dir == "y" ) ny = 1; 06573 else if ( dir == "z" ) nz = 1; 06574 06575 EMData* ret = new EMData; 06576 ret->set_size(nx,ny,nz); 06577 ret->to_zero(); 06578 06579 float* d = image->get_data(); 06580 for(int k = 0; k < image->get_zsize(); ++k ) { 06581 for(int j = 0; j < image->get_ysize(); ++j ) { 06582 for(int i = 0; i < image->get_xsize(); ++i, ++d ) { 06583 if ( dir == "x" ) { 06584 float v = ret->get_value_at(0,j,k); 06585 ret->set_value_at(0,j,k,*d+v); 06586 }else if ( dir == "y" ) { 06587 float v = ret->get_value_at(i,0,k); 06588 ret->set_value_at(i,0,k,*d+v); 06589 } 06590 else if ( dir == "z" ) { 06591 float v = ret->get_value_at(i,j,0); 06592 ret->set_value_at(i,j,0,*d+v); 06593 } 06594 } 06595 } 06596 } 06597 ret->update(); 06598 return ret; 06599 }
virtual void EMAN::DirectionalSumProcessor::process_inplace | ( | EMData * | image | ) | [inline, virtual] |
InvalidCallException | raised if this function is called |
Implements EMAN::Processor.
Definition at line 5460 of file processor.h.
References InvalidCallException.
05460 { 05461 throw InvalidCallException("The directional sum processor does not work inplace"); 05462 }
const string DirectionalSumProcessor::NAME = "misc.directional_sum" [static] |