#include <processor.h>
Inheritance diagram for EMAN::TestImageSphericalWave:
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.sphericalwave" |
wavelength | cos(2*pi*r/wavelength+phase) | |
phase | in radians | |
x | center of the spherical wave | |
y | center of the spherical wave | |
z | center of the spherical wave |
Definition at line 6278 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 6288 of file processor.h. 06289 { 06290 return "Replace a source image in 2d or 3d with a spherical wave cos(2*pi*r/wavelength+phase) also 1/r (2d) or 1/r^2 (3d)"; 06291 }
|
|
Get the processor's name. Each processor is identified by a unique name.
Implements EMAN::Processor. Definition at line 6283 of file processor.h. Referenced by process_inplace(). 06284 {
06285 return NAME;
06286 }
|
|
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 6298 of file processor.h. References EMAN::TypeDict::put(). 06299 { 06300 TypeDict d; 06301 d.put("wavelength", EMObject::FLOAT, "cos(2*pi*r/wavelength+phase)"); 06302 d.put("phase", EMObject::FLOAT, "in radians"); 06303 d.put("x", EMObject::FLOAT, "center of the spherical wave"); 06304 d.put("y", EMObject::FLOAT, "center of the spherical wave"); 06305 d.put("z", EMObject::FLOAT, "center of the spherical wave"); 06306 return d; 06307 }
|
|
Definition at line 6293 of file processor.h. 06294 { 06295 return new TestImageSphericalWave(); 06296 }
|
|
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 7513 of file processor.cpp. References get_name(), EMAN::EMData::get_ndim(), EMAN::Dict::has_key(), EMAN::Util::hypot3(), InvalidParameterException, LOGERR, nx, ny, phase(), pi, EMAN::TestImageProcessor::preprocess(), EMAN::EMData::set_value_at(), EMAN::EMData::update(), x, and y. 07514 { 07515 preprocess(image); 07516 07517 if(!params.has_key("wavelength")) { 07518 LOGERR("%s wavelength is required parameter", get_name().c_str()); 07519 throw InvalidParameterException("wavelength parameter is required."); 07520 } 07521 float wavelength = params["wavelength"]; 07522 07523 float phase = 0; 07524 if(params.has_key("phase")) { 07525 phase = params["phase"]; 07526 } 07527 07528 float x = (float)(nx/2); 07529 if (params.has_key("x")) x=params["x"]; 07530 float y = (float)(ny/2); 07531 if (params.has_key("y")) y=params["y"]; 07532 float z = (float)(nz/2); 07533 if (params.has_key("z")) z=params["z"]; 07534 07535 int ndim = image->get_ndim(); 07536 07537 if(ndim==2) { //2D 07538 for(int j=0; j<ny; ++j) { 07539 for(int i=0; i<nx; ++i) { 07540 #ifdef _WIN32 07541 float r=_hypotf(x-(float)i,y-(float)j); 07542 #else 07543 float r=hypot(x-(float)i,y-(float)j); 07544 #endif //_WIN32 07545 if (r<.5) continue; 07546 image->set_value_at(i,j,cos(2*(float)pi*r/wavelength+phase)/r); 07547 } 07548 } 07549 } 07550 else { //3D 07551 for(int k=0; k<nz; ++k) { 07552 for(int j=0; j<ny; ++j) { 07553 for(int i=0; i<nx; ++i) { 07554 float r=Util::hypot3(x-(float)i,y-(float)j,z-(float)k); 07555 if (r<.5) continue; 07556 image->set_value_at(i,j,k,cos(2*(float)pi*r/wavelength+phase)/(r*r)); 07557 } 07558 } 07559 } 07560 } 07561 07562 image->update(); 07563 }
|
|
Definition at line 201 of file processor.cpp. |