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

EMAN::PhaseToCenterProcessor Class Reference
[unit test in Python]

Translates a cornered image to the center Undoes the PhaseToCornerProcessor. More...

#include <processor.h>

Inheritance diagram for EMAN::PhaseToCenterProcessor:

Inheritance graph
[legend]
Collaboration diagram for EMAN::PhaseToCenterProcessor:

Collaboration graph
[legend]
List of all members.

Public Member Functions

virtual void process_inplace (EMData *image)
 To process an image in-place.
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.phaseorigin.tocenter"

Detailed Description

Translates a cornered image to the center Undoes the PhaseToCornerProcessor.

works for 1D, 2D and 3D images, for all combinations of even and oddness

Author:
David Woolford <woolford@bcm.edu>
Date:
October 2007

Definition at line 4803 of file processor.h.


Member Function Documentation

virtual string EMAN::PhaseToCenterProcessor::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 4818 of file processor.h.

04819                         {
04820                                 return "Undoes the effect of the xform.phaseorigin.tocorner processor";
04821                         }

virtual string EMAN::PhaseToCenterProcessor::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 4808 of file processor.h.

04809                         {
04810                                 return NAME;
04811                         }

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

Definition at line 4813 of file processor.h.

04814                         {
04815                                 return new PhaseToCenterProcessor();
04816                         }

void PhaseToCenterProcessor::process_inplace EMData image  )  [virtual]
 

To process an image in-place.

For those processors which can only be processed out-of-place, override this function to just print out some error message to remind user call the out-of-place version.

Parameters:
image The image to be processed.

Implements EMAN::Processor.

Definition at line 5102 of file processor.cpp.

References emdata_phaseorigin_to_center(), EMAN::Phase180Processor::fourier_phaseshift180(), EMAN::EMData::get_data(), EMAN::EMData::get_ndim(), EMAN::EMData::get_xsize(), EMAN::EMData::get_ysize(), EMAN::EMData::get_zsize(), EMAN::EMData::is_complex(), NullPointerException, nx, ny, rdata, EMAN::Phase180Processor::swap_central_slices_180(), and EMAN::Phase180Processor::swap_corners_180().

