#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 | |
static Processor * | NEW () |
Static Public Attributes | |
static 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 6490 of file processor.h.
virtual string EMAN::TestImageCirclesphere::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 6500 of file processor.h.
06501 { 06502 return "Replace a source image as a circle or sphere depends on 2D or 3D of the source image"; 06503 }
virtual string EMAN::TestImageCirclesphere::get_name | ( | ) | const [inline, virtual] |
Get the processor's name.
Each processor is identified by a unique name.
Implements EMAN::Processor.
Definition at line 6495 of file processor.h.
References NAME.
06496 { 06497 return NAME; 06498 }
virtual TypeDict EMAN::TestImageCirclesphere::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 6510 of file processor.h.
References EMAN::EMObject::FLOAT, EMAN::EMObject::INT, EMAN::TypeDict::put(), and EMAN::EMObject::STRING.
06511 { 06512 TypeDict d; 06513 d.put("radius", EMObject::FLOAT, "radius of circle or sphere, unit: pixel"); 06514 d.put("axis", EMObject::STRING, "specify a major axis for asymmetric features"); 06515 d.put("c", EMObject::FLOAT, "distance between focus and the center of an ellipse"); 06516 d.put("fill", EMObject::INT, "Flag indicating if image is filled, default filled, 1 for filled, 0 for blank."); 06517 return d; 06518 }
static Processor* EMAN::TestImageCirclesphere::NEW | ( | ) | [inline, static] |
Definition at line 6505 of file processor.h.
06506 { 06507 return new TestImageCirclesphere(); 06508 }
void TestImageCirclesphere::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 7696 of file processor.cpp.
References EMAN::EMData::get_data(), InvalidValueException, EMAN::Processor::params, EMAN::TestImageProcessor::preprocess(), EMAN::Dict::set_default(), and EMAN::EMData::update().
07697 { 07698 preprocess(image); 07699 07700 float radius = params.set_default("radius",nx/2.0f); 07701 string axis = (const char*)params["axis"]; 07702 float c = params.set_default("c",nx/2.0f); 07703 int fill = params.set_default("fill",1); 07704 07705 float *dat = image->get_data(); 07706 float x2, y2, z2; //this is coordinates of this pixel from center 07707 float r = 0.0f; 07708 float asy = 0.0f; 07709 if(axis == ""){ 07710 asy = radius; 07711 } 07712 else if(axis == "x" || axis == "y"){ 07713 asy = c; 07714 } 07715 else if(axis=="z"){ 07716 if( nz == 1 ){ 07717 throw InvalidValueException(0, "This is a 2D image, no asymmetric feature for z axis"); 07718 } 07719 asy = c; 07720 } 07721 else{ 07722 throw InvalidValueException(0, "please specify a valid axis for asymmetric features"); 07723 } 07724 07725 for (int k = 0; k < nz; ++k) { 07726 for (int j = 0; j < ny; ++j) { 07727 for (int i = 0; i < nx; ++i, ++dat) { 07728 x2 = fabs((float)i - nx/2); 07729 y2 = fabs((float)j - ny/2); 07730 z2 = fabs((float)k - nz/2); 07731 if( axis == "" ){ 07732 r = (x2*x2)/(radius*radius) + (y2*y2)/(radius*radius) + (z2*z2)/(radius*radius); 07733 } 07734 else if (axis == "x"){ 07735 r = (x2*x2)/(asy*asy) + (y2*y2)/(radius*radius) + (z2*z2)/(radius*radius); 07736 } 07737 else if(axis == "y"){ 07738 r = (x2*x2)/(radius*radius) + (y2*y2)/(asy*asy) + (z2*z2)/(radius*radius); 07739 } 07740 else if(axis=="z"){ 07741 r = (x2*x2)/(radius*radius) + (y2*y2)/(radius*radius) + (z2*z2)/(asy*asy); 07742 } 07743 if( r<=1 ) { 07744 if( !fill) { 07745 *dat = 0; 07746 } 07747 else { 07748 *dat = 1; 07749 } 07750 } 07751 else { 07752 if( !fill ) { 07753 *dat = 1; 07754 } 07755 else { 07756 *dat = 0; 07757 } 07758 } 07759 } 07760 } 07761 } 07762 07763 image->update(); 07764 }
const string TestImageCirclesphere::NAME = "testimage.circlesphere" [static] |