#include <processor.h>


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.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 6127 of file processor.h.
| void TestImageSinewave::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 7187 of file processor.cpp.
References EMAN::EMData::get_data(), get_name(), EMAN::EMData::get_ndim(), EMAN::Dict::has_key(), InvalidParameterException, LOGERR, EMAN::Processor::params, phase(), phi, EMAN::TestImageProcessor::preprocess(), EMAN::EMData::transform(), and EMAN::EMData::update().
07188 { 07189 preprocess(image); 07190 07191 if(!params.has_key("wavelength")) { 07192 LOGERR("%s wavelength is required parameter", get_name().c_str()); 07193 throw InvalidParameterException("wavelength parameter is required."); 07194 } 07195 float wavelength = params["wavelength"]; 07196 07197 string axis = ""; 07198 if(params.has_key("axis")) { 07199 axis = (const char*)params["axis"]; 07200 } 07201 07202 float phase = 0; 07203 if(params.has_key("phase")) { 07204 phase = params["phase"]; 07205 } 07206 07207 int ndim = image->get_ndim(); 07208 float * dat = image->get_data(); 07209 07210 if(ndim==1) { //1D 07211 for(int i=0; i<nx; ++i, ++dat) { 07212 *dat = sin(i*(2.0f*M_PI/wavelength) + phase); 07213 } 07214 } 07215 else if(ndim==2) { //2D 07216 float alpha = 0; 07217 if(params.has_key("az")) { 07218 alpha = params["az"]; 07219 } 07220 for(int j=0; j<ny; ++j) { 07221 for(int i=0; i<nx; ++i, ++dat) { 07222 if(alpha != 0) { 07223 *dat = sin((i*sin((180-alpha)*M_PI/180)+j*cos((180-alpha)*M_PI/180))*(2.0f*M_PI/wavelength) + phase); 07224 } 07225 else if(axis.compare("y")==0 || axis.compare("Y")==0) { 07226 *dat = sin(j*(2.0f*M_PI/wavelength) + phase); 07227 } 07228 else { 07229 *dat = sin(i*(2.0f*M_PI/wavelength) + phase); 07230 } 07231 } 07232 } 07233 } 07234 else { //3D 07235 float az = 0; 07236 if(params.has_key("az")) { 07237 az = params["az"]; 07238 } 07239 float alt = 0; 07240 if(params.has_key("alt")) { 07241 alt = params["alt"]; 07242 } 07243 float phi = 0; 07244 if(params.has_key("phi")) { 07245 phi = params["phi"]; 07246 } 07247 07248 for(int k=0; k<nz; ++k) { 07249 for(int j=0; j<ny; ++j) { 07250 for(int i=0; i<nx; ++i, ++dat) { 07251 if(axis.compare("z")==0 || axis.compare("Z")==0) { 07252 *dat = sin(k*(2.0f*M_PI/wavelength) + phase); 07253 } 07254 else if(axis.compare("y")==0 || axis.compare("Y")==0) { 07255 *dat = sin(j*(2.0f*M_PI/wavelength) + phase); 07256 } 07257 else { 07258 *dat = sin(i*(2.0f*M_PI/wavelength) + phase); 07259 } 07260 } 07261 } 07262 } 07263 07264 if(az != 0 || alt != 0 || phi != 0) { 07265 Dict d("type","eman"); 07266 d["az"] = az; d["phi"] = phi; d["alt"] = alt; 07267 image->transform(Transform(d)); 07268 } 07269 } 07270 07271 image->update(); 07272 }
| virtual string EMAN::TestImageSinewave::get_name | ( | ) | const [inline, virtual] |
Get the processor's name.
Each processor is identified by a unique name.
Implements EMAN::Processor.
Definition at line 6132 of file processor.h.
References EMAN::NormalizeUnitSumProcessor::NAME.
Referenced by process_inplace().
06133 { 06134 return NAME; 06135 }
| virtual string EMAN::TestImageSinewave::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 6137 of file processor.h.
| static Processor* EMAN::TestImageSinewave::NEW | ( | ) | [inline, static] |
| virtual TypeDict EMAN::TestImageSinewave::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 6147 of file processor.h.
References EMAN::EMObject::FLOAT, EMAN::TypeDict::put(), and EMAN::EMObject::STRING.
06148 { 06149 TypeDict d; 06150 d.put("wavelength", EMObject::FLOAT, "wavelength in equation sin(x*2*PI/wavelength - phase*180/PI)"); 06151 d.put("axis", EMObject::STRING, "(optional) specify a major axis for asymmetric features, default x axis"); 06152 d.put("phase", EMObject::FLOAT, "(optional) the phase in equation sin(x*2*PI/wavelength - phase*180/PI)"); 06153 d.put("az", EMObject::FLOAT, "(optional) angle in degree. for 2D image, this is the rotated angle of the image, \ 06154 in 3D image, it's az for euler angle. default is zero"); 06155 d.put("alt", EMObject::FLOAT, "(optional) angle in degree. only in 3D case, alt for euler angle, default is zero"); 06156 d.put("phi", EMObject::FLOAT, "(optional) angle in degree. only in 3D case, phi for euler angle, default is zero"); 06157 return d; 06158 }
const string TestImageSinewave::NAME = "testimage.sinewave" [static] |
Definition at line 6160 of file processor.h.
1.5.6