#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 4677 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 4697 of file processor.h. 04698 {
04699 return "Undoes the xform.fourierorigin.tocenter processor";
04700 }
|
|
|
Get the processor's name. Each processor is identified by a unique name.
Implements EMAN::Processor. Definition at line 4687 of file processor.h. 04688 {
04689 return NAME;
04690 }
|
|
|
Definition at line 4692 of file processor.h. 04693 {
04694 return new FourierToCornerProcessor();
04695 }
|
|
|
Fourier origin shift the image in the backwards direction Should only be called after the application of FourierToCenterProcessor.
Implements EMAN::Processor. Definition at line 4430 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(). 04431 {
04432 if ( !image->is_complex() ) throw ImageFormatException("Can not Fourier origin shift an image that is not complex");
04433
04434 int nx=image->get_xsize();
04435 int ny=image->get_ysize();
04436 int nz=image->get_zsize();
04437
04438 int nxy = nx*ny;
04439
04440 if ( ny == 1 && nz == 1 ){
04441 cout << "Warning- attempted Fourier origin shift a 1D image - no action taken" << endl;
04442 return;
04443 }
04444 int yodd = (ny%2==1);
04445 int zodd = (nz%2==1);
04446
04447 float* rdata = image->get_data();
04448
04449 float tmp[2];
04450 float* p1;
04451 float* p2;
04452
04453 if (yodd){
04454 // Swap the middle slice (with respect to the y direction) with the bottom slice
04455 // shifting all slices above the middles slice upwards by one pixel, stopping
04456 // at the middle slice, not if nz = 1 we are not talking about slices, we are
04457 // talking about rows
04458 float prev[2];
04459 size_t idx;
04460 for( int s = 0; s < nz; s++ ) {
04461 for( int c =0; c < nx; c += 2 ) {
04462 idx = (size_t)s*nxy+ny/2*nx+c;
04463 prev[0] = rdata[idx];
04464 prev[1] = rdata[idx+1];
04465 for( int r = 0; r <= ny/2; ++r ) {
04466 idx = (size_t)s*nxy+r*nx+c;
04467 float* p1 = &rdata[idx];
04468 tmp[0] = p1[0];
04469 tmp[1] = p1[1];
04470
04471 p1[0] = prev[0];
04472 p1[1] = prev[1];
04473
04474 prev[0] = tmp[0];
04475 prev[1] = tmp[1];
04476 }
04477 }
04478 }
04479 }
04480
04481 // Shift slices (3D) or rows (2D) correctly in the y direction
04482 size_t idx1, idx2;
04483 for( int s = 0; s < nz; ++s ) {
04484 for( int r = 0 + yodd; r < ny/2+yodd; ++r ) {
04485 for( int c =0; c < nx; c += 2 ) {
04486 idx1 = (size_t)s*nxy+r*nx+c;
04487 idx2 = (size_t)s*nxy+(r+ny/2)*nx+c;
04488 p1 = &rdata[idx1];
04489 p2 = &rdata[idx2];
04490
04491 tmp[0] = p1[0];
04492 tmp[1] = p1[1];
04493
04494 p1[0] = p2[0];
04495 p1[1] = p2[1];
04496
04497 p2[0] = tmp[0];
04498 p2[1] = tmp[1];
04499 }
04500 }
04501 }
04502
04503 if ( nz != 1 )
04504 {
04505
04506 if (zodd){
04507 // Swap the middle slice (with respect to the z direction) and the front slice
04508 // shifting all behind the front slice towards the middle a distance of 1 voxel,
04509 // stopping at the middle slice.
04510 float prev[2];
04511 size_t idx;
04512 for( int r = 0; r < ny; ++r ) {
04513 for( int c =0; c < nx; c += 2 ) {
04514 idx = (size_t)nz/2*nxy+r*nx+c;
04515 prev[0] = rdata[idx];
04516 prev[1] = rdata[idx+1];
04517 for( int s = 0; s <= nz/2; ++s ) {
04518 idx = (size_t)s*nxy+r*nx+c;
04519 float* p1 = &rdata[idx];
04520 tmp[0] = p1[0];
04521 tmp[1] = p1[1];
04522
04523 p1[0] = prev[0];
04524 p1[1] = prev[1];
04525
04526 prev[0] = tmp[0];
04527 prev[1] = tmp[1];
04528 }
04529 }
04530 }
04531 }
04532
04533 // Shift slices correctly in the z direction
04534 size_t idx1, idx2;
04535 for( int s = 0+zodd; s < nz/2 + zodd; ++s ) {
04536 for( int r = 0; r < ny; ++r ) {
04537 for( int c =0; c < nx; c += 2 ) {
04538 idx1 = (size_t)s*nxy+r*nx+c;
04539 idx2 = (size_t)(s+nz/2)*nxy+r*nx+c;
04540 p1 = &rdata[idx1];
04541 p2 = &rdata[idx2];
04542
04543 tmp[0] = p1[0];
04544 tmp[1] = p1[1];
04545
04546 p1[0] = p2[0];
04547 p1[1] = p2[1];
04548
04549 p2[0] = tmp[0];
04550 p2[1] = tmp[1];
04551 }
04552 }
04553 }
04554 }
04555 image->set_shuffled(false);
04556 }
|
|
|
Definition at line 167 of file processor.cpp. |
1.3.9.1