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

ProcessorNEW ()

Static Public Attributes

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

04755                         {
04756                                 return "Translates a centered image to the corner in a forward fashion";
04757                         }

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

04745                         {
04746                                 return NAME;
04747                         }

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

Definition at line 4749 of file processor.h.

04750                         {
04751                                 return new PhaseToCornerProcessor();
04752                         }

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 4928 of file processor.cpp.

References emdata_phaseorigin_to_corner(), 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().

04929 {
04930         if (!image)     throw NullPointerException("Error: attempt to phase shift a null image");
04931 
04932 #ifdef EMAN2_USING_CUDA
04933         if (image->cudarwdata && image->get_ndim() == 2) { // Because CUDA phase origin to center only works for 2D atm
04934                 //cout << "CUDA tocorner" << endl;
04935                 emdata_phaseorigin_to_corner(image->cudarwdata, image->get_xsize(), image->get_ysize(), image->get_zsize());
04936                 return;
04937         }
04938 #endif // EMAN2_USING_CUDA
04939 
04940         if (image->is_complex()) {
04941                 fourier_phaseshift180(image);
04942                 return;
04943         }
04944 
04945         int nx = image->get_xsize();
04946         int ny = image->get_ysize();
04947         int nz = image->get_zsize();
04948 
04949         if ( ny == 1 && nz == 1 && nx == 1) return;
04950 
04951         int nxy = nx * ny;
04952 
04953         float *rdata = image->get_data();
04954 
04955         bool xodd = (nx % 2) == 1;
04956         bool yodd = (ny % 2) == 1;
04957         bool zodd = (nz % 2) == 1;
04958 
04959         if ( ny == 1 && nz == 1 ){
04960                 if (xodd){
04961                         // Put the last pixel in the center, shifting the contents
04962                         // to right of the center one step to the right
04963                         float in_x = rdata[nx-1];
04964                         float tmp;
04965                         for ( int i = nx/2; i < nx; ++i ) {
04966                                 tmp = rdata[i];
04967                                 rdata[i] = in_x;
04968                                 in_x = tmp;
04969                         }
04970                 }
04971                 // now the operation is straight forward
04972                 for ( int i = 0; i < nx/2; ++i ) {
04973                         int idx = i+nx/2+xodd;
04974                         float tmp = rdata[i];
04975                         rdata[i] = rdata[idx];
04976                         rdata[idx] = tmp;
04977                 }
04978 
04979         }
04980         else if ( nz == 1 ) {
04981                 if (yodd) {
04982                         // Tranfer the top row into the middle row,
04983                         // shifting all pixels above and including the current middle up one.
04984                         for ( int c = 0; c < nx; ++c ) {
04985                                 // Get the value in the top row
04986                                 float last_val = rdata[(ny-1)*nx + c];
04987                                 float tmp;
04988                                 for ( int r = ny/2; r < ny; ++r ){
04989                                         int idx =r*nx+c;
04990                                         tmp = rdata[idx];
04991                                         rdata[idx] = last_val;
04992                                         last_val = tmp;
04993                                 }
04994                         }
04995                 }
04996 
04997                 if (xodd) {
04998                         // Transfer the right most column into the center column
04999                         // Shift all columns right of and including center to the right one pixel
05000                         for ( int r  = 0; r < ny; ++r ) {
05001                                 float last_val = rdata[(r+1)*nx -1];
05002                                 float tmp;
05003                                 for ( int c = nx/2; c < nx; ++c ){
05004                                         int idx =r*nx+c;
05005                                         tmp = rdata[idx];
05006                                         rdata[idx] = last_val;
05007                                         last_val = tmp;
05008                                 }
05009                         }
05010                 }
05011                 // It is important central slice shifting come after the previous two operations
05012                 swap_central_slices_180(image);
05013                 // Now the corners of the image can be shifted...
05014                 swap_corners_180(image);
05015 
05016         }
05017         else
05018         {
05019                 float tmp;
05020                 if (zodd) {
05021                         // Tranfer the back slice into the middle slice,
05022                         // shifting all pixels beyond and including the middle slice back one.
05023                         size_t idx = 0;
05024                         for (int r = 0; r < ny; ++r){
05025                                 for (int c = 0; c < nx; ++c) {
05026                                         float last_val = rdata[(nz-1)*nxy+r*nx+c];
05027                                         for (int s = nz/2; s < nz; ++s) {
05028                                                 idx = (size_t)s*nxy+r*nx+c;
05029                                                 tmp = rdata[idx];
05030                                                 rdata[idx] = last_val;
05031                                                 last_val = tmp;
05032                                         }
05033                                 }
05034                         }
05035                 }
05036                 if (yodd) {
05037                         // Tranfer the top slice into the middle slice,
05038                         // shifting all pixels above and including the middle slice up one.
05039                         size_t idx = 0;
05040                         for (int s = 0; s < nz; ++s) {
05041                                 for (int c = 0; c < nx; ++c) {
05042                                 float last_val = rdata[s*nxy+(ny-1)*nx+c];
05043                                         for (int r = ny/2; r < ny; ++r){
05044                                                 idx = (size_t)s*nxy+r*nx+c;
05045                                                 tmp = rdata[idx];
05046                                                 rdata[idx] = last_val;
05047                                                 last_val = tmp;
05048                                         }
05049                                 }
05050                         }
05051                 }
05052                 if (xodd) {
05053                         // Transfer the right most slice into the central slice
05054                         // Shift all pixels to right of and including center slice to the right one pixel
05055                         size_t idx = 0;
05056                         for (int s = 0; s < nz; ++s) {
05057                                 for (int r = 0; r < ny; ++r) {
05058                                         float last_val = rdata[s*nxy+r*nx+nx-1];
05059                                         for (int c = nx/2; c < nx; ++c){
05060                                                 idx = (size_t)s*nxy+r*nx+c;
05061                                                 tmp = rdata[idx];
05062                                                 rdata[idx] = last_val;
05063                                                 last_val = tmp;
05064                                         }
05065                                 }
05066                         }
05067                 }
05068                 // Now swap the various parts in the central slices
05069                 swap_central_slices_180(image);
05070                 // Now shift the corners
05071                 swap_corners_180(image);
05072         }
05073 }


Member Data Documentation

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

Definition at line 162 of file processor.cpp.


The documentation for this class was generated from the following files:
Generated on Thu Mar 10 23:00:48 2011 for EMAN2 by  doxygen 1.3.9.1