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

06121                 {
06122                         return "Replace a source image as a sine wave in specified wave length";
06123                 }

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

Referenced by process_inplace().

06116                 {
06117                         return NAME;
06118                 }

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

References EMAN::TypeDict::put().

06131                 {
06132                         TypeDict d;
06133                         d.put("wavelength", EMObject::FLOAT, "wavelength in equation sin(x*2*PI/wavelength - phase*180/PI)");
06134                         d.put("axis", EMObject::STRING, "(optional) specify a major axis for asymmetric features, default x axis");
06135                         d.put("phase", EMObject::FLOAT, "(optional) the phase in radians");
06136                         d.put("az", EMObject::FLOAT, "(optional) angle in degree. for 2D image, this is the rotated angle of the image, \
06137                                                                                                 in 3D image, it's az for euler angle. default is zero");
06138                         d.put("alt", EMObject::FLOAT, "(optional) angle in degree. only in 3D case, alt for euler angle, default is zero");
06139                         d.put("phi", EMObject::FLOAT, "(optional) angle in degree. only in 3D case, phi for euler angle, default is zero");
06140                         return d;
06141                 }

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

Definition at line 6125 of file processor.h.

06126                 {
06127                         return new TestImageSinewave();
06128                 }

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

07299 {
07300         preprocess(image);
07301 
07302         if(!params.has_key("wavelength")) {
07303                 LOGERR("%s wavelength is required parameter", get_name().c_str());
07304                 throw InvalidParameterException("wavelength parameter is required.");
07305         }
07306         float wavelength = params["wavelength"];
07307 
07308         string axis = "";
07309         if(params.has_key("axis")) {
07310                 axis = (const char*)params["axis"];
07311         }
07312 
07313         float phase = 0;
07314         if(params.has_key("phase")) {
07315                 phase = params["phase"];
07316         }
07317 
07318         int ndim = image->get_ndim();
07319         float * dat = image->get_data();
07320 
07321         if(ndim==1) {   //1D
07322                 for(int i=0; i<nx; ++i, ++dat) {
07323                         *dat = sin(i*(2.0f*M_PI/wavelength) + phase);
07324                 }
07325         }
07326         else if(ndim==2) {      //2D
07327                 float alpha = 0;
07328                 if(params.has_key("az")) {
07329                         alpha = params["az"];
07330                 }
07331                 for(int j=0; j<ny; ++j) {
07332                         for(int i=0; i<nx; ++i, ++dat) {
07333                                 if(alpha != 0) {
07334                                         *dat = sin((i*sin((180-alpha)*M_PI/180)+j*cos((180-alpha)*M_PI/180))*(2.0f*M_PI/wavelength) + phase);
07335                                 }
07336                                 else if(axis.compare("y")==0 || axis.compare("Y")==0) {
07337                                         *dat = sin(j*(2.0f*M_PI/wavelength) + phase);
07338                                 }
07339                                 else {
07340                                         *dat = sin(i*(2.0f*M_PI/wavelength) + phase);
07341                                 }
07342                         }
07343                 }
07344         }
07345         else {  //3D
07346                 float az = 0;
07347                 if(params.has_key("az")) {
07348                         az = params["az"];
07349                 }
07350                 float alt = 0;
07351                 if(params.has_key("alt")) {
07352                         alt = params["alt"];
07353                 }
07354                 float phi = 0;
07355                 if(params.has_key("phi")) {
07356                         phi = params["phi"];
07357                 }
07358 
07359                 for(int k=0; k<nz; ++k) {
07360                         for(int j=0; j<ny; ++j) {
07361                                 for(int i=0; i<nx; ++i, ++dat) {
07362                                         if(axis.compare("z")==0 || axis.compare("Z")==0) {
07363                                                 *dat = sin(k*(2.0f*M_PI/wavelength) + phase);
07364                                         }
07365                                         else if(axis.compare("y")==0 || axis.compare("Y")==0) {
07366                                                 *dat = sin(j*(2.0f*M_PI/wavelength) + phase);
07367                                         }
07368                                         else {
07369                                                 *dat = sin(i*(2.0f*M_PI/wavelength) + phase);
07370                                         }
07371                                 }
07372                         }
07373                 }
07374 
07375                 if(az != 0 || alt != 0 || phi != 0) {
07376                         Dict d("type","eman");
07377                         d["az"] = az; d["phi"] = phi; d["alt"] = alt;
07378                         image->transform(Transform(d));
07379                 }
07380         }
07381 
07382         image->update();
07383 }


Member Data Documentation

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

Definition at line 199 of file processor.cpp.


The documentation for this class was generated from the following files:
Generated on Thu Mar 10 23:00:29 2011 for EMAN2 by  doxygen 1.3.9.1