EMAN2
Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes
EMAN::PaintProcessor Class Reference

'paints' a circle into the image at x,y,z with values inside r1 set to v1, values between r1 and r2 will be set to a value between v1 and v2, and values outside r2 will be unchanged More...

#include <processor.h>

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

List of all members.

Public Member Functions

 PaintProcessor ()
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.
virtual void set_params (const Dict &new_params)
 Set the processor parameters using a key/value dictionary.

Static Public Member Functions

static ProcessorNEW ()

Static Public Attributes

static const string NAME = "mask.paint"

Protected Member Functions

virtual void process_inplace (EMData *image)
 To process an image in-place.

Protected Attributes

int x
int y
int z
int r1
float v1
int r2
float v2

Detailed Description

'paints' a circle into the image at x,y,z with values inside r1 set to v1, values between r1 and r2 will be set to a value between v1 and v2, and values outside r2 will be unchanged

Parameters:
xx coordinate for Center of circle
yy coordinate for Center of circle
zz coordinate for Center of circle
r1Inner radius
v1Inner value
r2Outter radius
v2Outer Value

Definition at line 5866 of file processor.h.


Constructor & Destructor Documentation

EMAN::PaintProcessor::PaintProcessor ( ) [inline]

Definition at line 5869 of file processor.h.

Referenced by NEW().

                                :x(0), y(0), z(0),r1(0), v1(0.0), r2(0), v2(0.0)
                {
                }

Member Function Documentation

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

                {
                        return "Paints a circle with a decaying edge into the image. r<r1 -> v1, r1<r<r2 -> (v1,v2), r>r2 unchanged";
                }
virtual string EMAN::PaintProcessor::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 5873 of file processor.h.

References NAME.

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

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

                {
                        TypeDict d;
                        d.put("x", EMObject::INT, "x coordinate for Center of circle");
                        d.put("y", EMObject::INT, "y coordinate for Center of circle");
                        d.put("z", EMObject::INT, "z coordinate for Center of circle");
                        d.put("r1", EMObject::INT, "Inner radius");
                        d.put("v1", EMObject::FLOAT, "Inner value");
                        d.put("r2", EMObject::INT, "Outter radius");
                        d.put("v2", EMObject::FLOAT, "Outer Value");
                        return d;
                }
static Processor* EMAN::PaintProcessor::NEW ( ) [inline, static]

Definition at line 5878 of file processor.h.

References PaintProcessor().

                {
                        return new PaintProcessor();
                }
void PaintProcessor::process_inplace ( EMData image) [protected, 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 1516 of file processor.cpp.

References EMAN::EMData::get_xsize(), EMAN::EMData::get_ysize(), EMAN::EMData::get_zsize(), nx, ny, r1, r2, EMAN::EMData::set_value_at(), sqrt(), EMAN::Util::square(), EMAN::EMData::update(), v1, v2, x, y, and z.

                                                  {
        int nx=image->get_xsize();
        int ny=image->get_ysize();
        int nz=image->get_zsize();

        if (nz==1) {
                float r;
                for (int j=(y<r2?0:y-r2); j<(y+r2>ny?ny:y+r2); j++) {
                        for (int i=(x<r2?0:x-r2); i<(x+r2>nx?nx:x+r2); i++) {
                                r=sqrt(float(Util::square(i-x)+Util::square(j-y)));
                                if (r>r2 && r>r1) continue;
                                if (r>r1) image->set_value_at(i,j,0,v2*(r-r1)/(r2-r1)+v1*(r2-r)/(r2-r1));
                                else image->set_value_at(i,j,0,v1);
                        }
                }
        }
        else {
                float r;
                for (int k=(z<r2?0:z-r2); k<(z+r2>nz?nz:z+r2); k++) {
                        for (int j=(y<r2?0:y-r2); j<(y+r2>ny?ny:y+r2); j++) {
                                for (int i=(x<r2?0:x-r2); i<(x+r2>nx?nx:x+r2); i++) {
                                r=sqrt(float(Util::square(i-x)+Util::square(j-y)+Util::square(k-z)));
                                if (r>r2 && r>r1) continue;
                                if (r>r1) image->set_value_at(i,j,k,v2*(r-r1)/(r2-r1)+v1*(r2-r)/(r2-r1));
                                else image->set_value_at(i,j,k,v1);
                                }
                        }
                }
        }
        image->update();
}
virtual void EMAN::PaintProcessor::set_params ( const Dict new_params) [inline, virtual]

Set the processor parameters using a key/value dictionary.

Parameters:
new_paramsA dictionary containing the new parameters.

Reimplemented from EMAN::Processor.

Definition at line 5901 of file processor.h.

References EMAN::Dict::has_key(), EMAN::Processor::params, r1, r2, v1, v2, x, y, and z.

                {
                        params = new_params;

                        if (params.has_key("x")) x = params["x"];
                        if (params.has_key("y")) y = params["y"];
                        if (params.has_key("z")) z = params["z"];
                        if (params.has_key("r1")) r1 = params["r1"];
                        if (params.has_key("r2")) r2 = params["r2"];
                        if (params.has_key("v1")) v1 = params["v1"];
                        if (params.has_key("v2")) v2 = params["v2"];
                }

Member Data Documentation

const string PaintProcessor::NAME = "mask.paint" [static]

Definition at line 5914 of file processor.h.

Referenced by get_name().

int EMAN::PaintProcessor::r1 [protected]

Definition at line 5919 of file processor.h.

Referenced by process_inplace(), and set_params().

int EMAN::PaintProcessor::r2 [protected]

Definition at line 5921 of file processor.h.

Referenced by process_inplace(), and set_params().

float EMAN::PaintProcessor::v1 [protected]

Definition at line 5920 of file processor.h.

Referenced by process_inplace(), and set_params().

float EMAN::PaintProcessor::v2 [protected]

Definition at line 5922 of file processor.h.

Referenced by process_inplace(), and set_params().

int EMAN::PaintProcessor::x [protected]

Definition at line 5919 of file processor.h.

Referenced by process_inplace(), and set_params().

int EMAN::PaintProcessor::y [protected]

Definition at line 5919 of file processor.h.

Referenced by process_inplace(), and set_params().

int EMAN::PaintProcessor::z [protected]

Definition at line 5919 of file processor.h.

Referenced by process_inplace(), and set_params().


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