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 5560 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 5594 of file processor.h.

05595                 {
05596                         return "Calculates the projection of the image along one of the axial directions, either x, y or z";
05597                 }

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 5563 of file processor.h.

References NAME.

05564                 {
05565                         return NAME;
05566                 }

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 5585 of file processor.h.

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

05586                 {
05587                         TypeDict d;
05588                         d.put("axis", EMObject::STRING,"The direction of the sum, either x,y or z. Returned axes are xy, xz or zy.");
05589                         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)");
05590                         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)");
05591                         return d;
05592                 }

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

Definition at line 5568 of file processor.h.

05569                 {
05570                         return new DirectionalSumProcessor();
05571                 }

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 6862 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.

06862                                                                    {
06863         string dir = params.set_default("axis", "");
06864         if ( dir == "" || ( dir != "x" && dir != "y" && dir != "z" ) )
06865                 throw InvalidParameterException("The direction parameter must be either x, y, or z");
06866 
06867         int nx = image->get_xsize();
06868         int ny = image->get_ysize();
06869         int nz = image->get_zsize();
06870 
06871         int a0 = params.set_default("first", 0);
06872         int a1 = params.set_default("last", -1);
06873 
06874         EMData* ret = new EMData;
06875         // compress one of the dimensions
06876         if ( dir == "x" ) {
06877                 ret->set_size(nz,ny);
06878 
06879                 // bounds checks
06880                 if (a0<0) a0+=nx;
06881                 if (a1<0) a1+=nx;
06882                 if (a0<0) a0=0;
06883                 if (a1<0) a1=0;
06884                 if (a0>=nx) a0=nx-1;
06885                 if (a1>=nx) a1=nx-1;
06886 
06887                 for (int y=0; y<ny; y++) {
06888                         for (int z=0; z<nz; z++) {
06889                                 double sum=0.0;
06890                                 for (int x=a0; x<=a1; x++) sum+=image->get_value_at(x,y,z);
06891                                 ret->set_value_at(z,y,(float)sum);
06892                         }
06893                 }
06894         }
06895         else if ( dir == "y" ) {
06896                 ret->set_size(nx,nz);
06897 
06898                 // bounds checks
06899                 if (a0<0) a0+=ny;
06900                 if (a1<0) a1+=ny;
06901                 if (a0<0) a0=0;
06902                 if (a1<0) a1=0;
06903                 if (a0>=ny) a0=ny-1;
06904                 if (a1>=ny) a1=ny-1;
06905 
06906                 for (int x=0; x<nx; x++) {
06907                         for (int z=0; z<nz; z++) {
06908                                 double sum=0.0;
06909                                 for (int y=a0; y<=a1; y++) sum+=image->get_value_at(x,y,z);
06910                                 ret->set_value_at(x,z,(float)sum);
06911                         }
06912                 }
06913         }
06914         else if ( dir == "z" ) {
06915                 ret->set_size(nx,ny);
06916 
06917                 // bounds checks
06918                 if (a0<0) a0+=nz;
06919                 if (a1<0) a1+=nz;
06920                 if (a0<0) a0=0;
06921                 if (a1<0) a1=0;
06922                 if (a0>=nz) a0=nz-1;
06923                 if (a1>=nz) a1=nz-1;
06924 
06925                 for (int y=0; y<ny; y++) {
06926                         for (int x=0; x<nx; x++) {
06927                                 double sum=0.0;
06928                                 for (int z=a0; z<=a1; z++) sum+=image->get_value_at(x,y,z);
06929                                 ret->set_value_at(x,y,(float)sum);
06930                         }
06931                 }
06932         }
06933 
06934         ret->update();
06935         return ret;
06936 }

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

Exceptions:
InvalidCallException raised if this function is called

Implements EMAN::Processor.

Definition at line 5581 of file processor.h.

References InvalidCallException.

05581                                                       {
05582                         throw InvalidCallException("The directional sum processor does not work inplace");
05583                 }


Member Data Documentation

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

Definition at line 5599 of file processor.h.

Referenced by get_name().


The documentation for this class was generated from the following files:
Generated on Tue Jun 11 12:44:31 2013 for EMAN2 by  doxygen 1.4.7