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

Undo the effects of the FourierToCenterProcessor. More...

#include <processor.h>

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

List of all members.

Public Member Functions

virtual void process_inplace (EMData *image)
 Fourier origin shift the image in the backwards direction Should only be called after the application of FourierToCenterProcessor.
virtual string get_name () const
 Get the processor's name.
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.fourierorigin.tocorner"

Detailed Description

Undo the effects of the FourierToCenterProcessor.

Author:
David Woolford <woolford@bcm.edu>
Date:
October 2007

Definition at line 5008 of file processor.h.


Member Function Documentation

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

                        {
                                return "Undoes the xform.fourierorigin.tocenter processor";
                        }
virtual string EMAN::FourierToCornerProcessor::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 5018 of file processor.h.

References NAME.

                        {
                                return NAME;
                        }
static Processor* EMAN::FourierToCornerProcessor::NEW ( ) [inline, static]

Definition at line 5023 of file processor.h.

                        {
                                return new FourierToCornerProcessor();
                        }
void FourierToCornerProcessor::process_inplace ( EMData image) [virtual]

Fourier origin shift the image in the backwards direction Should only be called after the application of FourierToCenterProcessor.

Parameters:
imagethe image to operate on
Exceptions:
ImageFormatExceptionif the image is not complex

Implements EMAN::Processor.

Definition at line 4737 of file processor.cpp.

References EMAN::EMData::get_data(), EMAN::EMData::get_xsize(), EMAN::EMData::get_ysize(), EMAN::EMData::get_zsize(), ImageFormatException, EMAN::EMData::is_complex(), nx, ny, rdata, and EMAN::EMData::set_shuffled().

{
        if ( !image->is_complex() ) throw ImageFormatException("Can not Fourier origin shift an image that is not complex");

        int nx=image->get_xsize();
        int ny=image->get_ysize();
        int nz=image->get_zsize();

        int nxy = nx*ny;

        if ( ny == 1 && nz == 1 ){
                cout << "Warning- attempted     Fourier origin shift a 1D image - no action taken" << endl;
                return;
        }
        int yodd = (ny%2==1);
        int zodd = (nz%2==1);

        float* rdata = image->get_data();

        float tmp[2];
        float* p1;
        float* p2;

        if (yodd){
                // Swap the middle slice (with respect to the y direction) with the bottom slice
                // shifting all slices above the middles slice upwards by one pixel, stopping
                // at the middle slice, not if nz = 1 we are not talking about slices, we are
                // talking about rows
                float prev[2];
                size_t idx;
                for( int s = 0; s < nz; s++ ) {
                        for( int c =0; c < nx; c += 2 ) {
                                idx = (size_t)s*nxy+ny/2*nx+c;
                                prev[0] = rdata[idx];
                                prev[1] = rdata[idx+1];
                                for( int r = 0; r <= ny/2; ++r ) {
                                        idx = (size_t)s*nxy+r*nx+c;
                                        float* p1 = &rdata[idx];
                                        tmp[0] = p1[0];
                                        tmp[1] = p1[1];

                                        p1[0] = prev[0];
                                        p1[1] = prev[1];

                                        prev[0] = tmp[0];
                                        prev[1] = tmp[1];
                                }
                        }
                }
        }

        // Shift slices (3D) or rows (2D) correctly in the y direction
        size_t idx1, idx2;
        for( int s = 0; s < nz; ++s ) {
                for( int r = 0 + yodd; r < ny/2+yodd; ++r ) {
                        for( int c =0; c < nx; c += 2 ) {
                                idx1 = (size_t)s*nxy+r*nx+c;
                                idx2 = (size_t)s*nxy+(r+ny/2)*nx+c;
                                p1 = &rdata[idx1];
                                p2 = &rdata[idx2];

                                tmp[0] = p1[0];
                                tmp[1] = p1[1];

                                p1[0] = p2[0];
                                p1[1] = p2[1];

                                p2[0] = tmp[0];
                                p2[1] = tmp[1];
                        }
                }
        }

        if ( nz != 1 )
        {

                if (zodd){
                        // Swap the middle slice (with respect to the z direction) and the front slice
                        // shifting all behind the front slice towards the middle a distance of 1 voxel,
                        // stopping at the middle slice.
                        float prev[2];
                        size_t idx;
                        for( int r = 0; r < ny; ++r ) {
                                for( int c =0; c < nx; c += 2 ) {
                                        idx = (size_t)nz/2*nxy+r*nx+c;
                                        prev[0] = rdata[idx];
                                        prev[1] = rdata[idx+1];
                                        for( int s = 0; s <= nz/2; ++s ) {
                                                idx = (size_t)s*nxy+r*nx+c;
                                                float* p1 = &rdata[idx];
                                                tmp[0] = p1[0];
                                                tmp[1] = p1[1];

                                                p1[0] = prev[0];
                                                p1[1] = prev[1];

                                                prev[0] = tmp[0];
                                                prev[1] = tmp[1];
                                        }
                                }
                        }
                }

                // Shift slices correctly in the z direction
                size_t idx1, idx2;
                for( int s = 0+zodd; s < nz/2 + zodd; ++s ) {
                        for( int r = 0; r < ny; ++r ) {
                                for( int c =0; c < nx; c += 2 ) {
                                        idx1 = (size_t)s*nxy+r*nx+c;
                                        idx2 = (size_t)(s+nz/2)*nxy+r*nx+c;
                                        p1 = &rdata[idx1];
                                        p2 = &rdata[idx2];

                                        tmp[0] = p1[0];
                                        tmp[1] = p1[1];

                                        p1[0] = p2[0];
                                        p1[1] = p2[1];

                                        p2[0] = tmp[0];
                                        p2[1] = tmp[1];
                                }
                        }
                }
        }
        image->set_shuffled(false);
}

Member Data Documentation

const string FourierToCornerProcessor::NAME = "xform.fourierorigin.tocorner" [static]

Definition at line 5033 of file processor.h.

Referenced by get_name().


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