Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

EMAN::TestImageSphericalWave Class Reference

Replace a source image as a sine wave in specified wave length. More...

#include <processor.h>

Inheritance diagram for EMAN::TestImageSphericalWave:

[legend]
Collaboration diagram for EMAN::TestImageSphericalWave:
[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.sphericalwave"

Detailed Description

Replace a source image as a sine wave in specified wave length.

Parameters:
wavelength cos(2*pi*r/wavelength+phase)
phase in radians
x center of the spherical wave
y center of the spherical wave
z center of the spherical wave

Definition at line 6154 of file processor.h.


Member Function Documentation

virtual string EMAN::TestImageSphericalWave::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 6164 of file processor.h.

06165                 {
06166                         return "Replace a source image in 2d or 3d with a spherical wave cos(2*pi*r/wavelength+phase) also 1/r (2d) or 1/r^2 (3d)";
06167                 }

virtual string EMAN::TestImageSphericalWave::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 6159 of file processor.h.

Referenced by process_inplace().

06160                 {
06161                         return NAME;
06162                 }

virtual TypeDict EMAN::TestImageSphericalWave::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 6174 of file processor.h.

References EMAN::TypeDict::put().

06175                 {
06176                         TypeDict d;
06177                         d.put("wavelength", EMObject::FLOAT, "cos(2*pi*r/wavelength+phase)");
06178                         d.put("phase", EMObject::FLOAT, "in radians");
06179                         d.put("x", EMObject::FLOAT, "center of the spherical wave");
06180                         d.put("y", EMObject::FLOAT, "center of the spherical wave");
06181                         d.put("z", EMObject::FLOAT, "center of the spherical wave");
06182                         return d;
06183                 }

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

Definition at line 6169 of file processor.h.

06170                 {
06171                         return new TestImageSphericalWave();
06172                 }

void TestImageSphericalWave::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 7145 of file processor.cpp.

References get_name(), EMAN::EMData::get_ndim(), EMAN::Dict::has_key(), EMAN::Util::hypot3(), InvalidParameterException, LOGERR, nx, ny, phase(), pi, EMAN::TestImageProcessor::preprocess(), EMAN::EMData::set_value_at(), EMAN::EMData::update(), x, and y.

07146 {
07147         preprocess(image);
07148 
07149         if(!params.has_key("wavelength")) {
07150                 LOGERR("%s wavelength is required parameter", get_name().c_str());
07151                 throw InvalidParameterException("wavelength parameter is required.");
07152         }
07153         float wavelength = params["wavelength"];
07154 
07155         float phase = 0;
07156         if(params.has_key("phase")) {
07157                 phase = params["phase"];
07158         }
07159 
07160         float x = (float)(nx/2);
07161         if (params.has_key("x")) x=params["x"];
07162         float y = (float)(ny/2);
07163         if (params.has_key("y")) y=params["y"];
07164         float z = (float)(nz/2);
07165         if (params.has_key("z")) z=params["z"];
07166 
07167         int ndim = image->get_ndim();
07168 
07169         if(ndim==2) {   //2D
07170                 for(int j=0; j<ny; ++j) {
07171                         for(int i=0; i<nx; ++i) {
07172 #ifdef _WIN32
07173                                 float r=_hypotf(x-(float)i,y-(float)j);
07174 #else
07175                                 float r=hypot(x-(float)i,y-(float)j);
07176 #endif  //_WIN32
07177                                 if (r<.5) continue;
07178                                 image->set_value_at(i,j,cos(2*(float)pi*r/wavelength+phase)/r);
07179                         }
07180                 }
07181         }
07182         else {  //3D
07183                 for(int k=0; k<nz; ++k) {
07184                         for(int j=0; j<ny; ++j) {
07185                                 for(int i=0; i<nx; ++i) {
07186                                         float r=Util::hypot3(x-(float)i,y-(float)j,z-(float)k);
07187                                         if (r<.5) continue;
07188                                         image->set_value_at(i,j,k,cos(2*(float)pi*r/wavelength+phase)/(r*r));
07189                                 }
07190                         }
07191                 }
07192         }
07193 
07194         image->update();
07195 }


Member Data Documentation

const string TestImageSphericalWave::NAME = "testimage.sphericalwave" [static]
 

Definition at line 200 of file processor.cpp.


The documentation for this class was generated from the following files:
Generated on Fri Apr 30 15:39:28 2010 for EMAN2 by  doxygen 1.3.9.1