#include <processor.h>
Inheritance diagram for EMAN::RotationalAverageProcessor:
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 Processor * | NEW () |
Static Public Attributes | |
static const string | NAME = "math.rotationalaverage" |
Definition at line 4403 of file processor.h.
|
Get the descrition of this specific processor. This function must be overwritten by a subclass.
Implements EMAN::Processor. Definition at line 4418 of file processor.h.
|
|
Get the processor's name. Each processor is identified by a unique name.
Implements EMAN::Processor. Definition at line 4408 of file processor.h. References NAME. 04409 { 04410 return NAME; 04411 }
|
|
Definition at line 4413 of file processor.h. 04414 { 04415 return new RotationalAverageProcessor(); 04416 }
|
|
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.
Implements EMAN::Processor. Definition at line 4100 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. 04101 { 04102 if (!image || image->is_complex()) { 04103 LOGWARN("only works on real image. do nothing."); 04104 return; 04105 } 04106 04107 if (image->get_ndim() <= 0 || image->get_ndim() > 3) throw ImageDimensionException("radial average processor only works for 2D and 3D images"); 04108 04109 float *rdata = image->get_data(); 04110 int nx = image->get_xsize(); 04111 int ny = image->get_ysize(); 04112 04113 vector < float >dist = image->calc_radial_dist(nx / 2, 0, 1,0); 04114 04115 float midx = (float)((int)nx/2); 04116 float midy = (float)((int)ny/2); 04117 04118 size_t c = 0; 04119 if (image->get_ndim() == 2) { 04120 for (int y = 0; y < ny; y++) { 04121 for (int x = 0; x < nx; x++, c++) { 04122 #ifdef _WIN32 04123 float r = (float) _hypot(x - midx, y - midy); 04124 #else 04125 float r = (float) hypot(x - midx, y - midy); 04126 #endif //_WIN32 04127 04128 04129 int i = (int) floor(r); 04130 r -= i; 04131 if (i >= 0 && i < nx / 2 - 1) { 04132 rdata[c] = dist[i] * (1.0f - r) + dist[i + 1] * r; 04133 } 04134 else if (i < 0) { 04135 rdata[c] = dist[0]; 04136 } 04137 else { 04138 rdata[c] = 0; 04139 } 04140 } 04141 } 04142 } 04143 else if (image->get_ndim() == 3) { 04144 int nz = image->get_zsize(); 04145 float midz = (float)((int)nz/2); 04146 float r; 04147 int i; 04148 for (int z = 0; z < nz; ++z) { 04149 for (int y = 0; y < ny; ++y) { 04150 for (int x = 0; x < nx; ++x, ++c) { 04151 04152 r = (float) Util::hypot3(x - midx, y - midy, z - midz); 04153 04154 i = Util::fast_floor(r); 04155 r -= i; 04156 if (i >= 0 && i < nx / 2 - 1) { 04157 rdata[c] = dist[i] * (1.0f - r) + dist[i + 1] * r; 04158 } 04159 else if (i < 0) { 04160 rdata[c] = dist[0]; 04161 } 04162 else { 04163 rdata[c] = 0; 04164 } 04165 } 04166 } 04167 } 04168 } 04169 04170 image->update(); 04171 }
|
|
Definition at line 4423 of file processor.h. Referenced by get_name(). |