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


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 equation sin(x*2*PI/wavelength - phase*180/PI)
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 5822 of file processor.h.


Member Function Documentation

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

06817 {
06818         preprocess(image);
06819 
06820         if(!params.has_key("wavelength")) {
06821                 LOGERR("%s wavelength is required parameter", get_name().c_str());
06822                 throw InvalidParameterException("wavelength parameter is required.");
06823         }
06824         float wavelength = params["wavelength"];
06825 
06826         string axis = "";
06827         if(params.has_key("axis")) {
06828                 axis = (const char*)params["axis"];
06829         }
06830 
06831         float phase = 0;
06832         if(params.has_key("phase")) {
06833                 phase = params["phase"];
06834         }
06835 
06836         int ndim = image->get_ndim();
06837         float * dat = image->get_data();
06838 
06839         if(ndim==1) {   //1D
06840                 for(int i=0; i<nx; ++i, ++dat) {
06841                         *dat = sin(i*(2.0f*M_PI/wavelength) - phase*180/M_PI);
06842                 }
06843         }
06844         else if(ndim==2) {      //2D
06845                 float alpha = 0;
06846                 if(params.has_key("az")) {
06847                         alpha = params["az"];
06848                 }
06849                 for(int j=0; j<ny; ++j) {
06850                         for(int i=0; i<nx; ++i, ++dat) {
06851                                 if(alpha != 0) {
06852                                         *dat = sin((i*sin((180-alpha)*M_PI/180)+j*cos((180-alpha)*M_PI/180))*(2.0f*M_PI/wavelength) - phase*M_PI/180);
06853                                 }
06854                                 else if(axis.compare("y")==0 || axis.compare("Y")==0) {
06855                                         *dat = sin(j*(2.0f*M_PI/wavelength) - phase*M_PI/180);
06856                                 }
06857                                 else {
06858                                         *dat = sin(i*(2.0f*M_PI/wavelength) - phase*M_PI/180);
06859                                 }
06860                         }
06861                 }
06862         }
06863         else {  //3D
06864                 float az = 0;
06865                 if(params.has_key("az")) {
06866                         az = params["az"];
06867                 }
06868                 float alt = 0;
06869                 if(params.has_key("alt")) {
06870                         alt = params["alt"];
06871                 }
06872                 float phi = 0;
06873                 if(params.has_key("phi")) {
06874                         phi = params["phi"];
06875                 }
06876 
06877                 for(int k=0; k<nz; ++k) {
06878                         for(int j=0; j<ny; ++j) {
06879                                 for(int i=0; i<nx; ++i, ++dat) {
06880                                         if(axis.compare("z")==0 || axis.compare("Z")==0) {
06881                                                 *dat = sin(k*(2.0f*M_PI/wavelength) - phase*M_PI/180);
06882                                         }
06883                                         else if(axis.compare("y")==0 || axis.compare("Y")==0) {
06884                                                 *dat = sin(j*(2.0f*M_PI/wavelength) - phase*M_PI/180);
06885                                         }
06886                                         else {
06887                                                 *dat = sin(i*(2.0f*M_PI/wavelength) - phase*M_PI/180);
06888                                         }
06889                                 }
06890                         }
06891                 }
06892 
06893                 if(az != 0 || alt != 0 || phi != 0) {
06894                         Dict d("type","eman");
06895                         d["az"] = az; d["phi"] = phi; d["alt"] = alt;
06896                         image->transform(Transform(d));
06897                 }
06898         }
06899 
06900         image->update();
06901 }

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

Referenced by process_inplace().

05828                 {
05829                         return "testimage.sinewave";
05830                 }

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

05833                 {
05834                         return "Replace a source image as a sine wave in specified wave length";
05835                 }

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

Definition at line 5837 of file processor.h.

05838                 {
05839                         return new TestImageSinewave();
05840                 }

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

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

05843                 {
05844                         TypeDict d;
05845                         d.put("wavelength", EMObject::FLOAT, "wavelength in equation sin(x*2*PI/wavelength - phase*180/PI)");
05846                         d.put("axis", EMObject::STRING, "(optional) specify a major axis for asymmetric features, default x axis");
05847                         d.put("phase", EMObject::FLOAT, "(optional) the phase in equation sin(x*2*PI/wavelength - phase*180/PI)");
05848                         d.put("az", EMObject::FLOAT, "(optional) angle in degree. for 2D image, this is the rotated angle of the image, \
05849                                                                                                 in 3D image, it's az for euler angle. default is zero");
05850                         d.put("alt", EMObject::FLOAT, "(optional) angle in degree. only in 3D case, alt for euler angle, default is zero");
05851                         d.put("phi", EMObject::FLOAT, "(optional) angle in degree. only in 3D case, phi for euler angle, default is zero");
05852                         return d;
05853                 }


The documentation for this class was generated from the following files:

Generated on Sat Nov 21 02:20:38 2009 for EMAN2 by  doxygen 1.5.6