#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 6279 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 6289 of file processor.h. 06290 { 06291 return "Replace a source image as a square or cube depends on 2D or 3D of the source image"; 06292 }
|
|
Get the processor's name. Each processor is identified by a unique name.
Implements EMAN::Processor. Definition at line 6284 of file processor.h. References NAME. 06285 { 06286 return NAME; 06287 }
|
|
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 6299 of file processor.h. References EMAN::EMObject::FLOAT, EMAN::EMObject::INT, EMAN::TypeDict::put(), and EMAN::EMObject::STRING. 06300 { 06301 TypeDict d; 06302 d.put("edge_length", EMObject::FLOAT, "edge length of the square or cube, unit: pixel"); 06303 d.put("axis", EMObject::STRING, "specify a major axis for asymmetric features"); 06304 d.put("odd_edge", EMObject::FLOAT, "edge length for the asymmetric axis"); 06305 d.put("fill", EMObject::INT, "Flag indicating if image is filled, default filled, 1 for filled, 0 for blank"); 06306 return d; 06307 }
|
|
Definition at line 6294 of file processor.h. 06295 { 06296 return new TestImageSquarecube(); 06297 }
|
|
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 7369 of file processor.cpp. References EMAN::EMData::get_data(), InvalidValueException, EMAN::Processor::params, EMAN::TestImageProcessor::preprocess(), and EMAN::EMData::update(). 07370 { 07371 preprocess(image); 07372 07373 float edge_length = params["edge_length"]; 07374 string axis = (const char*)params["axis"]; 07375 float odd_edge = params["odd_edge"]; 07376 int fill = (int)params["fill"]; 07377 07378 float *dat = image->get_data(); 07379 float x2, y2, z2; //this coordinates of this pixel from center 07380 float xEdge, yEdge, zEdge; //half of edge length for this cube 07381 if(axis == ""){ 07382 xEdge = edge_length/2.0f; 07383 yEdge = edge_length/2.0f; 07384 zEdge = edge_length/2.0f; 07385 } 07386 else if(axis == "x"){ 07387 xEdge = odd_edge/2.0f; 07388 yEdge = edge_length/2.0f; 07389 zEdge = edge_length/2.0f; 07390 } 07391 else if(axis == "y"){ 07392 xEdge = edge_length/2.0f; 07393 yEdge = odd_edge/2.0f; 07394 zEdge = edge_length/2.0f; 07395 } 07396 else if(axis == "z"){ 07397 if( nz == 1 ){ 07398 throw InvalidValueException(0, "This is a 2D image, no asymmetric feature for z axis"); 07399 } 07400 xEdge = edge_length/2.0f; 07401 yEdge = edge_length/2.0f; 07402 zEdge = odd_edge/2.0f; 07403 } 07404 else{ 07405 throw InvalidValueException(0, "please specify a valid axis for asymmetric features"); 07406 } 07407 for (int k = 0; k < nz; ++k) { 07408 for (int j = 0; j < ny; ++j) { 07409 for (int i = 0; i < nx; ++i, ++dat) { 07410 x2 = (float)fabs((float)i - nx/2); 07411 y2 = (float)fabs((float)j - ny/2); 07412 z2 = (float)fabs((float)k - nz/2); 07413 if( x2<=xEdge && y2<=yEdge && z2<=zEdge ) { 07414 if( !fill) { 07415 *dat = 0; 07416 } 07417 else { 07418 *dat = 1; 07419 } 07420 } 07421 else { 07422 if( !fill ) { 07423 *dat = 1; 07424 } 07425 else { 07426 *dat = 0; 07427 } 07428 } 07429 } 07430 } 07431 } 07432 07433 image->update(); 07434 }
|
|
Definition at line 6309 of file processor.h. Referenced by get_name(). |