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

04735                         {
04736                                 return "Translates the origin in Fourier space from the corner to the center in y and z - works in 2D and 3D";
04737                         }

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

References NAME.

04725                         {
04726                                 return NAME;
04727                         }

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

Definition at line 4729 of file processor.h.

04730                         {
04731                                 return new FourierToCenterProcessor();
04732                         }

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 4501 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.

04502 {
04503 //      if ( !image->is_complex() ) throw ImageFormatException("Can not Fourier origin shift an image that is not complex");
04504 
04505         int nx=image->get_xsize();
04506         int ny=image->get_ysize();
04507         int nz=image->get_zsize();
04508 
04509         int nxy = nx*ny;
04510 
04511         if ( ny == 1 && nz == 1 ){
04512                 cout << "Warning- attempted     Fourier origin shift a 1D image - no action taken" << endl;
04513                 return;
04514         }
04515 
04516         int yodd = (ny%2==1);
04517         int zodd = (nz%2==1);
04518 
04519         float* rdata = image->get_data();
04520 
04521         float tmp[2];
04522         float* p1;
04523         float* p2;
04524 
04525         // This will tackle the 'normalization' images which come out of the Fourier reconstructor.
04526         // ie- real-space 1/2 FFt images centered on the corner
04527         if ( !image->is_complex() ) {
04528                 if (nz!=1 && !yodd && !zodd) {
04529                         for (int x=0; x<nx; x++) {
04530                                 for (int y=0; y<ny; y++) {
04531                                         for (int z=0; z<nz/2; z++) {
04532                                                 int y2=(y+ny/2)%ny;
04533                                                 int z2=(z+nz/2)%nz;             // %nz should be redundant here
04534                                                 size_t i=x+y*nx+z*nxy;
04535                                                 size_t i2=x+y2*nx+z2*nxy;
04536                                                 float swp=rdata[i];
04537                                                 rdata[i]=rdata[i2];
04538                                                 rdata[i2]=swp;
04539                                         }
04540                                 }
04541                         }
04542 
04543                         return;
04544                 }
04545                 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");
04546         }
04547 
04548         if (yodd){
04549                 // In 3D this is swapping the bottom slice (with respect to the y direction) and the middle slice,
04550                 // shifting all slices below the middle slice down one. In 2D it is equivalent, but in terms of rows.
04551                 float prev[2];
04552                 size_t idx;
04553                 for( int s = 0; s < nz; s++ ) {
04554                         for( int c =0; c < nx; c += 2 ) {
04555                                 idx = s*nxy+c;
04556                                 prev[0] = rdata[idx];
04557                                 prev[1] = rdata[idx+1];
04558                                 for( int r = ny/2; r >= 0; --r ) {
04559                                         idx = s*nxy+r*nx+c;
04560                                         float* p1 = &rdata[idx];
04561                                         tmp[0] = p1[0];
04562                                         tmp[1] = p1[1];
04563 
04564                                         p1[0] = prev[0];
04565                                         p1[1] = prev[1];
04566 
04567                                         prev[0] = tmp[0];
04568                                         prev[1] = tmp[1];
04569                                 }
04570                         }
04571                 }
04572         }
04573 
04574         // 3D - Shift slices correctly in the y direction, 2D - shift rows
04575         size_t idx1, idx2;
04576         for( int s = 0; s < nz; ++s ) {
04577                 for( int r = 0; r < ny/2; ++r ) {
04578                         for( int c =0; c < nx; c += 2 ) {
04579                                 idx1 = s*nxy+r*nx+c;
04580                                 idx2 = s*nxy+(r+ny/2+yodd)*nx+c;
04581                                 p1 = &rdata[idx1];
04582                                 p2 = &rdata[idx2];
04583 
04584                                 tmp[0] = p1[0];
04585                                 tmp[1] = p1[1];
04586 
04587                                 p1[0] = p2[0];
04588                                 p1[1] = p2[1];
04589 
04590                                 p2[0] = tmp[0];
04591                                 p2[1] = tmp[1];
04592                         }
04593                 }
04594         }
04595 
04596         if ( nz != 1 )  {
04597                 if (zodd){
04598                         // Swap the front slice (with respect to the z direction) and the middle slice
04599                         // shifting all slices behind the middles slice towards the front slice 1 voxel.
04600                         float prev[2];
04601                         size_t idx;
04602                         for( int r = 0; r < ny; ++r ) {
04603                                 for( int c =0; c < nx; c += 2 ) {
04604                                         prev[0] = rdata[r*nx+c];
04605                                         prev[1] = rdata[r*nx+c+1];
04606                                         for( int s = nz/2; s >= 0; --s ) {
04607                                                 idx = s*nxy+r*nx+c;
04608                                                 float* p1 = &rdata[idx];
04609                                                 tmp[0] = p1[0];
04610                                                 tmp[1] = p1[1];
04611 
04612                                                 p1[0] = prev[0];
04613                                                 p1[1] = prev[1];
04614 
04615                                                 prev[0] = tmp[0];
04616                                                 prev[1] = tmp[1];
04617                                         }
04618                                 }
04619                         }
04620                 }
04621 
04622                 // Shift slices correctly in the y direction
04623                 size_t idx1, idx2;
04624                 for( int s = 0; s < nz/2; ++s ) {
04625                         for( int r = 0; r < ny; ++r ) {
04626                                 for( int c =0; c < nx; c += 2 ) {
04627                                         idx1 = s*nxy+r*nx+c;
04628                                         idx2 = (s+nz/2+zodd)*nxy+r*nx+c;
04629                                         p1 = &rdata[idx1];
04630                                         p2 = &rdata[idx2];
04631 
04632                                         tmp[0] = p1[0];
04633                                         tmp[1] = p1[1];
04634 
04635                                         p1[0] = p2[0];
04636                                         p1[1] = p2[1];
04637 
04638                                         p2[0] = tmp[0];
04639                                         p2[1] = tmp[1];
04640                                 }
04641                         }
04642                 }
04643         }
04644         image->set_shuffled(true);
04645 }


Member Data Documentation

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

Definition at line 4739 of file processor.h.

Referenced by get_name().


The documentation for this class was generated from the following files:
Generated on Tue May 25 17:17:16 2010 for EMAN2 by  doxygen 1.4.7