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

Add additional shells/rings to an existing 1/0 mask image. More...

#include <processor.h>

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

Detailed Description

Add additional shells/rings to an existing 1/0 mask image.

Parameters:
nshellsnumber of shells to add

Definition at line 5427 of file processor.h.


Member Function Documentation

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

                {
                        return "Add additional shells/rings to an existing 1/0 mask image";
                }
virtual string EMAN::AddMaskShellProcessor::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 5432 of file processor.h.

References NAME.

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

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

                {
                        TypeDict d;
                        d.put("nshells", EMObject::INT, "number of shells to add");
                        return d;
                }
static Processor* EMAN::AddMaskShellProcessor::NEW ( ) [inline, static]

Definition at line 5442 of file processor.h.

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

References EMAN::EMData::get_data(), EMAN::EMData::get_xsize(), EMAN::EMData::get_ysize(), EMAN::EMData::get_zsize(), LOGERR, LOGWARN, nx, ny, EMAN::Processor::params, EMAN::Dict::set_default(), EMAN::EMData::update(), and x.

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

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

        if (ny == 1) {
                LOGERR("Tried to add mask shell to 1d image");
                return;
        }

        int num_shells = params.set_default("nshells",1);

        float *d = image->get_data();
        float k = 0.99999f;
        int nxy = nx * ny;

        if (nz == 1) {
                for (int i = 0; i < num_shells; i++) {
                        for (int y = 1; y < ny - 1; y++) {
                                int cur_y = y * nx;

                                for (int x = 1; x < nx - 1; x++) {
                                        int j = x + cur_y;
                                        if (!d[j] && (d[j - 1] > k || d[j + 1] > k || d[j + nx] > k || d[j - nx] > k)) {
                                                d[j] = k;
                                        }
                                }
                        }
                        k -= 0.00001f;
                }
        }
        else {
                for (int i = 0; i < num_shells; i++) {
                        for (int z = 1; z < nz - 1; z++) {
                                size_t cur_z = (size_t)z * nx * ny;

                                for (int y = 1; y < ny - 1; y++) {
                                        size_t cur_y = y * nx + cur_z;

                                        for (int x = 1; x < nx - 1; x++) {
                                                size_t j = x + cur_y;

                                                if (!d[j] && (d[j - 1] > k || d[j + 1] > k || d[j + nx] > k ||
                                                                          d[j - nx] > k || d[j - nxy] > k || d[j + nxy] > k)) {
                                                        d[j] = k;
                                                }
                                        }
                                }
                        }

                        k -= 0.00001f;
                }
        }

        size_t size = (size_t)nx * ny * nz;
        for (size_t i = 0; i < size; ++i) {
                if (d[i]) {
                        d[i] = 1;
                }
                else {
                        d[i] = 0;
                }
        }

        image->update();
}

Member Data Documentation

const string AddMaskShellProcessor::NAME = "mask.addshells" [static]

Definition at line 5454 of file processor.h.

Referenced by get_name().


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