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

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

Translates a centered image to the corner works for 1D, 2D and 3D images, for all combinations of even and oddness. More...

#include <processor.h>

Inheritance diagram for EMAN::PhaseToCornerProcessor:

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

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

static ProcessorNEW ()

Static Public Attributes

static const string NAME = "xform.phaseorigin.tocorner"

Detailed Description

Translates a centered image to the corner 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 4870 of file processor.h.


Member Function Documentation

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

04886                         {
04887                                 return "Translates a centered image to the corner in a forward fashion";
04888                         }

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

References NAME.

04876                         {
04877                                 return NAME;
04878                         }

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

Definition at line 4880 of file processor.h.

04881                         {
04882                                 return new PhaseToCornerProcessor();
04883                         }

void PhaseToCornerProcessor::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 5004 of file processor.cpp.

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

05005 {
05006         if (!image)     throw NullPointerException("Error: attempt to phase shift a null image");
05007 
05008         if (image->is_complex()) {
05009                 fourier_phaseshift180(image);
05010                 return;
05011         }
05012 
05013         int nx = image->get_xsize();
05014         int ny = image->get_ysize();
05015         int nz = image->get_zsize();
05016 
05017         if ( ny == 1 && nz == 1 && nx == 1) return;
05018 
05019         int nxy = nx * ny;
05020 
05021         float *rdata = image->get_data();
05022 
05023         bool xodd = (nx % 2) == 1;
05024         bool yodd = (ny % 2) == 1;
05025         bool zodd = (nz % 2) == 1;
05026 
05027         if ( ny == 1 && nz == 1 ){
05028                 if (xodd){
05029                         // Put the last pixel in the center, shifting the contents
05030                         // to right of the center one step to the right
05031                         float in_x = rdata[nx-1];
05032                         float tmp;
05033                         for ( int i = nx/2; i < nx; ++i ) {
05034                                 tmp = rdata[i];
05035                                 rdata[i] = in_x;
05036                                 in_x = tmp;
05037                         }
05038                 }
05039                 // now the operation is straight forward
05040                 for ( int i = 0; i < nx/2; ++i ) {
05041                         int idx = i+nx/2+xodd;
05042                         float tmp = rdata[i];
05043                         rdata[i] = rdata[idx];
05044                         rdata[idx] = tmp;
05045                 }
05046 
05047         }
05048         else if ( nz == 1 ) {
05049                 if (yodd) {
05050                         // Tranfer the top row into the middle row,
05051                         // shifting all pixels above and including the current middle up one.
05052                         for ( int c = 0; c < nx; ++c ) {
05053                                 // Get the value in the top row
05054                                 float last_val = rdata[(ny-1)*nx + c];
05055                                 float tmp;
05056                                 for ( int r = ny/2; r < ny; ++r ){
05057                                         int idx =r*nx+c;
05058                                         tmp = rdata[idx];
05059                                         rdata[idx] = last_val;
05060                                         last_val = tmp;
05061                                 }
05062                         }
05063                 }
05064 
05065                 if (xodd) {
05066                         // Transfer the right most column into the center column
05067                         // Shift all columns right of and including center to the right one pixel
05068                         for ( int r  = 0; r < ny; ++r ) {
05069                                 float last_val = rdata[(r+1)*nx -1];
05070                                 float tmp;
05071                                 for ( int c = nx/2; c < nx; ++c ){
05072                                         int idx =r*nx+c;
05073                                         tmp = rdata[idx];
05074                                         rdata[idx] = last_val;
05075                                         last_val = tmp;
05076                                 }
05077                         }
05078                 }
05079                 // It is important central slice shifting come after the previous two operations
05080                 swap_central_slices_180(image);
05081                 // Now the corners of the image can be shifted...
05082                 swap_corners_180(image);
05083 
05084         }
05085         else
05086         {
05087                 float tmp;
05088                 if (zodd) {
05089                         // Tranfer the back slice into the middle slice,
05090                         // shifting all pixels beyond and including the middle slice back one.
05091                         size_t idx = 0;
05092                         for (int r = 0; r < ny; ++r){
05093                                 for (int c = 0; c < nx; ++c) {
05094                                         float last_val = rdata[(nz-1)*nxy+r*nx+c];
05095                                         for (int s = nz/2; s < nz; ++s) {
05096                                                 idx = s*nxy+r*nx+c;
05097                                                 tmp = rdata[idx];
05098                                                 rdata[idx] = last_val;
05099                                                 last_val = tmp;
05100                                         }
05101                                 }
05102                         }
05103                 }
05104                 if (yodd) {
05105                         // Tranfer the top slice into the middle slice,
05106                         // shifting all pixels above and including the middle slice up one.
05107                         size_t idx = 0;
05108                         for (int s = 0; s < nz; ++s) {
05109                                 for (int c = 0; c < nx; ++c) {
05110                                 float last_val = rdata[s*nxy+(ny-1)*nx+c];
05111                                         for (int r = ny/2; r < ny; ++r){
05112                                                 idx = s*nxy+r*nx+c;
05113                                                 tmp = rdata[idx];
05114                                                 rdata[idx] = last_val;
05115                                                 last_val = tmp;
05116                                         }
05117                                 }
05118                         }
05119                 }
05120                 if (xodd) {
05121                         // Transfer the right most slice into the central slice
05122                         // Shift all pixels to right of and including center slice to the right one pixel
05123                         size_t idx = 0;
05124                         for (int s = 0; s < nz; ++s) {
05125                                 for (int r = 0; r < ny; ++r) {
05126                                         float last_val = rdata[s*nxy+r*nx+nx-1];
05127                                         for (int c = nx/2; c < nx; ++c){
05128                                                 idx = s*nxy+r*nx+c;
05129                                                 tmp = rdata[idx];
05130                                                 rdata[idx] = last_val;
05131                                                 last_val = tmp;
05132                                         }
05133                                 }
05134                         }
05135                 }
05136                 // Now swap the various parts in the central slices
05137                 swap_central_slices_180(image);
05138                 // Now shift the corners
05139                 swap_corners_180(image);
05140         }
05141 }


Member Data Documentation

const string PhaseToCornerProcessor::NAME = "xform.phaseorigin.tocorner" [static]
 

Definition at line 4890 of file processor.h.

Referenced by get_name().


The documentation for this class was generated from the following files:
Generated on Mon Jul 19 13:07:09 2010 for EMAN2 by  doxygen 1.4.4