#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 6208 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 6218 of file processor.h. 06219 {
06220 return "Replace a source image as a circular sine wave in specified wave length";
06221 }
|
|
|
Get the processor's name. Each processor is identified by a unique name.
Implements EMAN::Processor. Definition at line 6213 of file processor.h. 06214 {
06215 return NAME;
06216 }
|
|
|
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 6228 of file processor.h. References EMAN::TypeDict::put(). 06229 {
06230 TypeDict d;
06231 d.put("wavelength", EMObject::FLOAT, "(required)this value is the d in function |sin(x/d)|, unit: pixel");
06232 d.put("axis", EMObject::STRING, "specify a major axis for asymmetric features");
06233 d.put("c", EMObject::FLOAT, "distance between focus and the center of an ellipse");
06234 d.put("phase", EMObject::FLOAT, "(optional)phase for sine wave, default is 0");
06235 return d;
06236 }
|
|
|
Definition at line 6223 of file processor.h. 06224 {
06225 return new TestImageSinewaveCircular();
06226 }
|
|
|
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 7387 of file processor.cpp. References EMAN::EMData::get_data(), InvalidValueException, nx, ny, phase(), EMAN::TestImageProcessor::preprocess(), sqrt(), and EMAN::EMData::update(). 07388 {
07389 preprocess(image);
07390
07391 float wavelength = params["wavelength"];
07392 string axis = (const char*)params["axis"];
07393 float c = params["c"];
07394 float phase = params["phase"];
07395
07396 float *dat = image->get_data();
07397 float r; //this is the distance of pixel from the image center(nx/2, ny/2, nz/2)
07398 float x2, y2, z2; //this is the coordinates of this pixel from image center
07399 for (int k = 0; k < nz; ++k) {
07400 for (int j = 0; j < ny; ++j) {
07401 for (int i = 0; i < nx; ++i, ++dat) {
07402 x2 = (float)( i - nx/2 );
07403 y2 = (float)( j - ny/2 );
07404 z2 = (float)( k - nz/2 );
07405 if(axis == ""){
07406 r = (float)sqrt(x2*x2+y2*y2+z2*z2);
07407 }
07408 else if(axis == "x"){
07409 float lc = -c;
07410 float rc = c;
07411 r = ( (float)sqrt((x2-lc)*(x2-lc)+y2*y2+z2*z2) +
07412 (float)sqrt((x2-rc)*(x2-rc)+y2*y2+z2*z2) ) /2.0f - c;
07413 }
07414 else if(axis == "y"){
07415 float lc = -c;
07416 float rc = c;
07417 r = ( (float)sqrt(x2*x2+(y2-lc)*(y2-lc)+z2*z2) +
07418 (float)sqrt(x2*x2+(y2-rc)*(y2-rc)+z2*z2) ) /2.0f - c;
07419 }
07420 else if(axis == "z"){
07421 if( nz == 1 ){
07422 throw InvalidValueException(0, "This is a 2D image, no asymmetric feature for z axis");
07423 }
07424 float lc = -c;
07425 float rc = c;
07426 r = ( (float)sqrt(x2*x2+y2*y2+(z2-lc)*(z2-lc)) +
07427 (float)sqrt(x2*x2+y2*y2+(z2-rc)*(z2-rc)) ) /2.0f - c;
07428 }
07429 else{
07430 throw InvalidValueException(0, "please specify a valid axis for asymmetric features");
07431 }
07432 *dat = sin( r * (2.0f*M_PI/wavelength) - phase*180/M_PI);
07433 }
07434 }
07435 }
07436
07437 image->update();
07438 }
|
|
|
Definition at line 202 of file processor.cpp. |
1.3.9.1