#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 = "xform.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.
00072 { 00073 return "Mirrors an image along the specified axis. This will shift the image center for even box sizes. Use the 'xform.flip' processor to preserve center."; 00074 }
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"); 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 8260 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().
08261 { 08262 if (!image) { 08263 LOGWARN("NULL Image"); 08264 return; 08265 } 08266 08267 string axis = (const char*)params["axis"]; 08268 08269 float* data = image->EMData::get_data(); 08270 08271 int nx = image->get_xsize(); 08272 int ny = image->get_ysize(); 08273 int nz = image->get_zsize(); 08274 size_t nxy = nx*ny; 08275 08276 int x_start = 1-nx%2; 08277 int y_start = 1-ny%2; 08278 int z_start = 1-nz%2; 08279 08280 if (axis == "x" || axis == "X") { 08281 for (int iz = 0; iz < nz; iz++) 08282 for (int iy = 0; iy < ny; iy++) { 08283 int offset = nx*iy + nxy*iz; 08284 reverse(&data[offset+x_start],&data[offset+nx]); 08285 } 08286 } else if (axis == "y" || axis == "Y") { 08287 float *tmp = new float[nx]; 08288 int nhalf = ny/2; 08289 size_t beg = 0; 08290 for (int iz = 0; iz < nz; iz++) { 08291 beg = iz*nxy; 08292 for (int iy = y_start; iy < nhalf; iy++) { 08293 memcpy(tmp, &data[beg+iy*nx], nx*sizeof(float)); 08294 memcpy(&data[beg+iy*nx], &data[beg+(ny-iy-1+y_start)*nx], nx*sizeof(float)); 08295 memcpy(&data[beg+(ny-iy-1+y_start)*nx], tmp, nx*sizeof(float)); 08296 } 08297 } 08298 delete[] tmp; 08299 } else if (axis == "z" || axis == "Z") { 08300 if(1-z_start) { 08301 int nhalf = nz/2; 08302 float *tmp = new float[nxy]; 08303 for(int iz = 0;iz<nhalf;iz++){ 08304 memcpy(tmp,&data[iz*nxy],nxy*sizeof(float)); 08305 memcpy(&data[iz*nxy],&data[(nz-iz-1)*nxy],nxy*sizeof(float)); 08306 memcpy(&data[(nz-iz-1)*nxy],tmp,nxy*sizeof(float)); 08307 } 08308 delete[] tmp; 08309 } else { 08310 float *tmp = new float[nx]; 08311 int nhalf = nz/2; 08312 size_t beg = 0; 08313 for (int iy = 0; iy < ny; iy++) { 08314 beg = iy*nx; 08315 for (int iz = z_start; iz < nhalf; iz++) { 08316 memcpy(tmp, &data[beg+ iz*nxy], nx*sizeof(float)); 08317 memcpy(&data[beg+iz*nxy], &data[beg+(nz-iz-1+z_start)*nxy], nx*sizeof(float)); 08318 memcpy(&data[beg+(nz-iz-1+z_start)*nxy], tmp, nx*sizeof(float)); 08319 } 08320 } 08321 delete[] tmp; 08322 } 08323 } 08324 08325 image->update(); 08326 }
const string MirrorProcessor::NAME = "xform.mirror" [static] |