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

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

ProcessorNEW ()

Static Public Attributes

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

04660                         {
04661                                 return "Undoes the xform.fourierorigin.tocenter processor";
04662                         }

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

04650                         {
04651                                 return NAME;
04652                         }

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

Definition at line 4654 of file processor.h.

04655                         {
04656                                 return new FourierToCornerProcessor();
04657                         }

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

04403 {
04404         if ( !image->is_complex() ) throw ImageFormatException("Can not Fourier origin shift an image that is not complex");
04405 
04406         int nx=image->get_xsize();
04407         int ny=image->get_ysize();
04408         int nz=image->get_zsize();
04409 
04410         int nxy = nx*ny;
04411 
04412         if ( ny == 1 && nz == 1 ){
04413                 cout << "Warning- attempted     Fourier origin shift a 1D image - no action taken" << endl;
04414                 return;
04415         }
04416         int yodd = (ny%2==1);
04417         int zodd = (nz%2==1);
04418 
04419         float* rdata = image->get_data();
04420 
04421         float tmp[2];
04422         float* p1;
04423         float* p2;
04424 
04425         if (yodd){
04426                 // Swap the middle slice (with respect to the y direction) with the bottom slice
04427                 // shifting all slices above the middles slice upwards by one pixel, stopping
04428                 // at the middle slice, not if nz = 1 we are not talking about slices, we are
04429                 // talking about rows
04430                 float prev[2];
04431                 size_t idx;
04432                 for( int s = 0; s < nz; s++ ) {
04433                         for( int c =0; c < nx; c += 2 ) {
04434                                 idx = (size_t)s*nxy+ny/2*nx+c;
04435                                 prev[0] = rdata[idx];
04436                                 prev[1] = rdata[idx+1];
04437                                 for( int r = 0; r <= ny/2; ++r ) {
04438                                         idx = (size_t)s*nxy+r*nx+c;
04439                                         float* p1 = &rdata[idx];
04440                                         tmp[0] = p1[0];
04441                                         tmp[1] = p1[1];
04442 
04443                                         p1[0] = prev[0];
04444                                         p1[1] = prev[1];
04445 
04446                                         prev[0] = tmp[0];
04447                                         prev[1] = tmp[1];
04448                                 }
04449                         }
04450                 }
04451         }
04452 
04453         // Shift slices (3D) or rows (2D) correctly in the y direction
04454         size_t idx1, idx2;
04455         for( int s = 0; s < nz; ++s ) {
04456                 for( int r = 0 + yodd; r < ny/2+yodd; ++r ) {
04457                         for( int c =0; c < nx; c += 2 ) {
04458                                 idx1 = (size_t)s*nxy+r*nx+c;
04459                                 idx2 = (size_t)s*nxy+(r+ny/2)*nx+c;
04460                                 p1 = &rdata[idx1];
04461                                 p2 = &rdata[idx2];
04462 
04463                                 tmp[0] = p1[0];
04464                                 tmp[1] = p1[1];
04465 
04466                                 p1[0] = p2[0];
04467                                 p1[1] = p2[1];
04468 
04469                                 p2[0] = tmp[0];
04470                                 p2[1] = tmp[1];
04471                         }
04472                 }
04473         }
04474 
04475         if ( nz != 1 )
04476         {
04477 
04478                 if (zodd){
04479                         // Swap the middle slice (with respect to the z direction) and the front slice
04480                         // shifting all behind the front slice towards the middle a distance of 1 voxel,
04481                         // stopping at the middle slice.
04482                         float prev[2];
04483                         size_t idx;
04484                         for( int r = 0; r < ny; ++r ) {
04485                                 for( int c =0; c < nx; c += 2 ) {
04486                                         idx = (size_t)nz/2*nxy+r*nx+c;
04487                                         prev[0] = rdata[idx];
04488                                         prev[1] = rdata[idx+1];
04489                                         for( int s = 0; s <= nz/2; ++s ) {
04490                                                 idx = (size_t)s*nxy+r*nx+c;
04491                                                 float* p1 = &rdata[idx];
04492                                                 tmp[0] = p1[0];
04493                                                 tmp[1] = p1[1];
04494 
04495                                                 p1[0] = prev[0];
04496                                                 p1[1] = prev[1];
04497 
04498                                                 prev[0] = tmp[0];
04499                                                 prev[1] = tmp[1];
04500                                         }
04501                                 }
04502                         }
04503                 }
04504 
04505                 // Shift slices correctly in the z direction
04506                 size_t idx1, idx2;
04507                 for( int s = 0+zodd; s < nz/2 + zodd; ++s ) {
04508                         for( int r = 0; r < ny; ++r ) {
04509                                 for( int c =0; c < nx; c += 2 ) {
04510                                         idx1 = (size_t)s*nxy+r*nx+c;
04511                                         idx2 = (size_t)(s+nz/2)*nxy+r*nx+c;
04512                                         p1 = &rdata[idx1];
04513                                         p2 = &rdata[idx2];
04514 
04515                                         tmp[0] = p1[0];
04516                                         tmp[1] = p1[1];
04517 
04518                                         p1[0] = p2[0];
04519                                         p1[1] = p2[1];
04520 
04521                                         p2[0] = tmp[0];
04522                                         p2[1] = tmp[1];
04523                                 }
04524                         }
04525                 }
04526         }
04527         image->set_shuffled(false);
04528 }


Member Data Documentation

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

Definition at line 161 of file processor.cpp.


The documentation for this class was generated from the following files:
Generated on Mon May 2 13:30:34 2011 for EMAN2 by  doxygen 1.3.9.1