#include <processor.h>
Inheritance diagram for EMAN::TestImageEllipse:
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" |
a | equatorial radii along x axes | |
b | equatorial radii along y axes | |
c | polar radius | |
transform | Optionally transform the ellipse | |
fill | value you want to fill in ellipse, default to 1.0 |
Definition at line 6146 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 6156 of file processor.h. 06157 { 06158 return "Insert an ellipse into the image."; 06159 }
|
|
Get the processor's name. Each processor is identified by a unique name.
Implements EMAN::Processor. Definition at line 6151 of file processor.h. 06152 {
06153 return NAME;
06154 }
|
|
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 6166 of file processor.h. References EMAN::TypeDict::put(). 06167 { 06168 TypeDict d; 06169 d.put("a", EMObject::FLOAT, "equatorial radius along x axes (major semiaxes)"); 06170 d.put("b", EMObject::FLOAT, "equatorial radius along y axes (minor semiaxes)"); 06171 d.put("c", EMObject::FLOAT, "polar radius for ellipsoid (x^2/a^2+y^2/b^2+z^2/c^2=1)"); 06172 d.put("transform", EMObject::TRANSFORM, "Optionally transform the ellipse"); 06173 d.put("fill", EMObject::FLOAT, "value you want to fill in ellipse, default to 1.0"); 06174 return d; 06175 }
|
|
Definition at line 6161 of file processor.h. 06162 { 06163 return new TestImageEllipse(); 06164 }
|
|
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 7593 of file processor.cpp. References b, bi, 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. 07594 { 07595 preprocess(image); 07596 07597 07598 float a = params.set_default("a",nx/2.0f-1.0f); 07599 float b = params.set_default("b",ny/2.0f-1.0f); 07600 float c = params.set_default("c",nz/2.0f-1.0f); 07601 float fill = params.set_default("fill",1.0f); 07602 //bool hollow = params.set_default("hollow",false); 07603 Transform* t; 07604 if (params.has_key("transform")) { 07605 t = params["transform"]; 07606 } else { 07607 t = new Transform; 07608 } 07609 07610 07611 int mz = 2*(int)c+1; 07612 if ( nz < mz ) mz = nz; 07613 int my = 2*(int)b+1; 07614 if ( ny < my ) my = ny; 07615 int mx = 2*(int)a+1; 07616 if ( nx < mx ) mx = nx; 07617 07618 07619 float ai = 1/(a*a); 07620 float bi = 1/(b*b); 07621 float ci = 1/(c*c); 07622 07623 Vec3f origin(nx/2,ny/2,nz/2); 07624 07625 float x2, y2, z2, r; 07626 int xl, yl, zl; 07627 for (int k = 0; k < mz; ++k) { 07628 for (int j = 0; j < my; ++j) { 07629 for (int i = 0; i < mx; ++i) { 07630 x2 = (float)(i - mx/2); 07631 y2 = (float)(j - my/2); 07632 z2 = (float)(k - mz/2); 07633 r = (x2*x2)*ai + (y2*y2)*bi + (z2*z2)*ci; 07634 if (r <= 1) { 07635 07636 if (t != 0) { 07637 Vec3f v(x2,y2,z2); 07638 v = (*t)*v; 07639 v += origin; 07640 07641 // THIS ISN'T THE BEST STRATEGY BUT IT'S A STOP GAP. A FLOOD FILL IS PROBABLY BETTER 07642 // I fill in 3x3 cubes to make sure there are no gaps... 07643 07644 for( int kk = -1; kk <= 1; ++kk) 07645 for( int jj = -1; jj <= 1; ++jj) 07646 for( int ii = -1; ii <= 1; ++ii) { 07647 xl = (int)v[0]+ii; 07648 yl = (int)v[1]+jj; 07649 zl = (int)v[2]+kk; 07650 if (xl >= 0 && xl < nx && yl >= 0 && yl < ny && zl >= 0 && zl < nz) 07651 image->set_value_at(xl,yl,zl,fill); 07652 } 07653 } else { 07654 image->set_value_at((int)x2+nx/2,(int)y2+ny/2,(int)z2+nz/2,fill); 07655 } 07656 } 07657 } 07658 } 07659 } 07660 07661 delete t; 07662 07663 image->update(); 07664 }
|
|
Definition at line 199 of file processor.cpp. |