#include <processor.h>
Inheritance diagram for EMAN::TestImageCirclesphere:
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.circlesphere" |
radius | radius of circle or sphere | |
axis | specify a major axis for asymmetric features | |
c | distance between focus and the center of an ellipse | |
fill | answer 'yes' or 'no' to specify if it's filled or hollow, default filled |
Definition at line 6407 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 6417 of file processor.h. 06418 { 06419 return "Replace a source image as a circle or sphere depends on 2D or 3D of the source image"; 06420 }
|
|
Get the processor's name. Each processor is identified by a unique name.
Implements EMAN::Processor. Definition at line 6412 of file processor.h. 06413 {
06414 return NAME;
06415 }
|
|
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 6427 of file processor.h. References EMAN::TypeDict::put(). 06428 { 06429 TypeDict d; 06430 d.put("radius", EMObject::FLOAT, "radius of circle or sphere, unit: pixel"); 06431 d.put("axis", EMObject::STRING, "specify a major axis for asymmetric features"); 06432 d.put("c", EMObject::FLOAT, "distance between focus and the center of an ellipse"); 06433 d.put("fill", EMObject::INT, "Flag indicating if image is filled, default filled, 1 for filled, 0 for blank."); 06434 return d; 06435 }
|
|
Definition at line 6422 of file processor.h. 06423 { 06424 return new TestImageCirclesphere(); 06425 }
|
|
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 7405 of file processor.cpp. References EMAN::EMData::get_data(), InvalidValueException, nx, ny, EMAN::TestImageProcessor::preprocess(), EMAN::Dict::set_default(), and EMAN::EMData::update(). 07406 { 07407 preprocess(image); 07408 07409 float radius = params.set_default("radius",nx/2.0f); 07410 string axis = (const char*)params["axis"]; 07411 float c = params.set_default("c",nx/2.0f); 07412 int fill = params.set_default("fill",1); 07413 07414 float *dat = image->get_data(); 07415 float x2, y2, z2; //this is coordinates of this pixel from center 07416 float r = 0.0f; 07417 float asy = 0.0f; 07418 if(axis == ""){ 07419 asy = radius; 07420 } 07421 else if(axis == "x" || axis == "y"){ 07422 asy = c; 07423 } 07424 else if(axis=="z"){ 07425 if( nz == 1 ){ 07426 throw InvalidValueException(0, "This is a 2D image, no asymmetric feature for z axis"); 07427 } 07428 asy = c; 07429 } 07430 else{ 07431 throw InvalidValueException(0, "please specify a valid axis for asymmetric features"); 07432 } 07433 07434 for (int k = 0; k < nz; ++k) { 07435 for (int j = 0; j < ny; ++j) { 07436 for (int i = 0; i < nx; ++i, ++dat) { 07437 x2 = fabs((float)i - nx/2); 07438 y2 = fabs((float)j - ny/2); 07439 z2 = fabs((float)k - nz/2); 07440 if( axis == "" ){ 07441 r = (x2*x2)/(radius*radius) + (y2*y2)/(radius*radius) + (z2*z2)/(radius*radius); 07442 } 07443 else if (axis == "x"){ 07444 r = (x2*x2)/(asy*asy) + (y2*y2)/(radius*radius) + (z2*z2)/(radius*radius); 07445 } 07446 else if(axis == "y"){ 07447 r = (x2*x2)/(radius*radius) + (y2*y2)/(asy*asy) + (z2*z2)/(radius*radius); 07448 } 07449 else if(axis=="z"){ 07450 r = (x2*x2)/(radius*radius) + (y2*y2)/(radius*radius) + (z2*z2)/(asy*asy); 07451 } 07452 if( r<=1 ) { 07453 if( !fill) { 07454 *dat = 0; 07455 } 07456 else { 07457 *dat = 1; 07458 } 07459 } 07460 else { 07461 if( !fill ) { 07462 *dat = 1; 07463 } 07464 else { 07465 *dat = 0; 07466 } 07467 } 07468 } 07469 } 07470 } 07471 07472 image->update(); 07473 }
|
|
Definition at line 206 of file processor.cpp. |