Public Member Functions | Static Public Member Functions | Static Public Attributes
EMAN::TestImageEllipse Class Reference

Generate an ellipse or ellipsoid image. More...

#include <processor.h>

Inheritance diagram for EMAN::TestImageEllipse:
Inheritance graph
Collaboration diagram for EMAN::TestImageEllipse:
Collaboration graph

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

static ProcessorNEW ()

Static Public Attributes

static const string NAME = "testimage.ellipsoid"

Detailed Description

Generate an ellipse or ellipsoid image.

aequatorial radii along x axes
bequatorial radii along y axes
cpolar radius
transformOptionally transform the ellipse
fillvalue you want to fill in ellipse, default to 1.0

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

The description of this processor.

Implements EMAN::Processor.

Definition at line 6824 of file processor.h.

                        return "Insert an ellipse into the image.";
virtual string EMAN::TestImageEllipse::get_name ( ) const [inline, virtual]

Get the processor's name.

Each processor is identified by a unique name.

The processor's name.

Implements EMAN::Processor.

Definition at line 6819 of file processor.h.

References NAME.

                        return NAME;
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.

A dictionary containing the parameter info.

Reimplemented from EMAN::Processor.

Definition at line 6834 of file processor.h.

References EMAN::EMObject::FLOAT, EMAN::TypeDict::put(), and EMAN::EMObject::TRANSFORM.

                        TypeDict d;
                        d.put("a", EMObject::FLOAT, "equatorial radius along x axes (major semiaxes)");
                        d.put("b", EMObject::FLOAT, "equatorial radius along y axes (minor semiaxes)");
                        d.put("c", EMObject::FLOAT, "polar radius for ellipsoid (x^2/a^2+y^2/b^2+z^2/c^2=1)");
                        d.put("transform", EMObject::TRANSFORM, "Optionally transform the ellipse");
                        d.put("fill", EMObject::FLOAT, "value you want to fill in ellipse, default to 1.0");
                        return d;
static Processor* EMAN::TestImageEllipse::NEW ( ) [inline, static]

Definition at line 6829 of file processor.h.

                        return new TestImageEllipse();
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.

imageThe image to be processed.

Implements EMAN::Processor.

Definition at line 8366 of file processor.cpp.

References b, bi, EMAN::Dict::has_key(), nx, ny, EMAN::Processor::params, EMAN::Dict::set_default(), EMAN::EMData::set_value_at(), t, EMAN::EMData::update(), and v.


        float a = params.set_default("a",nx/2.0f-1.0f);
        float b = params.set_default("b",ny/2.0f-1.0f);
        float c = params.set_default("c",nz/2.0f-1.0f);
        float fill = params.set_default("fill",1.0f);
        //bool hollow = params.set_default("hollow",false);
        Transform* t;
        if (params.has_key("transform")) {
                t = params["transform"];
        } else {
                t = new Transform;

        int mz = 2*(int)c+1;
        if ( nz < mz ) mz = nz;
        int my = 2*(int)b+1;
        if ( ny < my ) my = ny;
        int mx = 2*(int)a+1;
        if ( nx < mx ) mx = nx;

        float ai = 1/(a*a);
        float bi = 1/(b*b);
        float ci = 1/(c*c);

        Vec3f origin(nx/2,ny/2,nz/2);

        float x2, y2, z2, r;
        int xl, yl, zl;
        for (int k = 0; k < mz; ++k) {
                for (int j = 0; j < my; ++j) {
                        for (int i = 0; i < mx; ++i) {
                                x2 = (float)(i - mx/2);
                                y2 = (float)(j - my/2);
                                z2 = (float)(k - mz/2);
                                r = (x2*x2)*ai + (y2*y2)*bi + (z2*z2)*ci;
                                if (r <= 1) {

                                        if (t != 0) {
                                                Vec3f v(x2,y2,z2);
                                                v = (*t)*v;
                                                v += origin;

                                                // THIS ISN'T THE BEST STRATEGY BUT IT'S A STOP GAP. A FLOOD FILL IS PROBABLY BETTER
                                                // I fill in 3x3 cubes to make sure there are no gaps...

                                                for( int kk = -1; kk <= 1; ++kk)
                                                        for( int jj = -1; jj <= 1; ++jj)
                                                                for( int ii = -1; ii <= 1; ++ii) {
                                                                        xl = (int)v[0]+ii;
                                                                        yl = (int)v[1]+jj;
                                                                        zl = (int)v[2]+kk;
                                                                        if (xl >= 0 && xl < nx && yl >= 0 && yl < ny && zl >= 0 && zl < nz)
                                        } else {

        delete t;


Member Data Documentation

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

Definition at line 6845 of file processor.h.

Referenced by get_name().

The documentation for this class was generated from the following files: