#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 4482 of file processor.h.
string EMAN::RotationalAverageProcessor::get_desc | ( | ) | const [inline, virtual] |
Get the descrition of this specific processor.
This function must be overwritten by a subclass.
Implements EMAN::Processor.
Definition at line 4497 of file processor.h.
string EMAN::RotationalAverageProcessor::get_name | ( | ) | const [inline, virtual] |
Get the processor's name.
Each processor is identified by a unique name.
Implements EMAN::Processor.
Definition at line 4487 of file processor.h.
References NAME.
04488 { 04489 return NAME; 04490 }
static Processor* EMAN::RotationalAverageProcessor::NEW | ( | ) | [inline, static] |
Definition at line 4492 of file processor.h.
04493 { 04494 return new RotationalAverageProcessor(); 04495 }
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.
image | The image to be processed. |
Implements EMAN::Processor.
Definition at line 4245 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.
04246 { 04247 if (!image || image->is_complex()) { 04248 LOGWARN("only works on real image. do nothing."); 04249 return; 04250 } 04251 04252 if (image->get_ndim() <= 0 || image->get_ndim() > 3) throw ImageDimensionException("radial average processor only works for 2D and 3D images"); 04253 04254 float *rdata = image->get_data(); 04255 int nx = image->get_xsize(); 04256 int ny = image->get_ysize(); 04257 04258 vector < float >dist = image->calc_radial_dist(nx / 2, 0, 1,0); 04259 04260 float midx = (float)((int)nx/2); 04261 float midy = (float)((int)ny/2); 04262 04263 size_t c = 0; 04264 if (image->get_ndim() == 2) { 04265 for (int y = 0; y < ny; y++) { 04266 for (int x = 0; x < nx; x++, c++) { 04267 #ifdef _WIN32 04268 float r = (float) _hypot(x - midx, y - midy); 04269 #else 04270 float r = (float) hypot(x - midx, y - midy); 04271 #endif //_WIN32 04272 04273 04274 int i = (int) floor(r); 04275 r -= i; 04276 if (i >= 0 && i < nx / 2 - 1) { 04277 rdata[c] = dist[i] * (1.0f - r) + dist[i + 1] * r; 04278 } 04279 else if (i < 0) { 04280 rdata[c] = dist[0]; 04281 } 04282 else { 04283 rdata[c] = 0; 04284 } 04285 } 04286 } 04287 } 04288 else if (image->get_ndim() == 3) { 04289 int nz = image->get_zsize(); 04290 float midz = (float)((int)nz/2); 04291 float r; 04292 int i; 04293 for (int z = 0; z < nz; ++z) { 04294 for (int y = 0; y < ny; ++y) { 04295 for (int x = 0; x < nx; ++x, ++c) { 04296 04297 r = (float) Util::hypot3(x - midx, y - midy, z - midz); 04298 04299 i = Util::fast_floor(r); 04300 r -= i; 04301 if (i >= 0 && i < nx / 2 - 1) { 04302 rdata[c] = dist[i] * (1.0f - r) + dist[i + 1] * r; 04303 } 04304 else if (i < 0) { 04305 rdata[c] = dist[0]; 04306 } 04307 else { 04308 rdata[c] = 0; 04309 } 04310 } 04311 } 04312 } 04313 } 04314 04315 image->update(); 04316 }
const string RotationalAverageProcessor::NAME = "math.rotationalaverage" [static] |