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:

Inheritance graph
[legend]
Collaboration diagram for EMAN::TestImageSphericalWave:

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

06250                 {
06251                         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)";
06252                 }

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

Referenced by process_inplace().

06245                 {
06246                         return NAME;
06247                 }

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

References EMAN::TypeDict::put().

06260                 {
06261                         TypeDict d;
06262                         d.put("wavelength", EMObject::FLOAT, "cos(2*pi*r/wavelength+phase)");
06263                         d.put("phase", EMObject::FLOAT, "in radians");
06264                         d.put("x", EMObject::FLOAT, "center of the spherical wave");
06265                         d.put("y", EMObject::FLOAT, "center of the spherical wave");
06266                         d.put("z", EMObject::FLOAT, "center of the spherical wave");
06267                         return d;
06268                 }

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

Definition at line 6254 of file processor.h.

06255                 {
06256                         return new TestImageSphericalWave();
06257                 }

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 7448 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.

07449 {
07450         preprocess(image);
07451 
07452         if(!params.has_key("wavelength")) {
07453                 LOGERR("%s wavelength is required parameter", get_name().c_str());
07454                 throw InvalidParameterException("wavelength parameter is required.");
07455         }
07456         float wavelength = params["wavelength"];
07457 
07458         float phase = 0;
07459         if(params.has_key("phase")) {
07460                 phase = params["phase"];
07461         }
07462 
07463         float x = (float)(nx/2);
07464         if (params.has_key("x")) x=params["x"];
07465         float y = (float)(ny/2);
07466         if (params.has_key("y")) y=params["y"];
07467         float z = (float)(nz/2);
07468         if (params.has_key("z")) z=params["z"];
07469 
07470         int ndim = image->get_ndim();
07471 
07472         if(ndim==2) {   //2D
07473                 for(int j=0; j<ny; ++j) {
07474                         for(int i=0; i<nx; ++i) {
07475 #ifdef _WIN32
07476                                 float r=_hypotf(x-(float)i,y-(float)j);
07477 #else
07478                                 float r=hypot(x-(float)i,y-(float)j);
07479 #endif  //_WIN32
07480                                 if (r<.5) continue;
07481                                 image->set_value_at(i,j,cos(2*(float)pi*r/wavelength+phase)/r);
07482                         }
07483                 }
07484         }
07485         else {  //3D
07486                 for(int k=0; k<nz; ++k) {
07487                         for(int j=0; j<ny; ++j) {
07488                                 for(int i=0; i<nx; ++i) {
07489                                         float r=Util::hypot3(x-(float)i,y-(float)j,z-(float)k);
07490                                         if (r<.5) continue;
07491                                         image->set_value_at(i,j,k,cos(2*(float)pi*r/wavelength+phase)/(r*r));
07492                                 }
07493                         }
07494                 }
07495         }
07496 
07497         image->update();
07498 }


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 Aug 10 16:37:35 2012 for EMAN2 by  doxygen 1.3.9.1