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

04459                 {
04460                         return "Makes image circularly/spherically symmetric.";
04461                 }

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

References NAME.

04449                 {
04450                         return NAME;
04451                 }

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

Definition at line 4453 of file processor.h.

04454                 {
04455                         return new RotationalAverageProcessor();
04456                 }

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 4207 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, rdata, EMAN::EMData::update(), and x.

04208 {
04209         if (!image || image->is_complex()) {
04210                 LOGWARN("only works on real image. do nothing.");
04211                 return;
04212         }
04213 
04214         if (image->get_ndim() <= 0 || image->get_ndim() > 3)    throw ImageDimensionException("radial average processor only works for 2D and 3D images");
04215 
04216         float *rdata = image->get_data();
04217         int nx = image->get_xsize();
04218         int ny = image->get_ysize();
04219 
04220         vector < float >dist = image->calc_radial_dist(nx / 2, 0, 1,0);
04221 
04222         float midx = (float)((int)nx/2);
04223         float midy = (float)((int)ny/2);
04224 
04225         size_t c = 0;
04226         if (image->get_ndim() == 2) {
04227                 for (int y = 0; y < ny; y++) {
04228                         for (int x = 0; x < nx; x++, c++) {
04229         #ifdef  _WIN32
04230                                 float r = (float) _hypot(x - midx, y - midy);
04231         #else
04232                                 float r = (float) hypot(x - midx, y - midy);
04233         #endif  //_WIN32
04234 
04235 
04236                                 int i = (int) floor(r);
04237                                 r -= i;
04238                                 if (i >= 0 && i < nx / 2 - 1) {
04239                                         rdata[c] = dist[i] * (1.0f - r) + dist[i + 1] * r;
04240                                 }
04241                                 else if (i < 0) {
04242                                         rdata[c] = dist[0];
04243                                 }
04244                                 else {
04245                                         rdata[c] = 0;
04246                                 }
04247                         }
04248                 }
04249         }
04250         else if (image->get_ndim() == 3) {
04251                 int nz = image->get_zsize();
04252                 float midz = (float)((int)nz/2);
04253                 float r;
04254                 int i;
04255                 for (int z = 0; z < nz; ++z) {
04256                         for (int y = 0; y < ny; ++y) {
04257                                 for (int x = 0; x < nx; ++x, ++c) {
04258 
04259                                         r = (float) Util::hypot3(x - midx, y - midy, z - midz);
04260 
04261                                         i = Util::fast_floor(r);
04262                                         r -= i;
04263                                         if (i >= 0 && i < nx / 2 - 1) {
04264                                                 rdata[c] = dist[i] * (1.0f - r) + dist[i + 1] * r;
04265                                         }
04266                                         else if (i < 0) {
04267                                                 rdata[c] = dist[0];
04268                                         }
04269                                         else {
04270                                                 rdata[c] = 0;
04271                                         }
04272                                 }
04273                         }
04274                 }
04275         }
04276 
04277         image->update();
04278 }


Member Data Documentation

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

Definition at line 4463 of file processor.h.

Referenced by get_name().


The documentation for this class was generated from the following files:
Generated on Mon Jul 19 12:43:46 2010 for EMAN2 by  doxygen 1.4.7