Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

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)
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

ProcessorNEW ()

Static Public Attributes

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

05509                 {
05510                         return "Calculates the projection of the image along one of the axial directions, either x, y or z";
05511                 }

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

05478                 {
05479                         return NAME;
05480                 }

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

References EMAN::TypeDict::put().

05500                 {
05501                         TypeDict d;
05502                         d.put("axis", EMObject::STRING,"The direction of the sum, either x,y or z. Returned axes are xy, xz or zy.");
05503                         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)");
05504                         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)");
05505                         return d;
05506                 }

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

Definition at line 5482 of file processor.h.

05483                 {
05484                         return new DirectionalSumProcessor();
05485                 }

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

06710                                                                    {
06711         string dir = params.set_default("axis", "");
06712         if ( dir == "" || ( dir != "x" && dir != "y" && dir != "z" ) )
06713                 throw InvalidParameterException("The direction parameter must be either x, y, or z");
06714 
06715         int nx = image->get_xsize();
06716         int ny = image->get_ysize();
06717         int nz = image->get_zsize();
06718 
06719         int a0 = params.set_default("first", 0);
06720         int a1 = params.set_default("last", -1);
06721 
06722         EMData* ret = new EMData;
06723         // compress one of the dimensions
06724         if ( dir == "x" ) {
06725                 ret->set_size(nz,ny);
06726 
06727                 // bounds checks
06728                 if (a0<0) a0+=nx;
06729                 if (a1<0) a1+=nx;
06730                 if (a0<0) a0=0;
06731                 if (a1<0) a1=0;
06732                 if (a0>=nx) a0=nx-1;
06733                 if (a1>=nx) a1=nx-1;
06734 
06735                 for (int y=0; y<ny; y++) {
06736                         for (int z=0; z<nz; z++) {
06737                                 double sum=0.0;
06738                                 for (int x=a0; x<=a1; x++) sum+=image->get_value_at(x,y,z);
06739                                 ret->set_value_at(z,y,(float)sum);
06740                         }
06741                 }
06742         }
06743         else if ( dir == "y" ) {
06744                 ret->set_size(nx,nz);
06745 
06746                 // bounds checks
06747                 if (a0<0) a0+=ny;
06748                 if (a1<0) a1+=ny;
06749                 if (a0<0) a0=0;
06750                 if (a1<0) a1=0;
06751                 if (a0>=ny) a0=ny-1;
06752                 if (a1>=ny) a1=ny-1;
06753 
06754                 for (int x=0; x<nx; x++) {
06755                         for (int z=0; z<nz; z++) {
06756                                 double sum=0.0;
06757                                 for (int y=a0; y<=a1; y++) sum+=image->get_value_at(x,y,z);
06758                                 ret->set_value_at(x,z,(float)sum);
06759                         }
06760                 }
06761         }
06762         else if ( dir == "z" ) {
06763                 ret->set_size(nx,ny);
06764 
06765                 // bounds checks
06766                 if (a0<0) a0+=nz;
06767                 if (a1<0) a1+=nz;
06768                 if (a0<0) a0=0;
06769                 if (a1<0) a1=0;
06770                 if (a0>=nz) a0=nz-1;
06771                 if (a1>=nz) a1=nz-1;
06772 
06773                 for (int y=0; y<ny; y++) {
06774                         for (int x=0; x<nx; x++) {
06775                                 double sum=0.0;
06776                                 for (int z=a0; z<=a1; z++) sum+=image->get_value_at(x,y,z);
06777                                 ret->set_value_at(x,y,(float)sum);
06778                         }
06779                 }
06780         }
06781 
06782         ret->update();
06783         return ret;
06784 }

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

Exceptions:
InvalidCallException raised if this function is called

Implements EMAN::Processor.

Definition at line 5495 of file processor.h.

References InvalidCallException.

05495                                                       {
05496                         throw InvalidCallException("The directional sum processor does not work inplace");
05497                 }


Member Data Documentation

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

Definition at line 181 of file processor.cpp.


The documentation for this class was generated from the following files:
Generated on Thu Nov 17 12:46:31 2011 for EMAN2 by  doxygen 1.3.9.1