#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 | |
static Processor * | NEW () |
Static Public Attributes | |
static 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 6067 of file processor.h.
virtual string EMAN::TestImageSphericalWave::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 6077 of file processor.h.
06078 { 06079 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)"; 06080 }
virtual string EMAN::TestImageSphericalWave::get_name | ( | ) | const [inline, virtual] |
Get the processor's name.
Each processor is identified by a unique name.
Implements EMAN::Processor.
Definition at line 6072 of file processor.h.
References NAME.
Referenced by process_inplace().
06073 { 06074 return NAME; 06075 }
virtual TypeDict EMAN::TestImageSphericalWave::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 6087 of file processor.h.
References EMAN::EMObject::FLOAT, and EMAN::TypeDict::put().
06088 { 06089 TypeDict d; 06090 d.put("wavelength", EMObject::FLOAT, "cos(2*pi*r/wavelength+phase)"); 06091 d.put("phase", EMObject::FLOAT, "in radians"); 06092 d.put("x", EMObject::FLOAT, "center of the spherical wave"); 06093 d.put("y", EMObject::FLOAT, "center of the spherical wave"); 06094 d.put("z", EMObject::FLOAT, "center of the spherical wave"); 06095 return d; 06096 }
static Processor* EMAN::TestImageSphericalWave::NEW | ( | ) | [inline, static] |
Definition at line 6082 of file processor.h.
06083 { 06084 return new TestImageSphericalWave(); 06085 }
void TestImageSphericalWave::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 7245 of file processor.cpp.
References get_name(), EMAN::EMData::get_ndim(), EMAN::Dict::has_key(), EMAN::Util::hypot3(), InvalidParameterException, LOGERR, EMAN::Processor::params, phase(), pi, EMAN::TestImageProcessor::preprocess(), EMAN::EMData::set_value_at(), EMAN::EMData::update(), and x.
07246 { 07247 preprocess(image); 07248 07249 if(!params.has_key("wavelength")) { 07250 LOGERR("%s wavelength is required parameter", get_name().c_str()); 07251 throw InvalidParameterException("wavelength parameter is required."); 07252 } 07253 float wavelength = params["wavelength"]; 07254 07255 float phase = 0; 07256 if(params.has_key("phase")) { 07257 phase = params["phase"]; 07258 } 07259 07260 float x = (float)(nx/2); 07261 if (params.has_key("x")) x=params["x"]; 07262 float y = (float)(ny/2); 07263 if (params.has_key("y")) y=params["y"]; 07264 float z = (float)(nz/2); 07265 if (params.has_key("z")) z=params["z"]; 07266 07267 int ndim = image->get_ndim(); 07268 07269 if(ndim==2) { //2D 07270 for(int j=0; j<ny; ++j) { 07271 for(int i=0; i<nx; ++i) { 07272 #ifdef _WIN32 07273 float r=_hypotf(x-(float)i,y-(float)j); 07274 #else 07275 float r=hypot(x-(float)i,y-(float)j); 07276 #endif //_WIN32 07277 if (r<.5) continue; 07278 image->set_value_at(i,j,cos(2*(float)pi*r/wavelength+phase)/r); 07279 } 07280 } 07281 } 07282 else { //3D 07283 for(int k=0; k<nz; ++k) { 07284 for(int j=0; j<ny; ++j) { 07285 for(int i=0; i<nx; ++i) { 07286 float r=Util::hypot3(x-(float)i,y-(float)j,z-(float)k); 07287 if (r<.5) continue; 07288 image->set_value_at(i,j,k,cos(2*(float)pi*r/wavelength+phase)/(r*r)); 07289 } 07290 } 07291 } 07292 } 07293 07294 image->update(); 07295 }
const string TestImageSphericalWave::NAME = "testimage.sphericalwave" [static] |