05103 {
05104         if (!image)     throw NullPointerException("Error: attempt to phase shift a null image");
05105 
05106 #ifdef EMAN2_USING_CUDA
05107         if (EMData::usecuda == 1 && image->getcudarwdata() && image->get_ndim() == 2) { // Because CUDA phase origin to center only works for 2D atm
05108                 //cout << "CUDA tocenter" << endl;
05109                 emdata_phaseorigin_to_center(image->getcudarwdata(), image->get_xsize(), image->get_ysize(), image->get_zsize());
05110                 return;
05111         }
05112 #endif // EMAN2_USING_CUDA
05113 
05114         if (image->is_complex()) {
05115                 fourier_phaseshift180(image);
05116                 return;
05117         }
05118 
05119         int nx = image->get_xsize();
05120         int ny = image->get_ysize();
05121         int nz = image->get_zsize();
05122 
05123         if ( ny == 1 && nz == 1 && nx == 1) return;
05124 
05125         int nxy = nx * ny;
05126 
05127         float *rdata = image->get_data();
05128 
05129         bool xodd = (nx % 2) == 1;
05130         bool yodd = (ny % 2) == 1;
05131         bool zodd = (nz % 2) == 1;
05132 
05133         if ( ny == 1 && nz == 1 ){
05134                 if (xodd) {
05135                         // Put the center pixel at the end, shifting the contents
05136                         // to right of the center one step to the left
05137                         float in_x = rdata[nx/2];
05138                         float tmp;
05139                         for ( int i = nx-1; i >= nx/2; --i ) {
05140                                 tmp = rdata[i];
05141                                 rdata[i] = in_x;
05142                                 in_x = tmp;
05143                         }
05144                 }
05145                 // now the operation is straight forward
05146                 for ( int i = 0; i < nx/2; ++i ) {
05147                         int idx = i + nx/2;
05148                         float tmp = rdata[i];
05149                         rdata[i] = rdata[idx];
05150                         rdata[idx] = tmp;
05151                 }
05152         }
05153         else if ( nz == 1 ){
05154                 // The order in which these operations occur literally undoes what the
05155                 // PhaseToCornerProcessor did to the image.
05156                 // First, the corners sections of the image are swapped appropriately
05157                 swap_corners_180(image);
05158                 // Second, central pixel lines are swapped
05159                 swap_central_slices_180(image);
05160 
05161                 float tmp;
05162                 // Third, appropriate sections of the image are cyclically shifted by one pixel
05163                 if (xodd) {
05164                         // Transfer the middle column to the far right
05165                         // Shift all from the far right to (but not including the) middle one to the left
05166                         for ( int r  = 0; r < ny; ++r ) {
05167                                 float last_val = rdata[r*nx+nx/2];
05168                                 for ( int c = nx-1; c >=  nx/2; --c ){
05169                                         int idx = r*nx+c;
05170                                         tmp = rdata[idx];
05171                                         rdata[idx] = last_val;
05172                                         last_val = tmp;
05173                                 }
05174                         }
05175                 }
05176                 if (yodd) {
05177                         // Tranfer the middle row to the top,
05178                         // shifting all pixels from the top row down one, until  but not including the) middle
05179                         for ( int c = 0; c < nx; ++c ) {
05180                                 // Get the value in the top row
05181                                 float last_val = rdata[ny/2*nx + c];
05182                                 for ( int r = ny-1; r >= ny/2; --r ){
05183                                         int idx = r*nx+c;
05184                                         tmp = rdata[idx];
05185                                         rdata[idx] = last_val;
05186                                         last_val = tmp;
05187                                 }
05188                         }
05189                 }
05190         }
05191         else
05192         {
05193                 // The order in which these operations occur literally undoes the
05194                 // PhaseToCornerProcessor operation - in 3D.
05195                 // First, the corner quadrants of the voxel volume are swapped
05196                 swap_corners_180(image);
05197                 // Second, appropriate parts of the central slices are swapped
05198                 swap_central_slices_180(image);
05199 
05200                 float tmp;
05201                 // Third, appropriate sections of the image are cyclically shifted by one voxel
05202                 if (xodd) {
05203                         // Transfer the central slice in the x direction to the far right
05204                         // moving all slices on the far right toward the center one pixel, until
05205                         // the center x slice is ecountered
05206                         size_t idx = 0;
05207                         for (int s = 0; s < nz; ++s) {
05208                                 for (int r = 0; r < ny; ++r) {
05209                                         float last_val = rdata[s*nxy+r*nx+nx/2];
05210                                         for (int c = nx-1; c >= nx/2; --c){
05211                                                 idx = (size_t)s*nxy+r*nx+c;
05212                                                 tmp = rdata[idx];
05213                                                 rdata[idx] = last_val;
05214                                                 last_val = tmp;
05215                                         }
05216                                 }
05217                         }
05218                 }
05219                 if (yodd) {
05220                         // Tranfer the central slice in the y direction to the top
05221                         // shifting all pixels below it down on, until the center y slice is encountered.
05222                         size_t idx = 0;
05223                         for (int s = 0; s < nz; ++s) {
05224                                 for (int c = 0; c < nx; ++c) {
05225                                         float last_val = rdata[s*nxy+ny/2*nx+c];
05226                                         for (int r = ny-1; r >= ny/2; --r){
05227                                                 idx = (size_t)s*nxy+r*nx+c;
05228                                                 tmp = rdata[idx];
05229                                                 rdata[idx] = last_val;
05230                                                 last_val = tmp;
05231                                         }
05232                                 }
05233                         }
05234                 }
05235                 if (zodd) {
05236                         // Tranfer the central slice in the z direction to the back
05237                         // shifting all pixels beyond and including the middle slice back one.
05238                         size_t idx = 0;
05239                         for (int r = 0; r < ny; ++r){
05240                                 for (int c = 0; c < nx; ++c) {
05241                                         float last_val = rdata[nz/2*nxy+r*nx+c];
05242                                         for (int s = nz-1; s >= nz/2; --s) {
05243                                                 idx = (size_t)s*nxy+r*nx+c;
05244                                                 tmp = rdata[idx];
05245                                                 rdata[idx] = last_val;
05246                                                 last_val = tmp;
05247                                         }
05248                                 }
05249                         }
05250                 }
05251 
05252 
05253         }
05254 }


Member Data Documentation

const string PhaseToCenterProcessor::NAME = "xform.phaseorigin.tocenter" [static]
 

Definition at line 169 of file processor.cpp.


The documentation for this class was generated from the following files:
Generated on Tue Jul 12 13:52:25 2011 for EMAN2 by  doxygen 1.3.9.1