EMAN2
Public Member Functions | Static Public Member Functions | Static Public Attributes
EMAN::TransposeProcessor Class Reference

Transpose a 2D image. More...

#include <processor.h>

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

List of all members.

Public Member Functions

virtual void process_inplace (EMData *image)
 See Processor comments for more details

Exceptions:
UnexpectedBehaviorExceptionif the image is not 2D
UnexpectedBehaviorExceptionif the image is complex.

virtual EMDataprocess (const EMData *const image)
 See Processor comments for more details

Exceptions:
UnexpectedBehaviorExceptionif the image is not 2D
UnexpectedBehaviorExceptionif the image is complex.

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

static ProcessorNEW ()

Static Public Attributes

static const string NAME = "xform.transpose"

Detailed Description

Transpose a 2D image.

Author:
David Woolford
Date:
April 27th 2009

Definition at line 4790 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 4822 of file processor.h.

                {
                        return "Get the transpose of an image. Works for 2D only";
                }
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 4806 of file processor.h.

References NAME.

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

                {
                        TypeDict d;
                        return d;
                }
static Processor* EMAN::TransposeProcessor::NEW ( ) [inline, static]

Definition at line 4811 of file processor.h.

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

See Processor comments for more details

Exceptions:
UnexpectedBehaviorExceptionif the image is not 2D
UnexpectedBehaviorExceptionif the image is complex.

Reimplemented from EMAN::Processor.

Definition at line 4574 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.

                                                             {
        if (image->get_ndim() != 2) throw UnexpectedBehaviorException("Transpose processor only works with 2D images");
        if (image->is_complex()) throw UnexpectedBehaviorException("Transpose processor only works with real images");

        EMData* ret = new EMData(image->get_ysize(),image->get_xsize(),1); // transpose dimensions

        for(int j = 0; j< image->get_ysize();++j) {
                for(int i = 0; i< image->get_xsize();++i) {
                        ret->set_value_at(j,i,image->get_value_at(i,j));
                }
        }

        return ret;

}
void TransposeProcessor::process_inplace ( EMData image) [virtual]

See Processor comments for more details

Exceptions:
UnexpectedBehaviorExceptionif the image is not 2D
UnexpectedBehaviorExceptionif the image is complex.

Implements EMAN::Processor.

Definition at line 4590 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_data(), and UnexpectedBehaviorException.

                                                      {
        if (image->get_ndim() != 2) throw UnexpectedBehaviorException("Transpose processor only works with 2D images");
        if (image->is_complex()) throw UnexpectedBehaviorException("Transpose processor only works with real images");

        float* data = (float*)malloc(image->get_ysize()*image->get_xsize()*sizeof(float));

        int nx = image->get_ysize(); // note tranpose
        for(int j = 0; j< image->get_ysize();++j) {
                for(int i = 0; i< image->get_xsize();++i) {
                        data[i*nx+j] = image->get_value_at(i,j);
                }
        }

        image->set_data(data,image->get_ysize(),image->get_xsize(),1);

}

Member Data Documentation

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

Definition at line 4827 of file processor.h.

Referenced by get_name().


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