#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 | |
Processor * | NEW () |
Static Public Attributes | |
const string | NAME = "misc.directional_sum" |
direction | The direction of the sum, either x,y or z |
Definition at line 5264 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 5298 of file processor.h. 05299 { 05300 return "Calculates the projection of the image along one of the axial directions, either x, y or z"; 05301 }
|
|
Get the processor's name. Each processor is identified by a unique name.
Implements EMAN::Processor. Definition at line 5267 of file processor.h. 05268 {
05269 return NAME;
05270 }
|
|
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 5289 of file processor.h. References EMAN::TypeDict::put(). 05290 { 05291 TypeDict d; 05292 d.put("axis", EMObject::STRING,"The direction of the sum, either x,y or z. Returned axes are xy, xz or zy."); 05293 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)"); 05294 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)"); 05295 return d; 05296 }
|
|
Definition at line 5272 of file processor.h. 05273 { 05274 return new DirectionalSumProcessor(); 05275 }
|
|
Reimplemented from EMAN::Processor. Definition at line 6530 of file processor.cpp. References EMAN::EMData::get_value_at(), EMAN::EMData::get_xsize(), EMAN::EMData::get_ysize(), EMAN::EMData::get_zsize(), InvalidParameterException, nx, ny, EMAN::Dict::set_default(), EMAN::EMData::set_size(), EMAN::EMData::set_value_at(), EMAN::EMData::update(), x, and y. 06530 { 06531 string dir = params.set_default("axis", ""); 06532 if ( dir == "" || ( dir != "x" && dir != "y" && dir != "z" ) ) 06533 throw InvalidParameterException("The direction parameter must be either x, y, or z"); 06534 06535 int nx = image->get_xsize(); 06536 int ny = image->get_ysize(); 06537 int nz = image->get_zsize(); 06538 06539 int a0 = params.set_default("first", 0); 06540 int a1 = params.set_default("last", -1); 06541 06542 EMData* ret = new EMData; 06543 // compress one of the dimensions 06544 if ( dir == "x" ) { 06545 ret->set_size(nz,ny); 06546 06547 // bounds checks 06548 if (a0<0) a0+=nx; 06549 if (a1<0) a1+=nx; 06550 if (a0<0) a0=0; 06551 if (a1<0) a1=0; 06552 if (a0>=nx) a0=nx-1; 06553 if (a1>=nx) a1=nx-1; 06554 06555 for (int y=0; y<ny; y++) { 06556 for (int z=0; z<nz; z++) { 06557 double sum=0.0; 06558 for (int x=a0; x<=a1; x++) sum+=image->get_value_at(x,y,z); 06559 ret->set_value_at(z,y,(float)sum); 06560 } 06561 } 06562 } 06563 else if ( dir == "y" ) { 06564 ret->set_size(nx,nz); 06565 06566 // bounds checks 06567 if (a0<0) a0+=ny; 06568 if (a1<0) a1+=ny; 06569 if (a0<0) a0=0; 06570 if (a1<0) a1=0; 06571 if (a0>=ny) a0=ny-1; 06572 if (a1>=ny) a1=ny-1; 06573 06574 for (int x=0; x<nx; x++) { 06575 for (int z=0; z<nz; z++) { 06576 double sum=0.0; 06577 for (int y=a0; y<=a1; y++) sum+=image->get_value_at(x,y,z); 06578 ret->set_value_at(x,z,(float)sum); 06579 } 06580 } 06581 } 06582 else if ( dir == "z" ) { 06583 ret->set_size(nx,ny); 06584 06585 // bounds checks 06586 if (a0<0) a0+=nz; 06587 if (a1<0) a1+=nz; 06588 if (a0<0) a0=0; 06589 if (a1<0) a1=0; 06590 if (a0>=nz) a0=nz-1; 06591 if (a1>=nz) a1=nz-1; 06592 06593 for (int y=0; y<ny; y++) { 06594 for (int x=0; x<nx; x++) { 06595 double sum=0.0; 06596 for (int z=a0; z<=a1; z++) sum+=image->get_value_at(x,y,z); 06597 ret->set_value_at(x,y,(float)sum); 06598 } 06599 } 06600 } 06601 06602 ret->update(); 06603 return ret; 06604 }
|
|
Implements EMAN::Processor. Definition at line 5285 of file processor.h. References InvalidCallException. 05285 { 05286 throw InvalidCallException("The directional sum processor does not work inplace"); 05287 }
|
|
Definition at line 175 of file processor.cpp. |