#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 6528 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 6538 of file processor.h. 06539 { 06540 return "Replace a source image as a cylinder"; 06541 }
|
|
Get the processor's name. Each processor is identified by a unique name.
Implements EMAN::Processor. Definition at line 6533 of file processor.h. 06534 {
06535 return NAME;
06536 }
|
|
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 6548 of file processor.h. References EMAN::TypeDict::put(). 06549 { 06550 TypeDict d; 06551 d.put("radius", EMObject::FLOAT, "radius for the cylinder"); 06552 d.put("height", EMObject::FLOAT, "height for the cylinder, by default it's the nz"); 06553 06554 return d; 06555 }
|
|
Definition at line 6543 of file processor.h. 06544 { 06545 return new TestImageCylinder(); 06546 }
|
|
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 7803 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(). 07804 { 07805 preprocess(image); 07806 07807 int nx = image->get_xsize(); 07808 int ny = image->get_ysize(); 07809 int nz = image->get_zsize(); 07810 07811 if(nz == 1) { 07812 throw ImageDimensionException("This processor only apply to 3D image"); 07813 } 07814 07815 float radius = params["radius"]; 07816 #ifdef _WIN32 07817 if(radius > _cpp_min(nx, ny)/2.0) { 07818 #else 07819 if(radius > std::min(nx, ny)/2.0) { 07820 #endif 07821 throw InvalidValueException(radius, "radius must be <= min(nx, ny)/2"); 07822 } 07823 07824 float height; 07825 if(params.has_key("height")) { 07826 height = params["height"]; 07827 if(height > nz) { 07828 throw InvalidValueException(radius, "height must be <= nz"); 07829 } 07830 } 07831 else { 07832 height = static_cast<float>(nz); 07833 } 07834 07835 float *dat = image->get_data(); 07836 float x2, y2; //this is coordinates of this pixel from center axle 07837 float r = 0.0f; 07838 for (int k = 0; k < nz; ++k) { 07839 for (int j = 0; j < ny; ++j) { 07840 for (int i = 0; i < nx; ++i, ++dat) { 07841 x2 = fabs((float)i - nx/2); 07842 y2 = fabs((float)j - ny/2); 07843 r = (x2*x2)/(radius*radius) + (y2*y2)/(radius*radius); 07844 07845 if(r<=1 && k>=(nz-height)/2 && k<=(nz+height)/2) { 07846 *dat = 1; 07847 } 07848 else { 07849 *dat = 0; 07850 } 07851 } 07852 } 07853 } 07854 07855 image->update(); 07856 }
|
|
Definition at line 214 of file processor.cpp. |