#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 | |
static Processor * | NEW () |
Static Public Attributes | |
static 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.
string EMAN::MirrorProcessor::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 71 of file processor_sparx.h.
string EMAN::MirrorProcessor::get_name | ( | ) | const [inline, virtual] |
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.
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.
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] |
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.
image | The image to be processed. |
Implements EMAN::Processor.
Definition at line 8144 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().
08145 { 08146 if (!image) { 08147 LOGWARN("NULL Image"); 08148 return; 08149 } 08150 08151 string axis = (const char*)params["axis"]; 08152 08153 float* data = image->EMData::get_data(); 08154 08155 int nx = image->get_xsize(); 08156 int ny = image->get_ysize(); 08157 int nz = image->get_zsize(); 08158 size_t nxy = nx*ny; 08159 08160 int x_start = 1-nx%2; 08161 int y_start = 1-ny%2; 08162 int z_start = 1-nz%2; 08163 08164 if (axis == "x" || axis == "X") { 08165 for (int iz = 0; iz < nz; iz++) 08166 for (int iy = 0; iy < ny; iy++) { 08167 int offset = nx*iy + nxy*iz; 08168 reverse(&data[offset+x_start],&data[offset+nx]); 08169 } 08170 } 08171 08172 if (axis == "y" || axis == "Y") { 08173 float *tmp = new float[nx]; 08174 int nhalf = ny/2; 08175 size_t beg = 0; 08176 for (int iz = 0; iz < nz; iz++) { 08177 beg = iz*nxy; 08178 for (int iy = y_start; iy < nhalf; iy++) { 08179 memcpy(tmp, &data[beg+iy*nx], nx*sizeof(float)); 08180 memcpy(&data[beg+iy*nx], &data[beg+(ny-iy-1+y_start)*nx], nx*sizeof(float)); 08181 memcpy(&data[beg+(ny-iy-1+y_start)*nx], tmp, nx*sizeof(float)); 08182 } 08183 } 08184 delete[] tmp; 08185 } 08186 08187 if (axis == "z" || axis == "Z") { 08188 if(1-z_start){ 08189 int nhalf = nz/2; 08190 float *tmp = new float[nxy]; 08191 for(int iz = 0;iz<nhalf;iz++){ 08192 memcpy(tmp,&data[iz*nxy],nxy*sizeof(float)); 08193 memcpy(&data[iz*nxy],&data[(nz-iz-1)*nxy],nxy*sizeof(float)); 08194 memcpy(&data[(nz-iz-1)*nxy],tmp,nxy*sizeof(float)); 08195 } 08196 delete[] tmp; 08197 } 08198 else{ 08199 float *tmp = new float[nx]; 08200 int nhalf = nz/2; 08201 size_t beg = 0; 08202 for (int iy = 0; iy < ny; iy++) { 08203 beg = iy*nx; 08204 for (int iz = z_start; iz < nhalf; iz++) { 08205 memcpy(tmp, &data[beg+ iz*nxy], nx*sizeof(float)); 08206 memcpy(&data[beg+iz*nxy], &data[beg+(nz-iz-1+z_start)*nxy], nx*sizeof(float)); 08207 memcpy(&data[beg+(nz-iz-1+z_start)*nxy], tmp, nx*sizeof(float)); 08208 } 08209 } 08210 delete[] tmp; 08211 } 08212 } 08213 08214 image->update(); 08215 }
const string MirrorProcessor::NAME = "mirror" [static] |