EMAN::DirectionalSumProcessor Class Reference

Does a projection in one the axial directions Doesn't support process_inplace (because the output has potentially been compressed in one dimension). More...

#include <processor.h>

Inheritance diagram for EMAN::DirectionalSumProcessor:

Inheritance graph
[legend]
Collaboration diagram for EMAN::DirectionalSumProcessor:

Collaboration graph
[legend]
List of all members.

Public Member Functions

virtual string get_name () const
 Get the processor's name.
virtual EMDataprocess (const EMData *const image)
 
Exceptions:
InvalidParameterException raised if the direction parameter is not "x", "y" or "z"

virtual void process_inplace (EMData *)
 
Exceptions:
InvalidCallException raised if this function is called

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

static ProcessorNEW ()

Static Public Attributes

static const string NAME = "misc.directional_sum"

Detailed Description

Does a projection in one the axial directions Doesn't support process_inplace (because the output has potentially been compressed in one dimension).

Parameters:
direction The direction of the sum, either x,y or z

Definition at line 5443 of file processor.h.


Member Function Documentation

string EMAN::DirectionalSumProcessor::get_desc (  )  const [inline, virtual]

Get the descrition of this specific processor.

This function must be overwritten by a subclass.

Returns:
The description of this processor.

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                 }

virtual string EMAN::DirectionalSumProcessor::get_name (  )  const [inline, virtual]

Get the processor's name.

Each processor is identified by a unique name.

Returns:
The processor's name.

Implements EMAN::Processor.

Definition at line 5446 of file processor.h.

References NAME.

05447                 {
05448                         return NAME;
05449                 }

virtual TypeDict EMAN::DirectionalSumProcessor::get_param_types (  )  const [inline, virtual]

Get processor parameter information in a dictionary.

Each parameter has one record in the dictionary. Each record contains its name, data-type, and description.

Returns:
A dictionary containing the parameter info.

Reimplemented from EMAN::Processor.

Definition at line 5468 of file processor.h.

References EMAN::EMObject::INT, EMAN::TypeDict::put(), and EMAN::EMObject::STRING.

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                 }

static Processor* EMAN::DirectionalSumProcessor::NEW (  )  [inline, static]

Definition at line 5451 of file processor.h.

05452                 {
05453                         return new DirectionalSumProcessor();
05454                 }

EMData * DirectionalSumProcessor::process ( const EMData *const   image  )  [virtual]

Exceptions:
InvalidParameterException raised if the direction parameter is not "x", "y" or "z"

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, EMAN::Processor::params, EMAN::Dict::set_default(), EMAN::EMData::set_size(), EMAN::EMData::set_value_at(), EMAN::EMData::update(), and x.

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 }

virtual void EMAN::DirectionalSumProcessor::process_inplace ( EMData  )  [inline, virtual]

Exceptions:
InvalidCallException raised if this function is called

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                 }


Member Data Documentation

const string DirectionalSumProcessor::NAME = "misc.directional_sum" [static]

Definition at line 5482 of file processor.h.

Referenced by get_name().


The documentation for this class was generated from the following files:
Generated on Tue Jul 12 13:49:31 2011 for EMAN2 by  doxygen 1.4.7