#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 | |
Processor * | NEW () |
Static Public Attributes | |
const string | NAME = "math.rotationalaverage" |
Definition at line 4484 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 4499 of file processor.h. 04500 { 04501 return "Makes image circularly/spherically symmetric."; 04502 }
|
|
Get the processor's name. Each processor is identified by a unique name.
Implements EMAN::Processor. Definition at line 4489 of file processor.h. 04490 {
04491 return NAME;
04492 }
|
|
Definition at line 4494 of file processor.h. 04495 { 04496 return new RotationalAverageProcessor(); 04497 }
|
|
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 4247 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. 04248 { 04249 if (!image || image->is_complex()) { 04250 LOGWARN("only works on real image. do nothing."); 04251 return; 04252 } 04253 04254 if (image->get_ndim() <= 0 || image->get_ndim() > 3) throw ImageDimensionException("radial average processor only works for 2D and 3D images"); 04255 04256 float *rdata = image->get_data(); 04257 int nx = image->get_xsize(); 04258 int ny = image->get_ysize(); 04259 04260 vector < float >dist = image->calc_radial_dist(nx / 2, 0, 1,0); 04261 04262 float midx = (float)((int)nx/2); 04263 float midy = (float)((int)ny/2); 04264 04265 size_t c = 0; 04266 if (image->get_ndim() == 2) { 04267 for (int y = 0; y < ny; y++) { 04268 for (int x = 0; x < nx; x++, c++) { 04269 #ifdef _WIN32 04270 float r = (float) _hypot(x - midx, y - midy); 04271 #else 04272 float r = (float) hypot(x - midx, y - midy); 04273 #endif //_WIN32 04274 04275 04276 int i = (int) floor(r); 04277 r -= i; 04278 if (i >= 0 && i < nx / 2 - 1) { 04279 rdata[c] = dist[i] * (1.0f - r) + dist[i + 1] * r; 04280 } 04281 else if (i < 0) { 04282 rdata[c] = dist[0]; 04283 } 04284 else { 04285 rdata[c] = 0; 04286 } 04287 } 04288 } 04289 } 04290 else if (image->get_ndim() == 3) { 04291 int nz = image->get_zsize(); 04292 float midz = (float)((int)nz/2); 04293 float r; 04294 int i; 04295 for (int z = 0; z < nz; ++z) { 04296 for (int y = 0; y < ny; ++y) { 04297 for (int x = 0; x < nx; ++x, ++c) { 04298 04299 r = (float) Util::hypot3(x - midx, y - midy, z - midz); 04300 04301 i = Util::fast_floor(r); 04302 r -= i; 04303 if (i >= 0 && i < nx / 2 - 1) { 04304 rdata[c] = dist[i] * (1.0f - r) + dist[i + 1] * r; 04305 } 04306 else if (i < 0) { 04307 rdata[c] = dist[0]; 04308 } 04309 else { 04310 rdata[c] = 0; 04311 } 04312 } 04313 } 04314 } 04315 } 04316 04317 image->update(); 04318 }
|
|
Definition at line 155 of file processor.cpp. |