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

Multiplies the image by the specified file using pixel coordinates instead of pixel indices. More...

#include <processor.h>

Inheritance diagram for EMAN::CoordinateMaskFileProcessor:
Inheritance graph
[legend]
Collaboration diagram for EMAN::CoordinateMaskFileProcessor:
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 = "mask.fromfile.sizediff"

Detailed Description

Multiplies the image by the specified file using pixel coordinates instead of pixel indices.

The images can be different size.

Parameters:
filenamemask image file name

Definition at line 5826 of file processor.h.


Member Function Documentation

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

                {
                        return "Multiplies the image by the specified file using pixel coordinates instead of pixel indices. The images can be different size.";
                }
virtual string EMAN::CoordinateMaskFileProcessor::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 5831 of file processor.h.

References NAME.

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

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

                {
                        TypeDict d;
                        d.put("filename", EMObject::STRING, "mask image file name");
                        return d;
                }
static Processor* EMAN::CoordinateMaskFileProcessor::NEW ( ) [inline, static]

Definition at line 5836 of file processor.h.

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

References EMAN::EMData::get_attr(), EMAN::EMData::get_attr_default(), EMAN::EMData::get_data(), EMAN::EMData::get_xsize(), EMAN::EMData::get_ysize(), EMAN::EMData::get_zsize(), LOGWARN, nx, ny, EMAN::Processor::params, EMAN::EMData::read_image(), and EMAN::EMData::update().

{
        if (!image) {
                LOGWARN("NULL Image");
                return;
        }

        const char *filename = params["filename"];
        EMData *msk = new EMData();
        msk->read_image(filename);

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

        int xm = msk->get_xsize();
        int ym = msk->get_ysize();
        int zm = msk->get_zsize();

        float apix = image->get_attr("apix_x");
        float apixm = msk->get_attr("apix_x");

        float xo = image->get_attr_default("origin_x",0.0);
        float yo = image->get_attr_default("origin_y",0.0);
        float zo = image->get_attr_default("origin_z",0.0);

        float xom = msk->get_attr_default("origin_x",0.0);
        float yom = msk->get_attr_default("origin_y",0.0);
        float zom = msk->get_attr_default("origin_z",0.0);

        float *dp = image->get_data();
        float *dpm = msk->get_data();
        int nxy = nx * ny;

        for (int k = 0; k < nz; k++) {
                float zc = zo + k * apix;
                if (zc <= zom || zc >= zom + zm * apixm) {
                        memset(&(dp[k * nxy]), 0, sizeof(float) * nxy);
                }
                else {
                        int km = (int) ((zc - zom) / apixm);

                        for (int j = 0; j < ny; j++) {
                                float yc = yo + j * apix;
                                if (yc <= yom || yc >= yom + ym * apixm) {
                                        memset(&(dp[k * nxy + j * nx]), 0, sizeof(float) * nx);
                                }
                                else {
                                        int jm = (int) ((yc - yom) / apixm);
                                        size_t idx = 0;
                                        float xc;
                                        int im;
                                        for (int i = 0; i < nx; i++) {
                                                xc = xo + i * apix;
                                                idx = (size_t)k * nxy + j * nx + i;
                                                if (xc <= xom || xc >= xom + xm * apixm) {
                                                        dp[idx] = 0;
                                                }
                                                else {
                                                        im = (int) ((xc - xom) / apixm);
                                                        if (dpm[km * xm * ym + jm * xm + im] <= 0) {
                                                                dp[idx] = 0;
                                                        }
                                                }
                                        }
                                }
                        }
                }
        }

        image->update();
        msk->update();
        if( msk )
        {
                delete msk;
                msk = 0;
        }
}

Member Data Documentation

const string CoordinateMaskFileProcessor::NAME = "mask.fromfile.sizediff" [static]

Definition at line 5853 of file processor.h.

Referenced by get_name().


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