#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 6349 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 6359 of file processor.h. 06360 { 06361 return "Replace a source image as a cylinder"; 06362 }
|
|
Get the processor's name. Each processor is identified by a unique name.
Implements EMAN::Processor. Definition at line 6354 of file processor.h. 06355 {
06356 return NAME;
06357 }
|
|
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 6369 of file processor.h. References EMAN::TypeDict::put(). 06370 { 06371 TypeDict d; 06372 d.put("radius", EMObject::FLOAT, "radius for the cylinder"); 06373 d.put("height", EMObject::FLOAT, "height for the cylinder, by default it's the nz"); 06374 06375 return d; 06376 }
|
|
Definition at line 6364 of file processor.h. 06365 { 06366 return new TestImageCylinder(); 06367 }
|
|
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 7706 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(). 07707 { 07708 preprocess(image); 07709 07710 int nx = image->get_xsize(); 07711 int ny = image->get_ysize(); 07712 int nz = image->get_zsize(); 07713 07714 if(nz == 1) { 07715 throw ImageDimensionException("This processor only apply to 3D image"); 07716 } 07717 07718 float radius = params["radius"]; 07719 #ifdef _WIN32 07720 if(radius > _cpp_min(nx, ny)/2.0) { 07721 #else 07722 if(radius > std::min(nx, ny)/2.0) { 07723 #endif 07724 throw InvalidValueException(radius, "radius must be <= min(nx, ny)/2"); 07725 } 07726 07727 float height; 07728 if(params.has_key("height")) { 07729 height = params["height"]; 07730 if(height > nz) { 07731 throw InvalidValueException(radius, "height must be <= nz"); 07732 } 07733 } 07734 else { 07735 height = static_cast<float>(nz); 07736 } 07737 07738 float *dat = image->get_data(); 07739 float x2, y2; //this is coordinates of this pixel from center axle 07740 float r = 0.0f; 07741 for (int k = 0; k < nz; ++k) { 07742 for (int j = 0; j < ny; ++j) { 07743 for (int i = 0; i < nx; ++i, ++dat) { 07744 x2 = fabs((float)i - nx/2); 07745 y2 = fabs((float)j - ny/2); 07746 r = (x2*x2)/(radius*radius) + (y2*y2)/(radius*radius); 07747 07748 if(r<=1 && k>=(nz-height)/2 && k<=(nz+height)/2) { 07749 *dat = 1; 07750 } 07751 else { 07752 *dat = 0; 07753 } 07754 } 07755 } 07756 } 07757 07758 image->update(); 07759 }
|
|
Definition at line 204 of file processor.cpp. |