#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 4437 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 4452 of file processor.h. 04453 { 04454 return "Makes image circularly/spherically symmetric."; 04455 }
|
|
Get the processor's name. Each processor is identified by a unique name.
Implements EMAN::Processor. Definition at line 4442 of file processor.h. 04443 {
04444 return NAME;
04445 }
|
|
Definition at line 4447 of file processor.h. 04448 { 04449 return new RotationalAverageProcessor(); 04450 }
|
|
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 4169 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. 04170 { 04171 if (!image || image->is_complex()) { 04172 LOGWARN("only works on real image. do nothing."); 04173 return; 04174 } 04175 04176 if (image->get_ndim() <= 0 || image->get_ndim() > 3) throw ImageDimensionException("radial average processor only works for 2D and 3D images"); 04177 04178 float *rdata = image->get_data(); 04179 int nx = image->get_xsize(); 04180 int ny = image->get_ysize(); 04181 04182 vector < float >dist = image->calc_radial_dist(nx / 2, 0, 1,0); 04183 04184 float midx = (float)((int)nx/2); 04185 float midy = (float)((int)ny/2); 04186 04187 size_t c = 0; 04188 if (image->get_ndim() == 2) { 04189 for (int y = 0; y < ny; y++) { 04190 for (int x = 0; x < nx; x++, c++) { 04191 #ifdef _WIN32 04192 float r = (float) _hypot(x - midx, y - midy); 04193 #else 04194 float r = (float) hypot(x - midx, y - midy); 04195 #endif //_WIN32 04196 04197 04198 int i = (int) floor(r); 04199 r -= i; 04200 if (i >= 0 && i < nx / 2 - 1) { 04201 rdata[c] = dist[i] * (1.0f - r) + dist[i + 1] * r; 04202 } 04203 else if (i < 0) { 04204 rdata[c] = dist[0]; 04205 } 04206 else { 04207 rdata[c] = 0; 04208 } 04209 } 04210 } 04211 } 04212 else if (image->get_ndim() == 3) { 04213 int nz = image->get_zsize(); 04214 float midz = (float)((int)nz/2); 04215 float r; 04216 int i; 04217 for (int z = 0; z < nz; ++z) { 04218 for (int y = 0; y < ny; ++y) { 04219 for (int x = 0; x < nx; ++x, ++c) { 04220 04221 r = (float) Util::hypot3(x - midx, y - midy, z - midz); 04222 04223 i = Util::fast_floor(r); 04224 r -= i; 04225 if (i >= 0 && i < nx / 2 - 1) { 04226 rdata[c] = dist[i] * (1.0f - r) + dist[i + 1] * r; 04227 } 04228 else if (i < 0) { 04229 rdata[c] = dist[0]; 04230 } 04231 else { 04232 rdata[c] = 0; 04233 } 04234 } 04235 } 04236 } 04237 } 04238 04239 image->update(); 04240 }
|
|
Definition at line 155 of file processor.cpp. |