#include <processor.h>
Inheritance diagram for EMAN::TestImageSinewaveCircular:
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.circular" |
wavelength | float this value is the d in function |sin(x/d)| | |
axis | char (optional) specify a major axis for asymmetric features | |
c | distance (optional) float between focus and the center of an ellipse | |
phase | degree (optional) phase for sine wave, default is 0 |
Definition at line 6240 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 6250 of file processor.h. 06251 { 06252 return "Replace a source image as a circular sine wave in specified wave length"; 06253 }
|
|
Get the processor's name. Each processor is identified by a unique name.
Implements EMAN::Processor. Definition at line 6245 of file processor.h. References NAME. 06246 { 06247 return NAME; 06248 }
|
|
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 6260 of file processor.h. References EMAN::EMObject::FLOAT, EMAN::TypeDict::put(), and EMAN::EMObject::STRING. 06261 { 06262 TypeDict d; 06263 d.put("wavelength", EMObject::FLOAT, "(required)this value is the d in function |sin(x/d)|, unit: pixel"); 06264 d.put("axis", EMObject::STRING, "specify a major axis for asymmetric features"); 06265 d.put("c", EMObject::FLOAT, "distance between focus and the center of an ellipse"); 06266 d.put("phase", EMObject::FLOAT, "(optional)phase for sine wave, default is 0"); 06267 return d; 06268 }
|
|
Definition at line 6255 of file processor.h. 06256 { 06257 return new TestImageSinewaveCircular(); 06258 }
|
|
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 7316 of file processor.cpp. References EMAN::EMData::get_data(), InvalidValueException, EMAN::Processor::params, phase(), EMAN::TestImageProcessor::preprocess(), sqrt(), and EMAN::EMData::update(). 07317 { 07318 preprocess(image); 07319 07320 float wavelength = params["wavelength"]; 07321 string axis = (const char*)params["axis"]; 07322 float c = params["c"]; 07323 float phase = params["phase"]; 07324 07325 float *dat = image->get_data(); 07326 float r; //this is the distance of pixel from the image center(nx/2, ny/2, nz/2) 07327 float x2, y2, z2; //this is the coordinates of this pixel from image center 07328 for (int k = 0; k < nz; ++k) { 07329 for (int j = 0; j < ny; ++j) { 07330 for (int i = 0; i < nx; ++i, ++dat) { 07331 x2 = (float)( i - nx/2 ); 07332 y2 = (float)( j - ny/2 ); 07333 z2 = (float)( k - nz/2 ); 07334 if(axis == ""){ 07335 r = (float)sqrt(x2*x2+y2*y2+z2*z2); 07336 } 07337 else if(axis == "x"){ 07338 float lc = -c; 07339 float rc = c; 07340 r = ( (float)sqrt((x2-lc)*(x2-lc)+y2*y2+z2*z2) + 07341 (float)sqrt((x2-rc)*(x2-rc)+y2*y2+z2*z2) ) /2.0f - c; 07342 } 07343 else if(axis == "y"){ 07344 float lc = -c; 07345 float rc = c; 07346 r = ( (float)sqrt(x2*x2+(y2-lc)*(y2-lc)+z2*z2) + 07347 (float)sqrt(x2*x2+(y2-rc)*(y2-rc)+z2*z2) ) /2.0f - c; 07348 } 07349 else if(axis == "z"){ 07350 if( nz == 1 ){ 07351 throw InvalidValueException(0, "This is a 2D image, no asymmetric feature for z axis"); 07352 } 07353 float lc = -c; 07354 float rc = c; 07355 r = ( (float)sqrt(x2*x2+y2*y2+(z2-lc)*(z2-lc)) + 07356 (float)sqrt(x2*x2+y2*y2+(z2-rc)*(z2-rc)) ) /2.0f - c; 07357 } 07358 else{ 07359 throw InvalidValueException(0, "please specify a valid axis for asymmetric features"); 07360 } 07361 *dat = sin( r * (2.0f*M_PI/wavelength) - phase*180/M_PI); 07362 } 07363 } 07364 } 07365 07366 image->update(); 07367 }
|
|
Definition at line 6270 of file processor.h. Referenced by get_name(). |