#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 | |
static Processor * | NEW () |
Static Public Attributes | |
static 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 6401 of file processor.h.
virtual string EMAN::TestImageEllipse::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 6411 of file processor.h.
virtual string EMAN::TestImageEllipse::get_name | ( | ) | const [inline, virtual] |
Get the processor's name.
Each processor is identified by a unique name.
Implements EMAN::Processor.
Definition at line 6406 of file processor.h.
References NAME.
06407 { 06408 return NAME; 06409 }
virtual TypeDict EMAN::TestImageEllipse::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 6421 of file processor.h.
References EMAN::EMObject::FLOAT, EMAN::TypeDict::put(), and EMAN::EMObject::TRANSFORM.
06422 { 06423 TypeDict d; 06424 d.put("a", EMObject::FLOAT, "equatorial radius along x axes (major semiaxes)"); 06425 d.put("b", EMObject::FLOAT, "equatorial radius along y axes (minor semiaxes)"); 06426 d.put("c", EMObject::FLOAT, "polar radius for ellipsoid (x^2/a^2+y^2/b^2+z^2/c^2=1)"); 06427 d.put("transform", EMObject::TRANSFORM, "Optionally transform the ellipse"); 06428 d.put("fill", EMObject::FLOAT, "value you want to fill in ellipse, default to 1.0"); 06429 return d; 06430 }
static Processor* EMAN::TestImageEllipse::NEW | ( | ) | [inline, static] |
void TestImageEllipse::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 7848 of file processor.cpp.
References b, bi, EMAN::Dict::has_key(), EMAN::Processor::params, EMAN::TestImageProcessor::preprocess(), EMAN::Dict::set_default(), EMAN::EMData::set_value_at(), t, EMAN::EMData::update(), and v.
07849 { 07850 preprocess(image); 07851 07852 07853 float a = params.set_default("a",nx/2.0f-1.0f); 07854 float b = params.set_default("b",ny/2.0f-1.0f); 07855 float c = params.set_default("c",nz/2.0f-1.0f); 07856 float fill = params.set_default("fill",1.0f); 07857 //bool hollow = params.set_default("hollow",false); 07858 Transform* t; 07859 if (params.has_key("transform")) { 07860 t = params["transform"]; 07861 } else { 07862 t = new Transform; 07863 } 07864 07865 07866 int mz = 2*(int)c+1; 07867 if ( nz < mz ) mz = nz; 07868 int my = 2*(int)b+1; 07869 if ( ny < my ) my = ny; 07870 int mx = 2*(int)a+1; 07871 if ( nx < mx ) mx = nx; 07872 07873 07874 float ai = 1/(a*a); 07875 float bi = 1/(b*b); 07876 float ci = 1/(c*c); 07877 07878 Vec3f origin(nx/2,ny/2,nz/2); 07879 07880 float x2, y2, z2, r; 07881 int xl, yl, zl; 07882 for (int k = 0; k < mz; ++k) { 07883 for (int j = 0; j < my; ++j) { 07884 for (int i = 0; i < mx; ++i) { 07885 x2 = (float)(i - mx/2); 07886 y2 = (float)(j - my/2); 07887 z2 = (float)(k - mz/2); 07888 r = (x2*x2)*ai + (y2*y2)*bi + (z2*z2)*ci; 07889 if (r <= 1) { 07890 07891 if (t != 0) { 07892 Vec3f v(x2,y2,z2); 07893 v = (*t)*v; 07894 v += origin; 07895 07896 // THIS ISN'T THE BEST STRATEGY BUT IT'S A STOP GAP. A FLOOD FILL IS PROBABLY BETTER 07897 // I fill in 3x3 cubes to make sure there are no gaps... 07898 07899 for( int kk = -1; kk <= 1; ++kk) 07900 for( int jj = -1; jj <= 1; ++jj) 07901 for( int ii = -1; ii <= 1; ++ii) { 07902 xl = (int)v[0]+ii; 07903 yl = (int)v[1]+jj; 07904 zl = (int)v[2]+kk; 07905 if (xl >= 0 && xl < nx && yl >= 0 && yl < ny && zl >= 0 && zl < nz) 07906 image->set_value_at(xl,yl,zl,fill); 07907 } 07908 } else { 07909 image->set_value_at((int)x2+nx/2,(int)y2+ny/2,(int)z2+nz/2,fill); 07910 } 07911 } 07912 } 07913 } 07914 } 07915 07916 delete t; 07917 07918 image->update(); 07919 }
const string TestImageEllipse::NAME = "testimage.ellipsoid" [static] |