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

06291                 {
06292                         return "Replace a source image as a sine wave in specified wave length";
06293                 }

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

References NAME.

Referenced by process_inplace().

06286                 {
06287                         return NAME;
06288                 }

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

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

06301                 {
06302                         TypeDict d;
06303                         d.put("wavelength", EMObject::FLOAT, "wavelength in equation sin(x*2*PI/wavelength - phase*180/PI)");
06304                         d.put("axis", EMObject::STRING, "(optional) specify a major axis for asymmetric features, default x axis");
06305                         d.put("phase", EMObject::FLOAT, "(optional) the phase in radians");
06306                         d.put("az", EMObject::FLOAT, "(optional) angle in degree. for 2D image, this is the rotated angle of the image, \
06307                                                                                                 in 3D image, it's az for euler angle. default is zero");
06308                         d.put("alt", EMObject::FLOAT, "(optional) angle in degree. only in 3D case, alt for euler angle, default is zero");
06309                         d.put("phi", EMObject::FLOAT, "(optional) angle in degree. only in 3D case, phi for euler angle, default is zero");
06310                         return d;
06311                 }

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

Definition at line 6295 of file processor.h.

06296                 {
06297                         return new TestImageSinewave();
06298                 }

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 7486 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().

07487 {
07488         preprocess(image);
07489 
07490         if(!params.has_key("wavelength")) {
07491                 LOGERR("%s wavelength is required parameter", get_name().c_str());
07492                 throw InvalidParameterException("wavelength parameter is required.");
07493         }
07494         float wavelength = params["wavelength"];
07495 
07496         string axis = "";
07497         if(params.has_key("axis")) {
07498                 axis = (const char*)params["axis"];
07499         }
07500 
07501         float phase = 0;
07502         if(params.has_key("phase")) {
07503                 phase = params["phase"];
07504         }
07505 
07506         int ndim = image->get_ndim();
07507         float * dat = image->get_data();
07508 
07509         if(ndim==1) {   //1D
07510                 for(int i=0; i<nx; ++i, ++dat) {
07511                         *dat = sin(i*(2.0f*M_PI/wavelength) + phase);
07512                 }
07513         }
07514         else if(ndim==2) {      //2D
07515                 float alpha = 0;
07516                 if(params.has_key("az")) {
07517                         alpha = params["az"];
07518                 }
07519                 for(int j=0; j<ny; ++j) {
07520                         for(int i=0; i<nx; ++i, ++dat) {
07521                                 if(alpha != 0) {
07522                                         *dat = sin((i*sin((180-alpha)*M_PI/180)+j*cos((180-alpha)*M_PI/180))*(2.0f*M_PI/wavelength) + phase);
07523                                 }
07524                                 else if(axis.compare("y")==0 || axis.compare("Y")==0) {
07525                                         *dat = sin(j*(2.0f*M_PI/wavelength) + phase);
07526                                 }
07527                                 else {
07528                                         *dat = sin(i*(2.0f*M_PI/wavelength) + phase);
07529                                 }
07530                         }
07531                 }
07532         }
07533         else {  //3D
07534                 float az = 0;
07535                 if(params.has_key("az")) {
07536                         az = params["az"];
07537                 }
07538                 float alt = 0;
07539                 if(params.has_key("alt")) {
07540                         alt = params["alt"];
07541                 }
07542                 float phi = 0;
07543                 if(params.has_key("phi")) {
07544                         phi = params["phi"];
07545                 }
07546 
07547                 for(int k=0; k<nz; ++k) {
07548                         for(int j=0; j<ny; ++j) {
07549                                 for(int i=0; i<nx; ++i, ++dat) {
07550                                         if(axis.compare("z")==0 || axis.compare("Z")==0) {
07551                                                 *dat = sin(k*(2.0f*M_PI/wavelength) + phase);
07552                                         }
07553                                         else if(axis.compare("y")==0 || axis.compare("Y")==0) {
07554                                                 *dat = sin(j*(2.0f*M_PI/wavelength) + phase);
07555                                         }
07556                                         else {
07557                                                 *dat = sin(i*(2.0f*M_PI/wavelength) + phase);
07558                                         }
07559                                 }
07560                         }
07561                 }
07562 
07563                 if(az != 0 || alt != 0 || phi != 0) {
07564                         Dict d("type","eman");
07565                         d["az"] = az; d["phi"] = phi; d["alt"] = alt;
07566                         image->transform(Transform(d));
07567                 }
07568         }
07569 
07570         image->update();
07571 }


Member Data Documentation

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

Definition at line 6313 of file processor.h.

Referenced by get_name().


The documentation for this class was generated from the following files:
Generated on Thu May 3 10:10:53 2012 for EMAN2 by  doxygen 1.4.7