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:

[legend]
Collaboration diagram for EMAN::RotationalAverageProcessor:
[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 4402 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 4417 of file processor.h.

04418                 {
04419                         return "Makes image circularly/spherically symmetric.";
04420                 }

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

04408                 {
04409                         return NAME;
04410                 }

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

Definition at line 4412 of file processor.h.

04413                 {
04414                         return new RotationalAverageProcessor();
04415                 }

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 4069 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.

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


Member Data Documentation

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

Definition at line 154 of file processor.cpp.


The documentation for this class was generated from the following files:
Generated on Fri Apr 30 15:39:24 2010 for EMAN2 by  doxygen 1.3.9.1