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

06542                 {
06543                         return "Replace a source image as a circle or sphere depends on 2D or 3D of the source image";
06544                 }

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

06537                 {
06538                         return NAME;
06539                 }

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

References EMAN::TypeDict::put().

06552                 {
06553                         TypeDict d;
06554                         d.put("radius", EMObject::FLOAT, "radius of circle or sphere, unit: pixel");
06555                         d.put("axis", EMObject::STRING, "specify a major axis for asymmetric features");
06556                         d.put("c", EMObject::FLOAT, "distance between focus and the center of an ellipse");
06557                         d.put("fill", EMObject::INT, "Flag indicating if image is filled, default filled, 1 for filled, 0 for blank.");
06558                         return d;
06559                 }

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

Definition at line 6546 of file processor.h.

06547                 {
06548                         return new TestImageCirclesphere();
06549                 }

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

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

07777 {
07778         preprocess(image);
07779 
07780         float radius = params.set_default("radius",nx/2.0f);
07781         string axis = (const char*)params["axis"];
07782         float c =  params.set_default("c",nx/2.0f);
07783         int fill = params.set_default("fill",1);
07784 
07785         float *dat = image->get_data();
07786         float x2, y2, z2; //this is coordinates of this pixel from center
07787         float r = 0.0f;
07788         float asy = 0.0f;
07789         if(axis == ""){
07790                 asy = radius;
07791         }
07792         else if(axis == "x" || axis == "y"){
07793                 asy = c;
07794         }
07795         else if(axis=="z"){
07796                 if( nz == 1 ){
07797                         throw InvalidValueException(0, "This is a 2D image, no asymmetric feature for z axis");
07798                 }
07799                 asy = c;
07800         }
07801         else{
07802                 throw InvalidValueException(0, "please specify a valid axis for asymmetric features");
07803         }
07804 
07805         for (int k = 0; k < nz; ++k) {
07806                 for (int j = 0; j < ny; ++j) {
07807                         for (int i = 0; i < nx; ++i, ++dat) {
07808                                 x2 = fabs((float)i - nx/2);
07809                                 y2 = fabs((float)j - ny/2);
07810                                 z2 = fabs((float)k - nz/2);
07811                                 if( axis == "" ){
07812                                         r = (x2*x2)/(radius*radius) + (y2*y2)/(radius*radius) + (z2*z2)/(radius*radius);
07813                                 }
07814                                 else if (axis == "x"){
07815                                         r = (x2*x2)/(asy*asy) + (y2*y2)/(radius*radius) + (z2*z2)/(radius*radius);
07816                                 }
07817                                 else if(axis == "y"){
07818                                         r = (x2*x2)/(radius*radius) + (y2*y2)/(asy*asy) + (z2*z2)/(radius*radius);
07819                                 }
07820                                 else if(axis=="z"){
07821                                         r = (x2*x2)/(radius*radius) + (y2*y2)/(radius*radius) + (z2*z2)/(asy*asy);
07822                                 }
07823                                 if( r<=1 ) {
07824                                         if( !fill) {
07825                                                 *dat = 0;
07826                                         }
07827                                         else {
07828                                                 *dat = 1;
07829                                         }
07830                                 }
07831                                 else {
07832                                         if( !fill ) {
07833                                                 *dat = 1;
07834                                         }
07835                                         else {
07836                                                 *dat = 0;
07837                                         }
07838                                 }
07839                         }
07840                 }
07841         }
07842 
07843         image->update();
07844 }


Member Data Documentation

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

Definition at line 207 of file processor.cpp.


The documentation for this class was generated from the following files:
Generated on Tue Jun 11 13:49:13 2013 for EMAN2 by  doxygen 1.3.9.1