EMAN2
Public Member Functions | Static Public Member Functions | Static Public Attributes
EMAN::TestImageGradient Class Reference

Put a gradient in the image of the form y = mx+b : "x" is a string indicating any of the image axes, i.e., x,y or z. More...

#include <processor.h>

Inheritance diagram for EMAN::TestImageGradient:
Inheritance graph
[legend]
Collaboration diagram for EMAN::TestImageGradient:
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.gradient"

Detailed Description

Put a gradient in the image of the form y = mx+b : "x" is a string indicating any of the image axes, i.e., x,y or z.

Author:
David Woolford <woolford@bcm.edu>
Date:
01/10/2008
Parameters:
axisThe axis the will be used to determine pixel values. Must be x,y or z. Default is x
mm in the equation m*axis+b. Default is 1.0
bb in the equation m*axis+b. Default is 0.0

Definition at line 6501 of file processor.h.


Member Function Documentation

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

                        {
                                return "Make a gradient image of the form y=mx+b, where x is any of the image axes.";
                        }
virtual string EMAN::TestImageGradient::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 6506 of file processor.h.

References NAME.

                        {
                                return NAME;
                        }
virtual TypeDict EMAN::TestImageGradient::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 6521 of file processor.h.

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

                        {
                                TypeDict d;
                                d.put("axis", EMObject::STRING, "The axis the will be used to determine pixel values. Must be x,y or z");
                                d.put("m", EMObject::FLOAT, "m in the equation m*axis+b. Default is 1.0");
                                d.put("b", EMObject::FLOAT, "b in the equation m*axis+b. Default is 0.0");
                                return d;
                        }
static Processor* EMAN::TestImageGradient::NEW ( ) [inline, static]

Definition at line 6516 of file processor.h.

                        {
                                return new TestImageGradient();
                        }
void TestImageGradient::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 7752 of file processor.cpp.

References b, InvalidParameterException, nx, ny, EMAN::Processor::params, EMAN::Dict::set_default(), EMAN::EMData::set_value_at(), and EMAN::EMData::update().

{
        string axis = params.set_default("axis", "x");

        float m = params.set_default("m", 1.0f);
        float b = params.set_default("b", 0.0f);

        if ( axis != "z" && axis != "y" && axis != "x") throw InvalidParameterException("Axis must be x,y or z");

        preprocess(image);

        if ( axis == "x")
        {
                for(int k=0; k<nz;++k) {
                        for(int j=0; j<ny; ++j) {
                                for(int i=0; i <nx; ++i) {
                                        image->set_value_at(i,j,k,m*i+b);
                                }
                        }
                }
        }
        else if ( axis == "y")
        {
                for(int k=0; k<nz;++k) {
                        for(int j=0; j<ny; ++j) {
                                for(int i=0; i <nx; ++i) {
                                        image->set_value_at(i,j,k,m*j+b);
                                }
                        }
                }
        }
        else if ( axis == "z")
        {
                for(int k=0; k<nz;++k) {
                        for(int j=0; j<ny; ++j) {
                                for(int i=0; i <nx; ++i) {
                                        image->set_value_at(i,j,k,m*k+b);
                                }
                        }
                }
        }
        image->update();
}

Member Data Documentation

const string TestImageGradient::NAME = "testimage.gradient" [static]

Definition at line 6530 of file processor.h.

Referenced by get_name().


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