#include <processor.h>
Inheritance diagram for EMAN::TestImageCylinder:
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.cylinder" |
radius | radius for the cylinder | |
height | height for the cylinder, by default it's the nz |
Definition at line 6521 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 6531 of file processor.h. 06532 { 06533 return "Replace a source image as a cylinder"; 06534 }
|
|
Get the processor's name. Each processor is identified by a unique name.
Implements EMAN::Processor. Definition at line 6526 of file processor.h. 06527 {
06528 return NAME;
06529 }
|
|
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 6541 of file processor.h. References EMAN::TypeDict::put(). 06542 { 06543 TypeDict d; 06544 d.put("radius", EMObject::FLOAT, "radius for the cylinder"); 06545 d.put("height", EMObject::FLOAT, "height for the cylinder, by default it's the nz"); 06546 06547 return d; 06548 }
|
|
Definition at line 6536 of file processor.h. 06537 { 06538 return new TestImageCylinder(); 06539 }
|
|
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 7670 of file processor.cpp. References EMAN::EMData::get_data(), EMAN::EMData::get_xsize(), EMAN::EMData::get_ysize(), EMAN::EMData::get_zsize(), EMAN::Dict::has_key(), ImageDimensionException, InvalidValueException, min, nx, ny, EMAN::TestImageProcessor::preprocess(), and EMAN::EMData::update(). 07671 { 07672 preprocess(image); 07673 07674 int nx = image->get_xsize(); 07675 int ny = image->get_ysize(); 07676 int nz = image->get_zsize(); 07677 07678 if(nz == 1) { 07679 throw ImageDimensionException("This processor only apply to 3D image"); 07680 } 07681 07682 float radius = params["radius"]; 07683 #ifdef _WIN32 07684 if(radius > _cpp_min(nx, ny)/2.0) { 07685 #else 07686 if(radius > std::min(nx, ny)/2.0) { 07687 #endif 07688 throw InvalidValueException(radius, "radius must be <= min(nx, ny)/2"); 07689 } 07690 07691 float height; 07692 if(params.has_key("height")) { 07693 height = params["height"]; 07694 if(height > nz) { 07695 throw InvalidValueException(radius, "height must be <= nz"); 07696 } 07697 } 07698 else { 07699 height = static_cast<float>(nz); 07700 } 07701 07702 float *dat = image->get_data(); 07703 float x2, y2; //this is coordinates of this pixel from center axle 07704 float r = 0.0f; 07705 for (int k = 0; k < nz; ++k) { 07706 for (int j = 0; j < ny; ++j) { 07707 for (int i = 0; i < nx; ++i, ++dat) { 07708 x2 = fabs((float)i - nx/2); 07709 y2 = fabs((float)j - ny/2); 07710 r = (x2*x2)/(radius*radius) + (y2*y2)/(radius*radius); 07711 07712 if(r<=1 && k>=(nz-height)/2 && k<=(nz+height)/2) { 07713 *dat = 1; 07714 } 07715 else { 07716 *dat = 0; 07717 } 07718 } 07719 } 07720 } 07721 07722 image->update(); 07723 }
|
|
Definition at line 209 of file processor.cpp. |