#include <processor_sparx.h>
Inheritance diagram for EMAN::MirrorProcessor:
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 | |
Processor * | NEW () |
Static Public Attributes | |
const string | NAME = "mirror" |
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.
|
Get the descrition of this specific processor. This function must be overwritten by a subclass.
Implements EMAN::Processor. Definition at line 71 of file processor_sparx.h. 00072 { 00073 return "mirror an image."; 00074 }
|
|
Get the processor's name. Each processor is identified by a unique name.
Implements EMAN::Processor. Definition at line 54 of file processor_sparx.h. 00055 {
00056 return NAME;
00057 }
|
|
Get processor parameter information in a dictionary. Each parameter has one record in the dictionary. Each record contains its name, data-type, and description.
Reimplemented from EMAN::Processor. Definition at line 64 of file processor_sparx.h. References EMAN::TypeDict::put(). 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 }
|
|
Definition at line 59 of file processor_sparx.h. 00060 { 00061 return new MirrorProcessor(); 00062 }
|
|
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.
Implements EMAN::Processor. Definition at line 8041 of file processor.cpp. References data, EMAN::EMData::get_xsize(), EMAN::EMData::get_ysize(), EMAN::EMData::get_zsize(), LOGWARN, nx, ny, and EMAN::EMData::update(). 08042 { 08043 if (!image) { 08044 LOGWARN("NULL Image"); 08045 return; 08046 } 08047 08048 string axis = (const char*)params["axis"]; 08049 08050 float* data = image->EMData::get_data(); 08051 08052 int nx = image->get_xsize(); 08053 int ny = image->get_ysize(); 08054 int nz = image->get_zsize(); 08055 size_t nxy = nx*ny; 08056 08057 int x_start = 1-nx%2; 08058 int y_start = 1-ny%2; 08059 int z_start = 1-nz%2; 08060 08061 if (axis == "x" || axis == "X") { 08062 for (int iz = 0; iz < nz; iz++) 08063 for (int iy = 0; iy < ny; iy++) { 08064 int offset = nx*iy + nxy*iz; 08065 reverse(&data[offset+x_start],&data[offset+nx]); 08066 } 08067 } 08068 08069 if (axis == "y" || axis == "Y") { 08070 float *tmp = new float[nx]; 08071 int nhalf = ny/2; 08072 size_t beg = 0; 08073 for (int iz = 0; iz < nz; iz++) { 08074 beg = iz*nxy; 08075 for (int iy = y_start; iy < nhalf; iy++) { 08076 memcpy(tmp, &data[beg+iy*nx], nx*sizeof(float)); 08077 memcpy(&data[beg+iy*nx], &data[beg+(ny-iy-1+y_start)*nx], nx*sizeof(float)); 08078 memcpy(&data[beg+(ny-iy-1+y_start)*nx], tmp, nx*sizeof(float)); 08079 } 08080 } 08081 delete[] tmp; 08082 } 08083 08084 if (axis == "z" || axis == "Z") { 08085 if(1-z_start){ 08086 int nhalf = nz/2; 08087 float *tmp = new float[nxy]; 08088 for(int iz = 0;iz<nhalf;iz++){ 08089 memcpy(tmp,&data[iz*nxy],nxy*sizeof(float)); 08090 memcpy(&data[iz*nxy],&data[(nz-iz-1)*nxy],nxy*sizeof(float)); 08091 memcpy(&data[(nz-iz-1)*nxy],tmp,nxy*sizeof(float)); 08092 } 08093 delete[] tmp; 08094 } 08095 else{ 08096 float *tmp = new float[nx]; 08097 int nhalf = nz/2; 08098 size_t beg = 0; 08099 for (int iy = 0; iy < ny; iy++) { 08100 beg = iy*nx; 08101 for (int iz = z_start; iz < nhalf; iz++) { 08102 memcpy(tmp, &data[beg+ iz*nxy], nx*sizeof(float)); 08103 memcpy(&data[beg+iz*nxy], &data[beg+(nz-iz-1+z_start)*nxy], nx*sizeof(float)); 08104 memcpy(&data[beg+(nz-iz-1+z_start)*nxy], tmp, nx*sizeof(float)); 08105 } 08106 } 08107 delete[] tmp; 08108 } 08109 } 08110 08111 image->update(); 08112 }
|
|
Definition at line 220 of file processor.cpp. |