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

Translates the origin in Fourier space from the corner to the center in y and z Handles 2D and 3D, and handles all combinations of even and oddness Typically you call this function after Fourier transforming a real space image. More...

#include <processor.h>

Inheritance diagram for EMAN::FourierToCenterProcessor:

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

Collaboration graph
[legend]
List of all members.

Public Member Functions

virtual void process_inplace (EMData *image)
 Fourier origin shift the image in the forward direction.
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.tocenter"

Detailed Description

Translates the origin in Fourier space from the corner to the center in y and z Handles 2D and 3D, and handles all combinations of even and oddness Typically you call this function after Fourier transforming a real space image.

After this you operate on the Fourier image in convenient format, then you call FourierToCornerProcessor (above) and then inverse FT to get to the original image

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

Definition at line 4793 of file processor.h.


Member Function Documentation

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

04814                         {
04815                                 return "Translates the origin in Fourier space from the corner to the center in y and z - works in 2D and 3D";
04816                         }

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

References NAME.

04804                         {
04805                                 return NAME;
04806                         }

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

Definition at line 4808 of file processor.h.

04809                         {
04810                                 return new FourierToCenterProcessor();
04811                         }

void FourierToCenterProcessor::process_inplace ( EMData image  )  [virtual]

Fourier origin shift the image in the forward direction.

Parameters:
image the image to operate on
Exceptions:
ImageFormatException if the image is not complex

Implements EMAN::Processor.

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

04650 {
04651 //      if ( !image->is_complex() ) throw ImageFormatException("Can not Fourier origin shift an image that is not complex");
04652 
04653         int nx=image->get_xsize();
04654         int ny=image->get_ysize();
04655         int nz=image->get_zsize();
04656 
04657         int nxy = nx*ny;
04658 
04659         if ( ny == 1 && nz == 1 ){
04660                 cout << "Warning- attempted     Fourier origin shift a 1D image - no action taken" << endl;
04661                 return;
04662         }
04663 
04664         int yodd = (ny%2==1);
04665         int zodd = (nz%2==1);
04666 
04667         float* rdata = image->get_data();
04668 
04669         float tmp[2];
04670         float* p1;
04671         float* p2;
04672 
04673         // This will tackle the 'normalization' images which come out of the Fourier reconstructor.
04674         // ie- real-space 1/2 FFt images centered on the corner
04675         if ( !image->is_complex() ) {
04676                 if (nz!=1 && !yodd && !zodd) {
04677                         for (int x=0; x<nx; x++) {
04678                                 for (int y=0; y<ny; y++) {
04679                                         for (int z=0; z<nz/2; z++) {
04680                                                 int y2=(y+ny/2)%ny;
04681                                                 int z2=(z+nz/2)%nz;             // %nz should be redundant here
04682                                                 size_t i=x+y*nx+(size_t)z*nxy;
04683                                                 size_t i2=x+y2*nx+(size_t)z2*nxy;
04684                                                 float swp=rdata[i];
04685                                                 rdata[i]=rdata[i2];
04686                                                 rdata[i2]=swp;
04687                                         }
04688                                 }
04689                         }
04690 
04691                         return;
04692                 }
04693                 else throw ImageFormatException("Can not Fourier origin shift an image that is not complex unless it is even in ny,nz and nx=ny/2+1");
04694         }
04695 
04696         if (yodd){
04697                 // In 3D this is swapping the bottom slice (with respect to the y direction) and the middle slice,
04698                 // shifting all slices below the middle slice down one. In 2D it is equivalent, but in terms of rows.
04699                 float prev[2];
04700                 size_t idx;
04701                 for( int s = 0; s < nz; s++ ) {
04702                         for( int c =0; c < nx; c += 2 ) {
04703                                 idx = (size_t)s*nxy+c;
04704                                 prev[0] = rdata[idx];
04705                                 prev[1] = rdata[idx+1];
04706                                 for( int r = ny/2; r >= 0; --r ) {
04707                                         idx = (size_t)s*nxy+r*nx+c;
04708                                         float* p1 = &rdata[idx];
04709                                         tmp[0] = p1[0];
04710                                         tmp[1] = p1[1];
04711 
04712                                         p1[0] = prev[0];
04713                                         p1[1] = prev[1];
04714 
04715                                         prev[0] = tmp[0];
04716                                         prev[1] = tmp[1];
04717                                 }
04718                         }
04719                 }
04720         }
04721 
04722         // 3D - Shift slices correctly in the y direction, 2D - shift rows
04723         size_t idx1, idx2;
04724         for( int s = 0; s < nz; ++s ) {
04725                 for( int r = 0; r < ny/2; ++r ) {
04726                         for( int c =0; c < nx; c += 2 ) {
04727                                 idx1 = (size_t)s*nxy+r*nx+c;
04728                                 idx2 = (size_t)s*nxy+(r+ny/2+yodd)*nx+c;
04729                                 p1 = &rdata[idx1];
04730                                 p2 = &rdata[idx2];
04731 
04732                                 tmp[0] = p1[0];
04733                                 tmp[1] = p1[1];
04734 
04735                                 p1[0] = p2[0];
04736                                 p1[1] = p2[1];
04737 
04738                                 p2[0] = tmp[0];
04739                                 p2[1] = tmp[1];
04740                         }
04741                 }
04742         }
04743 
04744         if ( nz != 1 )  {
04745                 if (zodd){
04746                         // Swap the front slice (with respect to the z direction) and the middle slice
04747                         // shifting all slices behind the middles slice towards the front slice 1 voxel.
04748                         float prev[2];
04749                         size_t idx;
04750                         for( int r = 0; r < ny; ++r ) {
04751                                 for( int c =0; c < nx; c += 2 ) {
04752                                         prev[0] = rdata[r*nx+c];
04753                                         prev[1] = rdata[r*nx+c+1];
04754                                         for( int s = nz/2; s >= 0; --s ) {
04755                                                 idx = (size_t)s*nxy+r*nx+c;
04756                                                 float* p1 = &rdata[idx];
04757                                                 tmp[0] = p1[0];
04758                                                 tmp[1] = p1[1];
04759 
04760                                                 p1[0] = prev[0];
04761                                                 p1[1] = prev[1];
04762 
04763                                                 prev[0] = tmp[0];
04764                                                 prev[1] = tmp[1];
04765                                         }
04766                                 }
04767                         }
04768                 }
04769 
04770                 // Shift slices correctly in the y direction
04771                 size_t idx1, idx2;
04772                 for( int s = 0; s < nz/2; ++s ) {
04773                         for( int r = 0; r < ny; ++r ) {
04774                                 for( int c =0; c < nx; c += 2 ) {
04775                                         idx1 = (size_t)s*nxy+r*nx+c;
04776                                         idx2 = (size_t)(s+nz/2+zodd)*nxy+r*nx+c;
04777                                         p1 = &rdata[idx1];
04778                                         p2 = &rdata[idx2];
04779 
04780                                         tmp[0] = p1[0];
04781                                         tmp[1] = p1[1];
04782 
04783                                         p1[0] = p2[0];
04784                                         p1[1] = p2[1];
04785 
04786                                         p2[0] = tmp[0];
04787                                         p2[1] = tmp[1];
04788                                 }
04789                         }
04790                 }
04791         }
04792         image->set_shuffled(true);
04793 }


Member Data Documentation

const string FourierToCenterProcessor::NAME = "xform.fourierorigin.tocenter" [static]

Definition at line 4818 of file processor.h.

Referenced by get_name().


The documentation for this class was generated from the following files:
Generated on Fri Aug 10 16:32:57 2012 for EMAN2 by  doxygen 1.4.7