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

Uses a 1/0 mask defining a region to use for the zero-normalization.if no_sigma is 1, standard deviation not modified. More...

#include <processor.h>

Inheritance diagram for EMAN::NormalizeMaskProcessor:
Inheritance graph
[legend]
Collaboration diagram for EMAN::NormalizeMaskProcessor:
Collaboration graph
[legend]

Public Member Functions

void process_inplace (EMData *image)
 To process an image in-place. More...
 
string get_name () const
 Get the processor's name. More...
 
string get_desc () const
 Get the descrition of this specific processor. More...
 
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 = "normalize.mask"
 

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

Uses a 1/0 mask defining a region to use for the zero-normalization.if no_sigma is 1, standard deviation not modified.

Parameters
maskThe 0-1 mask defining the region for the normalization. Any non-zero values will be considered
no_sigmaIf set, the mean will be set to zero, but sigma will not be modified
apply_maskIf set, the mask will also be applied (multiplied) to the volume

Definition at line 5958 of file processor.h.

Member Function Documentation

◆ get_desc()

string EMAN::NormalizeMaskProcessor::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 5968 of file processor.h.

5969 {
5970 return "Uses a 1/0 mask defining a region to use for the zero-normalization.if no_sigma is 1, standard deviation not modified.";
5971 }

◆ get_name()

string EMAN::NormalizeMaskProcessor::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 5963 of file processor.h.

5964 {
5965 return NAME;
5966 }
static const string NAME
Definition: processor.h:5987

References NAME.

◆ get_param_types()

TypeDict EMAN::NormalizeMaskProcessor::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 5978 of file processor.h.

5979 {
5980 TypeDict d;
5981 d.put("mask", EMObject::EMDATA, "The 0-1 mask defining the region for the normalization. Any non-zero values will be considered");
5982 d.put("no_sigma", EMObject::INT, "If set, the mean will be set to zero, but sigma will not be modified");
5983 d.put("apply_mask", EMObject::INT, "If set, the mask will also be applied (multiplied) to the volume");
5984 return d;
5985 }
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::EMDATA, EMAN::EMObject::INT, and EMAN::TypeDict::put().

◆ NEW()

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

Definition at line 5973 of file processor.h.

5974 {
5975 return new NormalizeMaskProcessor();
5976 }
Uses a 1/0 mask defining a region to use for the zero-normalization.if no_sigma is 1,...
Definition: processor.h:5959

◆ process_inplace()

void NormalizeMaskProcessor::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 4685 of file processor.cpp.

4686{
4687 if (!image) {
4688 LOGWARN("NULL Image");
4689 return;
4690 }
4691 EMData *mask = params["mask"];
4692 int no_sigma = params.set_default("no_sigma",0);
4693 int apply_mask = params.set_default("apply_mask",0);
4694
4695 int nx=image->get_xsize();
4696 int ny=image->get_ysize();
4697 int nz=image->get_zsize();
4698
4699 double sum=0;
4700 double sumsq=0;
4701 double nnz=0;
4702
4703 for (int z=0; z<nz; z++) {
4704 for (int y=0; y<ny; y++) {
4705 for (int x=0; x<nx; x++) {
4706 double m=mask->get_value_at(x,y,z);
4707 if (m==0) continue;
4708 if (!apply_mask) m=1.0; // If not applying the mask (which may have values between 0 and 1) we don't want to alter the values
4709 double v=(double)image->get_value_at(x,y,z)*m;
4710 sum+=v;
4711 sumsq+=v*v;
4712 nnz+=1.0;
4713 }
4714 }
4715 }
4716
4717 float mean=(float)(sum/nnz);
4718 float sigma=sqrt((float)(sumsq-sum*sum/nnz)/nnz);
4719 if (no_sigma) sigma=1.0f;
4720
4721 for (int z=0; z<nz; z++) {
4722 for (int y=0; y<ny; y++) {
4723 for (int x=0; x<nx; x++) {
4724 float m=mask->get_value_at(x,y,z);
4725 if (!apply_mask) m=1.0; // If not applying the mask (which may have values between 0 and 1) we don't want to alter the values
4726 if (m==0) image->set_value_at(x,y,z,0);
4727 else image->set_value_at(x,y,z,(image->get_value_at(x,y,z)*m-mean)/sigma);
4728 }
4729 }
4730 }
4731}
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
EMData * sqrt() const
return square root of current image
#define LOGWARN
Definition: log.h:53
#define y(i, j)
Definition: projector.cpp:1516
#define x(i)
Definition: projector.cpp:1517

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

Member Data Documentation

◆ NAME

const string NormalizeMaskProcessor::NAME = "normalize.mask"
static

Definition at line 5987 of file processor.h.

Referenced by get_name().


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