#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 | |
Processor * | NEW () |
Static Public Attributes | |
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 6324 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 6334 of file processor.h. 06335 { 06336 return "Replace a source image as a circular sine wave in specified wave length"; 06337 }
|
|
Get the processor's name. Each processor is identified by a unique name.
Implements EMAN::Processor. Definition at line 6329 of file processor.h. 06330 {
06331 return NAME;
06332 }
|
|
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 6344 of file processor.h. References EMAN::TypeDict::put(). 06345 { 06346 TypeDict d; 06347 d.put("wavelength", EMObject::FLOAT, "(required)this value is the d in function |sin(x/d)|, unit: pixel"); 06348 d.put("axis", EMObject::STRING, "specify a major axis for asymmetric features"); 06349 d.put("c", EMObject::FLOAT, "distance between focus and the center of an ellipse"); 06350 d.put("phase", EMObject::FLOAT, "(optional)phase for sine wave, default is 0"); 06351 return d; 06352 }
|
|
Definition at line 6339 of file processor.h. 06340 { 06341 return new TestImageSinewaveCircular(); 06342 }
|
|
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 7588 of file processor.cpp. References EMAN::EMData::get_data(), InvalidValueException, nx, ny, phase(), EMAN::TestImageProcessor::preprocess(), sqrt(), and EMAN::EMData::update(). 07589 { 07590 preprocess(image); 07591 07592 float wavelength = params["wavelength"]; 07593 string axis = (const char*)params["axis"]; 07594 float c = params["c"]; 07595 float phase = params["phase"]; 07596 07597 float *dat = image->get_data(); 07598 float r; //this is the distance of pixel from the image center(nx/2, ny/2, nz/2) 07599 float x2, y2, z2; //this is the coordinates of this pixel from image center 07600 for (int k = 0; k < nz; ++k) { 07601 for (int j = 0; j < ny; ++j) { 07602 for (int i = 0; i < nx; ++i, ++dat) { 07603 x2 = (float)( i - nx/2 ); 07604 y2 = (float)( j - ny/2 ); 07605 z2 = (float)( k - nz/2 ); 07606 if(axis == ""){ 07607 r = (float)sqrt(x2*x2+y2*y2+z2*z2); 07608 } 07609 else if(axis == "x"){ 07610 float lc = -c; 07611 float rc = c; 07612 r = ( (float)sqrt((x2-lc)*(x2-lc)+y2*y2+z2*z2) + 07613 (float)sqrt((x2-rc)*(x2-rc)+y2*y2+z2*z2) ) /2.0f - c; 07614 } 07615 else if(axis == "y"){ 07616 float lc = -c; 07617 float rc = c; 07618 r = ( (float)sqrt(x2*x2+(y2-lc)*(y2-lc)+z2*z2) + 07619 (float)sqrt(x2*x2+(y2-rc)*(y2-rc)+z2*z2) ) /2.0f - c; 07620 } 07621 else if(axis == "z"){ 07622 if( nz == 1 ){ 07623 throw InvalidValueException(0, "This is a 2D image, no asymmetric feature for z axis"); 07624 } 07625 float lc = -c; 07626 float rc = c; 07627 r = ( (float)sqrt(x2*x2+y2*y2+(z2-lc)*(z2-lc)) + 07628 (float)sqrt(x2*x2+y2*y2+(z2-rc)*(z2-rc)) ) /2.0f - c; 07629 } 07630 else{ 07631 throw InvalidValueException(0, "please specify a valid axis for asymmetric features"); 07632 } 07633 *dat = sin( r * (2.0f*M_PI/wavelength) - phase*180/M_PI); 07634 } 07635 } 07636 } 07637 07638 image->update(); 07639 }
|
|
Definition at line 202 of file processor.cpp. |