EMAN2
Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
EMAN::AutoMask3DProcessor Class Reference

Tries to mask out only interesting density. More...

#include <processor.h>

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

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...
 
- Protected Attributes inherited from EMAN::Processor
Dict params
 

Detailed Description

Tries to mask out only interesting density.

Parameters
threshold1
threshold2

Definition at line 6906 of file processor.h.

Member Function Documentation

◆ get_desc()

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

6934 {
6935 return "Tries to mask out only interesting density";
6936 }

◆ get_name()

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

6912 {
6913 return NAME;
6914 }
static const string NAME
Definition: processor.h:6938

References NAME.

◆ get_param_types()

virtual TypeDict EMAN::AutoMask3DProcessor::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 6921 of file processor.h.

6922 {
6923 TypeDict d;
6924 d.put("threshold1", EMObject::FLOAT, "High initial threshold for seeding.");
6925 d.put("threshold2", EMObject::FLOAT, "Lower secondary threshold to define boundary.");
6926 d.put("nshells", EMObject::INT, "Number of 1-voxel shells to expand the mask by.");
6927 d.put("nshellsgauss", EMObject::INT, "Width in voxels of a Gaussian decay at the edge of the mask.");
6928 d.put("return_mask", EMObject::BOOL, "If true the result of the operation will produce the mask, not the masked volume.");
6929
6930 return d;
6931 }
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::BOOL, EMAN::EMObject::FLOAT, EMAN::EMObject::INT, and EMAN::TypeDict::put().

◆ NEW()

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

Definition at line 6916 of file processor.h.

6917 {
6918 return new AutoMask3DProcessor();
6919 }
Tries to mask out only interesting density.
Definition: processor.h:6907

◆ process_inplace()

void AutoMask3DProcessor::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 8486 of file processor.cpp.

8487{
8488 if (!image) {
8489 LOGWARN("NULL Image");
8490 return;
8491 }
8492
8493
8494 float sig = image->get_attr("sigma");
8495 float mean = image->get_attr("mean");
8496
8497 float thr1 = params.set_default("threshold1",mean + sig * 2);
8498 float thr2 = params.set_default("threshold2",mean + sig * 1);
8499
8500 EMData *mask=image->copy();
8501 mask->process_inplace("threshold.binary",Dict("value",thr1));
8502
8503 EMData *mask2=image->copy();
8504 mask2->process_inplace("threshold.binary",Dict("value",thr2));
8505 float maskmean=mask->get_attr("mean");
8506 for (int i=0; i<1000; i++){
8507 mask->process_inplace("mask.addshells",Dict("nshells",2));
8508 mask->mult(*mask2);
8509 if (float(mask->get_attr("mean"))==maskmean)
8510 break;
8511 maskmean=mask->get_attr("mean");
8512// printf("%d\t%f\n", i, maskmean);
8513 }
8514
8515
8516 // below copied from mask.auto3d
8517 int nshells = params["nshells"];
8518 int nshellsgauss = params["nshellsgauss"];
8519
8520 mask->process_inplace("mask.addshells.gauss", Dict("val1", (int)(nshells+nshellsgauss/2),"val2",0));
8521 if (nshellsgauss>0)
8522 mask->process_inplace("filter.lowpass.gauss", Dict("cutoff_abs", (float)(1.0f/(float)nshellsgauss)));
8523
8524 mask->process_inplace("threshold.belowtozero", Dict("minval",(float)0.002)); // this makes the value exactly 0 beyond ~2.5 sigma
8525
8526 bool return_mask = params.set_default("return_mask",false);
8527 if (return_mask) {
8528 // Yes there is probably a much more efficient way of getting the mask itself, but I am only providing a stop gap at the moment.
8529 float *dat = image->get_data();
8530 float *dat2 = mask->get_data();
8531 memcpy(dat,dat2,image->get_size()*sizeof(float));
8532 } else {
8533 image->mult(*mask);
8534 }
8535
8536 delete mask;
8537 delete mask2;
8538}
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

References LOGWARN, EMAN::Processor::params, and EMAN::Dict::set_default().

Member Data Documentation

◆ NAME

const string AutoMask3DProcessor::NAME = "mask.auto3d.thresh"
static

Definition at line 6938 of file processor.h.

Referenced by get_name().


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