#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 6559 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 6569 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 6564 of file processor.h.
References NAME.
06565 { 06566 return NAME; 06567 }
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 6579 of file processor.h.
References EMAN::EMObject::FLOAT, and EMAN::TypeDict::put().
06580 { 06581 TypeDict d; 06582 d.put("radius", EMObject::FLOAT, "radius for the cylinder"); 06583 d.put("height", EMObject::FLOAT, "height for the cylinder, by default it's the nz"); 06584 06585 return d; 06586 }
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 7889 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().
07890 { 07891 preprocess(image); 07892 07893 int nx = image->get_xsize(); 07894 int ny = image->get_ysize(); 07895 int nz = image->get_zsize(); 07896 07897 if(nz == 1) { 07898 throw ImageDimensionException("This processor only apply to 3D image"); 07899 } 07900 07901 float radius = params["radius"]; 07902 #ifdef _WIN32 07903 if(radius > _cpp_min(nx, ny)/2.0) { 07904 #else 07905 if(radius > std::min(nx, ny)/2.0) { 07906 #endif 07907 throw InvalidValueException(radius, "radius must be <= min(nx, ny)/2"); 07908 } 07909 07910 float height; 07911 if(params.has_key("height")) { 07912 height = params["height"]; 07913 if(height > nz) { 07914 throw InvalidValueException(radius, "height must be <= nz"); 07915 } 07916 } 07917 else { 07918 height = static_cast<float>(nz); 07919 } 07920 07921 float *dat = image->get_data(); 07922 float x2, y2; //this is coordinates of this pixel from center axle 07923 float r = 0.0f; 07924 for (int k = 0; k < nz; ++k) { 07925 for (int j = 0; j < ny; ++j) { 07926 for (int i = 0; i < nx; ++i, ++dat) { 07927 x2 = fabs((float)i - nx/2); 07928 y2 = fabs((float)j - ny/2); 07929 r = (x2*x2)/(radius*radius) + (y2*y2)/(radius*radius); 07930 07931 if(r<=1 && k>=(nz-height)/2 && k<=(nz+height)/2) { 07932 *dat = 1; 07933 } 07934 else { 07935 *dat = 0; 07936 } 07937 } 07938 } 07939 } 07940 07941 image->update(); 07942 }
const string TestImageCylinder::NAME = "testimage.cylinder" [static] |