Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

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

ProcessorNEW ()

Static Public Attributes

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

04559                         {
04560                                 return "Translates the origin in Fourier space from the corner to the center in y and z - works in 2D and 3D";
04561                         }

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

04549                         {
04550                                 return NAME;
04551                         }

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

Definition at line 4553 of file processor.h.

04554                         {
04555                                 return new FourierToCenterProcessor();
04556                         }

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 4469 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, EMAN::EMData::set_shuffled(), x, and y.

04470 {
04471 //      if ( !image->is_complex() ) throw ImageFormatException("Can not Fourier origin shift an image that is not complex");
04472 
04473         int nx=image->get_xsize();
04474         int ny=image->get_ysize();
04475         int nz=image->get_zsize();
04476 
04477         int nxy = nx*ny;
04478 
04479         if ( ny == 1 && nz == 1 ){
04480                 cout << "Warning- attempted     Fourier origin shift a 1D image - no action taken" << endl;
04481                 return;
04482         }
04483 
04484         int yodd = (ny%2==1);
04485         int zodd = (nz%2==1);
04486 
04487         float* rdata = image->get_data();
04488 
04489         float tmp[2];
04490         float* p1;
04491         float* p2;
04492 
04493         // This will tackle the 'normalization' images which come out of the Fourier reconstructor.
04494         // ie- real-space 1/2 FFt images centered on the corner
04495         if ( !image->is_complex() ) {
04496                 if (nz!=1 && !yodd && !zodd) {
04497                         for (int x=0; x<nx; x++) {
04498                                 for (int y=0; y<ny; y++) {
04499                                         for (int z=0; z<nz/2; z++) {
04500                                                 int y2=(y+ny/2)%ny;
04501                                                 int z2=(z+nz/2)%nz;             // %nz should be redundant here
04502                                                 size_t i=x+y*nx+z*nxy;
04503                                                 size_t i2=x+y2*nx+z2*nxy;
04504                                                 float swp=rdata[i];
04505                                                 rdata[i]=rdata[i2];
04506                                                 rdata[i2]=swp;
04507                                         }
04508                                 }
04509                         }
04510 
04511                         return;
04512                 }
04513                 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");
04514         }
04515 
04516         if (yodd){
04517                 // In 3D this is swapping the bottom slice (with respect to the y direction) and the middle slice,
04518                 // shifting all slices below the middle slice down one. In 2D it is equivalent, but in terms of rows.
04519                 float prev[2];
04520                 size_t idx;
04521                 for( int s = 0; s < nz; s++ ) {
04522                         for( int c =0; c < nx; c += 2 ) {
04523                                 idx = s*nxy+c;
04524                                 prev[0] = rdata[idx];
04525                                 prev[1] = rdata[idx+1];
04526                                 for( int r = ny/2; r >= 0; --r ) {
04527                                         idx = s*nxy+r*nx+c;
04528                                         float* p1 = &rdata[idx];
04529                                         tmp[0] = p1[0];
04530                                         tmp[1] = p1[1];
04531 
04532                                         p1[0] = prev[0];
04533                                         p1[1] = prev[1];
04534 
04535                                         prev[0] = tmp[0];
04536                                         prev[1] = tmp[1];
04537                                 }
04538                         }
04539                 }
04540         }
04541 
04542         // 3D - Shift slices correctly in the y direction, 2D - shift rows
04543         size_t idx1, idx2;
04544         for( int s = 0; s < nz; ++s ) {
04545                 for( int r = 0; r < ny/2; ++r ) {
04546                         for( int c =0; c < nx; c += 2 ) {
04547                                 idx1 = s*nxy+r*nx+c;
04548                                 idx2 = s*nxy+(r+ny/2+yodd)*nx+c;
04549                                 p1 = &rdata[idx1];
04550                                 p2 = &rdata[idx2];
04551 
04552                                 tmp[0] = p1[0];
04553                                 tmp[1] = p1[1];
04554 
04555                                 p1[0] = p2[0];
04556                                 p1[1] = p2[1];
04557 
04558                                 p2[0] = tmp[0];
04559                                 p2[1] = tmp[1];
04560                         }
04561                 }
04562         }
04563 
04564         if ( nz != 1 )  {
04565                 if (zodd){
04566                         // Swap the front slice (with respect to the z direction) and the middle slice
04567                         // shifting all slices behind the middles slice towards the front slice 1 voxel.
04568                         float prev[2];
04569                         size_t idx;
04570                         for( int r = 0; r < ny; ++r ) {
04571                                 for( int c =0; c < nx; c += 2 ) {
04572                                         prev[0] = rdata[r*nx+c];
04573                                         prev[1] = rdata[r*nx+c+1];
04574                                         for( int s = nz/2; s >= 0; --s ) {
04575                                                 idx = s*nxy+r*nx+c;
04576                                                 float* p1 = &rdata[idx];
04577                                                 tmp[0] = p1[0];
04578                                                 tmp[1] = p1[1];
04579 
04580                                                 p1[0] = prev[0];
04581                                                 p1[1] = prev[1];
04582 
04583                                                 prev[0] = tmp[0];
04584                                                 prev[1] = tmp[1];
04585                                         }
04586                                 }
04587                         }
04588                 }
04589 
04590                 // Shift slices correctly in the y direction
04591                 size_t idx1, idx2;
04592                 for( int s = 0; s < nz/2; ++s ) {
04593                         for( int r = 0; r < ny; ++r ) {
04594                                 for( int c =0; c < nx; c += 2 ) {
04595                                         idx1 = s*nxy+r*nx+c;
04596                                         idx2 = (s+nz/2+zodd)*nxy+r*nx+c;
04597                                         p1 = &rdata[idx1];
04598                                         p2 = &rdata[idx2];
04599 
04600                                         tmp[0] = p1[0];
04601                                         tmp[1] = p1[1];
04602 
04603                                         p1[0] = p2[0];
04604                                         p1[1] = p2[1];
04605 
04606                                         p2[0] = tmp[0];
04607                                         p2[1] = tmp[1];
04608                                 }
04609                         }
04610                 }
04611         }
04612         image->set_shuffled(true);
04613 }


Member Data Documentation

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

Definition at line 157 of file processor.cpp.


The documentation for this class was generated from the following files:
Generated on Thu Dec 9 13:48:10 2010 for EMAN2 by  doxygen 1.3.9.1