#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 6414 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 6424 of file processor.h. 06425 {
06426 return "Replace a source image as a circle or sphere depends on 2D or 3D of the source image";
06427 }
|
|
|
Get the processor's name. Each processor is identified by a unique name.
Implements EMAN::Processor. Definition at line 6419 of file processor.h. 06420 {
06421 return NAME;
06422 }
|
|
|
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 6434 of file processor.h. References EMAN::TypeDict::put(). 06435 {
06436 TypeDict d;
06437 d.put("radius", EMObject::FLOAT, "radius of circle or sphere, unit: pixel");
06438 d.put("axis", EMObject::STRING, "specify a major axis for asymmetric features");
06439 d.put("c", EMObject::FLOAT, "distance between focus and the center of an ellipse");
06440 d.put("fill", EMObject::INT, "Flag indicating if image is filled, default filled, 1 for filled, 0 for blank.");
06441 return d;
06442 }
|
|
|
Definition at line 6429 of file processor.h. 06430 {
06431 return new TestImageCirclesphere();
06432 }
|
|
|
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 7538 of file processor.cpp. References EMAN::EMData::get_data(), InvalidValueException, nx, ny, EMAN::TestImageProcessor::preprocess(), EMAN::Dict::set_default(), and EMAN::EMData::update(). 07539 {
07540 preprocess(image);
07541
07542 float radius = params.set_default("radius",nx/2.0f);
07543 string axis = (const char*)params["axis"];
07544 float c = params.set_default("c",nx/2.0f);
07545 int fill = params.set_default("fill",1);
07546
07547 float *dat = image->get_data();
07548 float x2, y2, z2; //this is coordinates of this pixel from center
07549 float r = 0.0f;
07550 float asy = 0.0f;
07551 if(axis == ""){
07552 asy = radius;
07553 }
07554 else if(axis == "x" || axis == "y"){
07555 asy = c;
07556 }
07557 else if(axis=="z"){
07558 if( nz == 1 ){
07559 throw InvalidValueException(0, "This is a 2D image, no asymmetric feature for z axis");
07560 }
07561 asy = c;
07562 }
07563 else{
07564 throw InvalidValueException(0, "please specify a valid axis for asymmetric features");
07565 }
07566
07567 for (int k = 0; k < nz; ++k) {
07568 for (int j = 0; j < ny; ++j) {
07569 for (int i = 0; i < nx; ++i, ++dat) {
07570 x2 = fabs((float)i - nx/2);
07571 y2 = fabs((float)j - ny/2);
07572 z2 = fabs((float)k - nz/2);
07573 if( axis == "" ){
07574 r = (x2*x2)/(radius*radius) + (y2*y2)/(radius*radius) + (z2*z2)/(radius*radius);
07575 }
07576 else if (axis == "x"){
07577 r = (x2*x2)/(asy*asy) + (y2*y2)/(radius*radius) + (z2*z2)/(radius*radius);
07578 }
07579 else if(axis == "y"){
07580 r = (x2*x2)/(radius*radius) + (y2*y2)/(asy*asy) + (z2*z2)/(radius*radius);
07581 }
07582 else if(axis=="z"){
07583 r = (x2*x2)/(radius*radius) + (y2*y2)/(radius*radius) + (z2*z2)/(asy*asy);
07584 }
07585 if( r<=1 ) {
07586 if( !fill) {
07587 *dat = 0;
07588 }
07589 else {
07590 *dat = 1;
07591 }
07592 }
07593 else {
07594 if( !fill ) {
07595 *dat = 1;
07596 }
07597 else {
07598 *dat = 0;
07599 }
07600 }
07601 }
07602 }
07603 }
07604
07605 image->update();
07606 }
|
|
|
Definition at line 211 of file processor.cpp. |
1.3.9.1