Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

EMAN::TestImageEllipse Class Reference

Generate an ellipse or ellipsoid image. More...

#include <processor.h>

Inheritance diagram for EMAN::TestImageEllipse:

Inheritance graph
[legend]
Collaboration diagram for EMAN::TestImageEllipse:

Collaboration graph
[legend]
List of all members.

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

ProcessorNEW ()

Static Public Attributes

const string NAME = "testimage.ellipsoid"

Detailed Description

Generate an ellipse or ellipsoid image.

Parameters:
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 6325 of file processor.h.


Member Function Documentation

virtual string EMAN::TestImageEllipse::get_desc  )  const [inline, virtual]
 

Get the descrition of this specific processor.

This function must be overwritten by a subclass.

Returns:
The description of this processor.

Implements EMAN::Processor.

Definition at line 6335 of file processor.h.

06336                 {
06337                         return "Insert an ellipse into the image.";
06338                 }

virtual string EMAN::TestImageEllipse::get_name  )  const [inline, virtual]
 

Get the processor's name.

Each processor is identified by a unique name.

Returns:
The processor's name.

Implements EMAN::Processor.

Definition at line 6330 of file processor.h.

06331                 {
06332                         return NAME;
06333                 }

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.

Returns:
A dictionary containing the parameter info.

Reimplemented from EMAN::Processor.

Definition at line 6345 of file processor.h.

References EMAN::TypeDict::put().

06346                 {
06347                         TypeDict d;
06348                         d.put("a", EMObject::FLOAT, "equatorial radius along x axes (major semiaxes)");
06349                         d.put("b", EMObject::FLOAT, "equatorial radius along y axes (minor semiaxes)");
06350                         d.put("c", EMObject::FLOAT, "polar radius for ellipsoid (x^2/a^2+y^2/b^2+z^2/c^2=1)");
06351                         d.put("transform", EMObject::TRANSFORM, "Optionally transform the ellipse");
06352                         d.put("fill", EMObject::FLOAT, "value you want to fill in ellipse, default to 1.0");
06353                         return d;
06354                 }

Processor* EMAN::TestImageEllipse::NEW  )  [inline, static]
 

Definition at line 6340 of file processor.h.

06341                 {
06342                         return new TestImageEllipse();
06343                 }

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.

Parameters:
image The image to be processed.

Implements EMAN::Processor.

Definition at line 7690 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.

07691 {
07692         preprocess(image);
07693 
07694 
07695         float a = params.set_default("a",nx/2.0f-1.0f);
07696         float b = params.set_default("b",ny/2.0f-1.0f);
07697         float c = params.set_default("c",nz/2.0f-1.0f);
07698         float fill = params.set_default("fill",1.0f);
07699         //bool hollow = params.set_default("hollow",false);
07700         Transform* t;
07701         if (params.has_key("transform")) {
07702                 t = params["transform"];
07703         } else {
07704                 t = new Transform;
07705         }
07706 
07707 
07708         int mz = 2*(int)c+1;
07709         if ( nz < mz ) mz = nz;
07710         int my = 2*(int)b+1;
07711         if ( ny < my ) my = ny;
07712         int mx = 2*(int)a+1;
07713         if ( nx < mx ) mx = nx;
07714 
07715 
07716         float ai = 1/(a*a);
07717         float bi = 1/(b*b);
07718         float ci = 1/(c*c);
07719 
07720         Vec3f origin(nx/2,ny/2,nz/2);
07721 
07722         float x2, y2, z2, r;
07723         int xl, yl, zl;
07724         for (int k = 0; k < mz; ++k) {
07725                 for (int j = 0; j < my; ++j) {
07726                         for (int i = 0; i < mx; ++i) {
07727                                 x2 = (float)(i - mx/2);
07728                                 y2 = (float)(j - my/2);
07729                                 z2 = (float)(k - mz/2);
07730                                 r = (x2*x2)*ai + (y2*y2)*bi + (z2*z2)*ci;
07731                                 if (r <= 1) {
07732 
07733                                         if (t != 0) {
07734                                                 Vec3f v(x2,y2,z2);
07735                                                 v = (*t)*v;
07736                                                 v += origin;
07737 
07738                                                 // THIS ISN'T THE BEST STRATEGY BUT IT'S A STOP GAP. A FLOOD FILL IS PROBABLY BETTER
07739                                                 // I fill in 3x3 cubes to make sure there are no gaps...
07740 
07741                                                 for( int kk = -1; kk <= 1; ++kk)
07742                                                         for( int jj = -1; jj <= 1; ++jj)
07743                                                                 for( int ii = -1; ii <= 1; ++ii) {
07744                                                                         xl = (int)v[0]+ii;
07745                                                                         yl = (int)v[1]+jj;
07746                                                                         zl = (int)v[2]+kk;
07747                                                                         if (xl >= 0 && xl < nx && yl >= 0 && yl < ny && zl >= 0 && zl < nz)
07748                                                                                 image->set_value_at(xl,yl,zl,fill);
07749                                                                 }
07750                                         } else {
07751                                                 image->set_value_at((int)x2+nx/2,(int)y2+ny/2,(int)z2+nz/2,fill);
07752                                         }
07753                                 }
07754                         }
07755                 }
07756         }
07757 
07758         delete t;
07759 
07760         image->update();
07761 }


Member Data Documentation

const string TestImageEllipse::NAME = "testimage.ellipsoid" [static]
 

Definition at line 209 of file processor.cpp.


The documentation for this class was generated from the following files:
Generated on Tue Jul 12 13:52:40 2011 for EMAN2 by  doxygen 1.3.9.1