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 6403 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 6413 of file processor.h.

06414                 {
06415                         return "Insert an ellipse into the image.";
06416                 }

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 6408 of file processor.h.

06409                 {
06410                         return NAME;
06411                 }

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 6423 of file processor.h.

References EMAN::TypeDict::put().

06424                 {
06425                         TypeDict d;
06426                         d.put("a", EMObject::FLOAT, "equatorial radius along x axes (major semiaxes)");
06427                         d.put("b", EMObject::FLOAT, "equatorial radius along y axes (minor semiaxes)");
06428                         d.put("c", EMObject::FLOAT, "polar radius for ellipsoid (x^2/a^2+y^2/b^2+z^2/c^2=1)");
06429                         d.put("transform", EMObject::TRANSFORM, "Optionally transform the ellipse");
06430                         d.put("fill", EMObject::FLOAT, "value you want to fill in ellipse, default to 1.0");
06431                         return d;
06432                 }

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

Definition at line 6418 of file processor.h.

06419                 {
06420                         return new TestImageEllipse();
06421                 }

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 7863 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.

07864 {
07865         preprocess(image);
07866 
07867 
07868         float a = params.set_default("a",nx/2.0f-1.0f);
07869         float b = params.set_default("b",ny/2.0f-1.0f);
07870         float c = params.set_default("c",nz/2.0f-1.0f);
07871         float fill = params.set_default("fill",1.0f);
07872         //bool hollow = params.set_default("hollow",false);
07873         Transform* t;
07874         if (params.has_key("transform")) {
07875                 t = params["transform"];
07876         } else {
07877                 t = new Transform;
07878         }
07879 
07880 
07881         int mz = 2*(int)c+1;
07882         if ( nz < mz ) mz = nz;
07883         int my = 2*(int)b+1;
07884         if ( ny < my ) my = ny;
07885         int mx = 2*(int)a+1;
07886         if ( nx < mx ) mx = nx;
07887 
07888 
07889         float ai = 1/(a*a);
07890         float bi = 1/(b*b);
07891         float ci = 1/(c*c);
07892 
07893         Vec3f origin(nx/2,ny/2,nz/2);
07894 
07895         float x2, y2, z2, r;
07896         int xl, yl, zl;
07897         for (int k = 0; k < mz; ++k) {
07898                 for (int j = 0; j < my; ++j) {
07899                         for (int i = 0; i < mx; ++i) {
07900                                 x2 = (float)(i - mx/2);
07901                                 y2 = (float)(j - my/2);
07902                                 z2 = (float)(k - mz/2);
07903                                 r = (x2*x2)*ai + (y2*y2)*bi + (z2*z2)*ci;
07904                                 if (r <= 1) {
07905 
07906                                         if (t != 0) {
07907                                                 Vec3f v(x2,y2,z2);
07908                                                 v = (*t)*v;
07909                                                 v += origin;
07910 
07911                                                 // THIS ISN'T THE BEST STRATEGY BUT IT'S A STOP GAP. A FLOOD FILL IS PROBABLY BETTER
07912                                                 // I fill in 3x3 cubes to make sure there are no gaps...
07913 
07914                                                 for( int kk = -1; kk <= 1; ++kk)
07915                                                         for( int jj = -1; jj <= 1; ++jj)
07916                                                                 for( int ii = -1; ii <= 1; ++ii) {
07917                                                                         xl = (int)v[0]+ii;
07918                                                                         yl = (int)v[1]+jj;
07919                                                                         zl = (int)v[2]+kk;
07920                                                                         if (xl >= 0 && xl < nx && yl >= 0 && yl < ny && zl >= 0 && zl < nz)
07921                                                                                 image->set_value_at(xl,yl,zl,fill);
07922                                                                 }
07923                                         } else {
07924                                                 image->set_value_at((int)x2+nx/2,(int)y2+ny/2,(int)z2+nz/2,fill);
07925                                         }
07926                                 }
07927                         }
07928                 }
07929         }
07930 
07931         delete t;
07932 
07933         image->update();
07934 }


Member Data Documentation

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

Definition at line 204 of file processor.cpp.


The documentation for this class was generated from the following files:
Generated on Fri Aug 10 16:37:37 2012 for EMAN2 by  doxygen 1.3.9.1