EMAN::FourierToCornerProcessor Class Reference
[unit test in Python]

Undo the effects of the FourierToCenterProcessor. More...

#include <processor.h>

Inheritance diagram for EMAN::FourierToCornerProcessor:

Inheritance graph
[legend]
Collaboration diagram for EMAN::FourierToCornerProcessor:

Collaboration graph
[legend]

List of all members.

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 ProcessorNEW ()

Static Public Attributes

static const string NAME = "xform.fourierorigin.tocorner"


Detailed Description

Undo the effects of the FourierToCenterProcessor.

Author:
David Woolford <woolford@bcm.edu>
Date:
October 2007

Definition at line 4613 of file processor.h.


Member Function Documentation

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.

Parameters:
image the image to operate on
Exceptions:
ImageFormatException if the image is not complex

Implements EMAN::Processor.

Definition at line 4279 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().

04280 {
04281         if ( !image->is_complex() ) throw ImageFormatException("Can not Fourier origin shift an image that is not complex");
04282 
04283         int nx=image->get_xsize();
04284         int ny=image->get_ysize();
04285         int nz=image->get_zsize();
04286 
04287         int nxy = nx*ny;
04288 
04289         if ( ny == 1 && nz == 1 ){
04290                 cout << "Warning- attempted     Fourier origin shift a 1D image - no action taken" << endl;
04291                 return;
04292         }
04293         int yodd = (ny%2==1);
04294         int zodd = (nz%2==1);
04295 
04296         float* rdata = image->get_data();
04297 
04298         float tmp[2];
04299         float* p1;
04300         float* p2;
04301 
04302         if (yodd){
04303                 // Swap the middle slice (with respect to the y direction) with the bottom slice
04304                 // shifting all slices above the middles slice upwards by one pixel, stopping
04305                 // at the middle slice, not if nz = 1 we are not talking about slices, we are
04306                 // talking about rows
04307                 float prev[2];
04308                 size_t idx;
04309                 for( int s = 0; s < nz; s++ ) {
04310                         for( int c =0; c < nx; c += 2 ) {
04311                                 idx = s*nxy+ny/2*nx+c;
04312                                 prev[0] = rdata[idx];
04313                                 prev[1] = rdata[idx+1];
04314                                 for( int r = 0; r <= ny/2; ++r ) {
04315                                         idx = s*nxy+r*nx+c;
04316                                         float* p1 = &rdata[idx];
04317                                         tmp[0] = p1[0];
04318                                         tmp[1] = p1[1];
04319 
04320                                         p1[0] = prev[0];
04321                                         p1[1] = prev[1];
04322 
04323                                         prev[0] = tmp[0];
04324                                         prev[1] = tmp[1];
04325                                 }
04326                         }
04327                 }
04328         }
04329 
04330         // Shift slices (3D) or rows (2D) correctly in the y direction
04331         size_t idx1, idx2;
04332         for( int s = 0; s < nz; ++s ) {
04333                 for( int r = 0 + yodd; r < ny/2+yodd; ++r ) {
04334                         for( int c =0; c < nx; c += 2 ) {
04335                                 idx1 = s*nxy+r*nx+c;
04336                                 idx2 = s*nxy+(r+ny/2)*nx+c;
04337                                 p1 = &rdata[idx1];
04338                                 p2 = &rdata[idx2];
04339 
04340                                 tmp[0] = p1[0];
04341                                 tmp[1] = p1[1];
04342 
04343                                 p1[0] = p2[0];
04344                                 p1[1] = p2[1];
04345 
04346                                 p2[0] = tmp[0];
04347                                 p2[1] = tmp[1];
04348                         }
04349                 }
04350         }
04351 
04352         if ( nz != 1 )
04353         {
04354 
04355                 if (zodd){
04356                         // Swap the middle slice (with respect to the z direction) and the front slice
04357                         // shifting all behind the front slice towards the middle a distance of 1 voxel,
04358                         // stopping at the middle slice.
04359                         float prev[2];
04360                         size_t idx;
04361                         for( int r = 0; r < ny; ++r ) {
04362                                 for( int c =0; c < nx; c += 2 ) {
04363                                         idx = nz/2*nxy+r*nx+c;
04364                                         prev[0] = rdata[idx];
04365                                         prev[1] = rdata[idx+1];
04366                                         for( int s = 0; s <= nz/2; ++s ) {
04367                                                 idx = s*nxy+r*nx+c;
04368                                                 float* p1 = &rdata[idx];
04369                                                 tmp[0] = p1[0];
04370                                                 tmp[1] = p1[1];
04371 
04372                                                 p1[0] = prev[0];
04373                                                 p1[1] = prev[1];
04374 
04375                                                 prev[0] = tmp[0];
04376                                                 prev[1] = tmp[1];
04377                                         }
04378                                 }
04379                         }
04380                 }
04381 
04382                 // Shift slices correctly in the z direction
04383                 size_t idx1, idx2;
04384                 for( int s = 0+zodd; s < nz/2 + zodd; ++s ) {
04385                         for( int r = 0; r < ny; ++r ) {
04386                                 for( int c =0; c < nx; c += 2 ) {
04387                                         idx1 = s*nxy+r*nx+c;
04388                                         idx2 = (s+nz/2)*nxy+r*nx+c;
04389                                         p1 = &rdata[idx1];
04390                                         p2 = &rdata[idx2];
04391 
04392                                         tmp[0] = p1[0];
04393                                         tmp[1] = p1[1];
04394 
04395                                         p1[0] = p2[0];
04396                                         p1[1] = p2[1];
04397 
04398                                         p2[0] = tmp[0];
04399                                         p2[1] = tmp[1];
04400                                 }
04401                         }
04402                 }
04403         }
04404         image->set_shuffled(false);
04405 }

virtual string EMAN::FourierToCornerProcessor::get_name (  )  const [inline, virtual]

Get the processor's name.

Each processor is identified by a unique name.

Returns:
The processor's name.

Implements EMAN::Processor.

Definition at line 4623 of file processor.h.

References EMAN::NormalizeUnitSumProcessor::NAME.

04624                         {
04625                                 return NAME;
04626                         }

static Processor* EMAN::FourierToCornerProcessor::NEW (  )  [inline, static]

Definition at line 4628 of file processor.h.

04629                         {
04630                                 return new FourierToCornerProcessor();
04631                         }

virtual string EMAN::FourierToCornerProcessor::get_desc (  )  const [inline, virtual]

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 4633 of file processor.h.

04634                         {
04635                                 return "Undoes the xform.fourierorigin.tocenter processor";
04636                         }


Member Data Documentation

const string FourierToCornerProcessor::NAME = "xform.fourierorigin.tocorner" [static]

Definition at line 4638 of file processor.h.


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

Generated on Sun Mar 21 02:20:30 2010 for EMAN2 by  doxygen 1.5.6