#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 4241 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.
04242 { 04243 if (!image || image->is_complex()) { 04244 LOGWARN("only works on real image. do nothing."); 04245 return; 04246 } 04247 04248 if (image->get_ndim() <= 0 || image->get_ndim() > 3) throw ImageDimensionException("radial average processor only works for 2D and 3D images"); 04249 04250 float *rdata = image->get_data(); 04251 int nx = image->get_xsize(); 04252 int ny = image->get_ysize(); 04253 04254 vector < float >dist = image->calc_radial_dist(nx / 2, 0, 1,0); 04255 04256 float midx = (float)((int)nx/2); 04257 float midy = (float)((int)ny/2); 04258 04259 size_t c = 0; 04260 if (image->get_ndim() == 2) { 04261 for (int y = 0; y < ny; y++) { 04262 for (int x = 0; x < nx; x++, c++) { 04263 #ifdef _WIN32 04264 float r = (float) _hypot(x - midx, y - midy); 04265 #else 04266 float r = (float) hypot(x - midx, y - midy); 04267 #endif //_WIN32 04268 04269 04270 int i = (int) floor(r); 04271 r -= i; 04272 if (i >= 0 && i < nx / 2 - 1) { 04273 rdata[c] = dist[i] * (1.0f - r) + dist[i + 1] * r; 04274 } 04275 else if (i < 0) { 04276 rdata[c] = dist[0]; 04277 } 04278 else { 04279 rdata[c] = 0; 04280 } 04281 } 04282 } 04283 } 04284 else if (image->get_ndim() == 3) { 04285 int nz = image->get_zsize(); 04286 float midz = (float)((int)nz/2); 04287 float r; 04288 int i; 04289 for (int z = 0; z < nz; ++z) { 04290 for (int y = 0; y < ny; ++y) { 04291 for (int x = 0; x < nx; ++x, ++c) { 04292 04293 r = (float) Util::hypot3(x - midx, y - midy, z - midz); 04294 04295 i = Util::fast_floor(r); 04296 r -= i; 04297 if (i >= 0 && i < nx / 2 - 1) { 04298 rdata[c] = dist[i] * (1.0f - r) + dist[i + 1] * r; 04299 } 04300 else if (i < 0) { 04301 rdata[c] = dist[0]; 04302 } 04303 else { 04304 rdata[c] = 0; 04305 } 04306 } 04307 } 04308 } 04309 } 04310 04311 image->update(); 04312 }
const string RotationalAverageProcessor::NAME = "math.rotationalaverage" [static] |