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

06419                 {
06420                         return "Replace a source image as a circle or sphere depends on 2D or 3D of the source image";
06421                 }

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

References NAME.

06414                 {
06415                         return NAME;
06416                 }

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

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

06429                 {
06430                         TypeDict d;
06431                         d.put("radius", EMObject::FLOAT, "radius of circle or sphere, unit: pixel");
06432                         d.put("axis", EMObject::STRING, "specify a major axis for asymmetric features");
06433                         d.put("c", EMObject::FLOAT, "distance between focus and the center of an ellipse");
06434                         d.put("fill", EMObject::INT, "Flag indicating if image is filled, default filled, 1 for filled, 0 for blank.");
06435                         return d;
06436                 }

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

Definition at line 6423 of file processor.h.

06424                 {
06425                         return new TestImageCirclesphere();
06426                 }

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 7436 of file processor.cpp.

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

07437 {
07438         preprocess(image);
07439 
07440         float radius = params.set_default("radius",nx/2.0f);
07441         string axis = (const char*)params["axis"];
07442         float c =  params.set_default("c",nx/2.0f);
07443         int fill = params.set_default("fill",1);
07444 
07445         float *dat = image->get_data();
07446         float x2, y2, z2; //this is coordinates of this pixel from center
07447         float r = 0.0f;
07448         float asy = 0.0f;
07449         if(axis == ""){
07450                 asy = radius;
07451         }
07452         else if(axis == "x" || axis == "y"){
07453                 asy = c;
07454         }
07455         else if(axis=="z"){
07456                 if( nz == 1 ){
07457                         throw InvalidValueException(0, "This is a 2D image, no asymmetric feature for z axis");
07458                 }
07459                 asy = c;
07460         }
07461         else{
07462                 throw InvalidValueException(0, "please specify a valid axis for asymmetric features");
07463         }
07464 
07465         for (int k = 0; k < nz; ++k) {
07466                 for (int j = 0; j < ny; ++j) {
07467                         for (int i = 0; i < nx; ++i, ++dat) {
07468                                 x2 = fabs((float)i - nx/2);
07469                                 y2 = fabs((float)j - ny/2);
07470                                 z2 = fabs((float)k - nz/2);
07471                                 if( axis == "" ){
07472                                         r = (x2*x2)/(radius*radius) + (y2*y2)/(radius*radius) + (z2*z2)/(radius*radius);
07473                                 }
07474                                 else if (axis == "x"){
07475                                         r = (x2*x2)/(asy*asy) + (y2*y2)/(radius*radius) + (z2*z2)/(radius*radius);
07476                                 }
07477                                 else if(axis == "y"){
07478                                         r = (x2*x2)/(radius*radius) + (y2*y2)/(asy*asy) + (z2*z2)/(radius*radius);
07479                                 }
07480                                 else if(axis=="z"){
07481                                         r = (x2*x2)/(radius*radius) + (y2*y2)/(radius*radius) + (z2*z2)/(asy*asy);
07482                                 }
07483                                 if( r<=1 ) {
07484                                         if( !fill) {
07485                                                 *dat = 0;
07486                                         }
07487                                         else {
07488                                                 *dat = 1;
07489                                         }
07490                                 }
07491                                 else {
07492                                         if( !fill ) {
07493                                                 *dat = 1;
07494                                         }
07495                                         else {
07496                                                 *dat = 0;
07497                                         }
07498                                 }
07499                         }
07500                 }
07501         }
07502 
07503         image->update();
07504 }


Member Data Documentation

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

Definition at line 6438 of file processor.h.

Referenced by get_name().


The documentation for this class was generated from the following files:
Generated on Tue May 25 17:17:38 2010 for EMAN2 by  doxygen 1.4.7