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

Smart mask processor. More...

#include <processor.h>

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

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

Smart mask processor.

Parameters
maskmask value

Definition at line 7986 of file processor.h.

Member Function Documentation

◆ get_desc()

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

8002 {
8003 return "Smart mask processor.";
8004 }

◆ get_name()

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

7992 {
7993 return NAME;
7994 }
static const string NAME
Definition: processor.h:8013

References NAME.

◆ get_param_types()

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

8007 {
8008 TypeDict d;
8009 d.put("mask", EMObject::FLOAT, "mask value");
8010 return d;
8011 }
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::SmartMaskProcessor::NEW ( )
inlinestatic

Definition at line 7996 of file processor.h.

7997 {
7998 return new SmartMaskProcessor();
7999 }
Smart mask processor.
Definition: processor.h:7987

◆ process_inplace()

void SmartMaskProcessor::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 8431 of file processor.cpp.

8432{
8433 if (!image) {
8434 LOGWARN("NULL Image");
8435 return;
8436 }
8437
8438 float mask = params["mask"];
8439
8440 int nx = image->get_xsize();
8441 int ny = image->get_ysize();
8442 int nz = image->get_zsize();
8443
8444 float *dat = image->get_data();
8445 double sma = 0;
8446 size_t smn = 0;
8447 float r = 0.0f;
8448 for (int k = 0; k < nz; ++k) {
8449 for (int j = 0; j < ny; ++j) {
8450 for (int i = 0; i < nx; ++i, ++dat) {
8451 r =
8452 sqrt((float) Util::square(i - nx / 2) + Util::square(j - ny / 2) +
8453 Util::square(k - nz / 2));
8454 if (r > mask - 1.5f && r < mask - 0.5f) {
8455 sma += *dat;
8456 smn++;
8457 }
8458 }
8459 }
8460 }
8461
8462 float smask = (float) (sma / smn);
8463 image->update();
8464
8465 dat = image->get_data();
8466 for (int k = 0; k < nz; ++k) {
8467 for (int j = 0; j < ny; ++j) {
8468 for (int i = 0; i < nx; ++i, ++dat) {
8469 r =
8470 sqrt((float) Util::square(i - nx / 2) + Util::square(j - ny / 2) +
8471 Util::square(k - nz / 2));
8472 if (r > mask - .5) {
8473 *dat = 0;
8474 }
8475 else {
8476 *dat -= smask;
8477 }
8478 }
8479 }
8480 }
8481
8482 image->update();
8483}
static int square(int n)
Calculate a number's square.
Definition: util.h:736
EMData * sqrt() const
return square root of current image
#define LOGWARN
Definition: log.h:53

References LOGWARN, EMAN::Processor::params, sqrt(), and EMAN::Util::square().

Member Data Documentation

◆ NAME

const string SmartMaskProcessor::NAME = "mask.smart"
static

Definition at line 8013 of file processor.h.

Referenced by get_name().


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