#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 6322 of file processor.h.
virtual string EMAN::TestImageSinewaveCircular::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 6332 of file processor.h.
06333 { 06334 return "Replace a source image as a circular sine wave in specified wave length"; 06335 }
virtual string EMAN::TestImageSinewaveCircular::get_name | ( | ) | const [inline, virtual] |
Get the processor's name.
Each processor is identified by a unique name.
Implements EMAN::Processor.
Definition at line 6327 of file processor.h.
References NAME.
06328 { 06329 return NAME; 06330 }
virtual TypeDict EMAN::TestImageSinewaveCircular::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 6342 of file processor.h.
References EMAN::EMObject::FLOAT, EMAN::TypeDict::put(), and EMAN::EMObject::STRING.
06343 { 06344 TypeDict d; 06345 d.put("wavelength", EMObject::FLOAT, "(required)this value is the d in function |sin(x/d)|, unit: pixel"); 06346 d.put("axis", EMObject::STRING, "specify a major axis for asymmetric features"); 06347 d.put("c", EMObject::FLOAT, "distance between focus and the center of an ellipse"); 06348 d.put("phase", EMObject::FLOAT, "(optional)phase for sine wave, default is 0"); 06349 return d; 06350 }
static Processor* EMAN::TestImageSinewaveCircular::NEW | ( | ) | [inline, static] |
Definition at line 6337 of file processor.h.
06338 { 06339 return new TestImageSinewaveCircular(); 06340 }
void TestImageSinewaveCircular::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 7573 of file processor.cpp.
References EMAN::EMData::get_data(), InvalidValueException, EMAN::Processor::params, phase(), EMAN::TestImageProcessor::preprocess(), sqrt(), and EMAN::EMData::update().
07574 { 07575 preprocess(image); 07576 07577 float wavelength = params["wavelength"]; 07578 string axis = (const char*)params["axis"]; 07579 float c = params["c"]; 07580 float phase = params["phase"]; 07581 07582 float *dat = image->get_data(); 07583 float r; //this is the distance of pixel from the image center(nx/2, ny/2, nz/2) 07584 float x2, y2, z2; //this is the coordinates of this pixel from image center 07585 for (int k = 0; k < nz; ++k) { 07586 for (int j = 0; j < ny; ++j) { 07587 for (int i = 0; i < nx; ++i, ++dat) { 07588 x2 = (float)( i - nx/2 ); 07589 y2 = (float)( j - ny/2 ); 07590 z2 = (float)( k - nz/2 ); 07591 if(axis == ""){ 07592 r = (float)sqrt(x2*x2+y2*y2+z2*z2); 07593 } 07594 else if(axis == "x"){ 07595 float lc = -c; 07596 float rc = c; 07597 r = ( (float)sqrt((x2-lc)*(x2-lc)+y2*y2+z2*z2) + 07598 (float)sqrt((x2-rc)*(x2-rc)+y2*y2+z2*z2) ) /2.0f - c; 07599 } 07600 else if(axis == "y"){ 07601 float lc = -c; 07602 float rc = c; 07603 r = ( (float)sqrt(x2*x2+(y2-lc)*(y2-lc)+z2*z2) + 07604 (float)sqrt(x2*x2+(y2-rc)*(y2-rc)+z2*z2) ) /2.0f - c; 07605 } 07606 else if(axis == "z"){ 07607 if( nz == 1 ){ 07608 throw InvalidValueException(0, "This is a 2D image, no asymmetric feature for z axis"); 07609 } 07610 float lc = -c; 07611 float rc = c; 07612 r = ( (float)sqrt(x2*x2+y2*y2+(z2-lc)*(z2-lc)) + 07613 (float)sqrt(x2*x2+y2*y2+(z2-rc)*(z2-rc)) ) /2.0f - c; 07614 } 07615 else{ 07616 throw InvalidValueException(0, "please specify a valid axis for asymmetric features"); 07617 } 07618 *dat = sin( r * (2.0f*M_PI/wavelength) - phase*180/M_PI); 07619 } 07620 } 07621 } 07622 07623 image->update(); 07624 }
const string TestImageSinewaveCircular::NAME = "testimage.sinewave.circular" [static] |