EMAN2
Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Attributes | List of all members
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
[legend]
Collaboration diagram for EMAN::AutoMaskDustProcessor:
Collaboration graph
[legend]

Public Member Functions

virtual void process_inplace (EMData *image)
 To process an image in-place. More...
 
virtual string get_name () const
 Get the processor's name. More...
 
virtual TypeDict get_param_types () const
 Get processor parameter information in a dictionary. More...
 
virtual string get_desc () const
 Get the descrition of this specific processor. More...
 
- Public Member Functions inherited from EMAN::Processor
virtual ~Processor ()
 
virtual EMDataprocess (const EMData *const image)
 To proccess an image out-of-place. More...
 
virtual void process_list_inplace (vector< EMData * > &images)
 To process multiple images using the same algorithm. More...
 
virtual Dict get_params () const
 Get the processor parameters in a key/value dictionary. More...
 
virtual void set_params (const Dict &new_params)
 Set the processor parameters using a key/value dictionary. More...
 

Static Public Member Functions

static ProcessorNEW ()
 
- Static Public Member Functions inherited from EMAN::Processor
static string get_group_desc ()
 Get the description of this group of processors. More...
 
static void EMFourierFilterInPlace (EMData *fimage, Dict params)
 Compute a Fourier-filter processed image in place. More...
 
static EMDataEMFourierFilter (EMData *fimage, Dict params)
 Compute a Fourier-processor processed image without altering the original image. More...
 

Static Public Attributes

static const string NAME = "mask.dust3d"
 

Protected Attributes

EMDatamask
 
EMDataimage
 
- Protected Attributes inherited from EMAN::Processor
Dict params
 

Additional Inherited Members

- Public Types inherited from EMAN::Processor
enum  fourier_filter_types {
  TOP_HAT_LOW_PASS , TOP_HAT_HIGH_PASS , TOP_HAT_BAND_PASS , TOP_HOMOMORPHIC ,
  GAUSS_LOW_PASS , GAUSS_HIGH_PASS , GAUSS_BAND_PASS , GAUSS_INVERSE ,
  GAUSS_HOMOMORPHIC , BUTTERWORTH_LOW_PASS , BUTTERWORTH_HIGH_PASS , BUTTERWORTH_HOMOMORPHIC ,
  KAISER_I0 , KAISER_SINH , KAISER_I0_INVERSE , KAISER_SINH_INVERSE ,
  SHIFT , TANH_LOW_PASS , TANH_HIGH_PASS , TANH_HOMOMORPHIC ,
  TANH_BAND_PASS , RADIAL_TABLE , CTF_
}
 Fourier filter Processor type enum. More...
 

Detailed Description

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

Parameters
voxels
threshold

Definition at line 6866 of file processor.h.

Member Function Documentation

◆ get_desc()

virtual string EMAN::AutoMaskDustProcessor::get_desc ( ) const
inlinevirtual

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 6890 of file processor.h.

6891 {
6892 return "A dust removal filter which will remove above threshold densities smaller than a given size";
6893 }

◆ get_name()

virtual string EMAN::AutoMaskDustProcessor::get_name ( ) const
inlinevirtual

Get the processor's name.

Each processor is identified by a unique name.

Returns
The processor's name.

Implements EMAN::Processor.

Definition at line 6871 of file processor.h.

6872 {
6873 return NAME;
6874 }
static const string NAME
Definition: processor.h:6895

References NAME.

◆ get_param_types()

virtual TypeDict EMAN::AutoMaskDustProcessor::get_param_types ( ) const
inlinevirtual

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 6881 of file processor.h.

6882 {
6883 TypeDict d;
6884 d.put("threshold", EMObject::FLOAT,"Only considers densities above the threshold");
6885 d.put("voxels", EMObject::INT,"If a connected mass is smaller than this many voxels it is removed");
6886 d.put("verbose", EMObject::INT, "Level of verbosity, 0 default. 1 will print each non-excluded zone");
6887 return d;
6888 }
TypeDict is a dictionary to store <string, EMObject::ObjectType> pair.
Definition: emobject.h:305
void put(const string &key, EMObject::ObjectType o, const string &desc="")
Definition: emobject.h:330

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

◆ NEW()

static Processor * EMAN::AutoMaskDustProcessor::NEW ( )
inlinestatic

Definition at line 6876 of file processor.h.

