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

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

06209                 {
06210                         return "Replace a source image as a sine wave in specified wave length";
06211                 }

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

References NAME.

Referenced by process_inplace().

06204                 {
06205                         return NAME;
06206                 }

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

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

06219                 {
06220                         TypeDict d;
06221                         d.put("wavelength", EMObject::FLOAT, "wavelength in equation sin(x*2*PI/wavelength - phase*180/PI)");
06222                         d.put("axis", EMObject::STRING, "(optional) specify a major axis for asymmetric features, default x axis");
06223                         d.put("phase", EMObject::FLOAT, "(optional) the phase in equation sin(x*2*PI/wavelength - phase*180/PI)");
06224                         d.put("az", EMObject::FLOAT, "(optional) angle in degree. for 2D image, this is the rotated angle of the image, \
06225                                                                                                 in 3D image, it's az for euler angle. default is zero");
06226                         d.put("alt", EMObject::FLOAT, "(optional) angle in degree. only in 3D case, alt for euler angle, default is zero");
06227                         d.put("phi", EMObject::FLOAT, "(optional) angle in degree. only in 3D case, phi for euler angle, default is zero");
06228                         return d;
06229                 }

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

Definition at line 6213 of file processor.h.

06214                 {
06215                         return new TestImageSinewave();
06216                 }

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

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


Member Data Documentation

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

Definition at line 6231 of file processor.h.

Referenced by get_name().


The documentation for this class was generated from the following files:
Generated on Tue May 25 17:37:49 2010 for EMAN2 by  doxygen 1.4.4