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:

[legend]
Collaboration diagram for EMAN::PhaseToCornerProcessor:
[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 4829 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 4844 of file processor.h.

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

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

04835                         {
04836                                 return NAME;
04837                         }

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

Definition at line 4839 of file processor.h.

04840                         {
04841                                 return new PhaseToCornerProcessor();
04842                         }

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 4866 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, nx, ny, rdata, EMAN::Phase180Processor::swap_central_slices_180(), and EMAN::Phase180Processor::swap_corners_180().

04867 {
04868         if (!image)     throw NullPointerException("Error: attempt to phase shift a null image");
04869 
04870         if (image->is_complex()) {
04871                 fourier_phaseshift180(image);
04872                 return;
04873         }
04874 
04875         int nx = image->get_xsize();
04876         int ny = image->get_ysize();
04877         int nz = image->get_zsize();
04878 
04879         if ( ny == 1 && nz == 1 && nx == 1) return;
04880 
04881         int nxy = nx * ny;
04882 
04883         float *rdata = image->get_data();
04884 
04885         bool xodd = (nx % 2) == 1;
04886         bool yodd = (ny % 2) == 1;
04887         bool zodd = (nz % 2) == 1;
04888 
04889         if ( ny == 1 && nz == 1 ){
04890                 if (xodd){
04891                         // Put the last pixel in the center, shifting the contents
04892                         // to right of the center one step to the right
04893                         float in_x = rdata[nx-1];
04894                         float tmp;
04895                         for ( int i = nx/2; i < nx; ++i ) {
04896                                 tmp = rdata[i];
04897                                 rdata[i] = in_x;
04898                                 in_x = tmp;
04899                         }
04900                 }
04901                 // now the operation is straight forward
04902                 for ( int i = 0; i < nx/2; ++i ) {
04903                         int idx = i+nx/2+xodd;
04904                         float tmp = rdata[i];
04905                         rdata[i] = rdata[idx];
04906                         rdata[idx] = tmp;
04907                 }
04908 
04909         }
04910         else if ( nz == 1 ) {
04911                 if (yodd) {
04912                         // Tranfer the top row into the middle row,
04913                         // shifting all pixels above and including the current middle up one.
04914                         for ( int c = 0; c < nx; ++c ) {
04915                                 // Get the value in the top row
04916                                 float last_val = rdata[(ny-1)*nx + c];
04917                                 float tmp;
04918                                 for ( int r = ny/2; r < ny; ++r ){
04919                                         int idx =r*nx+c;
04920                                         tmp = rdata[idx];
04921                                         rdata[idx] = last_val;
04922                                         last_val = tmp;
04923                                 }
04924                         }
04925                 }
04926 
04927                 if (xodd) {
04928                         // Transfer the right most column into the center column
04929                         // Shift all columns right of and including center to the right one pixel
04930                         for ( int r  = 0; r < ny; ++r ) {
04931                                 float last_val = rdata[(r+1)*nx -1];
04932                                 float tmp;
04933                                 for ( int c = nx/2; c < nx; ++c ){
04934                                         int idx =r*nx+c;
04935                                         tmp = rdata[idx];
04936                                         rdata[idx] = last_val;
04937                                         last_val = tmp;
04938                                 }
04939                         }
04940                 }
04941                 // It is important central slice shifting come after the previous two operations
04942                 swap_central_slices_180(image);
04943                 // Now the corners of the image can be shifted...
04944                 swap_corners_180(image);
04945 
04946         }
04947         else
04948         {
04949                 float tmp;
04950                 if (zodd) {
04951                         // Tranfer the back slice into the middle slice,
04952                         // shifting all pixels beyond and including the middle slice back one.
04953                         size_t idx = 0;
04954                         for (int r = 0; r < ny; ++r){
04955                                 for (int c = 0; c < nx; ++c) {
04956                                         float last_val = rdata[(nz-1)*nxy+r*nx+c];
04957                                         for (int s = nz/2; s < nz; ++s) {
04958                                                 idx = s*nxy+r*nx+c;
04959                                                 tmp = rdata[idx];
04960                                                 rdata[idx] = last_val;
04961                                                 last_val = tmp;
04962                                         }
04963                                 }
04964                         }
04965                 }
04966                 if (yodd) {
04967                         // Tranfer the top slice into the middle slice,
04968                         // shifting all pixels above and including the middle slice up one.
04969                         size_t idx = 0;
04970                         for (int s = 0; s < nz; ++s) {
04971                                 for (int c = 0; c < nx; ++c) {
04972                                 float last_val = rdata[s*nxy+(ny-1)*nx+c];
04973                                         for (int r = ny/2; r < ny; ++r){
04974                                                 idx = s*nxy+r*nx+c;
04975                                                 tmp = rdata[idx];
04976                                                 rdata[idx] = last_val;
04977                                                 last_val = tmp;
04978                                         }
04979                                 }
04980                         }
04981                 }
04982                 if (xodd) {
04983                         // Transfer the right most slice into the central slice
04984                         // Shift all pixels to right of and including center slice to the right one pixel
04985                         size_t idx = 0;
04986                         for (int s = 0; s < nz; ++s) {
04987                                 for (int r = 0; r < ny; ++r) {
04988                                         float last_val = rdata[s*nxy+r*nx+nx-1];
04989                                         for (int c = nx/2; c < nx; ++c){
04990                                                 idx = s*nxy+r*nx+c;
04991                                                 tmp = rdata[idx];
04992                                                 rdata[idx] = last_val;
04993                                                 last_val = tmp;
04994                                         }
04995                                 }
04996                         }
04997                 }
04998                 // Now swap the various parts in the central slices
04999                 swap_central_slices_180(image);
05000                 // Now shift the corners
05001                 swap_corners_180(image);
05002         }
05003 }


Member Data Documentation

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

Definition at line 164 of file processor.cpp.


The documentation for this class was generated from the following files:
Generated on Fri Apr 30 15:39:25 2010 for EMAN2 by  doxygen 1.3.9.1