#include <processor.h>
Inheritance diagram for EMAN::TestImageHollowEllipse:
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.ellipsoid.hollow" |
xwidth | inner equatorial radii along x axes | |
ywidth | inner equatorial radii along y axes | |
zwidth | inner polar radius | |
a | outter equatorial radii along x axes | |
b | outter equatorial radii along y axes | |
c | outter polar radius | |
width | specify the width or specify each width explicitly - xwidth, ywidth, zwidth | |
transform | Optionally transform the ellipse | |
fill | value you want to fill in hollow ellipse, default to 1.0 |
Definition at line 6370 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 6380 of file processor.h. 06381 { 06382 return "Insert a hollow ellipse into the image."; 06383 }
|
|
Get the processor's name. Each processor is identified by a unique name.
Implements EMAN::Processor. Definition at line 6375 of file processor.h. 06376 {
06377 return NAME;
06378 }
|
|
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 6390 of file processor.h. References EMAN::TypeDict::put(). 06391 { 06392 TypeDict d; 06393 d.put("xwidth", EMObject::FLOAT, "inner equatorial radii along x axes"); 06394 d.put("ywidth", EMObject::FLOAT, "inner equatorial radii along y axes"); 06395 d.put("zwidth", EMObject::FLOAT, "inner polar radius"); 06396 d.put("a", EMObject::FLOAT, "outter equatorial radii along x axes"); 06397 d.put("b", EMObject::FLOAT, "outter equatorial radii along y axes"); 06398 d.put("c", EMObject::FLOAT, "outter polar radius"); 06399 d.put("width",EMObject::FLOAT, "width - specify the width or specify each width explicitly - xwidth, ywidth, zwidth"); 06400 d.put("transform", EMObject::TRANSFORM, "Optionally transform the ellipse"); 06401 d.put("fill", EMObject::FLOAT, "value you want to fill in hollow ellipse, default to 1.0"); 06402 return d; 06403 }
|
|
Definition at line 6385 of file processor.h. 06386 { 06387 return new TestImageHollowEllipse(); 06388 }
|
|
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 7608 of file processor.cpp. References EMAN::Dict::has_key(), nx, ny, EMAN::TestImageProcessor::preprocess(), EMAN::Dict::set_default(), EMAN::EMData::set_value_at(), t, EMAN::EMData::update(), v, and EMAN::Vec3f. 07609 { 07610 preprocess(image); 07611 07612 float width = params.set_default("width",2.0f); 07613 07614 float a2 = params.set_default("a",nx/2.0f-1.0f); 07615 float b2 = params.set_default("b",ny/2.0f-1.0f); 07616 float c2 = params.set_default("c",nz/2.0f-1.0f); 07617 07618 float a1 = params.set_default("xwidth",a2-width); 07619 float b1 = params.set_default("ywidth",b2-width); 07620 float c1 = params.set_default("zwidth",c2-width); 07621 07622 float fill = params.set_default("fill",1.0f); 07623 Transform* t; 07624 if (params.has_key("transform")) { 07625 t = params["transform"]; 07626 } else { 07627 t = new Transform; 07628 } 07629 07630 07631 int mz = 2*(int)c2+1; 07632 if ( nz < mz ) mz = nz; 07633 int my = 2*(int)b2+1; 07634 if ( ny < my ) my = ny; 07635 int mx = 2*(int)a2+1; 07636 if ( nx < mx ) mx = nx; 07637 07638 float ai1 = 1/(a1*a1); 07639 float bi1 = 1/(b1*b1); 07640 float ci1 = 1/(c1*c1); 07641 07642 float ai2 = 1/(a2*a2); 07643 float bi2 = 1/(b2*b2); 07644 float ci2 = 1/(c2*c2); 07645 07646 Vec3f origin(nx/2,ny/2,nz/2); 07647 07648 float x2, y2, z2, r1,r2; 07649 int xl, yl, zl; 07650 for (int k = 0; k < mz; ++k) { 07651 for (int j = 0; j < my; ++j) { 07652 for (int i = 0; i < mx; ++i) { 07653 x2 = (float)(i - mx/2); 07654 y2 = (float)(j - my/2); 07655 z2 = (float)(k - mz/2); 07656 r1 = (x2*x2)*ai1 + (y2*y2)*bi1 + (z2*z2)*ci1; 07657 r2 = (x2*x2)*ai2 + (y2*y2)*bi2 + (z2*z2)*ci2; 07658 if (r2 <= 1 && r1 >= 1) { 07659 07660 if (t != 0) { 07661 Vec3f v(x2,y2,z2); 07662 v = (*t)*v; 07663 v += origin; 07664 07665 // THIS ISN'T THE BEST STRATEGY BUT IT'S A STOP GAP. A FLOOD FILL IS PROBABLY BETTER 07666 // I fill in 3x3 cubes to make sure there are no gaps... 07667 07668 for( int kk = -1; kk <= 1; ++kk) 07669 for( int jj = -1; jj <= 1; ++jj) 07670 for( int ii = -1; ii <= 1; ++ii) { 07671 xl = (int)v[0]+ii; 07672 yl = (int)v[1]+jj; 07673 zl = (int)v[2]+kk; 07674 if (xl >= 0 && xl < nx && yl >= 0 && yl < ny && zl >= 0 && zl < nz) 07675 image->set_value_at(xl,yl,zl,1.0); 07676 } 07677 } else { 07678 image->set_value_at((int)x2+nx/2,(int)y2+ny/2,(int)z2+nz/2,fill); 07679 } 07680 } 07681 } 07682 } 07683 } 07684 07685 delete t; 07686 07687 image->update(); 07688 }
|
|
Definition at line 210 of file processor.cpp. |