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

Iterative expansion of a binary mask, val1 is number of pixels to expand, if val2!=0 will make a soft Gaussian edge starting after val2 pixels. More...

#include <processor.h>

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

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

Iterative expansion of a binary mask, val1 is number of pixels to expand, if val2!=0 will make a soft Gaussian edge starting after val2 pixels.

Parameters
val1number of pixels to expand
val2number of Gaussian pixels to expand, following the first expansion

Definition at line 8020 of file processor.h.

Member Function Documentation

◆ get_desc()

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

8031 {
8032 return "Iterative expansion of a binary mask, val1 is number of pixels to expand, if val2!=0 will make a soft Gaussian edge starting after val2 pixels.";
8033 }

◆ get_name()

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

8026 {
8027 return NAME;
8028 }
static const string NAME
Definition: processor.h:8048

References NAME.

◆ get_param_types()

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

8041 {
8042 TypeDict d;
8043 d.put("val1", EMObject::FLOAT, "number of pixels to expand");
8044 d.put("val2", EMObject::FLOAT, "number of Gaussian pixels to expand, following the first expansion");
8045 return d;
8046 }
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, and EMAN::TypeDict::put().

◆ NEW()

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

Definition at line 8035 of file processor.h.

8036 {
8037 return new IterBinMaskProcessor();
8038 }
Iterative expansion of a binary mask, val1 is number of pixels to expand, if val2!...
Definition: processor.h:8021

◆ process_inplace()

void IterBinMaskProcessor::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 8745 of file processor.cpp.

8746{
8747 if (!image) {
8748 LOGWARN("NULL Image");
8749 return;
8750 }
8751
8752 float val1 = params["val1"];
8753 float val2 = params["val2"];
8754
8755 int nx = image->get_xsize();
8756 int ny = image->get_ysize();
8757 int nz = image->get_zsize();
8758 EMData *image2 = new EMData(nx,ny,nz);
8759
8760 // Got a compile warning complaining that these things were never used. Hope I didn't break anything - apologies if so (d.woolford)
8761// float *dat = image->get_data();
8762// float *dat2 = image2->get_data();
8763
8764
8765 float *d = image->get_data();
8766 float *d2 = image2->get_data();
8767
8768 const int nxy = nx * ny;
8769 size_t size = (size_t)nx * ny * nz;
8770
8771 // TODO: THIS IS EXTREMELY INEFFICIENT
8772 if (nz != 1) {
8773 for (int l = 1; l <= (int) val1+val2; ++l) {
8774 for (size_t i=0; i<size; i++) d2[i]=d[i];
8775 for (int k = 1; k < nz - 1; ++k) {
8776 for (int j = 1; j < ny - 1; ++j) {
8777 for (int i = 1; i < nx - 1; ++i) {
8778 size_t t = i + j*nx+(size_t)k*nx*ny;
8779 if (d[t]) continue;
8780 if (d2[t - 1] || d2[t + 1] || d2[t + nx] || d2[t - nx] || d2[t + nxy] || d2[t - nxy]) d[t] = (float) l + 1;
8781 }
8782 }
8783 }
8784 }
8785 }
8786 else {
8787 for (int l = 1; l <= (int) val1+val2; ++l) {
8788 for (size_t i=0; i<size; i++) d2[i]=d[i];
8789 for (int j = 1; j < ny - 1; ++j) {
8790 for (int i = 1; i < nx - 1; ++i) {
8791 size_t t = i + j * nx;
8792 if (d[t]) continue;
8793 if (d2[t - 1] || d2[t + 1] || d2[t + nx] || d2[t - nx]) d[t] = (float) l + 1;
8794 }
8795 }
8796 }
8797 }
8798
8799 vector<float> vec;
8800 for (int i=0; i<val1+2; i++) vec.push_back(1.0);
8801 for (int i=0; i<val2; i++) {
8802 vec.push_back(exp(-pow(2.0f*i/(val2),2.0f)));
8803// printf("%f\n",exp(-pow(2.0*i/(val1-val2),2.0)));
8804 }
8805 for (size_t i = 0; i < size; ++i) if (d[i]) d[i]=vec[(int)d[i]];
8806
8807 image->update();
8808 delete image2;
8809}
EMData stores an image's data and defines core image processing routines.
Definition: emdata.h:82
#define LOGWARN
Definition: log.h:53

References LOGWARN, and EMAN::Processor::params.

Member Data Documentation

◆ NAME

const string IterBinMaskProcessor::NAME = "mask.addshells.gauss"
static

Definition at line 8048 of file processor.h.

Referenced by get_name().


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