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

EMAN::TestImageSinewaveCircular Class Reference

Replace a source image as a circular sine wave in specified wave length. More...

#include <processor.h>

Inheritance diagram for EMAN::TestImageSinewaveCircular:

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

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.sinewave.circular"

Detailed Description

Replace a source image as a circular sine wave in specified wave length.

Parameters:
wavelength float this value is the d in function |sin(x/d)|
axis char (optional) specify a major axis for asymmetric features
c distance (optional) float between focus and the center of an ellipse
phase degree (optional) phase for sine wave, default is 0

Definition at line 6246 of file processor.h.


Member Function Documentation

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

06257                 {
06258                         return "Replace a source image as a circular sine wave in specified wave length";
06259                 }

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

06252                 {
06253                         return NAME;
06254                 }

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

References EMAN::TypeDict::put().

06267                 {
06268                         TypeDict d;
06269                         d.put("wavelength", EMObject::FLOAT, "(required)this value is the d in function |sin(x/d)|, unit: pixel");
06270                         d.put("axis", EMObject::STRING, "specify a major axis for asymmetric features");
06271                         d.put("c", EMObject::FLOAT, "distance between focus and the center of an ellipse");
06272                         d.put("phase", EMObject::FLOAT, "(optional)phase for sine wave, default is 0");
06273                         return d;
06274                 }

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

Definition at line 6261 of file processor.h.

06262                 {
06263                         return new TestImageSinewaveCircular();
06264                 }

void TestImageSinewaveCircular::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 7415 of file processor.cpp.

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

07416 {
07417         preprocess(image);
07418 
07419         float wavelength = params["wavelength"];
07420         string axis = (const char*)params["axis"];
07421         float c = params["c"];
07422         float phase = params["phase"];
07423 
07424         float *dat = image->get_data();
07425         float r; //this is the distance of pixel from the image center(nx/2, ny/2, nz/2)
07426         float x2, y2, z2; //this is the coordinates of this pixel from image center
07427         for (int k = 0; k < nz; ++k) {
07428                 for (int j = 0; j < ny; ++j) {
07429                         for (int i = 0; i < nx; ++i, ++dat) {
07430                                 x2 = (float)( i - nx/2 );
07431                                 y2 = (float)( j - ny/2 );
07432                                 z2 = (float)( k - nz/2 );
07433                                 if(axis == ""){
07434                                         r = (float)sqrt(x2*x2+y2*y2+z2*z2);
07435                                 }
07436                                 else if(axis == "x"){
07437                                         float lc = -c;
07438                                         float rc = c;
07439                                         r = ( (float)sqrt((x2-lc)*(x2-lc)+y2*y2+z2*z2) +
07440                                                   (float)sqrt((x2-rc)*(x2-rc)+y2*y2+z2*z2) ) /2.0f - c;
07441                                 }
07442                                 else if(axis == "y"){
07443                                         float lc = -c;
07444                                         float rc = c;
07445                                         r = ( (float)sqrt(x2*x2+(y2-lc)*(y2-lc)+z2*z2) +
07446                                                   (float)sqrt(x2*x2+(y2-rc)*(y2-rc)+z2*z2) ) /2.0f - c;
07447                                 }
07448                                 else if(axis == "z"){
07449                                         if( nz == 1 ){
07450                                                 throw InvalidValueException(0, "This is a 2D image, no asymmetric feature for z axis");
07451                                         }
07452                                         float lc = -c;
07453                                         float rc = c;
07454                                         r = ( (float)sqrt(x2*x2+y2*y2+(z2-lc)*(z2-lc)) +
07455                                                   (float)sqrt(x2*x2+y2*y2+(z2-rc)*(z2-rc)) ) /2.0f - c;
07456                                 }
07457                                 else{
07458                                         throw InvalidValueException(0, "please specify a valid axis for asymmetric features");
07459                                 }
07460                                 *dat = sin( r * (2.0f*M_PI/wavelength) - phase*180/M_PI);
07461                         }
07462                 }
07463         }
07464 
07465         image->update();
07466 }


Member Data Documentation

const string TestImageSinewaveCircular::NAME = "testimage.sinewave.circular" [static]
 

Definition at line 207 of file processor.cpp.


The documentation for this class was generated from the following files:
Generated on Tue Jul 12 13:51:30 2011 for EMAN2 by  doxygen 1.3.9.1