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

This expands a multilevel mask volume so inter-mask boundaries are preserved. More...

#include <processor.h>

Inheritance diagram for EMAN::IterMultiMaskProcessor:
Inheritance graph
[legend]
Collaboration diagram for EMAN::IterMultiMaskProcessor:
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 string get_desc () const
 Get the descrition of this specific processor. More...
 
virtual TypeDict get_param_types () const
 Get processor parameter information in a dictionary. 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.addshells.multilevel"
 

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

This expands a multilevel mask volume so inter-mask boundaries are preserved.

Parameters
nshellsnumber of shells to add

Definition at line 6990 of file processor.h.

Member Function Documentation

◆ get_desc()

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

7001 {
7002 return "A multilevel mask has an integer value at each pixel location. -1 indicates unmasked regions. 0-n-1 are individual masks. Expands the masked regions into unmasked areas by nshells.";
7003 }

◆ get_name()

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

6996 {
6997 return NAME;
6998 }
static const string NAME
Definition: processor.h:7017

References NAME.

◆ get_param_types()

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

7011 {
7012 TypeDict d;
7013 d.put("nshells", EMObject::INT, "number of shells to add");
7014 return d;
7015 }
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::INT, and EMAN::TypeDict::put().

◆ NEW()

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

Definition at line 7005 of file processor.h.

7006 {
7007 return new IterMultiMaskProcessor();
7008 }
This expands a multilevel mask volume so inter-mask boundaries are preserved.
Definition: processor.h:6991

◆ process_inplace()

void IterMultiMaskProcessor::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 7096 of file processor.cpp.

7097{
7098 if (!image) {
7099 LOGWARN("NULL Image");
7100 return;
7101 }
7102
7103 int nx = image->get_xsize();
7104 int ny = image->get_ysize();
7105 int nz = image->get_zsize();
7106
7107 if (ny == 1) {
7108 LOGERR("Error: mask.addshells.multilevel works only in 2/3-D");
7109 return;
7110 }
7111
7112 int num_shells = params.set_default("nshells",1);
7113
7114 // there are other strategies which might allow us to avoid the extra copy, but this will have to do for now
7115 EMData *image1=image;
7116 EMData *image2=image->copy();
7117 if (nz == 1) {
7118 for (int i = 0; i < num_shells; i++) {
7119 for (int y = 1; y < ny - 1; y++) {
7120 for (int x = 1; x < nx - 1; x++) {
7121 if (image1->get_value_at(x,y)>0) continue; // already part of a masked region
7122
7123 // Note that this produces a directional bias in the case of ambiguous pixels
7124 // While this could be improved upon slightly, there can be truly ambiguous cases
7125 // and at least this method is deterministic
7126 if (image1->get_value_at(x-1,y)>0) image2->set_value_at_fast(x,y,image1->get_value_at(x-1,y));
7127 else if (image1->get_value_at(x+1,y)>0) image2->set_value_at_fast(x,y,image1->get_value_at(x+1,y));
7128 else if (image1->get_value_at(x,y-1)>0) image2->set_value_at_fast(x,y,image1->get_value_at(x,y-1));
7129 else if (image1->get_value_at(x,y+1)>0) image2->set_value_at_fast(x,y,image1->get_value_at(x,y+1));
7130
7131 }
7132 }
7133 memcpy(image1->get_data(),image2->get_data(),image1->get_size()*sizeof(float));
7134 }
7135 }
7136 else {
7137 for (int i = 0; i < num_shells; i++) {
7138 for (int z = 1; z < nz - 1; z++) {
7139 for (int y = 1; y < ny - 1; y++) {
7140 for (int x = 1; x < nx - 1; x++) {
7141 if (image1->get_value_at(x,y,z)>0) continue; // already part of a masked region
7142
7143 // Note that this produces a directional bias in the case of ambiguous pixels
7144 // While this could be improved upon slightly, there can be truly ambiguous cases
7145 // and at least this method is deterministic
7146 if (image1->get_value_at(x-1,y,z)>0) image2->set_value_at_fast(x,y,z,image1->get_value_at(x-1,y,z));
7147 else if (image1->get_value_at(x+1,y,z)>0) image2->set_value_at_fast(x,y,z,image1->get_value_at(x+1,y,z));
7148 else if (image1->get_value_at(x,y-1,z)>0) image2->set_value_at_fast(x,y,z,image1->get_value_at(x,y-1,z));
7149 else if (image1->get_value_at(x,y+1,z)>0) image2->set_value_at_fast(x,y,z,image1->get_value_at(x,y+1,z));
7150 else if (image1->get_value_at(x,y,z-1)>0) image2->set_value_at_fast(x,y,z,image1->get_value_at(x,y,z-1));
7151 else if (image1->get_value_at(x,y,z+1)>0) image2->set_value_at_fast(x,y,z,image1->get_value_at(x,y,z+1));
7152
7153 }
7154 }
7155 }
7156 memcpy(image1->get_data(),image2->get_data(),image1->get_size()*sizeof(float));
7157 }
7158 }
7159
7160 delete image2;
7161 image->update();
7162}
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
#define LOGERR
Definition: log.h:51
#define y(i, j)
Definition: projector.cpp:1516
#define x(i)
Definition: projector.cpp:1517

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

Member Data Documentation

◆ NAME

const string IterMultiMaskProcessor::NAME = "mask.addshells.multilevel"
static

Definition at line 7017 of file processor.h.

Referenced by get_name().


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