6877 {
6878 return new AutoMaskDustProcessor();
6879 }
A "dust removal" filter which will remove above threshold densities smaller than a given size.
Definition: processor.h:6867

◆ process_inplace()

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.

Parameters
imageThe image to be processed.

Implements EMAN::Processor.

Definition at line 8542 of file processor.cpp.

8543{
8544 if (!imagein) {
8545 LOGWARN("NULL Image");
8546 return;
8547 }
8548 image=imagein;
8549
8550 int nx = image->get_xsize();
8551 int ny = image->get_ysize();
8552 int nz = image->get_zsize();
8553
8554 int verbose=params.set_default("verbose",0);
8555 unsigned int voxels=params.set_default("voxels",27);
8556 float threshold=params.set_default("threshold",1.5);
8557
8558 mask = new EMData();
8559 mask->set_size(nx, ny, nz);
8560 mask->to_one();
8561
8562 for (int zz = 0; zz < nz; zz++) {
8563 for (int yy = 0; yy < ny; yy++) {
8564 for (int xx = 0; xx < nx; xx++) {
8565 if (image->get_value_at(xx,yy,zz)>threshold && mask->get_value_at(xx,yy,zz)==1.0) {
8566 vector<Vec3i> pvec;
8567 pvec.push_back(Vec3i(xx,yy,zz));
8568 for (uint i=0; i<pvec.size(); i++) {
8569 // Duplicates will occur the way the algorithm is constructed, so we eliminate them as we encounter them
8570 if (mask->sget_value_at(pvec[i])==0.0f) {
8571 pvec.erase(pvec.begin()+i);
8572 i--;
8573 continue;
8574 }
8575
8576 // mask out the points in the volume
8577 mask->set_value_at(pvec[i],0.0f);
8578
8579 int x=pvec[i][0];
8580 int y=pvec[i][1];
8581 int z=pvec[i][2];
8582 // Any neighboring values above threshold we haven't already set get added to the list
8583 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));
8584 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));
8585 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));
8586 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));
8587 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));
8588 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));
8589 }
8590
8591 // If the blob is too big, then we don't mask it out after all, but we set the value
8592 // to 2.0 so we know the voxels have already been examined, and don't check them again
8593 if (pvec.size()>voxels) {
8594 if (verbose) printf("%d\t%d\t%d\tvoxels: %d\n",xx,yy,zz,(int)pvec.size());
8595 for (uint i=0; i<pvec.size(); i++) mask->set_value_at(pvec[i],2.0);
8596 }
8597 }
8598 }
8599 }
8600 }
8601
8602 mask->process_inplace("threshold.binary",Dict("value",0.5));
8603
8604 // Now we expand the mask by 1 pixel and blur the edge
8605 mask->mult(-1.0f);
8606 mask->add(1.0f);
8607 mask->process_inplace("mask.addshells",Dict("nshells",2)); // expand by 1 shell
8608 mask->process_inplace("filter.lowpass.gauss",Dict("cutoff_abs",0.25f));
8609 mask->mult(-1.0f);
8610 mask->add(1.0f);
8611 mask->update();
8612
8613 // apply the mask
8614 image->mult(*mask);
8615 if (verbose>1) mask->write_image("mask.hdf", 0, EMUtil::IMAGE_HDF);
8616
8617 delete mask;
8618}
Dict is a dictionary to store <string, EMObject> pair.
Definition: emobject.h:385
type set_default(const string &key, type val)
Default setting behavior This can be achieved using a template - d.woolford Jan 2008 (before there wa...
Definition: emobject.h:569
EMData stores an image's data and defines core image processing routines.
Definition: emdata.h:82
#define LOGWARN
Definition: log.h:53
Vec3< int > Vec3i
Definition: vec3.h:694
#define y(i, j)
Definition: projector.cpp:1516
#define x(i)
Definition: projector.cpp:1517

References image, EMAN::EMUtil::IMAGE_HDF, LOGWARN, mask, EMAN::Processor::params, EMAN::Dict::set_default(), x, and y.

Member Data Documentation

◆ image

EMData* EMAN::AutoMaskDustProcessor::image
protected

Definition at line 6899 of file processor.h.

Referenced by process_inplace().

◆ mask

EMData* EMAN::AutoMaskDustProcessor::mask
protected

Definition at line 6898 of file processor.h.

Referenced by process_inplace().

◆ NAME

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

Definition at line 6895 of file processor.h.

Referenced by get_name().


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