EMAN::TestImageCirclesphere Class Reference

Replace a source image as a circle or sphere depends on 2D or 3D of the source image. More...

#include <processor.h>

Inheritance diagram for EMAN::TestImageCirclesphere:

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

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

static ProcessorNEW ()

Static Public Attributes

static const string NAME = "testimage.circlesphere"

Detailed Description

Replace a source image as a circle or sphere depends on 2D or 3D of the source image.

Parameters:
radius radius of circle or sphere
axis specify a major axis for asymmetric features
c distance between focus and the center of an ellipse
fill answer 'yes' or 'no' to specify if it's filled or hollow, default filled

Definition at line 6448 of file processor.h.


Member Function Documentation

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

06459                 {
06460                         return "Replace a source image as a circle or sphere depends on 2D or 3D of the source image";
06461                 }

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

References NAME.

06454                 {
06455                         return NAME;
06456                 }

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

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

06469                 {
06470                         TypeDict d;
06471                         d.put("radius", EMObject::FLOAT, "radius of circle or sphere, unit: pixel");
06472                         d.put("axis", EMObject::STRING, "specify a major axis for asymmetric features");
06473                         d.put("c", EMObject::FLOAT, "distance between focus and the center of an ellipse");
06474                         d.put("fill", EMObject::INT, "Flag indicating if image is filled, default filled, 1 for filled, 0 for blank.");
06475                         return d;
06476                 }

static Processor* EMAN::TestImageCirclesphere::NEW (  )  [inline, static]

Definition at line 6463 of file processor.h.

06464                 {
06465                         return new TestImageCirclesphere();
06466                 }

void TestImageCirclesphere::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 7543 of file processor.cpp.

References EMAN::EMData::get_data(), InvalidValueException, EMAN::Processor::params, EMAN::TestImageProcessor::preprocess(), EMAN::Dict::set_default(), and EMAN::EMData::update().

07544 {
07545         preprocess(image);
07546 
07547         float radius = params.set_default("radius",nx/2.0f);
07548         string axis = (const char*)params["axis"];
07549         float c =  params.set_default("c",nx/2.0f);
07550         int fill = params.set_default("fill",1);
07551 
07552         float *dat = image->get_data();
07553         float x2, y2, z2; //this is coordinates of this pixel from center
07554         float r = 0.0f;
07555         float asy = 0.0f;
07556         if(axis == ""){
07557                 asy = radius;
07558         }
07559         else if(axis == "x" || axis == "y"){
07560                 asy = c;
07561         }
07562         else if(axis=="z"){
07563                 if( nz == 1 ){
07564                         throw InvalidValueException(0, "This is a 2D image, no asymmetric feature for z axis");
07565                 }
07566                 asy = c;
07567         }
07568         else{
07569                 throw InvalidValueException(0, "please specify a valid axis for asymmetric features");
07570         }
07571 
07572         for (int k = 0; k < nz; ++k) {
07573                 for (int j = 0; j < ny; ++j) {
07574                         for (int i = 0; i < nx; ++i, ++dat) {
07575                                 x2 = fabs((float)i - nx/2);
07576                                 y2 = fabs((float)j - ny/2);
07577                                 z2 = fabs((float)k - nz/2);
07578                                 if( axis == "" ){
07579                                         r = (x2*x2)/(radius*radius) + (y2*y2)/(radius*radius) + (z2*z2)/(radius*radius);
07580                                 }
07581                                 else if (axis == "x"){
07582                                         r = (x2*x2)/(asy*asy) + (y2*y2)/(radius*radius) + (z2*z2)/(radius*radius);
07583                                 }
07584                                 else if(axis == "y"){
07585                                         r = (x2*x2)/(radius*radius) + (y2*y2)/(asy*asy) + (z2*z2)/(radius*radius);
07586                                 }
07587                                 else if(axis=="z"){
07588                                         r = (x2*x2)/(radius*radius) + (y2*y2)/(radius*radius) + (z2*z2)/(asy*asy);
07589                                 }
07590                                 if( r<=1 ) {
07591                                         if( !fill) {
07592                                                 *dat = 0;
07593                                         }
07594                                         else {
07595                                                 *dat = 1;
07596                                         }
07597                                 }
07598                                 else {
07599                                         if( !fill ) {
07600                                                 *dat = 1;
07601                                         }
07602                                         else {
07603                                                 *dat = 0;
07604                                         }
07605                                 }
07606                         }
07607                 }
07608         }
07609 
07610         image->update();
07611 }


Member Data Documentation

const string TestImageCirclesphere::NAME = "testimage.circlesphere" [static]

Definition at line 6478 of file processor.h.

Referenced by get_name().


The documentation for this class was generated from the following files:
Generated on Mon Jul 19 12:44:11 2010 for EMAN2 by  doxygen 1.4.7