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

EMAN::IntTranslateProcessor Class Reference
[a function or class that is CUDA enabled]

Translate the image an integer amount Uses EMData::clip_inplace (inplace) and EMData::get_clip (out of place) to do the translation. More...

#include <processor.h>

Inheritance diagram for EMAN::IntTranslateProcessor:

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

Collaboration graph
[legend]
List of all members.

Public Member Functions

virtual string get_name () const
 Get the processor's name.
virtual void process_inplace (EMData *image)
virtual EMDataprocess (const EMData *const image)
virtual TypeDict get_param_types () const
 Get processor parameter information in a dictionary.
virtual string get_desc () const
 Get the descrition of this specific processor.

Static Public Member Functions

ProcessorNEW ()

Static Public Attributes

const string NAME = "math.translate.int"

Private Member Functions

void assert_valid_aspect (const vector< int > &translation, const EMData *const image) const
 Check that the particular aspect is valid.
Region get_clip_region (vector< int > &translation, const EMData *const image) const
 Get the clip region that will achieve the desired translation.

Detailed Description

Translate the image an integer amount Uses EMData::clip_inplace (inplace) and EMData::get_clip (out of place) to do the translation.

Author:
David Woolford
Date:
March 2009
Parameters:
trans The displacement array, can be length 1-3

Definition at line 1520 of file processor.h.


Member Function Documentation

void IntTranslateProcessor::assert_valid_aspect const vector< int > &  translation,
const EMData *const   image
const [private]
 

Check that the particular aspect is valid.

Exceptions:
ImageDimensionException if the image is not 1,2 or 3D

Definition at line 8584 of file processor.cpp.

References InvalidParameterException.

Referenced by process(), and process_inplace().

08584                                                                                                          {
08585         if (translation.size() == 0 ) throw InvalidParameterException("You must specify the trans argument");
08586 }

Region IntTranslateProcessor::get_clip_region vector< int > &  translation,
const EMData *const   image
const [private]
 

Get the clip region that will achieve the desired translation.

Exceptions:
ImageDimensionException if the image is not 1,2 or 3D
Parameters:
translation the amount by which to translate
image the image that will eventually used for the translation operation

Definition at line 8588 of file processor.cpp.

References EMAN::EMData::get_ndim(), EMAN::EMData::get_xsize(), EMAN::EMData::get_ysize(), EMAN::EMData::get_zsize(), and ImageDimensionException.

Referenced by process(), and process_inplace().

08588                                                                                                        {
08589         unsigned int dim = static_cast<unsigned int> (image->get_ndim());
08590 
08591         if ( translation.size() != dim ) {
08592                 for(unsigned int i = translation.size(); i < dim; ++i ) translation.push_back(0);
08593         }
08594 
08595         Region clip_region;
08596         if (dim == 1) {
08597                 clip_region = Region(-translation[0],image->get_xsize());
08598         } else if ( dim == 2 ) {
08599                 clip_region = Region(-translation[0],-translation[1],image->get_xsize(),image->get_ysize());
08600         } else if ( dim == 3 ) {
08601                 clip_region = Region(-translation[0],-translation[1],-translation[2],image->get_xsize(),image->get_ysize(),image->get_zsize());
08602         } else throw ImageDimensionException("Only 1,2 and 3D images are supported");
08603 
08604         return clip_region;
08605 }

virtual string EMAN::IntTranslateProcessor::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 1552 of file processor.h.

01553                         {
01554                                 return "The image is translated an integer amount";
01555                         }

virtual string EMAN::IntTranslateProcessor::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 1523 of file processor.h.

01524                         {
01525                                 return NAME;
01526                         }

virtual TypeDict EMAN::IntTranslateProcessor::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 1545 of file processor.h.

References EMAN::TypeDict::put().

01546                         {
01547                                 TypeDict d;
01548                                 d.put("trans", EMObject::INTARRAY, "The displacement array, can be length 1-3" );
01549                                 return d;
01550                         }

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

Definition at line 1528 of file processor.h.

01529                         {
01530                                 return new IntTranslateProcessor();
01531                         }

EMData * IntTranslateProcessor::process const EMData *const   image  )  [virtual]
 

Exceptions:
ImageDimensionException if the image is not 1,2 or 3D
InvalidParameterException if the Transform parameter is not specified

Reimplemented from EMAN::Processor.

Definition at line 8620 of file processor.cpp.

References assert_valid_aspect(), EMAN::EMData::get_clip(), get_clip_region(), and EMAN::Dict::set_default().

08620                                                                 {
08621 
08622         vector<int> translation = params.set_default("trans",vector<int>() );
08623 
08624         assert_valid_aspect(translation,image);
08625 
08626         Region clip_region = get_clip_region(translation,image);
08627 
08628         return image->get_clip(clip_region,0);
08629         // clip_inplace does the update!
08630 }

void IntTranslateProcessor::process_inplace EMData image  )  [virtual]
 

Exceptions:
ImageDimensionException if the image is not 1,2 or 3D
InvalidParameterException if the Transform parameter is not specified

Implements EMAN::Processor.

Definition at line 8607 of file processor.cpp.

References assert_valid_aspect(), EMAN::EMData::clip_inplace(), get_clip_region(), and EMAN::Dict::set_default().

08607                                                          {
08608 
08609         vector<int> translation = params.set_default("trans",vector<int>() );
08610 
08611 
08612         assert_valid_aspect(translation,image);
08613 
08614         Region clip_region = get_clip_region(translation,image);
08615 
08616         image->clip_inplace(clip_region,0);
08617         // clip_inplace does the update!
08618 }


Member Data Documentation

const string IntTranslateProcessor::NAME = "math.translate.int" [static]
 

Definition at line 87 of file processor.cpp.


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