#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 5405 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 5439 of file processor.h. 05440 {
05441 return "Calculates the projection of the image along one of the axial directions, either x, y or z";
05442 }
|
|
|
Get the processor's name. Each processor is identified by a unique name.
Implements EMAN::Processor. Definition at line 5408 of file processor.h. 05409 {
05410 return NAME;
05411 }
|
|
|
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 5430 of file processor.h. References EMAN::TypeDict::put(). 05431 {
05432 TypeDict d;
05433 d.put("axis", EMObject::STRING,"The direction of the sum, either x,y or z. Returned axes are xy, xz or zy.");
05434 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)");
05435 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)");
05436 return d;
05437 }
|
|
|
Definition at line 5413 of file processor.h. 05414 {
05415 return new DirectionalSumProcessor();
05416 }
|
|
|
Reimplemented from EMAN::Processor. Definition at line 6596 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. 06596 {
06597 string dir = params.set_default("axis", "");
06598 if ( dir == "" || ( dir != "x" && dir != "y" && dir != "z" ) )
06599 throw InvalidParameterException("The direction parameter must be either x, y, or z");
06600
06601 int nx = image->get_xsize();
06602 int ny = image->get_ysize();
06603 int nz = image->get_zsize();
06604
06605 int a0 = params.set_default("first", 0);
06606 int a1 = params.set_default("last", -1);
06607
06608 EMData* ret = new EMData;
06609 // compress one of the dimensions
06610 if ( dir == "x" ) {
06611 ret->set_size(nz,ny);
06612
06613 // bounds checks
06614 if (a0<0) a0+=nx;
06615 if (a1<0) a1+=nx;
06616 if (a0<0) a0=0;
06617 if (a1<0) a1=0;
06618 if (a0>=nx) a0=nx-1;
06619 if (a1>=nx) a1=nx-1;
06620
06621 for (int y=0; y<ny; y++) {
06622 for (int z=0; z<nz; z++) {
06623 double sum=0.0;
06624 for (int x=a0; x<=a1; x++) sum+=image->get_value_at(x,y,z);
06625 ret->set_value_at(z,y,(float)sum);
06626 }
06627 }
06628 }
06629 else if ( dir == "y" ) {
06630 ret->set_size(nx,nz);
06631
06632 // bounds checks
06633 if (a0<0) a0+=ny;
06634 if (a1<0) a1+=ny;
06635 if (a0<0) a0=0;
06636 if (a1<0) a1=0;
06637 if (a0>=ny) a0=ny-1;
06638 if (a1>=ny) a1=ny-1;
06639
06640 for (int x=0; x<nx; x++) {
06641 for (int z=0; z<nz; z++) {
06642 double sum=0.0;
06643 for (int y=a0; y<=a1; y++) sum+=image->get_value_at(x,y,z);
06644 ret->set_value_at(x,z,(float)sum);
06645 }
06646 }
06647 }
06648 else if ( dir == "z" ) {
06649 ret->set_size(nx,ny);
06650
06651 // bounds checks
06652 if (a0<0) a0+=nz;
06653 if (a1<0) a1+=nz;
06654 if (a0<0) a0=0;
06655 if (a1<0) a1=0;
06656 if (a0>=nz) a0=nz-1;
06657 if (a1>=nz) a1=nz-1;
06658
06659 for (int y=0; y<ny; y++) {
06660 for (int x=0; x<nx; x++) {
06661 double sum=0.0;
06662 for (int z=a0; z<=a1; z++) sum+=image->get_value_at(x,y,z);
06663 ret->set_value_at(x,y,(float)sum);
06664 }
06665 }
06666 }
06667
06668 ret->update();
06669 return ret;
06670 }
|
|
|
Implements EMAN::Processor. Definition at line 5426 of file processor.h. References InvalidCallException. 05426 {
05427 throw InvalidCallException("The directional sum processor does not work inplace");
05428 }
|
|
|
Definition at line 180 of file processor.cpp. |
1.3.9.1