EMAN2
Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
EMAN::PhaseToCenterProcessor Class Reference

Translates a cornered image to the center Undoes the PhaseToCornerProcessor. More...

#include <processor.h>

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

Public Member Functions

virtual void process_inplace (EMData *image)
 To process an image in-place. More...
 
virtual string get_name () const
 Get the processor's name. More...
 
virtual string get_desc () const
 Get the descrition of this specific processor. More...
 
- Public Member Functions inherited from EMAN::Processor
virtual ~Processor ()
 
virtual EMDataprocess (const EMData *const image)
 To proccess an image out-of-place. More...
 
virtual void process_list_inplace (vector< EMData * > &images)
 To process multiple images using the same algorithm. More...
 
virtual Dict get_params () const
 Get the processor parameters in a key/value dictionary. More...
 
virtual void set_params (const Dict &new_params)
 Set the processor parameters using a key/value dictionary. More...
 
virtual TypeDict get_param_types () const
 Get processor parameter information in a dictionary. More...
 

Static Public Member Functions

static ProcessorNEW ()
 
- Static Public Member Functions inherited from EMAN::Processor
static string get_group_desc ()
 Get the description of this group of processors. More...
 
static void EMFourierFilterInPlace (EMData *fimage, Dict params)
 Compute a Fourier-filter processed image in place. More...
 
static EMDataEMFourierFilter (EMData *fimage, Dict params)
 Compute a Fourier-processor processed image without altering the original image. More...
 

Static Public Attributes

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

Additional Inherited Members

- Public Types inherited from EMAN::Processor
enum  fourier_filter_types {
  TOP_HAT_LOW_PASS , TOP_HAT_HIGH_PASS , TOP_HAT_BAND_PASS , TOP_HOMOMORPHIC ,
  GAUSS_LOW_PASS , GAUSS_HIGH_PASS , GAUSS_BAND_PASS , GAUSS_INVERSE ,
  GAUSS_HOMOMORPHIC , BUTTERWORTH_LOW_PASS , BUTTERWORTH_HIGH_PASS , BUTTERWORTH_HOMOMORPHIC ,
  KAISER_I0 , KAISER_SINH , KAISER_I0_INVERSE , KAISER_SINH_INVERSE ,
  SHIFT , TANH_LOW_PASS , TANH_HIGH_PASS , TANH_HOMOMORPHIC ,
  TANH_BAND_PASS , RADIAL_TABLE , CTF_
}
 Fourier filter Processor type enum. More...
 
- Protected Member Functions inherited from EMAN::Phase180Processor
void swap_corners_180 (EMData *image)
 swap_corners_180 - works on 2D and 3D images More...
 
void swap_central_slices_180 (EMData *image)
 swap_central_slices_180 - works on 2D and 3D images More...
 
void fourier_phaseshift180 (EMData *image)
 fourier_phaseshift180 - fourier phase shift by 180 this function is called internally if the argument to the process_inplace function is complex. More...
 
- Protected Attributes inherited from EMAN::Processor
Dict params
 

Detailed Description

Translates a cornered image to the center Undoes the PhaseToCornerProcessor.

works for 1D, 2D and 3D images, for all combinations of even and oddness

Author
David Woolford woolf.nosp@m.ord@.nosp@m.bcm.e.nosp@m.du
Date
October 2007

Definition at line 6729 of file processor.h.

Member Function Documentation

◆ get_desc()

virtual string EMAN::PhaseToCenterProcessor::get_desc ( ) const
inlinevirtual

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

6745 {
6746 return "Undoes the effect of the xform.phaseorigin.tocorner processor";
6747 }

◆ get_name()

virtual string EMAN::PhaseToCenterProcessor::get_name ( ) const
inlinevirtual

Get the processor's name.

Each processor is identified by a unique name.

Returns
The processor's name.

Implements EMAN::Processor.

Definition at line 6734 of file processor.h.

6735 {
6736 return NAME;
6737 }
static const string NAME
Definition: processor.h:6749

References NAME.

◆ NEW()

static Processor * EMAN::PhaseToCenterProcessor::NEW ( )
inlinestatic

Definition at line 6739 of file processor.h.

6740 {
6741 return new PhaseToCenterProcessor();
6742 }
Translates a cornered image to the center Undoes the PhaseToCornerProcessor.
Definition: processor.h:6730

◆ process_inplace()

void PhaseToCenterProcessor::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
imageThe image to be processed.

Implements EMAN::Processor.

Definition at line 6550 of file processor.cpp.

