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

makes image circularly symmetric. More...

#include <processor.h>

Inheritance diagram for EMAN::RotationalAverageProcessor:
Inheritance graph
[legend]
Collaboration diagram for EMAN::RotationalAverageProcessor:
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...
 
- 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...
 
virtual TypeDict get_param_types () const
 Get processor parameter information in a 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 = "math.rotationalaverage"
 

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

makes image circularly symmetric.

Definition at line 6300 of file processor.h.

Member Function Documentation

◆ get_desc()

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

6316 {
6317 return "Makes image circularly/spherically symmetric.";
6318 }

◆ get_name()

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

6306 {
6307 return NAME;
6308 }
static const string NAME
Definition: processor.h:6320

References NAME.

◆ NEW()

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

Definition at line 6310 of file processor.h.

6311 {
6312 return new RotationalAverageProcessor();
6313 }
makes image circularly symmetric.
Definition: processor.h:6301

◆ process_inplace()

void RotationalAverageProcessor::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 5595 of file processor.cpp.

5596{
5597 int isinten=image->get_attr_default("is_intensity",0);
5598 if (!image || ((image->is_complex() && image->get_ndim() > 2))){
5599 LOGWARN("only works on real or 2D intensity images. do nothing.");
5600 return;
5601 }
5602
5603 if (image->get_ndim() <= 0 || image->get_ndim() > 3) throw ImageDimensionException("radial average processor only works for real and 2D intensity images");
5604
5605 float *rdata = image->get_data();
5606 int nx = image->get_xsize();
5607 int ny = image->get_ysize();
5608
5609 vector < float >dist = image->calc_radial_dist(nx / 2, 0, 1, 1);
5610
5611 if ((!image->is_complex()) && (isinten == 1)) {
5612 std::reverse(dist.begin(),dist.end());
5613 }
5614
5615 float midx = (float)((int)nx/2);
5616 float midy = (float)((int)ny/2);
5617
5618 size_t c = 0;
5619 if (image->is_complex() && image->get_ndim() == 2) {
5620 for (int y = -ny/2; y < ny/2; y++) {
5621 for (int x = -ny/2-1; x < nx/2+1; x++) {
5622 float r = (float) hypot(x,y);
5623 int i = (int) floor(r);
5624 r -= i;
5625 if (i >= 0 && i < nx / 2 - 1) {
5626 image->set_complex_at(x, y, dist[i] * (1.0f - r) + dist[i + 1] * r);
5627 }
5628 else if (i < 0) {
5629 image->set_complex_at(x, y, dist[0]);
5630 }
5631 else {
5632 image->set_complex_at(x, y, 0);
5633 }
5634 }
5635 }
5636 }
5637 else if (image->get_ndim() == 2) {
5638 for (int y = 0; y < ny; y++) {
5639 for (int x = 0; x < nx; x++, c++) {
5640 float r = (float) hypot(x - midx, y - midy);
5641
5642 int i = (int) floor(r);
5643 r -= i;
5644 if (i >= 0 && i < nx / 2 - 1) {
5645 rdata[c] = dist[i] * (1.0f - r) + dist[i + 1] * r;
5646 }
5647 else if (i < 0) {
5648 rdata[c] = dist[0];
5649 }
5650 else {
5651 rdata[c] = 0;
5652 }
5653 }
5654 }
5655 }
5656 else if (image->get_ndim() == 3) {
5657 int nz = image->get_zsize();
5658 float midz = (float)((int)nz/2);
5659 float r;
5660 int i;
5661 for (int z = 0; z < nz; ++z) {
5662 for (int y = 0; y < ny; ++y) {
5663 for (int x = 0; x < nx; ++x, ++c) {
5664
5665 r = (float) Util::hypot3(x - midx, y - midy, z - midz);
5666
5667 i = Util::fast_floor(r);
5668 r -= i;
5669 if (i >= 0 && i < nx / 2 - 1) {
5670 rdata[c] = dist[i] * (1.0f - r) + dist[i + 1] * r;
5671 }
5672 else if (i < 0) {
5673 rdata[c] = dist[0];
5674 }
5675 else {
5676 rdata[c] = 0;
5677 }
5678 }
5679 }
5680 }
5681 }
5682
5683 image->update();
5684}
#define rdata(i)
Definition: analyzer.cpp:592
vector< float > calc_radial_dist(int n, float x0, float dx, int inten)
calculates radial distribution.
Definition: emdata.cpp:2781
static int fast_floor(float x)
A fast way to calculate a floor, which is largest integral value not greater than argument.
Definition: util.h:874
static float hypot3(int x, int y, int z)
Euclidean distance function in 3D: f(x,y,z) = sqrt(x*x + y*y + z*z);.
Definition: util.h:827
#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 EMAN::EMData::calc_radial_dist(), EMAN::Util::fast_floor(), EMAN::Util::hypot3(), ImageDimensionException, LOGWARN, rdata, x, and y.

Member Data Documentation

◆ NAME

const string RotationalAverageProcessor::NAME = "math.rotationalaverage"
static

Definition at line 6320 of file processor.h.

Referenced by get_name().


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