EMAN::BoxMedianProcessor Class Reference

A processor for noise reduction. More...

#include <processor.h>

Inheritance diagram for EMAN::BoxMedianProcessor:

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

Collaboration graph
[legend]
List of all members.

Public Member Functions

string get_name () const
 Get the processor's name.
string get_desc () const
 Get the descrition of this specific processor.

Static Public Member Functions

static ProcessorNEW ()

Static Public Attributes

static const string NAME = "eman1.filter.median"

Protected Member Functions

void process_pixel (float *pixel, const float *array, int n) const

Detailed Description

A processor for noise reduction.

pixel = median of values surrounding pixel.

Definition at line 2964 of file processor.h.


Member Function Documentation

string EMAN::BoxMedianProcessor::get_desc (  )  const [inline, virtual]

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 2976 of file processor.h.

02977                 {
02978                         return "A processor for noise reduction. pixel = median of values surrounding pixel.";
02979                 }

string EMAN::BoxMedianProcessor::get_name (  )  const [inline, virtual]

Get the processor's name.

Each processor is identified by a unique name.

Returns:
The processor's name.

Implements EMAN::Processor.

Definition at line 2967 of file processor.h.

References NAME.

02968                 {
02969                         return NAME;
02970                 }

static Processor* EMAN::BoxMedianProcessor::NEW (  )  [inline, static]

Definition at line 2971 of file processor.h.

02972                 {
02973                         return new BoxMedianProcessor();
02974                 }

void EMAN::BoxMedianProcessor::process_pixel ( float *  pixel,
const float *  array,
int  n 
) const [inline, protected, virtual]

Implements EMAN::BoxStatProcessor.

Definition at line 2984 of file processor.h.

References data, and t.

02985                 {
02986                         float *data = new float[n];
02987                         memcpy(data, array, sizeof(float) * n);
02988 
02989                         for (int i = 0; i <= n / 2; i++)
02990                         {
02991                                 for (int j = i + 1; j < n; j++)
02992                                 {
02993                                         if (data[i] < data[j]) {
02994                                                 float t = data[i];
02995                                                 data[i] = data[j];
02996                                                 data[j] = t;
02997                                         }
02998                                 }
02999                         }
03000 
03001                         if (n % 2 != 0)
03002                         {
03003                                 *pixel = data[n / 2];
03004                         }
03005                         else {
03006                                 *pixel = (data[n / 2] + data[n / 2 - 1]) / 2;
03007                         }
03008                         if( data )
03009                         {
03010                                 delete[]data;
03011                                 data = 0;
03012                         }
03013                 }


Member Data Documentation

const string BoxMedianProcessor::NAME = "eman1.filter.median" [static]

Definition at line 2981 of file processor.h.

Referenced by get_name().


The documentation for this class was generated from the following files:
Generated on Tue May 25 17:16:53 2010 for EMAN2 by  doxygen 1.4.7