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

04846                         {
04847                                 return "Translates a centered image to the corner in a forward fashion";
04848                         }

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

References NAME.

04836                         {
04837                                 return NAME;
04838                         }

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

Definition at line 4840 of file processor.h.

04841                         {
04842                                 return new PhaseToCornerProcessor();
04843                         }

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

04898 {
04899         if (!image)     throw NullPointerException("Error: attempt to phase shift a null image");
04900 
04901         if (image->is_complex()) {
04902                 fourier_phaseshift180(image);
04903                 return;
04904         }
04905 
04906         int nx = image->get_xsize();
04907         int ny = image->get_ysize();
04908         int nz = image->get_zsize();
04909 
04910         if ( ny == 1 && nz == 1 && nx == 1) return;
04911 
04912         int nxy = nx * ny;
04913 
04914         float *rdata = image->get_data();
04915 
04916         bool xodd = (nx % 2) == 1;
04917         bool yodd = (ny % 2) == 1;
04918         bool zodd = (nz % 2) == 1;
04919 
04920         if ( ny == 1 && nz == 1 ){
04921                 if (xodd){
04922                         // Put the last pixel in the center, shifting the contents
04923                         // to right of the center one step to the right
04924                         float in_x = rdata[nx-1];
04925                         float tmp;
04926                         for ( int i = nx/2; i < nx; ++i ) {
04927                                 tmp = rdata[i];
04928                                 rdata[i] = in_x;
04929                                 in_x = tmp;
04930                         }
04931                 }
04932                 // now the operation is straight forward
04933                 for ( int i = 0; i < nx/2; ++i ) {
04934                         int idx = i+nx/2+xodd;
04935                         float tmp = rdata[i];
04936                         rdata[i] = rdata[idx];
04937                         rdata[idx] = tmp;
04938                 }
04939 
04940         }
04941         else if ( nz == 1 ) {
04942                 if (yodd) {
04943                         // Tranfer the top row into the middle row,
04944                         // shifting all pixels above and including the current middle up one.
04945                         for ( int c = 0; c < nx; ++c ) {
04946                                 // Get the value in the top row
04947                                 float last_val = rdata[(ny-1)*nx + c];
04948                                 float tmp;
04949                                 for ( int r = ny/2; r < ny; ++r ){
04950                                         int idx =r*nx+c;
04951                                         tmp = rdata[idx];
04952                                         rdata[idx] = last_val;
04953                                         last_val = tmp;
04954                                 }
04955                         }
04956                 }
04957 
04958                 if (xodd) {
04959                         // Transfer the right most column into the center column
04960                         // Shift all columns right of and including center to the right one pixel
04961                         for ( int r  = 0; r < ny; ++r ) {
04962                                 float last_val = rdata[(r+1)*nx -1];
04963                                 float tmp;
04964                                 for ( int c = nx/2; c < nx; ++c ){
04965                                         int idx =r*nx+c;
04966                                         tmp = rdata[idx];
04967                                         rdata[idx] = last_val;
04968                                         last_val = tmp;
04969                                 }
04970                         }
04971                 }
04972                 // It is important central slice shifting come after the previous two operations
04973                 swap_central_slices_180(image);
04974                 // Now the corners of the image can be shifted...
04975                 swap_corners_180(image);
04976 
04977         }
04978         else
04979         {
04980                 float tmp;
04981                 if (zodd) {
04982                         // Tranfer the back slice into the middle slice,
04983                         // shifting all pixels beyond and including the middle slice back one.
04984                         size_t idx = 0;
04985                         for (int r = 0; r < ny; ++r){
04986                                 for (int c = 0; c < nx; ++c) {
04987                                         float last_val = rdata[(nz-1)*nxy+r*nx+c];
04988                                         for (int s = nz/2; s < nz; ++s) {
04989                                                 idx = s*nxy+r*nx+c;
04990                                                 tmp = rdata[idx];
04991                                                 rdata[idx] = last_val;
04992                                                 last_val = tmp;
04993                                         }
04994                                 }
04995                         }
04996                 }
04997                 if (yodd) {
04998                         // Tranfer the top slice into the middle slice,
04999                         // shifting all pixels above and including the middle slice up one.
05000                         size_t idx = 0;
05001                         for (int s = 0; s < nz; ++s) {
05002                                 for (int c = 0; c < nx; ++c) {
05003                                 float last_val = rdata[s*nxy+(ny-1)*nx+c];
05004                                         for (int r = ny/2; r < ny; ++r){
05005                                                 idx = s*nxy+r*nx+c;
05006                                                 tmp = rdata[idx];
05007                                                 rdata[idx] = last_val;
05008                                                 last_val = tmp;
05009                                         }
05010                                 }
05011                         }
05012                 }
05013                 if (xodd) {
05014                         // Transfer the right most slice into the central slice
05015                         // Shift all pixels to right of and including center slice to the right one pixel
05016                         size_t idx = 0;
05017                         for (int s = 0; s < nz; ++s) {
05018                                 for (int r = 0; r < ny; ++r) {
05019                                         float last_val = rdata[s*nxy+r*nx+nx-1];
05020                                         for (int c = nx/2; c < nx; ++c){
05021                                                 idx = s*nxy+r*nx+c;
05022                                                 tmp = rdata[idx];
05023                                                 rdata[idx] = last_val;
05024                                                 last_val = tmp;
05025                                         }
05026                                 }
05027                         }
05028                 }
05029                 // Now swap the various parts in the central slices
05030                 swap_central_slices_180(image);
05031                 // Now shift the corners
05032                 swap_corners_180(image);
05033         }
05034 }


Member Data Documentation

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

Definition at line 4850 of file processor.h.

Referenced by get_name().


The documentation for this class was generated from the following files:
Generated on Tue May 25 17:17:18 2010 for EMAN2 by  doxygen 1.4.7