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

Calculate the circular average around the center in real space. More...

#include <analyzer.h>

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

Public Member Functions

 CircularAverageAnalyzer ()
 
virtual int insert_image (EMData *image)
 insert a image to the list of input images More...
 
virtual vector< EMData * > analyze ()
 main function for Analyzer, analyze input images and create output images More...
 
string get_name () const
 Get the Analyzer's name. More...
 
string get_desc () const
 Get the Analyzer's description. More...
 
TypeDict get_param_types () const
 Get Analyzer parameter information in a dictionary. More...
 
- Public Member Functions inherited from EMAN::Analyzer
 Analyzer ()
 
virtual ~Analyzer ()
 
virtual int insert_images_list (vector< EMData * > image_list)
 insert a list of images to the list of input images More...
 
virtual void set_params (const Dict &new_params)
 Set the Analyzer parameters using a key/value dictionary. More...
 
virtual Dict get_params () const
 Get the Reconstructor's parameters in a key/value dictionary. More...
 

Static Public Member Functions

static AnalyzerNEW ()
 

Static Public Attributes

static const string NAME = "cir_avg"
 

Protected Attributes

int verbose
 
vector< EMData * > ret
 
- Protected Attributes inherited from EMAN::Analyzer
Dict params
 
vector< EMData * > images
 

Detailed Description

Calculate the circular average around the center in real space.

Author
: Muyuan Chen
Date
: 04/2015

Definition at line 368 of file analyzer.h.

Constructor & Destructor Documentation

◆ CircularAverageAnalyzer()

EMAN::CircularAverageAnalyzer::CircularAverageAnalyzer ( )
inline

Definition at line 371 of file analyzer.h.

Referenced by NEW().

Member Function Documentation

◆ analyze()

vector< EMData * > CircularAverageAnalyzer::analyze ( )
virtual

main function for Analyzer, analyze input images and create output images

Returns
vector<EMData *> result os images analysis

Implements EMAN::Analyzer.

Definition at line 1034 of file analyzer.cpp.

1034 {
1035// for (int i=0; i<10; i++)
1036// avg->set_value_at(i,0,i);
1037
1038 if (images.size()!=1) throw ImageDimensionException("Only takes a single image as input");
1039 int nx=images[0]->get_xsize();
1040 int ny=images[0]->get_ysize();
1041 int nz=images[0]->get_zsize();
1042 if (nz>1)
1043 throw ImageDimensionException("Only takes 2D images.");
1044 int maxr=params.set_default("maxr",nx/2-1);
1045 int step=params.set_default("step",2);
1046
1047 EMData *avg = new EMData(maxr/step+1,1);
1048
1049 int ix,iy,it,count;
1050 for (it=0; it<maxr; it+=step){
1051 float mn=0;
1052 count=0;
1053 for (ix=-maxr-1; ix<=maxr+1; ix++){
1054 for (iy=-maxr-1; iy<=maxr+1; iy++){
1055 int d2=ix*ix+iy*iy;
1056 if (d2>=it*it && d2<(it+step)*(it+step)){
1057 count++;
1058 mn+=images[0]->sget_value_at(ix+nx/2,iy+ny/2);
1059
1060 }
1061 }
1062 }
1063
1064 mn/=count;
1065 if(verbose>0) printf("%d,%d,%f\n",it,count,mn);
1066 avg->set_value_at(it/step,0,mn);
1067 }
1068
1069
1070 ret.push_back(avg);
1071 return ret;
1072}
vector< EMData * > images
Definition: analyzer.h:117
vector< EMData * > ret
Definition: analyzer.h:408
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
#define ImageDimensionException(desc)
Definition: exception.h:166

References ImageDimensionException, EMAN::Analyzer::images, EMAN::Analyzer::params, ret, EMAN::Dict::set_default(), and verbose.

◆ get_desc()

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

Get the Analyzer's description.

Returns
The Analyzer's description.

Implements EMAN::Analyzer.

Definition at line 385 of file analyzer.h.

386 {
387 return "Calculate the circular average around the center in real space";
388 }

◆ get_name()

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

Get the Analyzer's name.

Each Analyzer is identified by a unique name.

Returns
The Analyzer's name.

Implements EMAN::Analyzer.

Definition at line 380 of file analyzer.h.

381 {
382 return NAME;
383 }
static const string NAME
Definition: analyzer.h:404

References NAME.

◆ get_param_types()

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

Get Analyzer 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.

Implements EMAN::Analyzer.

Definition at line 395 of file analyzer.h.

396 {
397 TypeDict d;
398 d.put("verbose", EMObject::INT, "Display progress if set, more detail with larger numbers");
399 d.put("maxr", EMObject::INT, "Maximum radius.");
400 d.put("step", EMObject::INT, "Thickness of the ring.");
401 return d;
402 }

References EMAN::EMObject::INT, and EMAN::TypeDict::put().

◆ insert_image()

virtual int EMAN::CircularAverageAnalyzer::insert_image ( EMData image)
inlinevirtual

insert a image to the list of input images

Parameters
image
Returns
int 0 for success, <0 for fail

Implements EMAN::Analyzer.

Definition at line 373 of file analyzer.h.

373 {
374 images.push_back(image);
375 return 0;
376 }

References EMAN::Analyzer::images.

◆ NEW()

static Analyzer * EMAN::CircularAverageAnalyzer::NEW ( )
inlinestatic

Definition at line 390 of file analyzer.h.

391 {
392 return new CircularAverageAnalyzer();
393 }

References CircularAverageAnalyzer().

Member Data Documentation

◆ NAME

const string EMAN::CircularAverageAnalyzer::NAME = "cir_avg"
static

Definition at line 404 of file analyzer.h.

Referenced by get_name().

◆ ret

vector<EMData *> EMAN::CircularAverageAnalyzer::ret
protected

Definition at line 408 of file analyzer.h.

Referenced by analyze().

◆ verbose

int EMAN::CircularAverageAnalyzer::verbose
protected

Definition at line 407 of file analyzer.h.

Referenced by analyze().


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