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

Replace a source image as a square or cube depends on 2D or 3D of the source image. More...

#include <processor.h>

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

Detailed Description

Replace a source image as a square or cube depends on 2D or 3D of the source image.

Parameters:
edge_lengthedge length of the square or cube
axisspecify a major axis for asymmetric features
odd_edgeedge length for the asymmetric axis
fillanswer 'yes' or 'no' to specify if it's filled or hollow, default filled

Definition at line 6774 of file processor.h.


Member Function Documentation

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

                {
                        return "Replace a source image as a square or cube depends on 2D or 3D of the source image";
                }
virtual string EMAN::TestImageSquarecube::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 6779 of file processor.h.

References NAME.

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

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

                {
                        TypeDict d;
                        d.put("edge_length", EMObject::FLOAT, "edge length of the square or cube, unit: pixel");
                        d.put("axis", EMObject::STRING, "specify a major axis for asymmetric features");
                        d.put("odd_edge", EMObject::FLOAT, "edge length for the asymmetric axis");
                        d.put("fill", EMObject::INT, "Flag indicating if image is filled, default filled, 1 for filled, 0 for blank");
                        return d;
                }
static Processor* EMAN::TestImageSquarecube::NEW ( ) [inline, static]

Definition at line 6789 of file processor.h.

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

References EMAN::EMData::get_data(), EMAN::Dict::has_key(), InvalidValueException, nx, ny, EMAN::Processor::params, and EMAN::EMData::update().

{
        preprocess(image);

        float edge_length = params["edge_length"];
        string axis = (const char*)params["axis"];
        float odd_edge = params["odd_edge"];
        int fill = 1;
        if(params.has_key("fill")) {
                fill = (int)params["fill"];
        }

        float *dat = image->get_data();
        float x2, y2, z2; //this coordinates of this pixel from center
        float xEdge, yEdge, zEdge; //half of edge length for this cube
        if(axis == ""){
                xEdge = edge_length/2.0f;
                yEdge = edge_length/2.0f;
                zEdge = edge_length/2.0f;
        }
        else if(axis == "x"){
                xEdge = odd_edge/2.0f;
                yEdge = edge_length/2.0f;
                zEdge = edge_length/2.0f;
        }
        else if(axis == "y"){
                xEdge = edge_length/2.0f;
                yEdge = odd_edge/2.0f;
                zEdge = edge_length/2.0f;
        }
        else if(axis == "z"){
                if( nz == 1 ){
                        throw InvalidValueException(0, "This is a 2D image, no asymmetric feature for z axis");
                }
                xEdge = edge_length/2.0f;
                yEdge = edge_length/2.0f;
                zEdge = odd_edge/2.0f;
        }
        else{
                throw InvalidValueException(0, "please specify a valid axis for asymmetric features");
        }
        for (int k = 0; k < nz; ++k) {
                for (int j = 0; j < ny; ++j) {
                        for (int i = 0; i < nx; ++i, ++dat) {
                                x2 = (float)fabs((float)i - nx/2);
                                y2 = (float)fabs((float)j - ny/2);
                                z2 = (float)fabs((float)k - nz/2);
                                if( x2<=xEdge && y2<=yEdge && z2<=zEdge ) {
                                        if( !fill) {
                                                *dat = 0;
                                        }
                                        else {
                                                *dat = 1;
                                        }
                                }
                                else {
                                        if( !fill ) {
                                                *dat = 1;
                                        }
                                        else {
                                                *dat = 0;
                                        }
                                }
                        }
                }
        }

        image->update();
}

Member Data Documentation

const string TestImageSquarecube::NAME = "testimage.squarecube" [static]

Definition at line 6804 of file processor.h.

Referenced by get_name().


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