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

04604                         {
04605                                 return "Undoes the xform.fourierorigin.tocenter processor";
04606                         }

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

04594                         {
04595                                 return NAME;
04596                         }

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

Definition at line 4598 of file processor.h.

04599                         {
04600                                 return new FourierToCornerProcessor();
04601                         }

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

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


Member Data Documentation

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

Definition at line 159 of file processor.cpp.


The documentation for this class was generated from the following files:
Generated on Mon Mar 7 18:21:07 2011 for EMAN2 by  doxygen 1.3.9.1