EMAN2
Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all 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]

Public Member Functions

virtual void process_inplace (EMData *image)
 To process an image in-place. More...
 
virtual string get_name () const
 Get the processor's name. More...
 
virtual string get_desc () const
 Get the descrition of this specific processor. More...
 
virtual TypeDict get_param_types () const
 Get processor parameter information in a dictionary. More...
 
- Public Member Functions inherited from EMAN::Processor
virtual ~Processor ()
 
virtual EMDataprocess (const EMData *const image)
 To proccess an image out-of-place. More...
 
virtual void process_list_inplace (vector< EMData * > &images)
 To process multiple images using the same algorithm. More...
 
virtual Dict get_params () const
 Get the processor parameters in a key/value dictionary. More...
 
virtual void set_params (const Dict &new_params)
 Set the processor parameters using a key/value dictionary. More...
 

Static Public Member Functions

static ProcessorNEW ()
 
- Static Public Member Functions inherited from EMAN::TestImageProcessor
static string get_group_desc ()
 
- Static Public Member Functions inherited from EMAN::Processor
static string get_group_desc ()
 Get the description of this group of processors. More...
 
static void EMFourierFilterInPlace (EMData *fimage, Dict params)
 Compute a Fourier-filter processed image in place. More...
 
static EMDataEMFourierFilter (EMData *fimage, Dict params)
 Compute a Fourier-processor processed image without altering the original image. More...
 

Static Public Attributes

static const string NAME = "testimage.ellipsoid"
 

Additional Inherited Members

- Public Types inherited from EMAN::Processor
enum  fourier_filter_types {
  TOP_HAT_LOW_PASS , TOP_HAT_HIGH_PASS , TOP_HAT_BAND_PASS , TOP_HOMOMORPHIC ,
  GAUSS_LOW_PASS , GAUSS_HIGH_PASS , GAUSS_BAND_PASS , GAUSS_INVERSE ,
  GAUSS_HOMOMORPHIC , BUTTERWORTH_LOW_PASS , BUTTERWORTH_HIGH_PASS , BUTTERWORTH_HOMOMORPHIC ,
  KAISER_I0 , KAISER_SINH , KAISER_I0_INVERSE , KAISER_SINH_INVERSE ,
  SHIFT , TANH_LOW_PASS , TANH_HIGH_PASS , TANH_HOMOMORPHIC ,
  TANH_BAND_PASS , RADIAL_TABLE , CTF_
}
 Fourier filter Processor type enum. More...
 
- Protected Member Functions inherited from EMAN::TestImageProcessor
void preprocess (EMData *image)
 
- Protected Attributes inherited from EMAN::TestImageProcessor
int nx
 
int ny
 
int nz
 
- Protected Attributes inherited from EMAN::Processor
Dict params
 

Detailed Description

Generate an ellipse or ellipsoid image.

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

Member Function Documentation

◆ get_desc()

virtual string EMAN::TestImageEllipse::get_desc ( ) const
inlinevirtual

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

8655 {
8656 return "Insert an ellipse into the image.";
8657 }

◆ get_name()

virtual string EMAN::TestImageEllipse::get_name ( ) const
inlinevirtual

Get the processor's name.

Each processor is identified by a unique name.

Returns
The processor's name.

Implements EMAN::Processor.

Definition at line 8649 of file processor.h.

8650 {
8651 return NAME;
8652 }
static const string NAME
Definition: processor.h:8675

References NAME.

◆ get_param_types()

virtual TypeDict EMAN::TestImageEllipse::get_param_types ( ) const
inlinevirtual

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

8665 {
8666 TypeDict d;
8667 d.put("a", EMObject::FLOAT, "equatorial radius along x axes (major semiaxes)");
8668 d.put("b", EMObject::FLOAT, "equatorial radius along y axes (minor semiaxes)");
8669 d.put("c", EMObject::FLOAT, "polar radius for ellipsoid (x^2/a^2+y^2/b^2+z^2/c^2=1)");
8670 d.put("transform", EMObject::TRANSFORM, "Optionally transform the ellipse");
8671 d.put("fill", EMObject::FLOAT, "value you want to fill in ellipse, default to 1.0");
8672 return d;
8673 }
TypeDict is a dictionary to store <string, EMObject::ObjectType> pair.
Definition: emobject.h:305
void put(const string &key, EMObject::ObjectType o, const string &desc="")
Definition: emobject.h:330

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

