Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Attributes
EMAN::AutoMaskDustProcessor Class Reference

A "dust removal" filter which will remove above threshold densities smaller than a given size. More...

#include <processor.h>

Inheritance diagram for EMAN::AutoMaskDustProcessor:
Inheritance graph
Collaboration diagram for EMAN::AutoMaskDustProcessor:
Collaboration graph

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 TypeDict get_param_types () const
 Get processor parameter information in a dictionary.
virtual string get_desc () const
 Get the descrition of this specific processor.

Static Public Member Functions

static ProcessorNEW ()

Static Public Attributes

static const string NAME = "mask.dust3d"

Protected Attributes


Detailed Description

A "dust removal" filter which will remove above threshold densities smaller than a given size.


Definition at line 5270 of file processor.h.

Member Function Documentation

virtual string EMAN::AutoMaskDustProcessor::get_desc ( ) const [inline, virtual]

Get the descrition of this specific processor.

This function must be overwritten by a subclass.

The description of this processor.

Implements EMAN::Processor.

Definition at line 5294 of file processor.h.

                        return "A dust removal filter which will remove above threshold densities smaller than a given size";
virtual string EMAN::AutoMaskDustProcessor::get_name ( ) const [inline, virtual]

Get the processor's name.

Each processor is identified by a unique name.

The processor's name.

Implements EMAN::Processor.

Definition at line 5275 of file processor.h.

References NAME.

                        return NAME;
virtual TypeDict EMAN::AutoMaskDustProcessor::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.

A dictionary containing the parameter info.

Reimplemented from EMAN::Processor.

Definition at line 5285 of file processor.h.

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

                        TypeDict d;
                        d.put("threshold", EMObject::FLOAT,"Only considers densities above the threshold");
                        d.put("voxels", EMObject::INT,"If a connected mass is smaller than this many voxels it is removed");
                        d.put("verbose", EMObject::INT, "Level of verbosity, 0 default. 1 will print each non-excluded zone");
                        return d;
static Processor* EMAN::AutoMaskDustProcessor::NEW ( ) [inline, static]

Definition at line 5280 of file processor.h.

                        return new AutoMaskDustProcessor();
void AutoMaskDustProcessor::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.

imageThe image to be processed.

Implements EMAN::Processor.

Definition at line 7031 of file processor.cpp.

References EMAN::EMData::get_value_at(), EMAN::EMData::get_xsize(), EMAN::EMData::get_ysize(), EMAN::EMData::get_zsize(), EMAN::EMUtil::IMAGE_HDF, LOGWARN, EMAN::EMData::mult(), nx, ny, EMAN::Processor::params, EMAN::Dict::set_default(), EMAN::EMData::sget_value_at(), and x.

        if (!imagein) {
                LOGWARN("NULL Image");

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

        int verbose=params.set_default("verbose",0);
        unsigned int voxels=params.set_default("voxels",27);
        float threshold=params.set_default("threshold",1.5);

        mask = new EMData();
        mask->set_size(nx, ny, nz);

        for (int zz = 0; zz < nz; zz++) {
                for (int yy = 0; yy < ny; yy++) {
                        for (int xx = 0; xx < nx; xx++) {
                                if (image->get_value_at(xx,yy,zz)>threshold && mask->get_value_at(xx,yy,zz)==1.0) {
                                        vector<Vec3i> pvec;
                                        for (uint i=0; i<pvec.size(); i++) {
                                                // Duplicates will occur the way the algorithm is constructed, so we eliminate them as we encounter them
                                                if (mask->sget_value_at(pvec[i])==0.0f) {

                                                // mask out the points in the volume

                                                int x=pvec[i][0];
                                                int y=pvec[i][1];
                                                int z=pvec[i][2];
                                                // Any neighboring values above threshold we haven't already set get added to the list
                                                if (image->sget_value_at(x-1,y,z)>threshold && mask->get_value_at(x-1,y,z)==1.0) pvec.push_back(Vec3i(x-1,y,z));
                                                if (image->sget_value_at(x+1,y,z)>threshold && mask->get_value_at(x+1,y,z)==1.0) pvec.push_back(Vec3i(x+1,y,z));
                                                if (image->sget_value_at(x,y-1,z)>threshold && mask->get_value_at(x,y-1,z)==1.0) pvec.push_back(Vec3i(x,y-1,z));
                                                if (image->sget_value_at(x,y+1,z)>threshold && mask->get_value_at(x,y+1,z)==1.0) pvec.push_back(Vec3i(x,y+1,z));
                                                if (image->sget_value_at(x,y,z-1)>threshold && mask->get_value_at(x,y,z-1)==1.0) pvec.push_back(Vec3i(x,y,z-1));
                                                if (image->sget_value_at(x,y,z+1)>threshold && mask->get_value_at(x,y,z+1)==1.0) pvec.push_back(Vec3i(x,y,z+1));

                                        // If the blob is too big, then we don't mask it out after all, but we set the value
                                        // to 2.0 so we know the voxels have already been examined, and don't check them again
                                        if (pvec.size()>voxels) {
                                                if (verbose) printf("%d\t%d\t%d\tvoxels: %d\n",xx,yy,zz,(int)pvec.size());
                                                for (uint i=0; i<pvec.size(); i++) mask->set_value_at(pvec[i],2.0);


        // Now we expand the mask by 1 pixel and blur the edge
        mask->process_inplace("mask.addshells",Dict("nshells",2));              // expand by 1 shell

        // apply the mask
        if (verbose>1) mask->write_image("mask.hdf", 0, EMUtil::IMAGE_HDF);

        delete mask;

Member Data Documentation

Definition at line 5303 of file processor.h.

Definition at line 5302 of file processor.h.

const string AutoMaskDustProcessor::NAME = "mask.dust3d" [static]

Definition at line 5299 of file processor.h.

Referenced by get_name().

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