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

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]

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.tocorner"
 

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 centered image to the corner 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 6759 of file processor.h.

Member Function Documentation

◆ get_desc()

virtual string EMAN::PhaseToCornerProcessor::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 6774 of file processor.h.

6775 {
6776 return "Translates a centered image to the corner in a forward fashion";
6777 }

◆ get_name()

virtual string EMAN::PhaseToCornerProcessor::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 6764 of file processor.h.

6765 {
6766 return NAME;
6767 }
static const string NAME
Definition: processor.h:6779

References NAME.

◆ NEW()

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

Definition at line 6769 of file processor.h.

6770 {
6771 return new PhaseToCornerProcessor();
6772 }
Translates a centered image to the corner works for 1D, 2D and 3D images, for all combinations of eve...
Definition: processor.h:6760

◆ process_inplace()

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

Implements EMAN::Processor.

Definition at line 6402 of file processor.cpp.

6403{
6404 if (!image) throw NullPointerException("Error: attempt to phase shift a null image");
6405
6406#ifdef EMAN2_USING_CUDA
6407 if (EMData::usecuda == 1 && image->getcudarwdata() && image->get_ndim() == 2) { // Because CUDA phase origin to center only works for 2D atm
6408 //cout << "CUDA tocorner " << image->getcudarwdata() << endl;
6409 emdata_phaseorigin_to_corner(image->getcudarwdata(), image->get_xsize(), image->get_ysize(), image->get_zsize());
6410 return;
6411 }
6412#endif // EMAN2_USING_CUDA
6413
6414 if (image->is_complex()) {
6415 fourier_phaseshift180(image);
6416 return;
6417 }
6418
6419 int nx = image->get_xsize();
6420 int ny = image->get_ysize();
6421 int nz = image->get_zsize();
6422
6423 if ( ny == 1 && nz == 1 && nx == 1) return;
6424
6425 int nxy = nx * ny;
6426
6427 float *rdata = image->get_data();
6428
6429 bool xodd = (nx % 2) == 1;
6430 bool yodd = (ny % 2) == 1;
6431 bool zodd = (nz % 2) == 1;
6432
6433 if ( ny == 1 && nz == 1 ){
6434 if (xodd){
6435 // Put the last pixel in the center, shifting the contents
6436 // to right of the center one step to the right
6437 float in_x = rdata[nx-1];
6438 float tmp;
6439 for ( int i = nx/2; i < nx; ++i ) {
6440 tmp = rdata[i];
6441 rdata[i] = in_x;
6442 in_x = tmp;
6443 }
6444 }
6445 // now the operation is straight forward
6446 for ( int i = 0; i < nx/2; ++i ) {
6447 int idx = i+nx/2+xodd;
6448 float tmp = rdata[i];
6449 rdata[i] = rdata[idx];
6450 rdata[idx] = tmp;
6451 }
6452
6453 }
6454 else if ( nz == 1 ) {
6455 if (yodd) {
6456 // Tranfer the top row into the middle row,
6457 // shifting all pixels above and including the current middle up one.
6458 for ( int c = 0; c < nx; ++c ) {
6459 // Get the value in the top row
6460 float last_val = rdata[(ny-1)*nx + c];
6461 float tmp;
6462 for ( int r = ny/2; r < ny; ++r ){
6463 int idx =r*nx+c;
6464 tmp = rdata[idx];
6465 rdata[idx] = last_val;
6466 last_val = tmp;
6467 }
6468 }
6469 }
6470
6471 if (xodd) {
6472 // Transfer the right most column into the center column
6473 // Shift all columns right of and including center to the right one pixel
6474 for ( int r = 0; r < ny; ++r ) {
6475 float last_val = rdata[(r+1)*nx -1];
6476 float tmp;
6477 for ( int c = nx/2; c < nx; ++c ){
6478 int idx =r*nx+c;
6479 tmp = rdata[idx];
6480 rdata[idx] = last_val;
6481 last_val = tmp;
6482 }
6483 }
6484 }
6485 // It is important central slice shifting come after the previous two operations
6487 // Now the corners of the image can be shifted...
6488 swap_corners_180(image);
6489
6490 }
6491 else
6492 {
6493 float tmp;
6494 if (zodd) {
6495 // Tranfer the back slice into the middle slice,
6496 // shifting all pixels beyond and including the middle slice back one.
6497 size_t idx = 0;
6498 for (int r = 0; r < ny; ++r){
6499 for (int c = 0; c < nx; ++c) {
6500 float last_val = rdata[(nz-1)*nxy+r*nx+c];
6501 for (int s = nz/2; s < nz; ++s) {
6502 idx = (size_t)s*nxy+r*nx+c;
6503 tmp = rdata[idx];
6504 rdata[idx] = last_val;
6505 last_val = tmp;
6506 }
6507 }
6508 }
6509 }
6510 if (yodd) {
6511 // Tranfer the top slice into the middle slice,
6512 // shifting all pixels above and including the middle slice up one.
6513 size_t idx = 0;
6514 for (int s = 0; s < nz; ++s) {
6515 for (int c = 0; c < nx; ++c) {
6516 float last_val = rdata[s*nxy+(ny-1)*nx+c];
6517 for (int r = ny/2; r < ny; ++r){
6518 idx = (size_t)s*nxy+r*nx+c;
6519 tmp = rdata[idx];
6520 rdata[idx] = last_val;
6521 last_val = tmp;
6522 }
6523 }
6524 }
6525 }
6526 if (xodd) {
6527 // Transfer the right most slice into the central slice
6528 // Shift all pixels to right of and including center slice to the right one pixel
6529 size_t idx = 0;
6530 for (int s = 0; s < nz; ++s) {
6531 for (int r = 0; r < ny; ++r) {
6532 float last_val = rdata[s*nxy+r*nx+nx-1];
6533 for (int c = nx/2; c < nx; ++c){
6534 idx = (size_t)s*nxy+r*nx+c;
6535 tmp = rdata[idx];
6536 rdata[idx] = last_val;
6537 last_val = tmp;
6538 }
6539 }
6540 }
6541 }
6542 // Now swap the various parts in the central slices
6544 // Now shift the corners
6545 swap_corners_180(image);
6546 }
6547}
#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_corner(float *data, const int nx, const int ny, const int nz)
#define NullPointerException(desc)
Definition: exception.h:241

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

Member Data Documentation

◆ NAME

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

Definition at line 6779 of file processor.h.

Referenced by get_name().


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