#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 5521 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 5555 of file processor.h. 05556 { 05557 return "Calculates the projection of the image along one of the axial directions, either x, y or z"; 05558 }
|
|
Get the processor's name. Each processor is identified by a unique name.
Implements EMAN::Processor. Definition at line 5524 of file processor.h. 05525 {
05526 return NAME;
05527 }
|
|
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 5546 of file processor.h. References EMAN::TypeDict::put(). 05547 { 05548 TypeDict d; 05549 d.put("axis", EMObject::STRING,"The direction of the sum, either x,y or z. Returned axes are xy, xz or zy."); 05550 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)"); 05551 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)"); 05552 return d; 05553 }
|
|
Definition at line 5529 of file processor.h. 05530 { 05531 return new DirectionalSumProcessor(); 05532 }
|
|
Reimplemented from EMAN::Processor. Definition at line 6797 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. 06797 { 06798 string dir = params.set_default("axis", ""); 06799 if ( dir == "" || ( dir != "x" && dir != "y" && dir != "z" ) ) 06800 throw InvalidParameterException("The direction parameter must be either x, y, or z"); 06801 06802 int nx = image->get_xsize(); 06803 int ny = image->get_ysize(); 06804 int nz = image->get_zsize(); 06805 06806 int a0 = params.set_default("first", 0); 06807 int a1 = params.set_default("last", -1); 06808 06809 EMData* ret = new EMData; 06810 // compress one of the dimensions 06811 if ( dir == "x" ) { 06812 ret->set_size(nz,ny); 06813 06814 // bounds checks 06815 if (a0<0) a0+=nx; 06816 if (a1<0) a1+=nx; 06817 if (a0<0) a0=0; 06818 if (a1<0) a1=0; 06819 if (a0>=nx) a0=nx-1; 06820 if (a1>=nx) a1=nx-1; 06821 06822 for (int y=0; y<ny; y++) { 06823 for (int z=0; z<nz; z++) { 06824 double sum=0.0; 06825 for (int x=a0; x<=a1; x++) sum+=image->get_value_at(x,y,z); 06826 ret->set_value_at(z,y,(float)sum); 06827 } 06828 } 06829 } 06830 else if ( dir == "y" ) { 06831 ret->set_size(nx,nz); 06832 06833 // bounds checks 06834 if (a0<0) a0+=ny; 06835 if (a1<0) a1+=ny; 06836 if (a0<0) a0=0; 06837 if (a1<0) a1=0; 06838 if (a0>=ny) a0=ny-1; 06839 if (a1>=ny) a1=ny-1; 06840 06841 for (int x=0; x<nx; x++) { 06842 for (int z=0; z<nz; z++) { 06843 double sum=0.0; 06844 for (int y=a0; y<=a1; y++) sum+=image->get_value_at(x,y,z); 06845 ret->set_value_at(x,z,(float)sum); 06846 } 06847 } 06848 } 06849 else if ( dir == "z" ) { 06850 ret->set_size(nx,ny); 06851 06852 // bounds checks 06853 if (a0<0) a0+=nz; 06854 if (a1<0) a1+=nz; 06855 if (a0<0) a0=0; 06856 if (a1<0) a1=0; 06857 if (a0>=nz) a0=nz-1; 06858 if (a1>=nz) a1=nz-1; 06859 06860 for (int y=0; y<ny; y++) { 06861 for (int x=0; x<nx; x++) { 06862 double sum=0.0; 06863 for (int z=a0; z<=a1; z++) sum+=image->get_value_at(x,y,z); 06864 ret->set_value_at(x,y,(float)sum); 06865 } 06866 } 06867 } 06868 06869 ret->update(); 06870 return ret; 06871 }
|
|
Implements EMAN::Processor. Definition at line 5542 of file processor.h. References InvalidCallException. 05542 { 05543 throw InvalidCallException("The directional sum processor does not work inplace"); 05544 }
|
|
Definition at line 181 of file processor.cpp. |