#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 | |
static Processor * | NEW () |
Static Public Attributes | |
static const string | NAME = "testimage.cylinder" |
radius | radius for the cylinder | |
height | height for the cylinder, by default it's the nz |
Definition at line 6562 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 6572 of file processor.h.
|
|
Get the processor's name. Each processor is identified by a unique name.
Implements EMAN::Processor. Definition at line 6567 of file processor.h. References NAME. 06568 { 06569 return NAME; 06570 }
|
|
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 6582 of file processor.h. References EMAN::EMObject::FLOAT, and EMAN::TypeDict::put(). 06583 { 06584 TypeDict d; 06585 d.put("radius", EMObject::FLOAT, "radius for the cylinder"); 06586 d.put("height", EMObject::FLOAT, "height for the cylinder, by default it's the nz"); 06587 06588 return d; 06589 }
|
|
Definition at line 6577 of file processor.h. 06578 { 06579 return new TestImageCylinder(); 06580 }
|
|
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 7808 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, EMAN::Processor::params, EMAN::TestImageProcessor::preprocess(), and EMAN::EMData::update(). 07809 { 07810 preprocess(image); 07811 07812 int nx = image->get_xsize(); 07813 int ny = image->get_ysize(); 07814 int nz = image->get_zsize(); 07815 07816 if(nz == 1) { 07817 throw ImageDimensionException("This processor only apply to 3D image"); 07818 } 07819 07820 float radius = params["radius"]; 07821 #ifdef _WIN32 07822 if(radius > _cpp_min(nx, ny)/2.0) { 07823 #else 07824 if(radius > std::min(nx, ny)/2.0) { 07825 #endif 07826 throw InvalidValueException(radius, "radius must be <= min(nx, ny)/2"); 07827 } 07828 07829 float height; 07830 if(params.has_key("height")) { 07831 height = params["height"]; 07832 if(height > nz) { 07833 throw InvalidValueException(radius, "height must be <= nz"); 07834 } 07835 } 07836 else { 07837 height = static_cast<float>(nz); 07838 } 07839 07840 float *dat = image->get_data(); 07841 float x2, y2; //this is coordinates of this pixel from center axle 07842 float r = 0.0f; 07843 for (int k = 0; k < nz; ++k) { 07844 for (int j = 0; j < ny; ++j) { 07845 for (int i = 0; i < nx; ++i, ++dat) { 07846 x2 = fabs((float)i - nx/2); 07847 y2 = fabs((float)j - ny/2); 07848 r = (x2*x2)/(radius*radius) + (y2*y2)/(radius*radius); 07849 07850 if(r<=1 && k>=(nz-height)/2 && k<=(nz+height)/2) { 07851 *dat = 1; 07852 } 07853 else { 07854 *dat = 0; 07855 } 07856 } 07857 } 07858 } 07859 07860 image->update(); 07861 }
|
|
Definition at line 6591 of file processor.h. Referenced by get_name(). |