6551{
6552 if (!image) throw NullPointerException("Error: attempt to phase shift a null image");
6553
6554#ifdef EMAN2_USING_CUDA
6555 if (EMData::usecuda == 1 && image->getcudarwdata() && image->get_ndim() == 2) { // Because CUDA phase origin to center only works for 2D atm
6556 //cout << "CUDA tocenter" << endl;
6557 emdata_phaseorigin_to_center(image->getcudarwdata(), image->get_xsize(), image->get_ysize(), image->get_zsize());
6558 return;
6559 }
6560#endif // EMAN2_USING_CUDA
6561
6562 if (image->is_complex()) {
6563 fourier_phaseshift180(image);
6564 return;
6565 }
6566
6567 int nx = image->get_xsize();
6568 int ny = image->get_ysize();
6569 int nz = image->get_zsize();
6570
6571 if ( ny == 1 && nz == 1 && nx == 1) return;
6572
6573 int nxy = nx * ny;
6574
6575 float *rdata = image->get_data();
6576
6577 bool xodd = (nx % 2) == 1;
6578 bool yodd = (ny % 2) == 1;
6579 bool zodd = (nz % 2) == 1;
6580
6581 if ( ny == 1 && nz == 1 ){
6582 if (xodd) {
6583 // Put the center pixel at the end, shifting the contents
6584 // to right of the center one step to the left
6585 float in_x = rdata[nx/2];
6586 float tmp;
6587 for ( int i = nx-1; i >= nx/2; --i ) {
6588 tmp = rdata[i];
6589 rdata[i] = in_x;
6590 in_x = tmp;
6591 }
6592 }
6593 // now the operation is straight forward
6594 for ( int i = 0; i < nx/2; ++i ) {
6595 int idx = i + nx/2;
6596 float tmp = rdata[i];
6597 rdata[i] = rdata[idx];
6598 rdata[idx] = tmp;
6599 }
6600 }
6601 else if ( nz == 1 ){
6602 // The order in which these operations occur literally undoes what the
6603 // PhaseToCornerProcessor did to the image.
6604 // First, the corners sections of the image are swapped appropriately
6605 swap_corners_180(image);
6606 // Second, central pixel lines are swapped
6608
6609 float tmp;
6610 // Third, appropriate sections of the image are cyclically shifted by one pixel
6611 if (xodd) {
6612 // Transfer the middle column to the far right
6613 // Shift all from the far right to (but not including the) middle one to the left
6614 for ( int r = 0; r < ny; ++r ) {
6615 float last_val = rdata[r*nx+nx/2];
6616 for ( int c = nx-1; c >= nx/2; --c ){
6617 int idx = r*nx+c;
6618 tmp = rdata[idx];
6619 rdata[idx] = last_val;
6620 last_val = tmp;
6621 }
6622 }
6623 }
6624 if (yodd) {
6625 // Tranfer the middle row to the top,
6626 // shifting all pixels from the top row down one, until but not including the) middle
6627 for ( int c = 0; c < nx; ++c ) {
6628 // Get the value in the top row
6629 float last_val = rdata[ny/2*nx + c];
6630 for ( int r = ny-1; r >= ny/2; --r ){
6631 int idx = r*nx+c;
6632 tmp = rdata[idx];
6633 rdata[idx] = last_val;
6634 last_val = tmp;
6635 }
6636 }
6637 }
6638 }
6639 else
6640 {
6641 // The order in which these operations occur literally undoes the
6642 // PhaseToCornerProcessor operation - in 3D.
6643 // First, the corner quadrants of the voxel volume are swapped
6644 swap_corners_180(image);
6645 // Second, appropriate parts of the central slices are swapped
6647
6648 float tmp;
6649 // Third, appropriate sections of the image are cyclically shifted by one voxel
6650 if (xodd) {
6651 // Transfer the central slice in the x direction to the far right
6652 // moving all slices on the far right toward the center one pixel, until
6653 // the center x slice is ecountered
6654 size_t idx = 0;
6655 for (int s = 0; s < nz; ++s) {
6656 for (int r = 0; r < ny; ++r) {
6657 float last_val = rdata[s*nxy+r*nx+nx/2];
6658 for (int c = nx-1; c >= nx/2; --c){
6659 idx = (size_t)s*nxy+r*nx+c;
6660 tmp = rdata[idx];
6661 rdata[idx] = last_val;
6662 last_val = tmp;
6663 }
6664 }
6665 }
6666 }
6667 if (yodd) {
6668 // Tranfer the central slice in the y direction to the top
6669 // shifting all pixels below it down on, until the center y slice is encountered.
6670 size_t idx = 0;
6671 for (int s = 0; s < nz; ++s) {
6672 for (int c = 0; c < nx; ++c) {
6673 float last_val = rdata[s*nxy+ny/2*nx+c];
6674 for (int r = ny-1; r >= ny/2; --r){
6675 idx = (size_t)s*nxy+r*nx+c;
6676 tmp = rdata[idx];
6677 rdata[idx] = last_val;
6678 last_val = tmp;
6679 }
6680 }
6681 }
6682 }
6683 if (zodd) {
6684 // Tranfer the central slice in the z direction to the back
6685 // shifting all pixels beyond and including the middle slice back one.
6686 size_t idx = 0;
6687 for (int r = 0; r < ny; ++r){
6688 for (int c = 0; c < nx; ++c) {
6689 float last_val = rdata[nz/2*nxy+r*nx+c];
6690 for (int s = nz-1; s >= nz/2; --s) {
6691 idx = (size_t)s*nxy+r*nx+c;
6692 tmp = rdata[idx];
6693 rdata[idx] = last_val;
6694 last_val = tmp;
6695 }
6696 }
6697 }
6698 }
6699 }
6700}
#define rdata(i)
Definition: analyzer.cpp:592
void fourier_phaseshift180(EMData *image)
fourier_phaseshift180 - fourier phase shift by 180 this function is called internally if the argument...
Definition: processor.cpp:6159
void swap_corners_180(EMData *image)
swap_corners_180 - works on 2D and 3D images
Definition: processor.cpp:6184
void swap_central_slices_180(EMData *image)
swap_central_slices_180 - works on 2D and 3D images
Definition: processor.cpp:6281
void emdata_phaseorigin_to_center(float *data, const int nx, const int ny, const int nz)
#define NullPointerException(desc)
Definition: exception.h:241

References emdata_phaseorigin_to_center(), EMAN::Phase180Processor::fourier_phaseshift180(), NullPointerException, rdata, EMAN::Phase180Processor::swap_central_slices_180(), and EMAN::Phase180Processor::swap_corners_180().

Member Data Documentation

◆ NAME

const string PhaseToCenterProcessor::NAME = "xform.phaseorigin.tocenter"
static

Definition at line 6749 of file processor.h.

Referenced by get_name().


The documentation for this class was generated from the following files: