#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 equation sin(x*2*PI/wavelength - phase*180/PI) | |
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 6197 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 6207 of file processor.h. 06208 { 06209 return "Replace a source image as a sine wave in specified wave length"; 06210 }
|
|
Get the processor's name. Each processor is identified by a unique name.
Implements EMAN::Processor. Definition at line 6202 of file processor.h. Referenced by process_inplace(). 06203 {
06204 return NAME;
06205 }
|
|
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 6217 of file processor.h. References EMAN::TypeDict::put(). 06218 { 06219 TypeDict d; 06220 d.put("wavelength", EMObject::FLOAT, "wavelength in equation sin(x*2*PI/wavelength - phase*180/PI)"); 06221 d.put("axis", EMObject::STRING, "(optional) specify a major axis for asymmetric features, default x axis"); 06222 d.put("phase", EMObject::FLOAT, "(optional) the phase in equation sin(x*2*PI/wavelength - phase*180/PI)"); 06223 d.put("az", EMObject::FLOAT, "(optional) angle in degree. for 2D image, this is the rotated angle of the image, \ 06224 in 3D image, it's az for euler angle. default is zero"); 06225 d.put("alt", EMObject::FLOAT, "(optional) angle in degree. only in 3D case, alt for euler angle, default is zero"); 06226 d.put("phi", EMObject::FLOAT, "(optional) angle in degree. only in 3D case, phi for euler angle, default is zero"); 06227 return d; 06228 }
|
|
Definition at line 6212 of file processor.h. 06213 { 06214 return new TestImageSinewave(); 06215 }
|
|
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 7198 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(). 07199 { 07200 preprocess(image); 07201 07202 if(!params.has_key("wavelength")) { 07203 LOGERR("%s wavelength is required parameter", get_name().c_str()); 07204 throw InvalidParameterException("wavelength parameter is required."); 07205 } 07206 float wavelength = params["wavelength"]; 07207 07208 string axis = ""; 07209 if(params.has_key("axis")) { 07210 axis = (const char*)params["axis"]; 07211 } 07212 07213 float phase = 0; 07214 if(params.has_key("phase")) { 07215 phase = params["phase"]; 07216 } 07217 07218 int ndim = image->get_ndim(); 07219 float * dat = image->get_data(); 07220 07221 if(ndim==1) { //1D 07222 for(int i=0; i<nx; ++i, ++dat) { 07223 *dat = sin(i*(2.0f*M_PI/wavelength) + phase); 07224 } 07225 } 07226 else if(ndim==2) { //2D 07227 float alpha = 0; 07228 if(params.has_key("az")) { 07229 alpha = params["az"]; 07230 } 07231 for(int j=0; j<ny; ++j) { 07232 for(int i=0; i<nx; ++i, ++dat) { 07233 if(alpha != 0) { 07234 *dat = sin((i*sin((180-alpha)*M_PI/180)+j*cos((180-alpha)*M_PI/180))*(2.0f*M_PI/wavelength) + phase); 07235 } 07236 else if(axis.compare("y")==0 || axis.compare("Y")==0) { 07237 *dat = sin(j*(2.0f*M_PI/wavelength) + phase); 07238 } 07239 else { 07240 *dat = sin(i*(2.0f*M_PI/wavelength) + phase); 07241 } 07242 } 07243 } 07244 } 07245 else { //3D 07246 float az = 0; 07247 if(params.has_key("az")) { 07248 az = params["az"]; 07249 } 07250 float alt = 0; 07251 if(params.has_key("alt")) { 07252 alt = params["alt"]; 07253 } 07254 float phi = 0; 07255 if(params.has_key("phi")) { 07256 phi = params["phi"]; 07257 } 07258 07259 for(int k=0; k<nz; ++k) { 07260 for(int j=0; j<ny; ++j) { 07261 for(int i=0; i<nx; ++i, ++dat) { 07262 if(axis.compare("z")==0 || axis.compare("Z")==0) { 07263 *dat = sin(k*(2.0f*M_PI/wavelength) + phase); 07264 } 07265 else if(axis.compare("y")==0 || axis.compare("Y")==0) { 07266 *dat = sin(j*(2.0f*M_PI/wavelength) + phase); 07267 } 07268 else { 07269 *dat = sin(i*(2.0f*M_PI/wavelength) + phase); 07270 } 07271 } 07272 } 07273 } 07274 07275 if(az != 0 || alt != 0 || phi != 0) { 07276 Dict d("type","eman"); 07277 d["az"] = az; d["phi"] = phi; d["alt"] = alt; 07278 image->transform(Transform(d)); 07279 } 07280 } 07281 07282 image->update(); 07283 }
|
|
Definition at line 201 of file processor.cpp. |