EMAN2
Public Member Functions | Static Public Member Functions | Static Public Attributes
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]

List of all members.

Public Member Functions

void process_inplace (EMData *image)
 To process an image in-place.
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 = "math.rotationalaverage"

Detailed Description

makes image circularly symmetric.

Definition at line 4737 of file processor.h.


Member Function Documentation

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

                {
                        return "Makes image circularly/spherically symmetric.";
                }
string EMAN::RotationalAverageProcessor::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 4742 of file processor.h.

References NAME.

                {
                        return NAME;
                }
static Processor* EMAN::RotationalAverageProcessor::NEW ( ) [inline, static]

Definition at line 4747 of file processor.h.

                {
                        return new RotationalAverageProcessor();
                }
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 4461 of file processor.cpp.

References EMAN::EMData::calc_radial_dist(), dist(), EMAN::Util::fast_floor(), EMAN::EMData::get_data(), EMAN::EMData::get_ndim(), EMAN::EMData::get_xsize(), EMAN::EMData::get_ysize(), EMAN::EMData::get_zsize(), EMAN::Util::hypot3(), ImageDimensionException, EMAN::EMData::is_complex(), LOGWARN, nx, ny, rdata, EMAN::EMData::update(), x, and y.

{
        if (!image || image->is_complex()) {
                LOGWARN("only works on real image. do nothing.");
                return;
        }

        if (image->get_ndim() <= 0 || image->get_ndim() > 3)    throw ImageDimensionException("radial average processor only works for 2D and 3D images");

        float *rdata = image->get_data();
        int nx = image->get_xsize();
        int ny = image->get_ysize();

        vector < float >dist = image->calc_radial_dist(nx / 2, 0, 1,0);

        float midx = (float)((int)nx/2);
        float midy = (float)((int)ny/2);

        size_t c = 0;
        if (image->get_ndim() == 2) {
                for (int y = 0; y < ny; y++) {
                        for (int x = 0; x < nx; x++, c++) {
        #ifdef  _WIN32
                                float r = (float) _hypot(x - midx, y - midy);
        #else
                                float r = (float) hypot(x - midx, y - midy);
        #endif  //_WIN32


                                int i = (int) floor(r);
                                r -= i;
                                if (i >= 0 && i < nx / 2 - 1) {
                                        rdata[c] = dist[i] * (1.0f - r) + dist[i + 1] * r;
                                }
                                else if (i < 0) {
                                        rdata[c] = dist[0];
                                }
                                else {
                                        rdata[c] = 0;
                                }
                        }
                }
        }
        else if (image->get_ndim() == 3) {
                int nz = image->get_zsize();
                float midz = (float)((int)nz/2);
                float r;
                int i;
                for (int z = 0; z < nz; ++z) {
                        for (int y = 0; y < ny; ++y) {
                                for (int x = 0; x < nx; ++x, ++c) {

                                        r = (float) Util::hypot3(x - midx, y - midy, z - midz);

                                        i = Util::fast_floor(r);
                                        r -= i;
                                        if (i >= 0 && i < nx / 2 - 1) {
                                                rdata[c] = dist[i] * (1.0f - r) + dist[i + 1] * r;
                                        }
                                        else if (i < 0) {
                                                rdata[c] = dist[0];
                                        }
                                        else {
                                                rdata[c] = 0;
                                        }
                                }
                        }
                }
        }

        image->update();
}

Member Data Documentation

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

Definition at line 4757 of file processor.h.

Referenced by get_name().


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