EMAN2
Public Member Functions | Static Public Member Functions | Static Public Attributes | Private Member Functions
EMAN::IntTranslateProcessor Class Reference

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)
 
Exceptions:
ImageDimensionExceptionif the image is not 1,2 or 3D
InvalidParameterExceptionif the Transform parameter is not specified

virtual EMDataprocess (const EMData *const image)
 
Exceptions:
ImageDimensionExceptionif the image is not 1,2 or 3D
InvalidParameterExceptionif the Transform parameter is not specified

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

static ProcessorNEW ()

Static Public Attributes

static const string NAME = "xform.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

Exceptions:
ImageDimensionExceptionif the image is not 1,2 or 3D.

Region get_clip_region (vector< int > &translation, const EMData *const image) const
 Get the clip region that will achieve the desired translation

Exceptions:
ImageDimensionExceptionif the image is not 1,2 or 3D.


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:
transThe displacement array, can be length 1-3

Definition at line 1698 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:
ImageDimensionExceptionif the image is not 1,2 or 3D.

Definition at line 9175 of file processor.cpp.

References InvalidParameterException.

                                                                                                         {
        if (translation.size() == 0 ) throw InvalidParameterException("You must specify the trans argument");
}
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:
ImageDimensionExceptionif the image is not 1,2 or 3D.

Parameters:
translationthe amount by which to translate
imagethe image that will eventually used for the translation operation

Definition at line 9179 of file processor.cpp.

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

                                                                                                       {
        unsigned int dim = static_cast<unsigned int> (image->get_ndim());

        if ( translation.size() != dim ) {
                for(unsigned int i = translation.size(); i < dim; ++i ) translation.push_back(0);
        }

        Region clip_region;
        if (dim == 1) {
                clip_region = Region(-translation[0],image->get_xsize());
        } else if ( dim == 2 ) {
                clip_region = Region(-translation[0],-translation[1],image->get_xsize(),image->get_ysize());
        } else if ( dim == 3 ) {
                clip_region = Region(-translation[0],-translation[1],-translation[2],image->get_xsize(),image->get_ysize(),image->get_zsize());
        } else throw ImageDimensionException("Only 1,2 and 3D images are supported");

        return clip_region;
}
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 1730 of file processor.h.

                        {
                                return "The image is translated an integer amount";
                        }
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 1701 of file processor.h.

References NAME.

                        {
                                return NAME;
                        }
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 1723 of file processor.h.

References EMAN::EMObject::INTARRAY, and EMAN::TypeDict::put().

                        {
                                TypeDict d;
                                d.put("trans", EMObject::INTARRAY, "The displacement array, can be length 1-3" );
                                return d;
                        }
static Processor* EMAN::IntTranslateProcessor::NEW ( ) [inline, static]

Definition at line 1706 of file processor.h.

                        {
                                return new IntTranslateProcessor();
                        }
EMData * IntTranslateProcessor::process ( const EMData *const  image) [virtual]

Exceptions:
ImageDimensionExceptionif the image is not 1,2 or 3D
InvalidParameterExceptionif the Transform parameter is not specified

Reimplemented from EMAN::Processor.

Definition at line 9211 of file processor.cpp.

References EMAN::EMData::get_clip(), EMAN::Processor::params, and EMAN::Dict::set_default().

                                                                {

        vector<int> translation = params.set_default("trans",vector<int>() );

        assert_valid_aspect(translation,image);

        Region clip_region = get_clip_region(translation,image);

        return image->get_clip(clip_region,0);
        // clip_inplace does the update!
}
void IntTranslateProcessor::process_inplace ( EMData image) [virtual]

Exceptions:
ImageDimensionExceptionif the image is not 1,2 or 3D
InvalidParameterExceptionif the Transform parameter is not specified

Implements EMAN::Processor.

Definition at line 9198 of file processor.cpp.

References EMAN::EMData::clip_inplace(), EMAN::Processor::params, and EMAN::Dict::set_default().

                                                         {

        vector<int> translation = params.set_default("trans",vector<int>() );


        assert_valid_aspect(translation,image);

        Region clip_region = get_clip_region(translation,image);

        image->clip_inplace(clip_region,0);
        // clip_inplace does the update!
}

Member Data Documentation

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

Definition at line 1735 of file processor.h.

Referenced by get_name().


The documentation for this class was generated from the following files: