#include <processor.h>
Inheritance diagram for EMAN::TestImageSquarecube:
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.squarecube" |
edge_length | edge length of the square or cube | |
axis | specify a major axis for asymmetric features | |
odd_edge | edge length for the asymmetric axis | |
fill | answer 'yes' or 'no' to specify if it's filled or hollow, default filled |
Definition at line 6402 of file processor.h.
virtual string EMAN::TestImageSquarecube::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 6412 of file processor.h.
06413 { 06414 return "Replace a source image as a square or cube depends on 2D or 3D of the source image"; 06415 }
virtual string EMAN::TestImageSquarecube::get_name | ( | ) | const [inline, virtual] |
Get the processor's name.
Each processor is identified by a unique name.
Implements EMAN::Processor.
Definition at line 6407 of file processor.h.
References NAME.
06408 { 06409 return NAME; 06410 }
virtual TypeDict EMAN::TestImageSquarecube::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 6422 of file processor.h.
References EMAN::EMObject::FLOAT, EMAN::EMObject::INT, EMAN::TypeDict::put(), and EMAN::EMObject::STRING.
06423 { 06424 TypeDict d; 06425 d.put("edge_length", EMObject::FLOAT, "edge length of the square or cube, unit: pixel"); 06426 d.put("axis", EMObject::STRING, "specify a major axis for asymmetric features"); 06427 d.put("odd_edge", EMObject::FLOAT, "edge length for the asymmetric axis"); 06428 d.put("fill", EMObject::INT, "Flag indicating if image is filled, default filled, 1 for filled, 0 for blank"); 06429 return d; 06430 }
static Processor* EMAN::TestImageSquarecube::NEW | ( | ) | [inline, static] |
void TestImageSquarecube::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 7706 of file processor.cpp.
References EMAN::EMData::get_data(), EMAN::Dict::has_key(), InvalidValueException, EMAN::Processor::params, EMAN::TestImageProcessor::preprocess(), and EMAN::EMData::update().
07707 { 07708 preprocess(image); 07709 07710 float edge_length = params["edge_length"]; 07711 string axis = (const char*)params["axis"]; 07712 float odd_edge = params["odd_edge"]; 07713 int fill = 1; 07714 if(params.has_key("fill")) { 07715 fill = (int)params["fill"]; 07716 } 07717 07718 float *dat = image->get_data(); 07719 float x2, y2, z2; //this coordinates of this pixel from center 07720 float xEdge, yEdge, zEdge; //half of edge length for this cube 07721 if(axis == ""){ 07722 xEdge = edge_length/2.0f; 07723 yEdge = edge_length/2.0f; 07724 zEdge = edge_length/2.0f; 07725 } 07726 else if(axis == "x"){ 07727 xEdge = odd_edge/2.0f; 07728 yEdge = edge_length/2.0f; 07729 zEdge = edge_length/2.0f; 07730 } 07731 else if(axis == "y"){ 07732 xEdge = edge_length/2.0f; 07733 yEdge = odd_edge/2.0f; 07734 zEdge = edge_length/2.0f; 07735 } 07736 else if(axis == "z"){ 07737 if( nz == 1 ){ 07738 throw InvalidValueException(0, "This is a 2D image, no asymmetric feature for z axis"); 07739 } 07740 xEdge = edge_length/2.0f; 07741 yEdge = edge_length/2.0f; 07742 zEdge = odd_edge/2.0f; 07743 } 07744 else{ 07745 throw InvalidValueException(0, "please specify a valid axis for asymmetric features"); 07746 } 07747 for (int k = 0; k < nz; ++k) { 07748 for (int j = 0; j < ny; ++j) { 07749 for (int i = 0; i < nx; ++i, ++dat) { 07750 x2 = (float)fabs((float)i - nx/2); 07751 y2 = (float)fabs((float)j - ny/2); 07752 z2 = (float)fabs((float)k - nz/2); 07753 if( x2<=xEdge && y2<=yEdge && z2<=zEdge ) { 07754 if( !fill) { 07755 *dat = 0; 07756 } 07757 else { 07758 *dat = 1; 07759 } 07760 } 07761 else { 07762 if( !fill ) { 07763 *dat = 1; 07764 } 07765 else { 07766 *dat = 0; 07767 } 07768 } 07769 } 07770 } 07771 } 07772 07773 image->update(); 07774 }
const string TestImageSquarecube::NAME = "testimage.squarecube" [static] |