Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File 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]
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

ProcessorNEW ()

Static Public Attributes

const string NAME = "math.rotationalaverage"

Detailed Description

makes image circularly symmetric.

Definition at line 4227 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 4242 of file processor.h.

04243                 {
04244                         return "Makes image circularly/spherically symmetric.";
04245                 }

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

04233                 {
04234                         return NAME;
04235                 }

Processor* EMAN::RotationalAverageProcessor::NEW  )  [inline, static]
 

Definition at line 4237 of file processor.h.

04238                 {
04239                         return new RotationalAverageProcessor();
04240                 }

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:
image The image to be processed.

Implements EMAN::Processor.

Definition at line 4068 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.

04069 {
04070         if (!image || image->is_complex()) {
04071                 LOGWARN("only works on real image. do nothing.");
04072                 return;
04073         }
04074 
04075         if (image->get_ndim() <= 0 || image->get_ndim() > 3)    throw ImageDimensionException("radial average processor only works for 2D and 3D images");
04076 
04077         float *rdata = image->get_data();
04078         int nx = image->get_xsize();
04079         int ny = image->get_ysize();
04080 
04081         vector < float >dist = image->calc_radial_dist(nx / 2, 0, 1,0);
04082 
04083         float midx = (float)((int)nx/2);
04084         float midy = (float)((int)ny/2);
04085 
04086         size_t c = 0;
04087         if (image->get_ndim() == 2) {
04088                 for (int y = 0; y < ny; y++) {
04089                         for (int x = 0; x < nx; x++, c++) {
04090         #ifdef  _WIN32
04091                                 float r = (float) _hypot(x - midx, y - midy);
04092         #else
04093                                 float r = (float) hypot(x - midx, y - midy);
04094         #endif  //_WIN32
04095 
04096 
04097                                 int i = (int) floor(r);
04098                                 r -= i;
04099                                 if (i >= 0 && i < nx / 2 - 1) {
04100                                         rdata[c] = dist[i] * (1.0f - r) + dist[i + 1] * r;
04101                                 }
04102                                 else if (i < 0) {
04103                                         rdata[c] = dist[0];
04104                                 }
04105                                 else {
04106                                         rdata[c] = 0;
04107                                 }
04108                         }
04109                 }
04110         }
04111         else if (image->get_ndim() == 3) {
04112                 int nz = image->get_zsize();
04113                 float midz = (float)((int)nz/2);
04114                 float r;
04115                 int i;
04116                 for (int z = 0; z < nz; ++z) {
04117                         for (int y = 0; y < ny; ++y) {
04118                                 for (int x = 0; x < nx; ++x, ++c) {
04119 
04120                                         r = (float) Util::hypot3(x - midx, y - midy, z - midz);
04121 
04122                                         i = Util::fast_floor(r);
04123                                         r -= i;
04124                                         if (i >= 0 && i < nx / 2 - 1) {
04125                                                 rdata[c] = dist[i] * (1.0f - r) + dist[i + 1] * r;
04126                                         }
04127                                         else if (i < 0) {
04128                                                 rdata[c] = dist[0];
04129                                         }
04130                                         else {
04131                                                 rdata[c] = 0;
04132                                         }
04133                                 }
04134                         }
04135                 }
04136         }
04137 
04138         image->update();
04139 }


Member Data Documentation

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

Definition at line 149 of file processor.cpp.


The documentation for this class was generated from the following files:
Generated on Thu Dec 9 13:48:07 2010 for EMAN2 by  doxygen 1.3.9.1