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

This processor will try and remove outliers (and optionally exactly zero values), replacing any identified values with the local mean value. More...

#include <processor.h>

Inheritance diagram for EMAN::OutlierProcessor:
Inheritance graph
[legend]
Collaboration diagram for EMAN::OutlierProcessor:
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...
 
TypeDict get_param_types () const
 Get processor parameter information in a dictionary. More...
 
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 ="threshold.outlier.localmean"
 

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 processor will try and remove outliers (and optionally exactly zero values), replacing any identified values with the local mean value.

Parameters
sigmaoutliers are defined as mean+-x*sigma where x is the specified value
fix_zeroif set, any values that are exactly zero will be treated as outliers)

Definition at line 5553 of file processor.h.

Member Function Documentation

◆ get_desc()

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

5577 {
5578 return "Identifies any pixels that are outliers and adjusts them to be the average of any nearby non-outlier pixels. Operates iteratively when required, so large 'outlier' areas can be corrected.";
5579 }

◆ get_name()

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

5559 {
5560 return NAME;
5561 }
static const string NAME
Definition: processor.h:5581

References NAME.

◆ get_param_types()

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

5569 {
5570 TypeDict d;
5571 d.put("fix_zero", EMObject::BOOL, "If set, any pixels that are exactly zero are considered to be outliers, default=false");
5572 d.put("sigma", EMObject::FLOAT, "outliers are defined as mean+-x*sigma where x is the specified value, default=3.0");
5573 return d;
5574 }
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, and EMAN::TypeDict::put().

◆ NEW()

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

Definition at line 5563 of file processor.h.

5564 {
5565 return new OutlierProcessor();
5566 }
This processor will try and remove outliers (and optionally exactly zero values), replacing any ident...
Definition: processor.h:5554

◆ process_inplace()

void OutlierProcessor::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 4166 of file processor.cpp.

4167{
4168 if (!image) {
4169 LOGWARN("NULL Image");
4170 return;
4171 }
4172
4173 bool fix_zero=(bool)params.set_default("fix_zero",0);
4174 float sigmamult=(float)params.set_default("sigma",3.0);
4175
4176 if (sigmamult<=0.0) throw InvalidValueException(sigmamult,"threshold.outlier.localmean: sigma must be >0");
4177
4178 float hithr=(float)image->get_attr("mean")+(float)(image->get_attr("sigma"))*sigmamult;
4179 float lothr=(float)image->get_attr("mean")-(float)(image->get_attr("sigma"))*sigmamult;
4180
4181 int nx=image->get_xsize();
4182 int ny=image->get_ysize();
4183 int nz=image->get_zsize();
4184
4185 // This isn't optimally efficient
4186 EMData *im[2];
4187 im[0]=image;
4188 im[1]=image->copy_head();
4189
4190 if (nz==1) {
4191 int repeat=1;
4192 while (repeat) {
4193 memcpy(im[1]->get_data(),im[0]->get_data(),image->get_xsize()*image->get_ysize()*image->get_zsize()*sizeof(float));
4194 repeat=0;
4195 for (int y=0; y<ny; y++) {
4196 for (int x=0; x<nx; x++) {
4197 // if the pixel is an outlier
4198 float pix=im[1]->get_value_at(x,y);
4199 if (pix>hithr || pix<lothr || (pix==0 && fix_zero)) {
4200 int y0=0>y-1?0:y-1;
4201 int y1=y>=ny-1?ny-1:y+1;
4202 int x0=0>x-1?0:x-1;
4203 int x1=x>=nx-1?nx-1:x+1;
4204 float c=0.0f,nc=0.0f;
4205 for (int yy=y0; yy<=y1; yy++) {
4206 for (int xx=x0; xx<=x1; xx++) {
4207 float lpix=im[1]->get_value_at(xx,yy);
4208 if (lpix>hithr || lpix<lothr || (lpix==0 && fix_zero)) continue;
4209 c+=lpix;
4210 nc++;
4211 }
4212 }
4213 if (nc!=0) im[0]->set_value_at(x,y,c/nc);
4214 else repeat=1;
4215 }
4216 }
4217 }
4218 }
4219 }
4220 else {
4221 throw ImageDimensionException("threshold.outlier.localmean: 3D not yet implemented");
4222 }
4223 delete im[1];
4224}
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
float * get_data() const
Get the image pixel density data in a 1D float array.
#define InvalidValueException(val, desc)
Definition: exception.h:285
#define ImageDimensionException(desc)
Definition: exception.h:166
#define LOGWARN
Definition: log.h:53
#define y(i, j)
Definition: projector.cpp:1516
#define x(i)
Definition: projector.cpp:1517

References get_data(), ImageDimensionException, InvalidValueException, LOGWARN, EMAN::Processor::params, EMAN::Dict::set_default(), x, and y.

Member Data Documentation

◆ NAME

const string OutlierProcessor::NAME ="threshold.outlier.localmean"
static

Definition at line 5581 of file processor.h.

Referenced by get_name().


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