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

EMAN::TestImageHollowEllipse Class Reference

Generate an ellipse/ellipsoid image with an inner hollow ellipse/ellipsoid. More...

#include <processor.h>

Inheritance diagram for EMAN::TestImageHollowEllipse:

[legend]
Collaboration diagram for EMAN::TestImageHollowEllipse:
[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.hollow"

Detailed Description

Generate an ellipse/ellipsoid image with an inner hollow ellipse/ellipsoid.

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


Member Function Documentation

virtual string EMAN::TestImageHollowEllipse::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 6373 of file processor.h.

06374                         {
06375                                 return "Insert a hollow ellipse into the image.";
06376                         }

virtual string EMAN::TestImageHollowEllipse::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 6368 of file processor.h.

06369                         {
06370                                 return NAME;
06371                         }

virtual TypeDict EMAN::TestImageHollowEllipse::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 6383 of file processor.h.

References EMAN::TypeDict::put().

06384                         {
06385                                 TypeDict d;
06386                                 d.put("xwidth", EMObject::FLOAT, "inner equatorial radii along x axes");
06387                                 d.put("ywidth", EMObject::FLOAT, "inner equatorial radii along y axes");
06388                                 d.put("zwidth", EMObject::FLOAT, "inner polar radius");
06389                                 d.put("a", EMObject::FLOAT, "outter equatorial radii along x axes");
06390                                 d.put("b", EMObject::FLOAT, "outter equatorial radii along y axes");
06391                                 d.put("c", EMObject::FLOAT, "outter polar radius");
06392                                 d.put("width",EMObject::FLOAT, "width - specify the width or specify each width explicitly - xwidth, ywidth, zwidth");
06393                                 d.put("transform", EMObject::TRANSFORM, "Optionally transform the ellipse");
06394                                 d.put("fill", EMObject::FLOAT, "value you want to fill in hollow ellipse, default to 1.0");
06395                                 return d;
06396                         }

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

Definition at line 6378 of file processor.h.

06379                         {
06380                                 return new TestImageHollowEllipse();
06381                         }

void TestImageHollowEllipse::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 7475 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.

07476 {
07477         preprocess(image);
07478 
07479         float width = params.set_default("width",2.0f);
07480 
07481         float a2 = params.set_default("a",nx/2.0f-1.0f);
07482         float b2 = params.set_default("b",ny/2.0f-1.0f);
07483         float c2 = params.set_default("c",nz/2.0f-1.0f);
07484 
07485         float a1 = params.set_default("xwidth",a2-width);
07486         float b1 = params.set_default("ywidth",b2-width);
07487         float c1 = params.set_default("zwidth",c2-width);
07488 
07489         float fill = params.set_default("fill",1.0f);
07490         Transform* t;
07491         if (params.has_key("transform")) {
07492                 t = params["transform"];
07493         } else {
07494                 t = new Transform;
07495         }
07496 
07497 
07498         int mz = 2*(int)c2+1;
07499         if ( nz < mz ) mz = nz;
07500         int my = 2*(int)b2+1;
07501         if ( ny < my ) my = ny;
07502         int mx = 2*(int)a2+1;
07503         if ( nx < mx ) mx = nx;
07504 
07505         float ai1 = 1/(a1*a1);
07506         float bi1 = 1/(b1*b1);
07507         float ci1 = 1/(c1*c1);
07508 
07509         float ai2 = 1/(a2*a2);
07510         float bi2 = 1/(b2*b2);
07511         float ci2 = 1/(c2*c2);
07512 
07513         Vec3f origin(nx/2,ny/2,nz/2);
07514 
07515         float x2, y2, z2, r1,r2;
07516         int xl, yl, zl;
07517         for (int k = 0; k < mz; ++k) {
07518                 for (int j = 0; j < my; ++j) {
07519                         for (int i = 0; i < mx; ++i) {
07520                                 x2 = (float)(i - mx/2);
07521                                 y2 = (float)(j - my/2);
07522                                 z2 = (float)(k - mz/2);
07523                                 r1 = (x2*x2)*ai1 + (y2*y2)*bi1 + (z2*z2)*ci1;
07524                                 r2 = (x2*x2)*ai2 + (y2*y2)*bi2 + (z2*z2)*ci2;
07525                                 if (r2 <= 1 && r1 >= 1) {
07526 
07527                                         if (t != 0) {
07528                                                 Vec3f v(x2,y2,z2);
07529                                                 v = (*t)*v;
07530                                                 v += origin;
07531 
07532                                                 // THIS ISN'T THE BEST STRATEGY BUT IT'S A STOP GAP. A FLOOD FILL IS PROBABLY BETTER
07533                                                 // I fill in 3x3 cubes to make sure there are no gaps...
07534 
07535                                                 for( int kk = -1; kk <= 1; ++kk)
07536                                                         for( int jj = -1; jj <= 1; ++jj)
07537                                                                 for( int ii = -1; ii <= 1; ++ii) {
07538                                                                         xl = (int)v[0]+ii;
07539                                                                         yl = (int)v[1]+jj;
07540                                                                         zl = (int)v[2]+kk;
07541                                                                         if (xl >= 0 && xl < nx && yl >= 0 && yl < ny && zl >= 0 && zl < nz)
07542                                                                                 image->set_value_at(xl,yl,zl,1.0);
07543                                                                 }
07544                                         } else {
07545                                                 image->set_value_at((int)x2+nx/2,(int)y2+ny/2,(int)z2+nz/2,fill);
07546                                         }
07547                                 }
07548                         }
07549                 }
07550         }
07551 
07552         delete t;
07553 
07554         image->update();
07555 }


Member Data Documentation

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

Definition at line 205 of file processor.cpp.


The documentation for this class was generated from the following files:
Generated on Fri Apr 30 15:39:29 2010 for EMAN2 by  doxygen 1.3.9.1