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

04729                         {
04730                                 return "Undoes the xform.fourierorigin.tocenter processor";
04731                         }

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

References NAME.

04719                         {
04720                                 return NAME;
04721                         }

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

Definition at line 4723 of file processor.h.

04724                         {
04725                                 return new FourierToCornerProcessor();
04726                         }

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

04446 {
04447         if ( !image->is_complex() ) throw ImageFormatException("Can not Fourier origin shift an image that is not complex");
04448 
04449         int nx=image->get_xsize();
04450         int ny=image->get_ysize();
04451         int nz=image->get_zsize();
04452 
04453         int nxy = nx*ny;
04454 
04455         if ( ny == 1 && nz == 1 ){
04456                 cout << "Warning- attempted     Fourier origin shift a 1D image - no action taken" << endl;
04457                 return;
04458         }
04459         int yodd = (ny%2==1);
04460         int zodd = (nz%2==1);
04461 
04462         float* rdata = image->get_data();
04463 
04464         float tmp[2];
04465         float* p1;
04466         float* p2;
04467 
04468         if (yodd){
04469                 // Swap the middle slice (with respect to the y direction) with the bottom slice
04470                 // shifting all slices above the middles slice upwards by one pixel, stopping
04471                 // at the middle slice, not if nz = 1 we are not talking about slices, we are
04472                 // talking about rows
04473                 float prev[2];
04474                 size_t idx;
04475                 for( int s = 0; s < nz; s++ ) {
04476                         for( int c =0; c < nx; c += 2 ) {
04477                                 idx = (size_t)s*nxy+ny/2*nx+c;
04478                                 prev[0] = rdata[idx];
04479                                 prev[1] = rdata[idx+1];
04480                                 for( int r = 0; r <= ny/2; ++r ) {
04481                                         idx = (size_t)s*nxy+r*nx+c;
04482                                         float* p1 = &rdata[idx];
04483                                         tmp[0] = p1[0];
04484                                         tmp[1] = p1[1];
04485 
04486                                         p1[0] = prev[0];
04487                                         p1[1] = prev[1];
04488 
04489                                         prev[0] = tmp[0];
04490                                         prev[1] = tmp[1];
04491                                 }
04492                         }
04493                 }
04494         }
04495 
04496         // Shift slices (3D) or rows (2D) correctly in the y direction
04497         size_t idx1, idx2;
04498         for( int s = 0; s < nz; ++s ) {
04499                 for( int r = 0 + yodd; r < ny/2+yodd; ++r ) {
04500                         for( int c =0; c < nx; c += 2 ) {
04501                                 idx1 = (size_t)s*nxy+r*nx+c;
04502                                 idx2 = (size_t)s*nxy+(r+ny/2)*nx+c;
04503                                 p1 = &rdata[idx1];
04504                                 p2 = &rdata[idx2];
04505 
04506                                 tmp[0] = p1[0];
04507                                 tmp[1] = p1[1];
04508 
04509                                 p1[0] = p2[0];
04510                                 p1[1] = p2[1];
04511 
04512                                 p2[0] = tmp[0];
04513                                 p2[1] = tmp[1];
04514                         }
04515                 }
04516         }
04517 
04518         if ( nz != 1 )
04519         {
04520 
04521                 if (zodd){
04522                         // Swap the middle slice (with respect to the z direction) and the front slice
04523                         // shifting all behind the front slice towards the middle a distance of 1 voxel,
04524                         // stopping at the middle slice.
04525                         float prev[2];
04526                         size_t idx;
04527                         for( int r = 0; r < ny; ++r ) {
04528                                 for( int c =0; c < nx; c += 2 ) {
04529                                         idx = (size_t)nz/2*nxy+r*nx+c;
04530                                         prev[0] = rdata[idx];
04531                                         prev[1] = rdata[idx+1];
04532                                         for( int s = 0; s <= nz/2; ++s ) {
04533                                                 idx = (size_t)s*nxy+r*nx+c;
04534                                                 float* p1 = &rdata[idx];
04535                                                 tmp[0] = p1[0];
04536                                                 tmp[1] = p1[1];
04537 
04538                                                 p1[0] = prev[0];
04539                                                 p1[1] = prev[1];
04540 
04541                                                 prev[0] = tmp[0];
04542                                                 prev[1] = tmp[1];
04543                                         }
04544                                 }
04545                         }
04546                 }
04547 
04548                 // Shift slices correctly in the z direction
04549                 size_t idx1, idx2;
04550                 for( int s = 0+zodd; s < nz/2 + zodd; ++s ) {
04551                         for( int r = 0; r < ny; ++r ) {
04552                                 for( int c =0; c < nx; c += 2 ) {
04553                                         idx1 = (size_t)s*nxy+r*nx+c;
04554                                         idx2 = (size_t)(s+nz/2)*nxy+r*nx+c;
04555                                         p1 = &rdata[idx1];
04556                                         p2 = &rdata[idx2];
04557 
04558                                         tmp[0] = p1[0];
04559                                         tmp[1] = p1[1];
04560 
04561                                         p1[0] = p2[0];
04562                                         p1[1] = p2[1];
04563 
04564                                         p2[0] = tmp[0];
04565                                         p2[1] = tmp[1];
04566                                 }
04567                         }
04568                 }
04569         }
04570         image->set_shuffled(false);
04571 }


Member Data Documentation

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

Definition at line 4733 of file processor.h.

Referenced by get_name().


The documentation for this class was generated from the following files:
Generated on Thu Nov 17 12:46:40 2011 for EMAN2 by  doxygen 1.4.7