#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 4673 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 4693 of file processor.h. 04694 { 04695 return "Undoes the xform.fourierorigin.tocenter processor"; 04696 }
|
|
Get the processor's name. Each processor is identified by a unique name.
Implements EMAN::Processor. Definition at line 4683 of file processor.h. 04684 {
04685 return NAME;
04686 }
|
|
Definition at line 4688 of file processor.h. 04689 { 04690 return new FourierToCornerProcessor(); 04691 }
|
|
Fourier origin shift the image in the backwards direction Should only be called after the application of FourierToCenterProcessor.
Implements EMAN::Processor. Definition at line 4342 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(). 04343 { 04344 if ( !image->is_complex() ) throw ImageFormatException("Can not Fourier origin shift an image that is not complex"); 04345 04346 int nx=image->get_xsize(); 04347 int ny=image->get_ysize(); 04348 int nz=image->get_zsize(); 04349 04350 int nxy = nx*ny; 04351 04352 if ( ny == 1 && nz == 1 ){ 04353 cout << "Warning- attempted Fourier origin shift a 1D image - no action taken" << endl; 04354 return; 04355 } 04356 int yodd = (ny%2==1); 04357 int zodd = (nz%2==1); 04358 04359 float* rdata = image->get_data(); 04360 04361 float tmp[2]; 04362 float* p1; 04363 float* p2; 04364 04365 if (yodd){ 04366 // Swap the middle slice (with respect to the y direction) with the bottom slice 04367 // shifting all slices above the middles slice upwards by one pixel, stopping 04368 // at the middle slice, not if nz = 1 we are not talking about slices, we are 04369 // talking about rows 04370 float prev[2]; 04371 size_t idx; 04372 for( int s = 0; s < nz; s++ ) { 04373 for( int c =0; c < nx; c += 2 ) { 04374 idx = s*nxy+ny/2*nx+c; 04375 prev[0] = rdata[idx]; 04376 prev[1] = rdata[idx+1]; 04377 for( int r = 0; r <= ny/2; ++r ) { 04378 idx = s*nxy+r*nx+c; 04379 float* p1 = &rdata[idx]; 04380 tmp[0] = p1[0]; 04381 tmp[1] = p1[1]; 04382 04383 p1[0] = prev[0]; 04384 p1[1] = prev[1]; 04385 04386 prev[0] = tmp[0]; 04387 prev[1] = tmp[1]; 04388 } 04389 } 04390 } 04391 } 04392 04393 // Shift slices (3D) or rows (2D) correctly in the y direction 04394 size_t idx1, idx2; 04395 for( int s = 0; s < nz; ++s ) { 04396 for( int r = 0 + yodd; r < ny/2+yodd; ++r ) { 04397 for( int c =0; c < nx; c += 2 ) { 04398 idx1 = s*nxy+r*nx+c; 04399 idx2 = s*nxy+(r+ny/2)*nx+c; 04400 p1 = &rdata[idx1]; 04401 p2 = &rdata[idx2]; 04402 04403 tmp[0] = p1[0]; 04404 tmp[1] = p1[1]; 04405 04406 p1[0] = p2[0]; 04407 p1[1] = p2[1]; 04408 04409 p2[0] = tmp[0]; 04410 p2[1] = tmp[1]; 04411 } 04412 } 04413 } 04414 04415 if ( nz != 1 ) 04416 { 04417 04418 if (zodd){ 04419 // Swap the middle slice (with respect to the z direction) and the front slice 04420 // shifting all behind the front slice towards the middle a distance of 1 voxel, 04421 // stopping at the middle slice. 04422 float prev[2]; 04423 size_t idx; 04424 for( int r = 0; r < ny; ++r ) { 04425 for( int c =0; c < nx; c += 2 ) { 04426 idx = nz/2*nxy+r*nx+c; 04427 prev[0] = rdata[idx]; 04428 prev[1] = rdata[idx+1]; 04429 for( int s = 0; s <= nz/2; ++s ) { 04430 idx = s*nxy+r*nx+c; 04431 float* p1 = &rdata[idx]; 04432 tmp[0] = p1[0]; 04433 tmp[1] = p1[1]; 04434 04435 p1[0] = prev[0]; 04436 p1[1] = prev[1]; 04437 04438 prev[0] = tmp[0]; 04439 prev[1] = tmp[1]; 04440 } 04441 } 04442 } 04443 } 04444 04445 // Shift slices correctly in the z direction 04446 size_t idx1, idx2; 04447 for( int s = 0+zodd; s < nz/2 + zodd; ++s ) { 04448 for( int r = 0; r < ny; ++r ) { 04449 for( int c =0; c < nx; c += 2 ) { 04450 idx1 = s*nxy+r*nx+c; 04451 idx2 = (s+nz/2)*nxy+r*nx+c; 04452 p1 = &rdata[idx1]; 04453 p2 = &rdata[idx2]; 04454 04455 tmp[0] = p1[0]; 04456 tmp[1] = p1[1]; 04457 04458 p1[0] = p2[0]; 04459 p1[1] = p2[1]; 04460 04461 p2[0] = tmp[0]; 04462 p2[1] = tmp[1]; 04463 } 04464 } 04465 } 04466 } 04467 image->set_shuffled(false); 04468 }
|
|
Definition at line 161 of file processor.cpp. |