#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 6123 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 6133 of file processor.h. 06134 { 06135 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)"; 06136 }
|
|
Get the processor's name. Each processor is identified by a unique name.
Implements EMAN::Processor. Definition at line 6128 of file processor.h. Referenced by process_inplace(). 06129 {
06130 return NAME;
06131 }
|
|
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 6143 of file processor.h. References EMAN::TypeDict::put(). 06144 { 06145 TypeDict d; 06146 d.put("wavelength", EMObject::FLOAT, "cos(2*pi*r/wavelength+phase)"); 06147 d.put("phase", EMObject::FLOAT, "in radians"); 06148 d.put("x", EMObject::FLOAT, "center of the spherical wave"); 06149 d.put("y", EMObject::FLOAT, "center of the spherical wave"); 06150 d.put("z", EMObject::FLOAT, "center of the spherical wave"); 06151 return d; 06152 }
|
|
Definition at line 6138 of file processor.h. 06139 { 06140 return new TestImageSphericalWave(); 06141 }
|
|
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 7247 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. 07248 { 07249 preprocess(image); 07250 07251 if(!params.has_key("wavelength")) { 07252 LOGERR("%s wavelength is required parameter", get_name().c_str()); 07253 throw InvalidParameterException("wavelength parameter is required."); 07254 } 07255 float wavelength = params["wavelength"]; 07256 07257 float phase = 0; 07258 if(params.has_key("phase")) { 07259 phase = params["phase"]; 07260 } 07261 07262 float x = (float)(nx/2); 07263 if (params.has_key("x")) x=params["x"]; 07264 float y = (float)(ny/2); 07265 if (params.has_key("y")) y=params["y"]; 07266 float z = (float)(nz/2); 07267 if (params.has_key("z")) z=params["z"]; 07268 07269 int ndim = image->get_ndim(); 07270 07271 if(ndim==2) { //2D 07272 for(int j=0; j<ny; ++j) { 07273 for(int i=0; i<nx; ++i) { 07274 #ifdef _WIN32 07275 float r=_hypotf(x-(float)i,y-(float)j); 07276 #else 07277 float r=hypot(x-(float)i,y-(float)j); 07278 #endif //_WIN32 07279 if (r<.5) continue; 07280 image->set_value_at(i,j,cos(2*(float)pi*r/wavelength+phase)/r); 07281 } 07282 } 07283 } 07284 else { //3D 07285 for(int k=0; k<nz; ++k) { 07286 for(int j=0; j<ny; ++j) { 07287 for(int i=0; i<nx; ++i) { 07288 float r=Util::hypot3(x-(float)i,y-(float)j,z-(float)k); 07289 if (r<.5) continue; 07290 image->set_value_at(i,j,k,cos(2*(float)pi*r/wavelength+phase)/(r*r)); 07291 } 07292 } 07293 } 07294 } 07295 07296 image->update(); 07297 }
|
|
Definition at line 200 of file processor.cpp. |