#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 6604 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 6614 of file processor.h. 06615 { 06616 return "Replace a source image as a cylinder"; 06617 }
|
|
Get the processor's name. Each processor is identified by a unique name.
Implements EMAN::Processor. Definition at line 6609 of file processor.h. 06610 {
06611 return NAME;
06612 }
|
|
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 6624 of file processor.h. References EMAN::TypeDict::put(). 06625 { 06626 TypeDict d; 06627 d.put("radius", EMObject::FLOAT, "radius for the cylinder"); 06628 d.put("height", EMObject::FLOAT, "height for the cylinder, by default it's the nz"); 06629 06630 return d; 06631 }
|
|
Definition at line 6619 of file processor.h. 06620 { 06621 return new TestImageCylinder(); 06622 }
|
|
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 7961 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(). 07962 { 07963 preprocess(image); 07964 07965 int nx = image->get_xsize(); 07966 int ny = image->get_ysize(); 07967 int nz = image->get_zsize(); 07968 07969 if(nz == 1) { 07970 throw ImageDimensionException("This processor only apply to 3D image"); 07971 } 07972 07973 float radius = params["radius"]; 07974 #ifdef _WIN32 07975 if(radius > _cpp_min(nx, ny)/2.0) { 07976 #else 07977 if(radius > std::min(nx, ny)/2.0) { 07978 #endif 07979 throw InvalidValueException(radius, "radius must be <= min(nx, ny)/2"); 07980 } 07981 07982 float height; 07983 if(params.has_key("height")) { 07984 height = params["height"]; 07985 if(height > nz) { 07986 throw InvalidValueException(radius, "height must be <= nz"); 07987 } 07988 } 07989 else { 07990 height = static_cast<float>(nz); 07991 } 07992 07993 float *dat = image->get_data(); 07994 float x2, y2; //this is coordinates of this pixel from center axle 07995 float r = 0.0f; 07996 for (int k = 0; k < nz; ++k) { 07997 for (int j = 0; j < ny; ++j) { 07998 for (int i = 0; i < nx; ++i, ++dat) { 07999 x2 = fabs((float)i - nx/2); 08000 y2 = fabs((float)j - ny/2); 08001 r = (x2*x2)/(radius*radius) + (y2*y2)/(radius*radius); 08002 08003 if(r<=1 && k>=(nz-height)/2 && k<=(nz+height)/2) { 08004 *dat = 1; 08005 } 08006 else { 08007 *dat = 0; 08008 } 08009 } 08010 } 08011 } 08012 08013 image->update(); 08014 }
|
|
Definition at line 209 of file processor.cpp. |