#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 | |
static Processor * | NEW () |
Static Public Attributes | |
static const string | NAME = "xform.fourierorigin.tocorner" |
Definition at line 4674 of file processor.h.
virtual string EMAN::FourierToCornerProcessor::get_desc | ( | ) | const [inline, virtual] |
Get the descrition of this specific processor.
This function must be overwritten by a subclass.
Implements EMAN::Processor.
Definition at line 4694 of file processor.h.
virtual string EMAN::FourierToCornerProcessor::get_name | ( | ) | const [inline, virtual] |
Get the processor's name.
Each processor is identified by a unique name.
Implements EMAN::Processor.
Definition at line 4684 of file processor.h.
References NAME.
04685 { 04686 return NAME; 04687 }
static Processor* EMAN::FourierToCornerProcessor::NEW | ( | ) | [inline, static] |
Definition at line 4689 of file processor.h.
04690 { 04691 return new FourierToCornerProcessor(); 04692 }
void FourierToCornerProcessor::process_inplace | ( | EMData * | image | ) | [virtual] |
Fourier origin shift the image in the backwards direction Should only be called after the application of FourierToCenterProcessor.
image | the image to operate on |
ImageFormatException | if the image is not complex |
Implements EMAN::Processor.
Definition at line 4373 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(), rdata, and EMAN::EMData::set_shuffled().
04374 { 04375 if ( !image->is_complex() ) throw ImageFormatException("Can not Fourier origin shift an image that is not complex"); 04376 04377 int nx=image->get_xsize(); 04378 int ny=image->get_ysize(); 04379 int nz=image->get_zsize(); 04380 04381 int nxy = nx*ny; 04382 04383 if ( ny == 1 && nz == 1 ){ 04384 cout << "Warning- attempted Fourier origin shift a 1D image - no action taken" << endl; 04385 return; 04386 } 04387 int yodd = (ny%2==1); 04388 int zodd = (nz%2==1); 04389 04390 float* rdata = image->get_data(); 04391 04392 float tmp[2]; 04393 float* p1; 04394 float* p2; 04395 04396 if (yodd){ 04397 // Swap the middle slice (with respect to the y direction) with the bottom slice 04398 // shifting all slices above the middles slice upwards by one pixel, stopping 04399 // at the middle slice, not if nz = 1 we are not talking about slices, we are 04400 // talking about rows 04401 float prev[2]; 04402 size_t idx; 04403 for( int s = 0; s < nz; s++ ) { 04404 for( int c =0; c < nx; c += 2 ) { 04405 idx = s*nxy+ny/2*nx+c; 04406 prev[0] = rdata[idx]; 04407 prev[1] = rdata[idx+1]; 04408 for( int r = 0; r <= ny/2; ++r ) { 04409 idx = s*nxy+r*nx+c; 04410 float* p1 = &rdata[idx]; 04411 tmp[0] = p1[0]; 04412 tmp[1] = p1[1]; 04413 04414 p1[0] = prev[0]; 04415 p1[1] = prev[1]; 04416 04417 prev[0] = tmp[0]; 04418 prev[1] = tmp[1]; 04419 } 04420 } 04421 } 04422 } 04423 04424 // Shift slices (3D) or rows (2D) correctly in the y direction 04425 size_t idx1, idx2; 04426 for( int s = 0; s < nz; ++s ) { 04427 for( int r = 0 + yodd; r < ny/2+yodd; ++r ) { 04428 for( int c =0; c < nx; c += 2 ) { 04429 idx1 = s*nxy+r*nx+c; 04430 idx2 = s*nxy+(r+ny/2)*nx+c; 04431 p1 = &rdata[idx1]; 04432 p2 = &rdata[idx2]; 04433 04434 tmp[0] = p1[0]; 04435 tmp[1] = p1[1]; 04436 04437 p1[0] = p2[0]; 04438 p1[1] = p2[1]; 04439 04440 p2[0] = tmp[0]; 04441 p2[1] = tmp[1]; 04442 } 04443 } 04444 } 04445 04446 if ( nz != 1 ) 04447 { 04448 04449 if (zodd){ 04450 // Swap the middle slice (with respect to the z direction) and the front slice 04451 // shifting all behind the front slice towards the middle a distance of 1 voxel, 04452 // stopping at the middle slice. 04453 float prev[2]; 04454 size_t idx; 04455 for( int r = 0; r < ny; ++r ) { 04456 for( int c =0; c < nx; c += 2 ) { 04457 idx = nz/2*nxy+r*nx+c; 04458 prev[0] = rdata[idx]; 04459 prev[1] = rdata[idx+1]; 04460 for( int s = 0; s <= nz/2; ++s ) { 04461 idx = s*nxy+r*nx+c; 04462 float* p1 = &rdata[idx]; 04463 tmp[0] = p1[0]; 04464 tmp[1] = p1[1]; 04465 04466 p1[0] = prev[0]; 04467 p1[1] = prev[1]; 04468 04469 prev[0] = tmp[0]; 04470 prev[1] = tmp[1]; 04471 } 04472 } 04473 } 04474 } 04475 04476 // Shift slices correctly in the z direction 04477 size_t idx1, idx2; 04478 for( int s = 0+zodd; s < nz/2 + zodd; ++s ) { 04479 for( int r = 0; r < ny; ++r ) { 04480 for( int c =0; c < nx; c += 2 ) { 04481 idx1 = s*nxy+r*nx+c; 04482 idx2 = (s+nz/2)*nxy+r*nx+c; 04483 p1 = &rdata[idx1]; 04484 p2 = &rdata[idx2]; 04485 04486 tmp[0] = p1[0]; 04487 tmp[1] = p1[1]; 04488 04489 p1[0] = p2[0]; 04490 p1[1] = p2[1]; 04491 04492 p2[0] = tmp[0]; 04493 p2[1] = tmp[1]; 04494 } 04495 } 04496 } 04497 } 04498 image->set_shuffled(false); 04499 }
const string FourierToCornerProcessor::NAME = "xform.fourierorigin.tocorner" [static] |