#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 6247 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 6257 of file processor.h. 06258 {
06259 return "Replace a source image as a square or cube depends on 2D or 3D of the source image";
06260 }
|
|
|
Get the processor's name. Each processor is identified by a unique name.
Implements EMAN::Processor. Definition at line 6252 of file processor.h. 06253 {
06254 return NAME;
06255 }
|
|
|
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 6267 of file processor.h. References EMAN::TypeDict::put(). 06268 {
06269 TypeDict d;
06270 d.put("edge_length", EMObject::FLOAT, "edge length of the square or cube, unit: pixel");
06271 d.put("axis", EMObject::STRING, "specify a major axis for asymmetric features");
06272 d.put("odd_edge", EMObject::FLOAT, "edge length for the asymmetric axis");
06273 d.put("fill", EMObject::INT, "Flag indicating if image is filled, default filled, 1 for filled, 0 for blank");
06274 return d;
06275 }
|
|
|
Definition at line 6262 of file processor.h. 06263 {
06264 return new TestImageSquarecube();
06265 }
|
|
|
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 7440 of file processor.cpp. References EMAN::EMData::get_data(), EMAN::Dict::has_key(), InvalidValueException, nx, ny, EMAN::TestImageProcessor::preprocess(), and EMAN::EMData::update(). 07441 {
07442 preprocess(image);
07443
07444 float edge_length = params["edge_length"];
07445 string axis = (const char*)params["axis"];
07446 float odd_edge = params["odd_edge"];
07447 int fill = 1;
07448 if(params.has_key("fill")) {
07449 fill = (int)params["fill"];
07450 }
07451
07452 float *dat = image->get_data();
07453 float x2, y2, z2; //this coordinates of this pixel from center
07454 float xEdge, yEdge, zEdge; //half of edge length for this cube
07455 if(axis == ""){
07456 xEdge = edge_length/2.0f;
07457 yEdge = edge_length/2.0f;
07458 zEdge = edge_length/2.0f;
07459 }
07460 else if(axis == "x"){
07461 xEdge = odd_edge/2.0f;
07462 yEdge = edge_length/2.0f;
07463 zEdge = edge_length/2.0f;
07464 }
07465 else if(axis == "y"){
07466 xEdge = edge_length/2.0f;
07467 yEdge = odd_edge/2.0f;
07468 zEdge = edge_length/2.0f;
07469 }
07470 else if(axis == "z"){
07471 if( nz == 1 ){
07472 throw InvalidValueException(0, "This is a 2D image, no asymmetric feature for z axis");
07473 }
07474 xEdge = edge_length/2.0f;
07475 yEdge = edge_length/2.0f;
07476 zEdge = odd_edge/2.0f;
07477 }
07478 else{
07479 throw InvalidValueException(0, "please specify a valid axis for asymmetric features");
07480 }
07481 for (int k = 0; k < nz; ++k) {
07482 for (int j = 0; j < ny; ++j) {
07483 for (int i = 0; i < nx; ++i, ++dat) {
07484 x2 = (float)fabs((float)i - nx/2);
07485 y2 = (float)fabs((float)j - ny/2);
07486 z2 = (float)fabs((float)k - nz/2);
07487 if( x2<=xEdge && y2<=yEdge && z2<=zEdge ) {
07488 if( !fill) {
07489 *dat = 0;
07490 }
07491 else {
07492 *dat = 1;
07493 }
07494 }
07495 else {
07496 if( !fill ) {
07497 *dat = 1;
07498 }
07499 else {
07500 *dat = 0;
07501 }
07502 }
07503 }
07504 }
07505 }
07506
07507 image->update();
07508 }
|
|
|
Definition at line 203 of file processor.cpp. |
1.3.9.1