◆ NEW()

static Processor * EMAN::TestImageEllipse::NEW ( )
inlinestatic

Definition at line 8659 of file processor.h.

8660 {
8661 return new TestImageEllipse();
8662 }
Generate an ellipse or ellipsoid image.
Definition: processor.h:8645

◆ process_inplace()

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
imageThe image to be processed.

Implements EMAN::Processor.

Definition at line 9964 of file processor.cpp.

9965{
9966 preprocess(image);
9967 image->to_zero(); // The testimage processors are supposed to replace the image contents
9968
9969
9970 float a = params.set_default("a",nx/2.0f-1.0f);
9971 float b = params.set_default("b",ny/2.0f-1.0f);
9972 float c = params.set_default("c",nz/2.0f-1.0f);
9973 float fill = params.set_default("fill",1.0f);
9974 //bool hollow = params.set_default("hollow",false);
9975 Transform* t;
9976 if (params.has_key("transform")) {
9977 t = params["transform"];
9978 } else {
9979 t = new Transform;
9980 }
9981
9982
9983 int mz = 2*(int)c+1;
9984 if ( nz < mz ) mz = nz;
9985 int my = 2*(int)b+1;
9986 if ( ny < my ) my = ny;
9987 int mx = 2*(int)a+1;
9988 if ( nx < mx ) mx = nx;
9989
9990
9991 float ai = 1/(a*a);
9992 float bi = 1/(b*b);
9993 float ci = 1/(c*c);
9994
9995 Vec3f origin(nx/2,ny/2,nz/2);
9996
9997 float x2, y2, z2, r;
9998 int xl, yl, zl;
9999 for (int k = 0; k < mz; ++k) {
10000 for (int j = 0; j < my; ++j) {
10001 for (int i = 0; i < mx; ++i) {
10002 x2 = (float)(i - mx/2);
10003 y2 = (float)(j - my/2);
10004 z2 = (float)(k - mz/2);
10005 r = (x2*x2)*ai + (y2*y2)*bi + (z2*z2)*ci;
10006 if (r <= 1) {
10007
10008 if (t != 0) {
10009 Vec3f v(x2,y2,z2);
10010 v = (*t)*v;
10011 v += origin;
10012
10013 // THIS ISN'T THE BEST STRATEGY BUT IT'S A STOP GAP. A FLOOD FILL IS PROBABLY BETTER
10014 // I fill in 3x3 cubes to make sure there are no gaps...
10015
10016 for( int kk = -1; kk <= 1; ++kk)
10017 for( int jj = -1; jj <= 1; ++jj)
10018 for( int ii = -1; ii <= 1; ++ii) {
10019 xl = (int)v[0]+ii;
10020 yl = (int)v[1]+jj;
10021 zl = (int)v[2]+kk;
10022 if (xl >= 0 && xl < nx && yl >= 0 && yl < ny && zl >= 0 && zl < nz)
10023 image->set_value_at(xl,yl,zl,fill);
10024 }
10025 } else {
10026 image->set_value_at((int)x2+nx/2,(int)y2+ny/2,(int)z2+nz/2,fill);
10027 }
10028 }
10029 }
10030 }
10031 }
10032
10033 delete t;
10034
10035 image->update();
10036}
type set_default(const string &key, type val)
Default setting behavior This can be achieved using a template - d.woolford Jan 2008 (before there wa...
Definition: emobject.h:569
bool has_key(const string &key) const
Ask the Dictionary if it as a particular key.
Definition: emobject.h:511
void preprocess(EMData *image)
Definition: processor.cpp:8923
A Transform object is a somewhat specialized object designed specifically for EMAN2/Sparx storage of ...
Definition: transform.h:75

References EMAN::Dict::has_key(), EMAN::TestImageProcessor::nx, EMAN::TestImageProcessor::ny, EMAN::TestImageProcessor::nz, EMAN::Processor::params, EMAN::TestImageProcessor::preprocess(), and EMAN::Dict::set_default().

Member Data Documentation

◆ NAME

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

Definition at line 8675 of file processor.h.

Referenced by get_name().


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