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

IterAverager performs iterative averaging of 3x3 pixel zones around each pixel, computing the mean of the 9 pixels initially, then iteratively refining the average to produce something self-consistent, but hopefully less noisy. More...

#include <averager.h>

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

Public Member Functions

 IterAverager ()
 
void add_image (EMData *image)
 To add an image to the Averager. More...
 
EMDatafinish ()
 Finish up the averaging and return the result. More...
 
string get_name () const
 Get the Averager's name. More...
 
string get_desc () const
 
TypeDict get_param_types () const
 Get Averager parameter information in a dictionary. More...
 
- Public Member Functions inherited from EMAN::Averager
 Averager ()
 
virtual ~Averager ()
 
virtual void add_image_list (const vector< EMData * > &images)
 To add multiple images to the Averager. More...
 
virtual void set_params (const Dict &new_params)
 Set the Averager parameters using a key/value dictionary. More...
 
virtual void mult (const float &s)
 Multiply the result image by some floating point constant This is useful when weighting the input images prior to calling add_image - a situation where it is likely you want to divide by the sum of the weights. More...
 

Static Public Member Functions

static AveragerNEW ()
 

Static Public Attributes

static const string NAME = "iterative"
 

Private Attributes

std::vector< EMData * > images
 

Additional Inherited Members

- Protected Attributes inherited from EMAN::Averager
Dict params
 
EMDataresult
 

Detailed Description

IterAverager performs iterative averaging of 3x3 pixel zones around each pixel, computing the mean of the 9 pixels initially, then iteratively refining the average to produce something self-consistent, but hopefully less noisy.

Definition at line 260 of file averager.h.

Constructor & Destructor Documentation

◆ IterAverager()

IterAverager::IterAverager ( )

Definition at line 685 of file averager.cpp.

686{
687
688}

Referenced by NEW().

Member Function Documentation

◆ add_image()

void IterAverager::add_image ( EMData image)
virtual

To add an image to the Averager.

This image will be averaged in this function.

Parameters
imageThe image to be averaged.

Reimplemented from EMAN::Averager.

Definition at line 690 of file averager.cpp.

691{
692 if (!image) return;
693
694 images.push_back(image->do_fft());
695}
std::vector< EMData * > images
Definition: averager.h:292

References images.

◆ finish()

EMData * IterAverager::finish ( )
virtual

Finish up the averaging and return the result.

Returns
The averaged image.

Implements EMAN::Averager.

Definition at line 697 of file averager.cpp.

698{
699 if (images.size()==0) return NULL;
700
701 int nx = images.front()->get_xsize();
702 int ny = images.front()->get_ysize();
703 int nz = images.front()->get_zsize();
704
705 if (nz!=1) throw ImageDimensionException("IterAverager is for 2-D images only");
706
707 if (result) delete result;
708 result=new EMData(nx-2,ny,nz,0);
709 result -> to_zero();
710
711 EMData *tmp=new EMData(nx-2,ny,nz,0);
712 tmp -> to_zero();
713
714 for (int it=0; it<4; it++) {
715 for (int y=-ny/2+1; y<ny/2-1; y++) {
716 for (int x=0; x<nx-2; x++) {
717 std::complex<double> nv=0;
718 // put the vector on the inside, then we can accumulate into a double easily
719 for (vector<EMData *>::iterator im=images.begin(); im<images.end(); im++) {
720 for (int yy=y-1; yy<=y+1; yy++) {
721 for (int xx=x-1; xx<=x+1; xx++) {
722 nv+=(*im)->get_complex_at(xx,yy)+tmp->get_complex_at(x,y)-tmp->get_complex_at(xx,yy);
723 }
724 }
725 }
726 result->set_complex_at(x,y,std::complex<float>(nv/(9.0*images.size())));
727 }
728 }
729 // Swap the pointers
730 result->write_image("dbug.hdf",-1);
731 EMData *swp=tmp;
732 tmp=result;
733 result=swp;
734 }
735
736 delete result;
737 result=0;
738 for (vector<EMData *>::iterator im=images.begin(); im<images.end(); im++) delete (*im);
739 images.clear();
740 result=tmp->do_ift();
741 delete tmp;
742 return result;
743}
EMData * result
Definition: averager.h:158
EMData stores an image's data and defines core image processing routines.
Definition: emdata.h:82
void to_zero()
Set all the pixel value = 0.
#define ImageDimensionException(desc)
Definition: exception.h:166
#define y(i, j)
Definition: projector.cpp:1516
#define x(i)
Definition: projector.cpp:1517

References ImageDimensionException, images, EMAN::Averager::result, to_zero(), x, and y.

◆ get_desc()

string EMAN::IterAverager::get_desc ( ) const
inlinevirtual

Implements EMAN::Averager.

Definition at line 273 of file averager.h.

274 {
275 return "EXPERIMENTAL! Not suggested for normal use. An iterative averager making use of local correlations for noise reduction";
276 }

◆ get_name()

string EMAN::IterAverager::get_name ( ) const
inlinevirtual

Get the Averager's name.

Each Averager is identified by a unique name.

Returns
The Averager's name.

Implements EMAN::Averager.

Definition at line 268 of file averager.h.

269 {
270 return NAME;
271 }
static const string NAME
Definition: averager.h:289

References NAME.

◆ get_param_types()

TypeDict EMAN::IterAverager::get_param_types ( ) const
inlinevirtual

Get Averager 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::Averager.

Definition at line 283 of file averager.h.

284 {
285 TypeDict d;
286 return d;
287 }

◆ NEW()

static Averager * EMAN::IterAverager::NEW ( )
inlinestatic

Definition at line 278 of file averager.h.

279 {
280 return new IterAverager();
281 }

References IterAverager().

Member Data Documentation

◆ images

std::vector<EMData*> EMAN::IterAverager::images
private

Definition at line 292 of file averager.h.

Referenced by add_image(), and finish().

◆ NAME

const string IterAverager::NAME = "iterative"
static

Definition at line 289 of file averager.h.

Referenced by get_name().


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