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

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

ProcessorNEW ()

Static Public Attributes

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

06331                 {
06332                         return "Replace a source image as a circle or sphere depends on 2D or 3D of the source image";
06333                 }

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

06326                 {
06327                         return NAME;
06328                 }

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

References EMAN::TypeDict::put().

06341                 {
06342                         TypeDict d;
06343                         d.put("radius", EMObject::FLOAT, "radius of circle or sphere, unit: pixel");
06344                         d.put("axis", EMObject::STRING, "specify a major axis for asymmetric features");
06345                         d.put("c", EMObject::FLOAT, "distance between focus and the center of an ellipse");
06346                         d.put("fill", EMObject::INT, "Flag indicating if image is filled, default filled, 1 for filled, 0 for blank.");
06347                         return d;
06348                 }

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

Definition at line 6335 of file processor.h.

06336                 {
06337                         return new TestImageCirclesphere();
06338                 }

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

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

07509 {
07510         preprocess(image);
07511 
07512         float radius = params.set_default("radius",nx/2.0f);
07513         string axis = (const char*)params["axis"];
07514         float c =  params.set_default("c",nx/2.0f);
07515         int fill = params.set_default("fill",1);
07516 
07517         float *dat = image->get_data();
07518         float x2, y2, z2; //this is coordinates of this pixel from center
07519         float r = 0.0f;
07520         float asy = 0.0f;
07521         if(axis == ""){
07522                 asy = radius;
07523         }
07524         else if(axis == "x" || axis == "y"){
07525                 asy = c;
07526         }
07527         else if(axis=="z"){
07528                 if( nz == 1 ){
07529                         throw InvalidValueException(0, "This is a 2D image, no asymmetric feature for z axis");
07530                 }
07531                 asy = c;
07532         }
07533         else{
07534                 throw InvalidValueException(0, "please specify a valid axis for asymmetric features");
07535         }
07536 
07537         for (int k = 0; k < nz; ++k) {
07538                 for (int j = 0; j < ny; ++j) {
07539                         for (int i = 0; i < nx; ++i, ++dat) {
07540                                 x2 = fabs((float)i - nx/2);
07541                                 y2 = fabs((float)j - ny/2);
07542                                 z2 = fabs((float)k - nz/2);
07543                                 if( axis == "" ){
07544                                         r = (x2*x2)/(radius*radius) + (y2*y2)/(radius*radius) + (z2*z2)/(radius*radius);
07545                                 }
07546                                 else if (axis == "x"){
07547                                         r = (x2*x2)/(asy*asy) + (y2*y2)/(radius*radius) + (z2*z2)/(radius*radius);
07548                                 }
07549                                 else if(axis == "y"){
07550                                         r = (x2*x2)/(radius*radius) + (y2*y2)/(asy*asy) + (z2*z2)/(radius*radius);
07551                                 }
07552                                 else if(axis=="z"){
07553                                         r = (x2*x2)/(radius*radius) + (y2*y2)/(radius*radius) + (z2*z2)/(asy*asy);
07554                                 }
07555                                 if( r<=1 ) {
07556                                         if( !fill) {
07557                                                 *dat = 0;
07558                                         }
07559                                         else {
07560                                                 *dat = 1;
07561                                         }
07562                                 }
07563                                 else {
07564                                         if( !fill ) {
07565                                                 *dat = 1;
07566                                         }
07567                                         else {
07568                                                 *dat = 0;
07569                                         }
07570                                 }
07571                         }
07572                 }
07573         }
07574 
07575         image->update();
07576 }


Member Data Documentation

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

Definition at line 204 of file processor.cpp.


The documentation for this class was generated from the following files:
Generated on Mon Mar 7 18:21:23 2011 for EMAN2 by  doxygen 1.3.9.1