#include <processor.h>
Inheritance diagram for EMAN::IntTranslateProcessor:
Public Member Functions | |||||||
virtual string | get_name () const | ||||||
Get the processor's name. | |||||||
virtual void | process_inplace (EMData *image) | ||||||
| |||||||
virtual EMData * | process (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 | |||||||
static Processor * | NEW () | ||||||
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
| |||||||
Region | get_clip_region (vector< int > &translation, const EMData *const image) const | ||||||
Get the clip region that will achieve the desired translation
|
trans | The displacement array, can be length 1-3 |
Definition at line 1565 of file processor.h.
void IntTranslateProcessor::assert_valid_aspect | ( | const vector< int > & | translation, | |
const EMData *const | image | |||
) | const [private] |
Check that the particular aspect is valid
ImageDimensionException | if the image is not 1,2 or 3D. |
Definition at line 8736 of file processor.cpp.
References InvalidParameterException.
Referenced by process(), and process_inplace().
08736 { 08737 if (translation.size() == 0 ) throw InvalidParameterException("You must specify the trans argument"); 08738 }
Region IntTranslateProcessor::get_clip_region | ( | vector< int > & | translation, | |
const EMData *const | image | |||
) | const [private] |
Get the clip region that will achieve the desired translation
ImageDimensionException | if the image is not 1,2 or 3D. |
translation | the amount by which to translate | |
image | the image that will eventually used for the translation operation |
Definition at line 8740 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().
08740 { 08741 unsigned int dim = static_cast<unsigned int> (image->get_ndim()); 08742 08743 if ( translation.size() != dim ) { 08744 for(unsigned int i = translation.size(); i < dim; ++i ) translation.push_back(0); 08745 } 08746 08747 Region clip_region; 08748 if (dim == 1) { 08749 clip_region = Region(-translation[0],image->get_xsize()); 08750 } else if ( dim == 2 ) { 08751 clip_region = Region(-translation[0],-translation[1],image->get_xsize(),image->get_ysize()); 08752 } else if ( dim == 3 ) { 08753 clip_region = Region(-translation[0],-translation[1],-translation[2],image->get_xsize(),image->get_ysize(),image->get_zsize()); 08754 } else throw ImageDimensionException("Only 1,2 and 3D images are supported"); 08755 08756 return clip_region; 08757 }
virtual string EMAN::IntTranslateProcessor::get_desc | ( | ) | const [inline, virtual] |
Get the descrition of this specific processor.
This function must be overwritten by a subclass.
Implements EMAN::Processor.
Definition at line 1597 of file processor.h.
virtual string EMAN::IntTranslateProcessor::get_name | ( | ) | const [inline, virtual] |
Get the processor's name.
Each processor is identified by a unique name.
Implements EMAN::Processor.
Definition at line 1568 of file processor.h.
References NAME.
01569 { 01570 return NAME; 01571 }
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.
Reimplemented from EMAN::Processor.
Definition at line 1590 of file processor.h.
References EMAN::EMObject::INTARRAY, and EMAN::TypeDict::put().
01591 { 01592 TypeDict d; 01593 d.put("trans", EMObject::INTARRAY, "The displacement array, can be length 1-3" ); 01594 return d; 01595 }
static Processor* EMAN::IntTranslateProcessor::NEW | ( | ) | [inline, static] |
Definition at line 1573 of file processor.h.
01574 { 01575 return new IntTranslateProcessor(); 01576 }
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 8772 of file processor.cpp.
References assert_valid_aspect(), EMAN::EMData::get_clip(), get_clip_region(), EMAN::Processor::params, and EMAN::Dict::set_default().
08772 { 08773 08774 vector<int> translation = params.set_default("trans",vector<int>() ); 08775 08776 assert_valid_aspect(translation,image); 08777 08778 Region clip_region = get_clip_region(translation,image); 08779 08780 return image->get_clip(clip_region,0); 08781 // clip_inplace does the update! 08782 }
void IntTranslateProcessor::process_inplace | ( | EMData * | image | ) | [virtual] |
ImageDimensionException | if the image is not 1,2 or 3D | |
InvalidParameterException | if the Transform parameter is not specified |
Implements EMAN::Processor.
Definition at line 8759 of file processor.cpp.
References assert_valid_aspect(), EMAN::EMData::clip_inplace(), get_clip_region(), EMAN::Processor::params, and EMAN::Dict::set_default().
08759 { 08760 08761 vector<int> translation = params.set_default("trans",vector<int>() ); 08762 08763 08764 assert_valid_aspect(translation,image); 08765 08766 Region clip_region = get_clip_region(translation,image); 08767 08768 image->clip_inplace(clip_region,0); 08769 // clip_inplace does the update! 08770 }
const string IntTranslateProcessor::NAME = "xform.translate.int" [static] |