EMAN2
Public Member Functions | Static Public Member Functions | Static Public Attributes
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:
wavelengthcos(2*pi*r/wavelength+phase)
phasein radians
xcenter of the spherical wave
ycenter of the spherical wave
zcenter of the spherical wave

Definition at line 6650 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 6660 of file processor.h.

                {
                        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)";
                }
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 6655 of file processor.h.

References NAME.

                {
                        return NAME;
                }
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 6670 of file processor.h.

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

                {
                        TypeDict d;
                        d.put("wavelength", EMObject::FLOAT, "cos(2*pi*r/wavelength+phase)");
                        d.put("phase", EMObject::FLOAT, "in radians");
                        d.put("x", EMObject::FLOAT, "center of the spherical wave");
                        d.put("y", EMObject::FLOAT, "center of the spherical wave");
                        d.put("z", EMObject::FLOAT, "center of the spherical wave");
                        return d;
                }
static Processor* EMAN::TestImageSphericalWave::NEW ( ) [inline, static]

Definition at line 6665 of file processor.h.

                {
                        return new TestImageSphericalWave();
                }
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:
imageThe image to be processed.

Implements EMAN::Processor.

Definition at line 7951 of file processor.cpp.

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

{
        preprocess(image);

        if(!params.has_key("wavelength")) {
                LOGERR("%s wavelength is required parameter", get_name().c_str());
                throw InvalidParameterException("wavelength parameter is required.");
        }
        float wavelength = params["wavelength"];

        float phase = 0;
        if(params.has_key("phase")) {
                phase = params["phase"];
        }

        float x = (float)(nx/2);
        if (params.has_key("x")) x=params["x"];
        float y = (float)(ny/2);
        if (params.has_key("y")) y=params["y"];
        float z = (float)(nz/2);
        if (params.has_key("z")) z=params["z"];

        int ndim = image->get_ndim();

        if(ndim==2) {   //2D
                for(int j=0; j<ny; ++j) {
                        for(int i=0; i<nx; ++i) {
#ifdef _WIN32
                                float r=_hypotf(x-(float)i,y-(float)j);
#else
                                float r=hypot(x-(float)i,y-(float)j);
#endif  //_WIN32
                                if (r<.5) continue;
                                image->set_value_at(i,j,cos(2*(float)pi*r/wavelength+phase)/r);
                        }
                }
        }
        else {  //3D
                for(int k=0; k<nz; ++k) {
                        for(int j=0; j<ny; ++j) {
                                for(int i=0; i<nx; ++i) {
                                        float r=Util::hypot3(x-(float)i,y-(float)j,z-(float)k);
                                        if (r<.5) continue;
                                        image->set_value_at(i,j,k,cos(2*(float)pi*r/wavelength+phase)/(r*r));
                                }
                        }
                }
        }

        image->update();
}

Member Data Documentation

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

Definition at line 6681 of file processor.h.

Referenced by get_name().


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