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

04670                         {
04671                                 return "Translates a centered image to the corner in a forward fashion";
04672                         }

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

04660                         {
04661                                 return NAME;
04662                         }

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

Definition at line 4664 of file processor.h.

04665                         {
04666                                 return new PhaseToCornerProcessor();
04667                         }

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

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


Member Data Documentation

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

Definition at line 159 of file processor.cpp.


The documentation for this class was generated from the following files:
Generated on Thu Dec 9 13:48:11 2010 for EMAN2 by  doxygen 1.3.9.1