Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

EMAN::MirrorProcessor Class Reference

mirror an image More...

#include <processor_sparx.h>

Inheritance diagram for EMAN::MirrorProcessor:

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

Collaboration graph
[legend]
List of all members.

Public Member Functions

void process_inplace (EMData *image)
 To process an image in-place.
string get_name () const
 Get the processor's name.
TypeDict get_param_types () const
 Get processor parameter information in a dictionary.
string get_desc () const
 Get the descrition of this specific processor.

Static Public Member Functions

static ProcessorNEW ()

Static Public Attributes

static const string NAME = "mirror"

Detailed Description

mirror an image

Parameters:
axis ''x', 'y', or 'z' axis, means mirror by changing the sign of the respective axis;

Definition at line 48 of file processor_sparx.h.


Member Function Documentation

string EMAN::MirrorProcessor::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 71 of file processor_sparx.h.

00072                 {
00073                         return "mirror an image.";
00074                 }

string EMAN::MirrorProcessor::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 54 of file processor_sparx.h.

References NAME.

00055                 {
00056                         return NAME;
00057                 }

TypeDict EMAN::MirrorProcessor::get_param_types  )  const [inline, virtual]
 

Get processor parameter information in a dictionary.

Each parameter has one record in the dictionary. Each record contains its name, data-type, and description.

Returns:
A dictionary containing the parameter info.

Reimplemented from EMAN::Processor.

Definition at line 64 of file processor_sparx.h.

References EMAN::TypeDict::put(), and EMAN::EMObject::STRING.

00065                 {
00066                         TypeDict d;
00067                         d.put("axis", EMObject::STRING, "'x', 'y', or 'z' axis, means mirror by changing the sign of the respective axis;");
00068                         return d;
00069                 }

static Processor* EMAN::MirrorProcessor::NEW  )  [inline, static]
 

Definition at line 59 of file processor_sparx.h.

00060                 {
00061                         return new MirrorProcessor();
00062                 }

void MirrorProcessor::process_inplace EMData image  )  [virtual]
 

To process an image in-place.

For those processors which can only be processed out-of-place, override this function to just print out some error message to remind user call the out-of-place version.

Parameters:
image The image to be processed.

Implements EMAN::Processor.

Definition at line 8072 of file processor.cpp.

References EMAN::EMData::get_xsize(), EMAN::EMData::get_ysize(), EMAN::EMData::get_zsize(), LOGWARN, EMAN::Processor::params, and EMAN::EMData::update().

08073 {
08074         if (!image) {
08075                 LOGWARN("NULL Image");
08076                 return;
08077         }
08078 
08079         string axis = (const char*)params["axis"];
08080 
08081         float* data = image->EMData::get_data();
08082 
08083         int nx = image->get_xsize();
08084         int ny = image->get_ysize();
08085         int nz = image->get_zsize();
08086         size_t nxy = nx*ny;
08087 
08088         int x_start = 1-nx%2;
08089         int y_start = 1-ny%2;
08090         int z_start = 1-nz%2;
08091 
08092         if (axis == "x" || axis == "X") {
08093                 for (int iz = 0; iz < nz; iz++)
08094                         for (int iy = 0; iy < ny; iy++) {
08095                                 int offset = nx*iy + nxy*iz;
08096                                  reverse(&data[offset+x_start],&data[offset+nx]);
08097                          }
08098          }
08099 
08100          if (axis == "y" || axis == "Y") {
08101                 float *tmp = new float[nx];
08102                  int nhalf   = ny/2;
08103                  size_t beg     = 0;
08104                  for (int iz = 0; iz < nz; iz++) {
08105                       beg = iz*nxy;
08106                       for (int iy = y_start; iy < nhalf; iy++) {
08107                                 memcpy(tmp, &data[beg+iy*nx], nx*sizeof(float));
08108                                 memcpy(&data[beg+iy*nx], &data[beg+(ny-iy-1+y_start)*nx], nx*sizeof(float));
08109                                 memcpy(&data[beg+(ny-iy-1+y_start)*nx], tmp, nx*sizeof(float));
08110                         }
08111                 }
08112                 delete[] tmp;
08113         }
08114 
08115          if (axis == "z" || axis == "Z") {
08116                 if(1-z_start){
08117                         int nhalf = nz/2;
08118                         float *tmp = new float[nxy];
08119                         for(int iz = 0;iz<nhalf;iz++){
08120                                 memcpy(tmp,&data[iz*nxy],nxy*sizeof(float));
08121                                 memcpy(&data[iz*nxy],&data[(nz-iz-1)*nxy],nxy*sizeof(float));
08122                                 memcpy(&data[(nz-iz-1)*nxy],tmp,nxy*sizeof(float));
08123                                 }
08124                         delete[] tmp;
08125                 }
08126                 else{
08127                         float *tmp = new float[nx];
08128                         int nhalf   = nz/2;
08129                         size_t beg     = 0;
08130                         for (int iy = 0; iy < ny; iy++) {
08131                                 beg = iy*nx;
08132                                 for (int iz = z_start; iz < nhalf; iz++) {
08133                                         memcpy(tmp, &data[beg+ iz*nxy], nx*sizeof(float));
08134                                         memcpy(&data[beg+iz*nxy], &data[beg+(nz-iz-1+z_start)*nxy], nx*sizeof(float));
08135                                         memcpy(&data[beg+(nz-iz-1+z_start)*nxy], tmp, nx*sizeof(float));
08136                                 }
08137                         }
08138                         delete[] tmp;
08139                 }
08140          }
08141 
08142          image->update();
08143 }


Member Data Documentation

const string MirrorProcessor::NAME = "mirror" [static]
 

Definition at line 76 of file processor_sparx.h.

Referenced by get_name().


The documentation for this class was generated from the following files:
Generated on Tue May 25 17:38:12 2010 for EMAN2 by  doxygen 1.4.4