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

static ProcessorNEW ()

Static Public Attributes

static 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 6235 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 6245 of file processor.h.

06246                 {
06247                         return "Replace a source image as a sine wave in specified wave length";
06248                 }

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

References NAME.

Referenced by process_inplace().

06241                 {
06242                         return NAME;
06243                 }

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

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

06256                 {
06257                         TypeDict d;
06258                         d.put("wavelength", EMObject::FLOAT, "wavelength in equation sin(x*2*PI/wavelength - phase*180/PI)");
06259                         d.put("axis", EMObject::STRING, "(optional) specify a major axis for asymmetric features, default x axis");
06260                         d.put("phase", EMObject::FLOAT, "(optional) the phase in radians");
06261                         d.put("az", EMObject::FLOAT, "(optional) angle in degree. for 2D image, this is the rotated angle of the image, \
06262                                                                                                 in 3D image, it's az for euler angle. default is zero");
06263                         d.put("alt", EMObject::FLOAT, "(optional) angle in degree. only in 3D case, alt for euler angle, default is zero");
06264                         d.put("phi", EMObject::FLOAT, "(optional) angle in degree. only in 3D case, phi for euler angle, default is zero");
06265                         return d;
06266                 }

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

Definition at line 6250 of file processor.h.

06251                 {
06252                         return new TestImageSinewave();
06253                 }

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

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

07415 {
07416         preprocess(image);
07417 
07418         if(!params.has_key("wavelength")) {
07419                 LOGERR("%s wavelength is required parameter", get_name().c_str());
07420                 throw InvalidParameterException("wavelength parameter is required.");
07421         }
07422         float wavelength = params["wavelength"];
07423 
07424         string axis = "";
07425         if(params.has_key("axis")) {
07426                 axis = (const char*)params["axis"];
07427         }
07428 
07429         float phase = 0;
07430         if(params.has_key("phase")) {
07431                 phase = params["phase"];
07432         }
07433 
07434         int ndim = image->get_ndim();
07435         float * dat = image->get_data();
07436 
07437         if(ndim==1) {   //1D
07438                 for(int i=0; i<nx; ++i, ++dat) {
07439                         *dat = sin(i*(2.0f*M_PI/wavelength) + phase);
07440                 }
07441         }
07442         else if(ndim==2) {      //2D
07443                 float alpha = 0;
07444                 if(params.has_key("az")) {
07445                         alpha = params["az"];
07446                 }
07447                 for(int j=0; j<ny; ++j) {
07448                         for(int i=0; i<nx; ++i, ++dat) {
07449                                 if(alpha != 0) {
07450                                         *dat = sin((i*sin((180-alpha)*M_PI/180)+j*cos((180-alpha)*M_PI/180))*(2.0f*M_PI/wavelength) + phase);
07451                                 }
07452                                 else if(axis.compare("y")==0 || axis.compare("Y")==0) {
07453                                         *dat = sin(j*(2.0f*M_PI/wavelength) + phase);
07454                                 }
07455                                 else {
07456                                         *dat = sin(i*(2.0f*M_PI/wavelength) + phase);
07457                                 }
07458                         }
07459                 }
07460         }
07461         else {  //3D
07462                 float az = 0;
07463                 if(params.has_key("az")) {
07464                         az = params["az"];
07465                 }
07466                 float alt = 0;
07467                 if(params.has_key("alt")) {
07468                         alt = params["alt"];
07469                 }
07470                 float phi = 0;
07471                 if(params.has_key("phi")) {
07472                         phi = params["phi"];
07473                 }
07474 
07475                 for(int k=0; k<nz; ++k) {
07476                         for(int j=0; j<ny; ++j) {
07477                                 for(int i=0; i<nx; ++i, ++dat) {
07478                                         if(axis.compare("z")==0 || axis.compare("Z")==0) {
07479                                                 *dat = sin(k*(2.0f*M_PI/wavelength) + phase);
07480                                         }
07481                                         else if(axis.compare("y")==0 || axis.compare("Y")==0) {
07482                                                 *dat = sin(j*(2.0f*M_PI/wavelength) + phase);
07483                                         }
07484                                         else {
07485                                                 *dat = sin(i*(2.0f*M_PI/wavelength) + phase);
07486                                         }
07487                                 }
07488                         }
07489                 }
07490 
07491                 if(az != 0 || alt != 0 || phi != 0) {
07492                         Dict d("type","eman");
07493                         d["az"] = az; d["phi"] = phi; d["alt"] = alt;
07494                         image->transform(Transform(d));
07495                 }
07496         }
07497 
07498         image->update();
07499 }


Member Data Documentation

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

Definition at line 6268 of file processor.h.

Referenced by get_name().


The documentation for this class was generated from the following files:
Generated on Thu Nov 17 12:46:58 2011 for EMAN2 by  doxygen 1.4.7