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

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 4753 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 4773 of file processor.h.

04774                         {
04775                                 return "Undoes the xform.fourierorigin.tocenter processor";
04776                         }

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 4763 of file processor.h.

References NAME.

04764                         {
04765                                 return NAME;
04766                         }

static Processor* EMAN::FourierToCornerProcessor::NEW (  )  [inline, static]

Definition at line 4768 of file processor.h.

04769                         {
04770                                 return new FourierToCornerProcessor();
04771                         }

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:
image the image to operate on
Exceptions:
ImageFormatException if the image is not complex

Implements EMAN::Processor.

Definition at line 4517 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(), rdata, and EMAN::EMData::set_shuffled().

04518 {
04519         if ( !image->is_complex() ) throw ImageFormatException("Can not Fourier origin shift an image that is not complex");
04520 
04521         int nx=image->get_xsize();
04522         int ny=image->get_ysize();
04523         int nz=image->get_zsize();
04524 
04525         int nxy = nx*ny;
04526 
04527         if ( ny == 1 && nz == 1 ){
04528                 cout << "Warning- attempted     Fourier origin shift a 1D image - no action taken" << endl;
04529                 return;
04530         }
04531         int yodd = (ny%2==1);
04532         int zodd = (nz%2==1);
04533 
04534         float* rdata = image->get_data();
04535 
04536         float tmp[2];
04537         float* p1;
04538         float* p2;
04539 
04540         if (yodd){
04541                 // Swap the middle slice (with respect to the y direction) with the bottom slice
04542                 // shifting all slices above the middles slice upwards by one pixel, stopping
04543                 // at the middle slice, not if nz = 1 we are not talking about slices, we are
04544                 // talking about rows
04545                 float prev[2];
04546                 size_t idx;
04547                 for( int s = 0; s < nz; s++ ) {
04548                         for( int c =0; c < nx; c += 2 ) {
04549                                 idx = (size_t)s*nxy+ny/2*nx+c;
04550                                 prev[0] = rdata[idx];
04551                                 prev[1] = rdata[idx+1];
04552                                 for( int r = 0; r <= ny/2; ++r ) {
04553                                         idx = (size_t)s*nxy+r*nx+c;
04554                                         float* p1 = &rdata[idx];
04555                                         tmp[0] = p1[0];
04556                                         tmp[1] = p1[1];
04557 
04558                                         p1[0] = prev[0];
04559                                         p1[1] = prev[1];
04560 
04561                                         prev[0] = tmp[0];
04562                                         prev[1] = tmp[1];
04563                                 }
04564                         }
04565                 }
04566         }
04567 
04568         // Shift slices (3D) or rows (2D) correctly in the y direction
04569         size_t idx1, idx2;
04570         for( int s = 0; s < nz; ++s ) {
04571                 for( int r = 0 + yodd; r < ny/2+yodd; ++r ) {
04572                         for( int c =0; c < nx; c += 2 ) {
04573                                 idx1 = (size_t)s*nxy+r*nx+c;
04574                                 idx2 = (size_t)s*nxy+(r+ny/2)*nx+c;
04575                                 p1 = &rdata[idx1];
04576                                 p2 = &rdata[idx2];
04577 
04578                                 tmp[0] = p1[0];
04579                                 tmp[1] = p1[1];
04580 
04581                                 p1[0] = p2[0];
04582                                 p1[1] = p2[1];
04583 
04584                                 p2[0] = tmp[0];
04585                                 p2[1] = tmp[1];
04586                         }
04587                 }
04588         }
04589 
04590         if ( nz != 1 )
04591         {
04592 
04593                 if (zodd){
04594                         // Swap the middle slice (with respect to the z direction) and the front slice
04595                         // shifting all behind the front slice towards the middle a distance of 1 voxel,
04596                         // stopping at the middle slice.
04597                         float prev[2];
04598                         size_t idx;
04599                         for( int r = 0; r < ny; ++r ) {
04600                                 for( int c =0; c < nx; c += 2 ) {
04601                                         idx = (size_t)nz/2*nxy+r*nx+c;
04602                                         prev[0] = rdata[idx];
04603                                         prev[1] = rdata[idx+1];
04604                                         for( int s = 0; s <= nz/2; ++s ) {
04605                                                 idx = (size_t)s*nxy+r*nx+c;
04606                                                 float* p1 = &rdata[idx];
04607                                                 tmp[0] = p1[0];
04608                                                 tmp[1] = p1[1];
04609 
04610                                                 p1[0] = prev[0];
04611                                                 p1[1] = prev[1];
04612 
04613                                                 prev[0] = tmp[0];
04614                                                 prev[1] = tmp[1];
04615                                         }
04616                                 }
04617                         }
04618                 }
04619 
04620                 // Shift slices correctly in the z direction
04621                 size_t idx1, idx2;
04622                 for( int s = 0+zodd; s < nz/2 + zodd; ++s ) {
04623                         for( int r = 0; r < ny; ++r ) {
04624                                 for( int c =0; c < nx; c += 2 ) {
04625                                         idx1 = (size_t)s*nxy+r*nx+c;
04626                                         idx2 = (size_t)(s+nz/2)*nxy+r*nx+c;
04627                                         p1 = &rdata[idx1];
04628                                         p2 = &rdata[idx2];
04629 
04630                                         tmp[0] = p1[0];
04631                                         tmp[1] = p1[1];
04632 
04633                                         p1[0] = p2[0];
04634                                         p1[1] = p2[1];
04635 
04636                                         p2[0] = tmp[0];
04637                                         p2[1] = tmp[1];
04638                                 }
04639                         }
04640                 }
04641         }
04642         image->set_shuffled(false);
04643 }


Member Data Documentation

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

Definition at line 4778 of file processor.h.

Referenced by get_name().


The documentation for this class was generated from the following files:
Generated on Thu May 3 10:10:32 2012 for EMAN2 by  doxygen 1.4.7