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

EMAN::TestImageSinewave Class Reference

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

#include <processor.h>

Inheritance diagram for EMAN::TestImageSinewave:

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

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"

Detailed Description

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

Parameters:
wavelength wavelength in equation sin(x*2*PI/wavelength - phase*180/PI)
axis (optional) specify a major axis for asymmetric features, default x axis
phase (optional) the phase in radians
az (optional) angle in degree. for 2D image, this is the rotated angle of the image, in 3D image, it's az for euler angle. default is zero
alt (optional) angle in degree. only in 3D case, alt for euler angle, default is zero
phi (optional) angle in degree. only in 3D case, phi for euler angle, default is zero

Definition at line 6025 of file processor.h.


Member Function Documentation

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

06036                 {
06037                         return "Replace a source image as a sine wave in specified wave length";
06038                 }

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

Referenced by process_inplace().

06031                 {
06032                         return NAME;
06033                 }

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

References EMAN::TypeDict::put().

06046                 {
06047                         TypeDict d;
06048                         d.put("wavelength", EMObject::FLOAT, "wavelength in equation sin(x*2*PI/wavelength - phase*180/PI)");
06049                         d.put("axis", EMObject::STRING, "(optional) specify a major axis for asymmetric features, default x axis");
06050                         d.put("phase", EMObject::FLOAT, "(optional) the phase in radians");
06051                         d.put("az", EMObject::FLOAT, "(optional) angle in degree. for 2D image, this is the rotated angle of the image, \
06052                                                                                                 in 3D image, it's az for euler angle. default is zero");
06053                         d.put("alt", EMObject::FLOAT, "(optional) angle in degree. only in 3D case, alt for euler angle, default is zero");
06054                         d.put("phi", EMObject::FLOAT, "(optional) angle in degree. only in 3D case, phi for euler angle, default is zero");
06055                         return d;
06056                 }

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

Definition at line 6040 of file processor.h.

06041                 {
06042                         return new TestImageSinewave();
06043                 }

void TestImageSinewave::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 7234 of file processor.cpp.

References EMAN::EMData::get_data(), get_name(), EMAN::EMData::get_ndim(), EMAN::Dict::has_key(), InvalidParameterException, LOGERR, phase(), phi, EMAN::TestImageProcessor::preprocess(), EMAN::EMData::transform(), and EMAN::EMData::update().

07235 {
07236         preprocess(image);
07237 
07238         if(!params.has_key("wavelength")) {
07239                 LOGERR("%s wavelength is required parameter", get_name().c_str());
07240                 throw InvalidParameterException("wavelength parameter is required.");
07241         }
07242         float wavelength = params["wavelength"];
07243 
07244         string axis = "";
07245         if(params.has_key("axis")) {
07246                 axis = (const char*)params["axis"];
07247         }
07248 
07249         float phase = 0;
07250         if(params.has_key("phase")) {
07251                 phase = params["phase"];
07252         }
07253 
07254         int ndim = image->get_ndim();
07255         float * dat = image->get_data();
07256 
07257         if(ndim==1) {   //1D
07258                 for(int i=0; i<nx; ++i, ++dat) {
07259                         *dat = sin(i*(2.0f*M_PI/wavelength) + phase);
07260                 }
07261         }
07262         else if(ndim==2) {      //2D
07263                 float alpha = 0;
07264                 if(params.has_key("az")) {
07265                         alpha = params["az"];
07266                 }
07267                 for(int j=0; j<ny; ++j) {
07268                         for(int i=0; i<nx; ++i, ++dat) {
07269                                 if(alpha != 0) {
07270                                         *dat = sin((i*sin((180-alpha)*M_PI/180)+j*cos((180-alpha)*M_PI/180))*(2.0f*M_PI/wavelength) + phase);
07271                                 }
07272                                 else if(axis.compare("y")==0 || axis.compare("Y")==0) {
07273                                         *dat = sin(j*(2.0f*M_PI/wavelength) + phase);
07274                                 }
07275                                 else {
07276                                         *dat = sin(i*(2.0f*M_PI/wavelength) + phase);
07277                                 }
07278                         }
07279                 }
07280         }
07281         else {  //3D
07282                 float az = 0;
07283                 if(params.has_key("az")) {
07284                         az = params["az"];
07285                 }
07286                 float alt = 0;
07287                 if(params.has_key("alt")) {
07288                         alt = params["alt"];
07289                 }
07290                 float phi = 0;
07291                 if(params.has_key("phi")) {
07292                         phi = params["phi"];
07293                 }
07294 
07295                 for(int k=0; k<nz; ++k) {
07296                         for(int j=0; j<ny; ++j) {
07297                                 for(int i=0; i<nx; ++i, ++dat) {
07298                                         if(axis.compare("z")==0 || axis.compare("Z")==0) {
07299                                                 *dat = sin(k*(2.0f*M_PI/wavelength) + phase);
07300                                         }
07301                                         else if(axis.compare("y")==0 || axis.compare("Y")==0) {
07302                                                 *dat = sin(j*(2.0f*M_PI/wavelength) + phase);
07303                                         }
07304                                         else {
07305                                                 *dat = sin(i*(2.0f*M_PI/wavelength) + phase);
07306                                         }
07307                                 }
07308                         }
07309                 }
07310 
07311                 if(az != 0 || alt != 0 || phi != 0) {
07312                         Dict d("type","eman");
07313                         d["az"] = az; d["phi"] = phi; d["alt"] = alt;
07314                         image->transform(Transform(d));
07315                 }
07316         }
07317 
07318         image->update();
07319 }


Member Data Documentation

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

Definition at line 196 of file processor.cpp.


The documentation for this class was generated from the following files:
Generated on Thu Dec 9 13:48:22 2010 for EMAN2 by  doxygen 1.3.9.1