#include <processor.h>
Inheritance diagram for EMAN::FourierToCornerProcessor:
Public Member Functions | |
virtual void | process_inplace (EMData *image) |
Fourier origin shift the image in the backwards direction Should only be called after the application of FourierToCenterProcessor. | |
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 | |
Processor * | NEW () |
Static Public Attributes | |
const string | NAME = "xform.fourierorigin.tocorner" |
Definition at line 4753 of file processor.h.
|
Get the descrition of this specific processor. This function must be overwritten by a subclass.
Implements EMAN::Processor. Definition at line 4773 of file processor.h. 04774 { 04775 return "Undoes the xform.fourierorigin.tocenter processor"; 04776 }
|
|
Get the processor's name. Each processor is identified by a unique name.
Implements EMAN::Processor. Definition at line 4763 of file processor.h. 04764 {
04765 return NAME;
04766 }
|
|
Definition at line 4768 of file processor.h. 04769 { 04770 return new FourierToCornerProcessor(); 04771 }
|
|
Fourier origin shift the image in the backwards direction Should only be called after the application of FourierToCenterProcessor.
Implements EMAN::Processor. Definition at line 4521 of file processor.cpp. References EMAN::EMData::get_data(), EMAN::EMData::get_xsize(), EMAN::EMData::get_ysize(), EMAN::EMData::get_zsize(), ImageFormatException, EMAN::EMData::is_complex(), nx, ny, rdata, and EMAN::EMData::set_shuffled(). 04522 { 04523 if ( !image->is_complex() ) throw ImageFormatException("Can not Fourier origin shift an image that is not complex"); 04524 04525 int nx=image->get_xsize(); 04526 int ny=image->get_ysize(); 04527 int nz=image->get_zsize(); 04528 04529 int nxy = nx*ny; 04530 04531 if ( ny == 1 && nz == 1 ){ 04532 cout << "Warning- attempted Fourier origin shift a 1D image - no action taken" << endl; 04533 return; 04534 } 04535 int yodd = (ny%2==1); 04536 int zodd = (nz%2==1); 04537 04538 float* rdata = image->get_data(); 04539 04540 float tmp[2]; 04541 float* p1; 04542 float* p2; 04543 04544 if (yodd){ 04545 // Swap the middle slice (with respect to the y direction) with the bottom slice 04546 // shifting all slices above the middles slice upwards by one pixel, stopping 04547 // at the middle slice, not if nz = 1 we are not talking about slices, we are 04548 // talking about rows 04549 float prev[2]; 04550 size_t idx; 04551 for( int s = 0; s < nz; s++ ) { 04552 for( int c =0; c < nx; c += 2 ) { 04553 idx = (size_t)s*nxy+ny/2*nx+c; 04554 prev[0] = rdata[idx]; 04555 prev[1] = rdata[idx+1]; 04556 for( int r = 0; r <= ny/2; ++r ) { 04557 idx = (size_t)s*nxy+r*nx+c; 04558 float* p1 = &rdata[idx]; 04559 tmp[0] = p1[0]; 04560 tmp[1] = p1[1]; 04561 04562 p1[0] = prev[0]; 04563 p1[1] = prev[1]; 04564 04565 prev[0] = tmp[0]; 04566 prev[1] = tmp[1]; 04567 } 04568 } 04569 } 04570 } 04571 04572 // Shift slices (3D) or rows (2D) correctly in the y direction 04573 size_t idx1, idx2; 04574 for( int s = 0; s < nz; ++s ) { 04575 for( int r = 0 + yodd; r < ny/2+yodd; ++r ) { 04576 for( int c =0; c < nx; c += 2 ) { 04577 idx1 = (size_t)s*nxy+r*nx+c; 04578 idx2 = (size_t)s*nxy+(r+ny/2)*nx+c; 04579 p1 = &rdata[idx1]; 04580 p2 = &rdata[idx2]; 04581 04582 tmp[0] = p1[0]; 04583 tmp[1] = p1[1]; 04584 04585 p1[0] = p2[0]; 04586 p1[1] = p2[1]; 04587 04588 p2[0] = tmp[0]; 04589 p2[1] = tmp[1]; 04590 } 04591 } 04592 } 04593 04594 if ( nz != 1 ) 04595 { 04596 04597 if (zodd){ 04598 // Swap the middle slice (with respect to the z direction) and the front slice 04599 // shifting all behind the front slice towards the middle a distance of 1 voxel, 04600 // stopping at the middle slice. 04601 float prev[2]; 04602 size_t idx; 04603 for( int r = 0; r < ny; ++r ) { 04604 for( int c =0; c < nx; c += 2 ) { 04605 idx = (size_t)nz/2*nxy+r*nx+c; 04606 prev[0] = rdata[idx]; 04607 prev[1] = rdata[idx+1]; 04608 for( int s = 0; s <= nz/2; ++s ) { 04609 idx = (size_t)s*nxy+r*nx+c; 04610 float* p1 = &rdata[idx]; 04611 tmp[0] = p1[0]; 04612 tmp[1] = p1[1]; 04613 04614 p1[0] = prev[0]; 04615 p1[1] = prev[1]; 04616 04617 prev[0] = tmp[0]; 04618 prev[1] = tmp[1]; 04619 } 04620 } 04621 } 04622 } 04623 04624 // Shift slices correctly in the z direction 04625 size_t idx1, idx2; 04626 for( int s = 0+zodd; s < nz/2 + zodd; ++s ) { 04627 for( int r = 0; r < ny; ++r ) { 04628 for( int c =0; c < nx; c += 2 ) { 04629 idx1 = (size_t)s*nxy+r*nx+c; 04630 idx2 = (size_t)(s+nz/2)*nxy+r*nx+c; 04631 p1 = &rdata[idx1]; 04632 p2 = &rdata[idx2]; 04633 04634 tmp[0] = p1[0]; 04635 tmp[1] = p1[1]; 04636 04637 p1[0] = p2[0]; 04638 p1[1] = p2[1]; 04639 04640 p2[0] = tmp[0]; 04641 p2[1] = tmp[1]; 04642 } 04643 } 04644 } 04645 } 04646 image->set_shuffled(false); 04647 }
|
|
Definition at line 162 of file processor.cpp. |