#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 5519 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 5553 of file processor.h. 05554 { 05555 return "Calculates the projection of the image along one of the axial directions, either x, y or z"; 05556 }
|
|
Get the processor's name. Each processor is identified by a unique name.
Implements EMAN::Processor. Definition at line 5522 of file processor.h. 05523 {
05524 return NAME;
05525 }
|
|
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 5544 of file processor.h. References EMAN::TypeDict::put(). 05545 { 05546 TypeDict d; 05547 d.put("axis", EMObject::STRING,"The direction of the sum, either x,y or z. Returned axes are xy, xz or zy."); 05548 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)"); 05549 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)"); 05550 return d; 05551 }
|
|
Definition at line 5527 of file processor.h. 05528 { 05529 return new DirectionalSumProcessor(); 05530 }
|
|
Reimplemented from EMAN::Processor. Definition at line 6782 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. 06782 { 06783 string dir = params.set_default("axis", ""); 06784 if ( dir == "" || ( dir != "x" && dir != "y" && dir != "z" ) ) 06785 throw InvalidParameterException("The direction parameter must be either x, y, or z"); 06786 06787 int nx = image->get_xsize(); 06788 int ny = image->get_ysize(); 06789 int nz = image->get_zsize(); 06790 06791 int a0 = params.set_default("first", 0); 06792 int a1 = params.set_default("last", -1); 06793 06794 EMData* ret = new EMData; 06795 // compress one of the dimensions 06796 if ( dir == "x" ) { 06797 ret->set_size(nz,ny); 06798 06799 // bounds checks 06800 if (a0<0) a0+=nx; 06801 if (a1<0) a1+=nx; 06802 if (a0<0) a0=0; 06803 if (a1<0) a1=0; 06804 if (a0>=nx) a0=nx-1; 06805 if (a1>=nx) a1=nx-1; 06806 06807 for (int y=0; y<ny; y++) { 06808 for (int z=0; z<nz; z++) { 06809 double sum=0.0; 06810 for (int x=a0; x<=a1; x++) sum+=image->get_value_at(x,y,z); 06811 ret->set_value_at(z,y,(float)sum); 06812 } 06813 } 06814 } 06815 else if ( dir == "y" ) { 06816 ret->set_size(nx,nz); 06817 06818 // bounds checks 06819 if (a0<0) a0+=ny; 06820 if (a1<0) a1+=ny; 06821 if (a0<0) a0=0; 06822 if (a1<0) a1=0; 06823 if (a0>=ny) a0=ny-1; 06824 if (a1>=ny) a1=ny-1; 06825 06826 for (int x=0; x<nx; x++) { 06827 for (int z=0; z<nz; z++) { 06828 double sum=0.0; 06829 for (int y=a0; y<=a1; y++) sum+=image->get_value_at(x,y,z); 06830 ret->set_value_at(x,z,(float)sum); 06831 } 06832 } 06833 } 06834 else if ( dir == "z" ) { 06835 ret->set_size(nx,ny); 06836 06837 // bounds checks 06838 if (a0<0) a0+=nz; 06839 if (a1<0) a1+=nz; 06840 if (a0<0) a0=0; 06841 if (a1<0) a1=0; 06842 if (a0>=nz) a0=nz-1; 06843 if (a1>=nz) a1=nz-1; 06844 06845 for (int y=0; y<ny; y++) { 06846 for (int x=0; x<nx; x++) { 06847 double sum=0.0; 06848 for (int z=a0; z<=a1; z++) sum+=image->get_value_at(x,y,z); 06849 ret->set_value_at(x,y,(float)sum); 06850 } 06851 } 06852 } 06853 06854 ret->update(); 06855 return ret; 06856 }
|
|
Implements EMAN::Processor. Definition at line 5540 of file processor.h. References InvalidCallException. 05540 { 05541 throw InvalidCallException("The directional sum processor does not work inplace"); 05542 }
|
|
Definition at line 181 of file processor.cpp. |