#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 6490 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 6500 of file processor.h. 06501 {
06502 return "Replace a source image as a cylinder";
06503 }
|
|
|
Get the processor's name. Each processor is identified by a unique name.
Implements EMAN::Processor. Definition at line 6495 of file processor.h. 06496 {
06497 return NAME;
06498 }
|
|
|
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 6510 of file processor.h. References EMAN::TypeDict::put(). 06511 {
06512 TypeDict d;
06513 d.put("radius", EMObject::FLOAT, "radius for the cylinder");
06514 d.put("height", EMObject::FLOAT, "height for the cylinder, by default it's the nz");
06515
06516 return d;
06517 }
|
|
|
Definition at line 6505 of file processor.h. 06506 {
06507 return new TestImageCylinder();
06508 }
|
|
|
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 7775 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(). 07776 {
07777 preprocess(image);
07778
07779 int nx = image->get_xsize();
07780 int ny = image->get_ysize();
07781 int nz = image->get_zsize();
07782
07783 if(nz == 1) {
07784 throw ImageDimensionException("This processor only apply to 3D image");
07785 }
07786
07787 float radius = params["radius"];
07788 #ifdef _WIN32
07789 if(radius > _cpp_min(nx, ny)/2.0) {
07790 #else
07791 if(radius > std::min(nx, ny)/2.0) {
07792 #endif
07793 throw InvalidValueException(radius, "radius must be <= min(nx, ny)/2");
07794 }
07795
07796 float height;
07797 if(params.has_key("height")) {
07798 height = params["height"];
07799 if(height > nz) {
07800 throw InvalidValueException(radius, "height must be <= nz");
07801 }
07802 }
07803 else {
07804 height = static_cast<float>(nz);
07805 }
07806
07807 float *dat = image->get_data();
07808 float x2, y2; //this is coordinates of this pixel from center axle
07809 float r = 0.0f;
07810 for (int k = 0; k < nz; ++k) {
07811 for (int j = 0; j < ny; ++j) {
07812 for (int i = 0; i < nx; ++i, ++dat) {
07813 x2 = fabs((float)i - nx/2);
07814 y2 = fabs((float)j - ny/2);
07815 r = (x2*x2)/(radius*radius) + (y2*y2)/(radius*radius);
07816
07817 if(r<=1 && k>=(nz-height)/2 && k<=(nz+height)/2) {
07818 *dat = 1;
07819 }
07820 else {
07821 *dat = 0;
07822 }
07823 }
07824 }
07825 }
07826
07827 image->update();
07828 }
|
|
|
Definition at line 209 of file processor.cpp. |
1.3.9.1