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

static ProcessorNEW ()

Static Public Attributes

static 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 6195 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 6205 of file processor.h.

06206                 {
06207                         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)";
06208                 }

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

References NAME.

Referenced by process_inplace().

06201                 {
06202                         return NAME;
06203                 }

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

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

06216                 {
06217                         TypeDict d;
06218                         d.put("wavelength", EMObject::FLOAT, "cos(2*pi*r/wavelength+phase)");
06219                         d.put("phase", EMObject::FLOAT, "in radians");
06220                         d.put("x", EMObject::FLOAT, "center of the spherical wave");
06221                         d.put("y", EMObject::FLOAT, "center of the spherical wave");
06222                         d.put("z", EMObject::FLOAT, "center of the spherical wave");
06223                         return d;
06224                 }

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

Definition at line 6210 of file processor.h.

06211                 {
06212                         return new TestImageSphericalWave();
06213                 }

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 7283 of file processor.cpp.

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

07284 {
07285         preprocess(image);
07286 
07287         if(!params.has_key("wavelength")) {
07288                 LOGERR("%s wavelength is required parameter", get_name().c_str());
07289                 throw InvalidParameterException("wavelength parameter is required.");
07290         }
07291         float wavelength = params["wavelength"];
07292 
07293         float phase = 0;
07294         if(params.has_key("phase")) {
07295                 phase = params["phase"];
07296         }
07297 
07298         float x = (float)(nx/2);
07299         if (params.has_key("x")) x=params["x"];
07300         float y = (float)(ny/2);
07301         if (params.has_key("y")) y=params["y"];
07302         float z = (float)(nz/2);
07303         if (params.has_key("z")) z=params["z"];
07304 
07305         int ndim = image->get_ndim();
07306 
07307         if(ndim==2) {   //2D
07308                 for(int j=0; j<ny; ++j) {
07309                         for(int i=0; i<nx; ++i) {
07310 #ifdef _WIN32
07311                                 float r=_hypotf(x-(float)i,y-(float)j);
07312 #else
07313                                 float r=hypot(x-(float)i,y-(float)j);
07314 #endif  //_WIN32
07315                                 if (r<.5) continue;
07316                                 image->set_value_at(i,j,cos(2*(float)pi*r/wavelength+phase)/r);
07317                         }
07318                 }
07319         }
07320         else {  //3D
07321                 for(int k=0; k<nz; ++k) {
07322                         for(int j=0; j<ny; ++j) {
07323                                 for(int i=0; i<nx; ++i) {
07324                                         float r=Util::hypot3(x-(float)i,y-(float)j,z-(float)k);
07325                                         if (r<.5) continue;
07326                                         image->set_value_at(i,j,k,cos(2*(float)pi*r/wavelength+phase)/(r*r));
07327                                 }
07328                         }
07329                 }
07330         }
07331 
07332         image->update();
07333 }


Member Data Documentation

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

Definition at line 6226 of file processor.h.

Referenced by get_name().


The documentation for this class was generated from the following files:
Generated on Mon Jul 19 12:44:08 2010 for EMAN2 by  doxygen 1.4.7