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

EMAN::TransposeProcessor Class Reference
[unit test in Python]

Transpose a 2D image. More...

#include <processor.h>

Inheritance diagram for EMAN::TransposeProcessor:

[legend]
Collaboration diagram for EMAN::TransposeProcessor:
[legend]
List of all members.

Public Member Functions

virtual void process_inplace (EMData *image)
 See Processor comments for more details.
virtual EMDataprocess (const EMData *const image)
 See Processor comments for more details.
virtual string get_name () const
 Get the processor's name.
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 = "xform.transpose"

Detailed Description

Transpose a 2D image.

Author:
David Woolford
Date:
April 27th 2009

Definition at line 4455 of file processor.h.


Member Function Documentation

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

04488                 {
04489                         return "Get the transpose of an image. Works for 2D only";
04490                 }

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

04472                 {
04473                         return NAME;
04474                 }

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

04482                 {
04483                         TypeDict d;
04484                         return d;
04485                 }

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

Definition at line 4476 of file processor.h.

04477                 {
04478                         return new TransposeProcessor();
04479                 }

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

See Processor comments for more details.

Exceptions:
UnexpectedBehaviorException if the image is not 2D
UnexpectedBehaviorException if the image is complex

Reimplemented from EMAN::Processor.

Definition at line 4182 of file processor.cpp.

References EMAN::EMData::get_ndim(), EMAN::EMData::get_value_at(), EMAN::EMData::get_xsize(), EMAN::EMData::get_ysize(), EMAN::EMData::is_complex(), EMAN::EMData::set_value_at(), and UnexpectedBehaviorException.

04182                                                              {
04183         if (image->get_ndim() != 2) throw UnexpectedBehaviorException("Transpose processor only works with 2D images");
04184         if (image->is_complex()) throw UnexpectedBehaviorException("Transpose processor only works with real images");
04185 
04186         EMData* ret = new EMData(image->get_ysize(),image->get_xsize(),1); // transpose dimensions
04187 
04188         for(int j = 0; j< image->get_ysize();++j) {
04189                 for(int i = 0; i< image->get_xsize();++i) {
04190                         ret->set_value_at(j,i,image->get_value_at(i,j));
04191                 }
04192         }
04193 
04194         return ret;
04195 
04196 }

void TransposeProcessor::process_inplace EMData image  )  [virtual]
 

See Processor comments for more details.

Exceptions:
UnexpectedBehaviorException if the image is not 2D
UnexpectedBehaviorException if the image is complex

Implements EMAN::Processor.

Definition at line 4198 of file processor.cpp.

References data, EMAN::EMData::get_ndim(), EMAN::EMData::get_value_at(), EMAN::EMData::get_xsize(), EMAN::EMData::get_ysize(), EMAN::EMData::is_complex(), nx, EMAN::EMData::set_data(), and UnexpectedBehaviorException.

04198                                                       {
04199         if (image->get_ndim() != 2) throw UnexpectedBehaviorException("Transpose processor only works with 2D images");
04200         if (image->is_complex()) throw UnexpectedBehaviorException("Transpose processor only works with real images");
04201 
04202         float* data = (float*)malloc(image->get_ysize()*image->get_xsize()*sizeof(float));
04203 
04204         int nx = image->get_ysize(); // note tranpose
04205         for(int j = 0; j< image->get_ysize();++j) {
04206                 for(int i = 0; i< image->get_xsize();++i) {
04207                         data[i*nx+j] = image->get_value_at(i,j);
04208                 }
04209         }
04210 
04211         image->set_data(data,image->get_ysize(),image->get_xsize(),1);
04212 
04213 }


Member Data Documentation

const string TransposeProcessor::NAME = "xform.transpose" [static]
 

Definition at line 156 of file processor.cpp.


The documentation for this class was generated from the following files:
Generated on Fri Apr 30 15:39:25 2010 for EMAN2 by  doxygen 1.3.9.1