#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 6606 of file processor.h.
virtual string EMAN::TestImageCylinder::get_desc | ( | ) | const [inline, virtual] |
Get the descrition of this specific processor.
This function must be overwritten by a subclass.
Implements EMAN::Processor.
Definition at line 6616 of file processor.h.
virtual string EMAN::TestImageCylinder::get_name | ( | ) | const [inline, virtual] |
Get the processor's name.
Each processor is identified by a unique name.
Implements EMAN::Processor.
Definition at line 6611 of file processor.h.
References NAME.
06612 { 06613 return NAME; 06614 }
virtual TypeDict EMAN::TestImageCylinder::get_param_types | ( | ) | const [inline, virtual] |
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 6626 of file processor.h.
References EMAN::EMObject::FLOAT, and EMAN::TypeDict::put().
06627 { 06628 TypeDict d; 06629 d.put("radius", EMObject::FLOAT, "radius for the cylinder"); 06630 d.put("height", EMObject::FLOAT, "height for the cylinder, by default it's the nz"); 06631 06632 return d; 06633 }
static Processor* EMAN::TestImageCylinder::NEW | ( | ) | [inline, static] |
void TestImageCylinder::process_inplace | ( | EMData * | image | ) | [virtual] |
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.
image | The image to be processed. |
Implements EMAN::Processor.
Definition at line 7976 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().
07977 { 07978 preprocess(image); 07979 07980 int nx = image->get_xsize(); 07981 int ny = image->get_ysize(); 07982 int nz = image->get_zsize(); 07983 07984 if(nz == 1) { 07985 throw ImageDimensionException("This processor only apply to 3D image"); 07986 } 07987 07988 float radius = params["radius"]; 07989 #ifdef _WIN32 07990 if(radius > _cpp_min(nx, ny)/2.0) { 07991 #else 07992 if(radius > std::min(nx, ny)/2.0) { 07993 #endif 07994 throw InvalidValueException(radius, "radius must be <= min(nx, ny)/2"); 07995 } 07996 07997 float height; 07998 if(params.has_key("height")) { 07999 height = params["height"]; 08000 if(height > nz) { 08001 throw InvalidValueException(radius, "height must be <= nz"); 08002 } 08003 } 08004 else { 08005 height = static_cast<float>(nz); 08006 } 08007 08008 float *dat = image->get_data(); 08009 float x2, y2; //this is coordinates of this pixel from center axle 08010 float r = 0.0f; 08011 for (int k = 0; k < nz; ++k) { 08012 for (int j = 0; j < ny; ++j) { 08013 for (int i = 0; i < nx; ++i, ++dat) { 08014 x2 = fabs((float)i - nx/2); 08015 y2 = fabs((float)j - ny/2); 08016 r = (x2*x2)/(radius*radius) + (y2*y2)/(radius*radius); 08017 08018 if(r<=1 && k>=(nz-height)/2 && k<=(nz+height)/2) { 08019 *dat = 1; 08020 } 08021 else { 08022 *dat = 0; 08023 } 08024 } 08025 } 08026 } 08027 08028 image->update(); 08029 }
const string TestImageCylinder::NAME = "testimage.cylinder" [static] |