#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 *) | |||
| ||||
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 5349 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 5383 of file processor.h.
05384 { 05385 return "Calculates the projection of the image along one of the axial directions, either x, y or z"; 05386 }
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 5352 of file processor.h.
References NAME.
05353 { 05354 return NAME; 05355 }
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 5374 of file processor.h.
References EMAN::EMObject::INT, EMAN::TypeDict::put(), and EMAN::EMObject::STRING.
05375 { 05376 TypeDict d; 05377 d.put("axis", EMObject::STRING,"The direction of the sum, either x,y or z. Returned axes are xy, xz or zy."); 05378 d.put("first", EMObject::INT,"The first position along the speficied axis to use in the sum. Neg val -> nx/y/z+first (default=0)"); 05379 d.put("last", EMObject::INT,"The last position along the speficied axis to use in the sum. Neg val -> nx/y/z+last (default=-1)"); 05380 return d; 05381 }
static Processor* EMAN::DirectionalSumProcessor::NEW | ( | ) | [inline, static] |
Definition at line 5357 of file processor.h.
05358 { 05359 return new DirectionalSumProcessor(); 05360 }
InvalidParameterException | raised if the direction parameter is not "x", "y" or "z" |
Reimplemented from EMAN::Processor.
Definition at line 6594 of file processor.cpp.
References 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::update(), and x.
06594 { 06595 string dir = params.set_default("axis", ""); 06596 if ( dir == "" || ( dir != "x" && dir != "y" && dir != "z" ) ) 06597 throw InvalidParameterException("The direction parameter must be either x, y, or z"); 06598 06599 int nx = image->get_xsize(); 06600 int ny = image->get_ysize(); 06601 int nz = image->get_zsize(); 06602 06603 int a0 = params.set_default("first", 0); 06604 int a1 = params.set_default("last", -1); 06605 06606 EMData* ret = new EMData; 06607 // compress one of the dimensions 06608 if ( dir == "x" ) { 06609 ret->set_size(nz,ny); 06610 06611 // bounds checks 06612 if (a0<0) a0+=nx; 06613 if (a1<0) a1+=nx; 06614 if (a0<0) a0=0; 06615 if (a1<0) a1=0; 06616 if (a0>=nx) a0=nx-1; 06617 if (a1>=nx) a1=nx-1; 06618 06619 for (int y=0; y<ny; y++) { 06620 for (int z=0; z<nz; z++) { 06621 double sum=0.0; 06622 for (int x=a0; x<=a1; x++) sum+=image->get_value_at(x,y,z); 06623 ret->set_value_at(z,y,(float)sum); 06624 } 06625 } 06626 } 06627 else if ( dir == "y" ) { 06628 ret->set_size(nx,nz); 06629 06630 // bounds checks 06631 if (a0<0) a0+=ny; 06632 if (a1<0) a1+=ny; 06633 if (a0<0) a0=0; 06634 if (a1<0) a1=0; 06635 if (a0>=ny) a0=ny-1; 06636 if (a1>=ny) a1=ny-1; 06637 06638 for (int x=0; x<nx; x++) { 06639 for (int z=0; z<nz; z++) { 06640 double sum=0.0; 06641 for (int y=a0; y<=a1; y++) sum+=image->get_value_at(x,y,z); 06642 ret->set_value_at(x,z,(float)sum); 06643 } 06644 } 06645 } 06646 else if ( dir == "z" ) { 06647 ret->set_size(nx,ny); 06648 06649 // bounds checks 06650 if (a0<0) a0+=nz; 06651 if (a1<0) a1+=nz; 06652 if (a0<0) a0=0; 06653 if (a1<0) a1=0; 06654 if (a0>=nz) a0=nz-1; 06655 if (a1>=nz) a1=nz-1; 06656 06657 for (int y=0; y<ny; y++) { 06658 for (int x=0; x<nx; x++) { 06659 double sum=0.0; 06660 for (int z=a0; z<=a1; z++) sum+=image->get_value_at(x,y,z); 06661 ret->set_value_at(x,y,(float)sum); 06662 } 06663 } 06664 } 06665 06666 ret->update(); 06667 return ret; 06668 }
virtual void EMAN::DirectionalSumProcessor::process_inplace | ( | EMData * | ) | [inline, virtual] |
InvalidCallException | raised if this function is called |
Implements EMAN::Processor.
Definition at line 5370 of file processor.h.
References InvalidCallException.
05370 { 05371 throw InvalidCallException("The directional sum processor does not work inplace"); 05372 }
const string DirectionalSumProcessor::NAME = "misc.directional_sum" [static] |