#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 | |
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 5443 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 5477 of file processor.h. 05478 { 05479 return "Calculates the projection of the image along one of the axial directions, either x, y or z"; 05480 }
|
|
Get the processor's name. Each processor is identified by a unique name.
Implements EMAN::Processor. Definition at line 5446 of file processor.h. 05447 {
05448 return NAME;
05449 }
|
|
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 5468 of file processor.h. References EMAN::TypeDict::put(). 05469 { 05470 TypeDict d; 05471 d.put("axis", EMObject::STRING,"The direction of the sum, either x,y or z. Returned axes are xy, xz or zy."); 05472 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)"); 05473 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)"); 05474 return d; 05475 }
|
|
Definition at line 5451 of file processor.h. 05452 { 05453 return new DirectionalSumProcessor(); 05454 }
|
|
Reimplemented from EMAN::Processor. Definition at line 6624 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. 06624 { 06625 string dir = params.set_default("axis", ""); 06626 if ( dir == "" || ( dir != "x" && dir != "y" && dir != "z" ) ) 06627 throw InvalidParameterException("The direction parameter must be either x, y, or z"); 06628 06629 int nx = image->get_xsize(); 06630 int ny = image->get_ysize(); 06631 int nz = image->get_zsize(); 06632 06633 int a0 = params.set_default("first", 0); 06634 int a1 = params.set_default("last", -1); 06635 06636 EMData* ret = new EMData; 06637 // compress one of the dimensions 06638 if ( dir == "x" ) { 06639 ret->set_size(nz,ny); 06640 06641 // bounds checks 06642 if (a0<0) a0+=nx; 06643 if (a1<0) a1+=nx; 06644 if (a0<0) a0=0; 06645 if (a1<0) a1=0; 06646 if (a0>=nx) a0=nx-1; 06647 if (a1>=nx) a1=nx-1; 06648 06649 for (int y=0; y<ny; y++) { 06650 for (int z=0; z<nz; z++) { 06651 double sum=0.0; 06652 for (int x=a0; x<=a1; x++) sum+=image->get_value_at(x,y,z); 06653 ret->set_value_at(z,y,(float)sum); 06654 } 06655 } 06656 } 06657 else if ( dir == "y" ) { 06658 ret->set_size(nx,nz); 06659 06660 // bounds checks 06661 if (a0<0) a0+=ny; 06662 if (a1<0) a1+=ny; 06663 if (a0<0) a0=0; 06664 if (a1<0) a1=0; 06665 if (a0>=ny) a0=ny-1; 06666 if (a1>=ny) a1=ny-1; 06667 06668 for (int x=0; x<nx; x++) { 06669 for (int z=0; z<nz; z++) { 06670 double sum=0.0; 06671 for (int y=a0; y<=a1; y++) sum+=image->get_value_at(x,y,z); 06672 ret->set_value_at(x,z,(float)sum); 06673 } 06674 } 06675 } 06676 else if ( dir == "z" ) { 06677 ret->set_size(nx,ny); 06678 06679 // bounds checks 06680 if (a0<0) a0+=nz; 06681 if (a1<0) a1+=nz; 06682 if (a0<0) a0=0; 06683 if (a1<0) a1=0; 06684 if (a0>=nz) a0=nz-1; 06685 if (a1>=nz) a1=nz-1; 06686 06687 for (int y=0; y<ny; y++) { 06688 for (int x=0; x<nx; x++) { 06689 double sum=0.0; 06690 for (int z=a0; z<=a1; z++) sum+=image->get_value_at(x,y,z); 06691 ret->set_value_at(x,y,(float)sum); 06692 } 06693 } 06694 } 06695 06696 ret->update(); 06697 return ret; 06698 }
|
|
Implements EMAN::Processor. Definition at line 5464 of file processor.h. References InvalidCallException. 05464 { 05465 throw InvalidCallException("The directional sum processor does not work inplace"); 05466 }
|
|
Definition at line 186 of file processor.cpp. |