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

04519                         {
04520                                 return "Undoes the xform.fourierorigin.tocenter processor";
04521                         }

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

04509                         {
04510                                 return NAME;
04511                         }

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

Definition at line 4513 of file processor.h.

04514                         {
04515                                 return new FourierToCornerProcessor();
04516                         }

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

04342 {
04343         if ( !image->is_complex() ) throw ImageFormatException("Can not Fourier origin shift an image that is not complex");
04344 
04345         int nx=image->get_xsize();
04346         int ny=image->get_ysize();
04347         int nz=image->get_zsize();
04348 
04349         int nxy = nx*ny;
04350 
04351         if ( ny == 1 && nz == 1 ){
04352                 cout << "Warning- attempted     Fourier origin shift a 1D image - no action taken" << endl;
04353                 return;
04354         }
04355         int yodd = (ny%2==1);
04356         int zodd = (nz%2==1);
04357 
04358         float* rdata = image->get_data();
04359 
04360         float tmp[2];
04361         float* p1;
04362         float* p2;
04363 
04364         if (yodd){
04365                 // Swap the middle slice (with respect to the y direction) with the bottom slice
04366                 // shifting all slices above the middles slice upwards by one pixel, stopping
04367                 // at the middle slice, not if nz = 1 we are not talking about slices, we are
04368                 // talking about rows
04369                 float prev[2];
04370                 size_t idx;
04371                 for( int s = 0; s < nz; s++ ) {
04372                         for( int c =0; c < nx; c += 2 ) {
04373                                 idx = s*nxy+ny/2*nx+c;
04374                                 prev[0] = rdata[idx];
04375                                 prev[1] = rdata[idx+1];
04376                                 for( int r = 0; r <= ny/2; ++r ) {
04377                                         idx = s*nxy+r*nx+c;
04378                                         float* p1 = &rdata[idx];
04379                                         tmp[0] = p1[0];
04380                                         tmp[1] = p1[1];
04381 
04382                                         p1[0] = prev[0];
04383                                         p1[1] = prev[1];
04384 
04385                                         prev[0] = tmp[0];
04386                                         prev[1] = tmp[1];
04387                                 }
04388                         }
04389                 }
04390         }
04391 
04392         // Shift slices (3D) or rows (2D) correctly in the y direction
04393         size_t idx1, idx2;
04394         for( int s = 0; s < nz; ++s ) {
04395                 for( int r = 0 + yodd; r < ny/2+yodd; ++r ) {
04396                         for( int c =0; c < nx; c += 2 ) {
04397                                 idx1 = s*nxy+r*nx+c;
04398                                 idx2 = s*nxy+(r+ny/2)*nx+c;
04399                                 p1 = &rdata[idx1];
04400                                 p2 = &rdata[idx2];
04401 
04402                                 tmp[0] = p1[0];
04403                                 tmp[1] = p1[1];
04404 
04405                                 p1[0] = p2[0];
04406                                 p1[1] = p2[1];
04407 
04408                                 p2[0] = tmp[0];
04409                                 p2[1] = tmp[1];
04410                         }
04411                 }
04412         }
04413 
04414         if ( nz != 1 )
04415         {
04416 
04417                 if (zodd){
04418                         // Swap the middle slice (with respect to the z direction) and the front slice
04419                         // shifting all behind the front slice towards the middle a distance of 1 voxel,
04420                         // stopping at the middle slice.
04421                         float prev[2];
04422                         size_t idx;
04423                         for( int r = 0; r < ny; ++r ) {
04424                                 for( int c =0; c < nx; c += 2 ) {
04425                                         idx = nz/2*nxy+r*nx+c;
04426                                         prev[0] = rdata[idx];
04427                                         prev[1] = rdata[idx+1];
04428                                         for( int s = 0; s <= nz/2; ++s ) {
04429                                                 idx = s*nxy+r*nx+c;
04430                                                 float* p1 = &rdata[idx];
04431                                                 tmp[0] = p1[0];
04432                                                 tmp[1] = p1[1];
04433 
04434                                                 p1[0] = prev[0];
04435                                                 p1[1] = prev[1];
04436 
04437                                                 prev[0] = tmp[0];
04438                                                 prev[1] = tmp[1];
04439                                         }
04440                                 }
04441                         }
04442                 }
04443 
04444                 // Shift slices correctly in the z direction
04445                 size_t idx1, idx2;
04446                 for( int s = 0+zodd; s < nz/2 + zodd; ++s ) {
04447                         for( int r = 0; r < ny; ++r ) {
04448                                 for( int c =0; c < nx; c += 2 ) {
04449                                         idx1 = s*nxy+r*nx+c;
04450                                         idx2 = (s+nz/2)*nxy+r*nx+c;
04451                                         p1 = &rdata[idx1];
04452                                         p2 = &rdata[idx2];
04453 
04454                                         tmp[0] = p1[0];
04455                                         tmp[1] = p1[1];
04456 
04457                                         p1[0] = p2[0];
04458                                         p1[1] = p2[1];
04459 
04460                                         p2[0] = tmp[0];
04461                                         p2[1] = tmp[1];
04462                                 }
04463                         }
04464                 }
04465         }
04466         image->set_shuffled(false);
04467 }


Member Data Documentation

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

Definition at line 156 of file processor.cpp.


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