#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 | |
Processor * | NEW () |
Static Public Attributes | |
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 6316 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 6326 of file processor.h. 06327 { 06328 return "Replace a source image as a square or cube depends on 2D or 3D of the source image"; 06329 }
|
|
Get the processor's name. Each processor is identified by a unique name.
Implements EMAN::Processor. Definition at line 6321 of file processor.h. 06322 {
06323 return NAME;
06324 }
|
|
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 6336 of file processor.h. References EMAN::TypeDict::put(). 06337 { 06338 TypeDict d; 06339 d.put("edge_length", EMObject::FLOAT, "edge length of the square or cube, unit: pixel"); 06340 d.put("axis", EMObject::STRING, "specify a major axis for asymmetric features"); 06341 d.put("odd_edge", EMObject::FLOAT, "edge length for the asymmetric axis"); 06342 d.put("fill", EMObject::INT, "Flag indicating if image is filled, default filled, 1 for filled, 0 for blank"); 06343 return d; 06344 }
|
|
Definition at line 6331 of file processor.h. 06332 { 06333 return new TestImageSquarecube(); 06334 }
|
|
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 7554 of file processor.cpp. References EMAN::EMData::get_data(), EMAN::Dict::has_key(), InvalidValueException, nx, ny, EMAN::TestImageProcessor::preprocess(), and EMAN::EMData::update(). 07555 { 07556 preprocess(image); 07557 07558 float edge_length = params["edge_length"]; 07559 string axis = (const char*)params["axis"]; 07560 float odd_edge = params["odd_edge"]; 07561 int fill = 1; 07562 if(params.has_key("fill")) { 07563 fill = (int)params["fill"]; 07564 } 07565 07566 float *dat = image->get_data(); 07567 float x2, y2, z2; //this coordinates of this pixel from center 07568 float xEdge, yEdge, zEdge; //half of edge length for this cube 07569 if(axis == ""){ 07570 xEdge = edge_length/2.0f; 07571 yEdge = edge_length/2.0f; 07572 zEdge = edge_length/2.0f; 07573 } 07574 else if(axis == "x"){ 07575 xEdge = odd_edge/2.0f; 07576 yEdge = edge_length/2.0f; 07577 zEdge = edge_length/2.0f; 07578 } 07579 else if(axis == "y"){ 07580 xEdge = edge_length/2.0f; 07581 yEdge = odd_edge/2.0f; 07582 zEdge = edge_length/2.0f; 07583 } 07584 else if(axis == "z"){ 07585 if( nz == 1 ){ 07586 throw InvalidValueException(0, "This is a 2D image, no asymmetric feature for z axis"); 07587 } 07588 xEdge = edge_length/2.0f; 07589 yEdge = edge_length/2.0f; 07590 zEdge = odd_edge/2.0f; 07591 } 07592 else{ 07593 throw InvalidValueException(0, "please specify a valid axis for asymmetric features"); 07594 } 07595 for (int k = 0; k < nz; ++k) { 07596 for (int j = 0; j < ny; ++j) { 07597 for (int i = 0; i < nx; ++i, ++dat) { 07598 x2 = (float)fabs((float)i - nx/2); 07599 y2 = (float)fabs((float)j - ny/2); 07600 z2 = (float)fabs((float)k - nz/2); 07601 if( x2<=xEdge && y2<=yEdge && z2<=zEdge ) { 07602 if( !fill) { 07603 *dat = 0; 07604 } 07605 else { 07606 *dat = 1; 07607 } 07608 } 07609 else { 07610 if( !fill ) { 07611 *dat = 1; 07612 } 07613 else { 07614 *dat = 0; 07615 } 07616 } 07617 } 07618 } 07619 } 07620 07621 image->update(); 07622 }
|
|
Definition at line 203 of file processor.cpp. |