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

04735                         {
04736                                 return "Undoes the xform.fourierorigin.tocenter processor";
04737                         }

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

References NAME.

04725                         {
04726                                 return NAME;
04727                         }

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

Definition at line 4729 of file processor.h.

04730                         {
04731                                 return new FourierToCornerProcessor();
04732                         }

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 4480 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().

04481 {
04482         if ( !image->is_complex() ) throw ImageFormatException("Can not Fourier origin shift an image that is not complex");
04483 
04484         int nx=image->get_xsize();
04485         int ny=image->get_ysize();
04486         int nz=image->get_zsize();
04487 
04488         int nxy = nx*ny;
04489 
04490         if ( ny == 1 && nz == 1 ){
04491                 cout << "Warning- attempted     Fourier origin shift a 1D image - no action taken" << endl;
04492                 return;
04493         }
04494         int yodd = (ny%2==1);
04495         int zodd = (nz%2==1);
04496 
04497         float* rdata = image->get_data();
04498 
04499         float tmp[2];
04500         float* p1;
04501         float* p2;
04502 
04503         if (yodd){
04504                 // Swap the middle slice (with respect to the y direction) with the bottom slice
04505                 // shifting all slices above the middles slice upwards by one pixel, stopping
04506                 // at the middle slice, not if nz = 1 we are not talking about slices, we are
04507                 // talking about rows
04508                 float prev[2];
04509                 size_t idx;
04510                 for( int s = 0; s < nz; s++ ) {
04511                         for( int c =0; c < nx; c += 2 ) {
04512                                 idx = s*nxy+ny/2*nx+c;
04513                                 prev[0] = rdata[idx];
04514                                 prev[1] = rdata[idx+1];
04515                                 for( int r = 0; r <= ny/2; ++r ) {
04516                                         idx = s*nxy+r*nx+c;
04517                                         float* p1 = &rdata[idx];
04518                                         tmp[0] = p1[0];
04519                                         tmp[1] = p1[1];
04520 
04521                                         p1[0] = prev[0];
04522                                         p1[1] = prev[1];
04523 
04524                                         prev[0] = tmp[0];
04525                                         prev[1] = tmp[1];
04526                                 }
04527                         }
04528                 }
04529         }
04530 
04531         // Shift slices (3D) or rows (2D) correctly in the y direction
04532         size_t idx1, idx2;
04533         for( int s = 0; s < nz; ++s ) {
04534                 for( int r = 0 + yodd; r < ny/2+yodd; ++r ) {
04535                         for( int c =0; c < nx; c += 2 ) {
04536                                 idx1 = s*nxy+r*nx+c;
04537                                 idx2 = s*nxy+(r+ny/2)*nx+c;
04538                                 p1 = &rdata[idx1];
04539                                 p2 = &rdata[idx2];
04540 
04541                                 tmp[0] = p1[0];
04542                                 tmp[1] = p1[1];
04543 
04544                                 p1[0] = p2[0];
04545                                 p1[1] = p2[1];
04546 
04547                                 p2[0] = tmp[0];
04548                                 p2[1] = tmp[1];
04549                         }
04550                 }
04551         }
04552 
04553         if ( nz != 1 )
04554         {
04555 
04556                 if (zodd){
04557                         // Swap the middle slice (with respect to the z direction) and the front slice
04558                         // shifting all behind the front slice towards the middle a distance of 1 voxel,
04559                         // stopping at the middle slice.
04560                         float prev[2];
04561                         size_t idx;
04562                         for( int r = 0; r < ny; ++r ) {
04563                                 for( int c =0; c < nx; c += 2 ) {
04564                                         idx = nz/2*nxy+r*nx+c;
04565                                         prev[0] = rdata[idx];
04566                                         prev[1] = rdata[idx+1];
04567                                         for( int s = 0; s <= nz/2; ++s ) {
04568                                                 idx = s*nxy+r*nx+c;
04569                                                 float* p1 = &rdata[idx];
04570                                                 tmp[0] = p1[0];
04571                                                 tmp[1] = p1[1];
04572 
04573                                                 p1[0] = prev[0];
04574                                                 p1[1] = prev[1];
04575 
04576                                                 prev[0] = tmp[0];
04577                                                 prev[1] = tmp[1];
04578                                         }
04579                                 }
04580                         }
04581                 }
04582 
04583                 // Shift slices correctly in the z direction
04584                 size_t idx1, idx2;
04585                 for( int s = 0+zodd; s < nz/2 + zodd; ++s ) {
04586                         for( int r = 0; r < ny; ++r ) {
04587                                 for( int c =0; c < nx; c += 2 ) {
04588                                         idx1 = s*nxy+r*nx+c;
04589                                         idx2 = (s+nz/2)*nxy+r*nx+c;
04590                                         p1 = &rdata[idx1];
04591                                         p2 = &rdata[idx2];
04592 
04593                                         tmp[0] = p1[0];
04594                                         tmp[1] = p1[1];
04595 
04596                                         p1[0] = p2[0];
04597                                         p1[1] = p2[1];
04598 
04599                                         p2[0] = tmp[0];
04600                                         p2[1] = tmp[1];
04601                                 }
04602                         }
04603                 }
04604         }
04605         image->set_shuffled(false);
04606 }


Member Data Documentation

const string FourierToCornerProcessor::NAME = "xform.fourierorigin.tocorner" [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 Mon Jul 19 12:43:49 2010 for EMAN2 by  doxygen 1.4.7