#include <processor.h>
Inheritance diagram for EMAN::TestImageSinewave:
Public Member Functions | |
virtual void | process_inplace (EMData *image) |
To process an image in-place. | |
virtual string | get_name () const |
Get the processor's name. | |
virtual string | get_desc () const |
Get the descrition of this specific processor. | |
virtual TypeDict | get_param_types () const |
Get processor parameter information in a dictionary. | |
Static Public Member Functions | |
Processor * | NEW () |
Static Public Attributes | |
const string | NAME = "testimage.sinewave" |
wavelength | wavelength in equation sin(x*2*PI/wavelength - phase*180/PI) | |
axis | (optional) specify a major axis for asymmetric features, default x axis | |
phase | (optional) the phase in radians | |
az | (optional) angle in degree. for 2D image, this is the rotated angle of the image, in 3D image, it's az for euler angle. default is zero | |
alt | (optional) angle in degree. only in 3D case, alt for euler angle, default is zero | |
phi | (optional) angle in degree. only in 3D case, phi for euler angle, default is zero |
Definition at line 6282 of file processor.h.
|
Get the descrition of this specific processor. This function must be overwritten by a subclass.
Implements EMAN::Processor. Definition at line 6292 of file processor.h. 06293 { 06294 return "Replace a source image as a sine wave in specified wave length"; 06295 }
|
|
Get the processor's name. Each processor is identified by a unique name.
Implements EMAN::Processor. Definition at line 6287 of file processor.h. Referenced by process_inplace(). 06288 {
06289 return NAME;
06290 }
|
|
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 6302 of file processor.h. References EMAN::TypeDict::put(). 06303 { 06304 TypeDict d; 06305 d.put("wavelength", EMObject::FLOAT, "wavelength in equation sin(x*2*PI/wavelength - phase*180/PI)"); 06306 d.put("axis", EMObject::STRING, "(optional) specify a major axis for asymmetric features, default x axis"); 06307 d.put("phase", EMObject::FLOAT, "(optional) the phase in radians"); 06308 d.put("az", EMObject::FLOAT, "(optional) angle in degree. for 2D image, this is the rotated angle of the image, \ 06309 in 3D image, it's az for euler angle. default is zero"); 06310 d.put("alt", EMObject::FLOAT, "(optional) angle in degree. only in 3D case, alt for euler angle, default is zero"); 06311 d.put("phi", EMObject::FLOAT, "(optional) angle in degree. only in 3D case, phi for euler angle, default is zero"); 06312 return d; 06313 }
|
|
Definition at line 6297 of file processor.h. 06298 { 06299 return new TestImageSinewave(); 06300 }
|
|
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 7501 of file processor.cpp. References EMAN::EMData::get_data(), get_name(), EMAN::EMData::get_ndim(), EMAN::Dict::has_key(), InvalidParameterException, LOGERR, phase(), phi, EMAN::TestImageProcessor::preprocess(), EMAN::EMData::transform(), and EMAN::EMData::update(). 07502 { 07503 preprocess(image); 07504 07505 if(!params.has_key("wavelength")) { 07506 LOGERR("%s wavelength is required parameter", get_name().c_str()); 07507 throw InvalidParameterException("wavelength parameter is required."); 07508 } 07509 float wavelength = params["wavelength"]; 07510 07511 string axis = ""; 07512 if(params.has_key("axis")) { 07513 axis = (const char*)params["axis"]; 07514 } 07515 07516 float phase = 0; 07517 if(params.has_key("phase")) { 07518 phase = params["phase"]; 07519 } 07520 07521 int ndim = image->get_ndim(); 07522 float * dat = image->get_data(); 07523 07524 if(ndim==1) { //1D 07525 for(int i=0; i<nx; ++i, ++dat) { 07526 *dat = sin(i*(2.0f*M_PI/wavelength) + phase); 07527 } 07528 } 07529 else if(ndim==2) { //2D 07530 float alpha = 0; 07531 if(params.has_key("az")) { 07532 alpha = params["az"]; 07533 } 07534 for(int j=0; j<ny; ++j) { 07535 for(int i=0; i<nx; ++i, ++dat) { 07536 if(alpha != 0) { 07537 *dat = sin((i*sin((180-alpha)*M_PI/180)+j*cos((180-alpha)*M_PI/180))*(2.0f*M_PI/wavelength) + phase); 07538 } 07539 else if(axis.compare("y")==0 || axis.compare("Y")==0) { 07540 *dat = sin(j*(2.0f*M_PI/wavelength) + phase); 07541 } 07542 else { 07543 *dat = sin(i*(2.0f*M_PI/wavelength) + phase); 07544 } 07545 } 07546 } 07547 } 07548 else { //3D 07549 float az = 0; 07550 if(params.has_key("az")) { 07551 az = params["az"]; 07552 } 07553 float alt = 0; 07554 if(params.has_key("alt")) { 07555 alt = params["alt"]; 07556 } 07557 float phi = 0; 07558 if(params.has_key("phi")) { 07559 phi = params["phi"]; 07560 } 07561 07562 for(int k=0; k<nz; ++k) { 07563 for(int j=0; j<ny; ++j) { 07564 for(int i=0; i<nx; ++i, ++dat) { 07565 if(axis.compare("z")==0 || axis.compare("Z")==0) { 07566 *dat = sin(k*(2.0f*M_PI/wavelength) + phase); 07567 } 07568 else if(axis.compare("y")==0 || axis.compare("Y")==0) { 07569 *dat = sin(j*(2.0f*M_PI/wavelength) + phase); 07570 } 07571 else { 07572 *dat = sin(i*(2.0f*M_PI/wavelength) + phase); 07573 } 07574 } 07575 } 07576 } 07577 07578 if(az != 0 || alt != 0 || phi != 0) { 07579 Dict d("type","eman"); 07580 d["az"] = az; d["phi"] = phi; d["alt"] = alt; 07581 image->transform(Transform(d)); 07582 } 07583 } 07584 07585 image->update(); 07586 }
|
|
Definition at line 201 of file processor.cpp. |