#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 4406 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 4421 of file processor.h. 04422 {
04423 return "Makes image circularly/spherically symmetric.";
04424 }
|
|
|
Get the processor's name. Each processor is identified by a unique name.
Implements EMAN::Processor. Definition at line 4411 of file processor.h. 04412 {
04413 return NAME;
04414 }
|
|
|
Definition at line 4416 of file processor.h. 04417 {
04418 return new RotationalAverageProcessor();
04419 }
|
|
|
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 4154 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. 04155 {
04156 if (!image || image->is_complex()) {
04157 LOGWARN("only works on real image. do nothing.");
04158 return;
04159 }
04160
04161 if (image->get_ndim() <= 0 || image->get_ndim() > 3) throw ImageDimensionException("radial average processor only works for 2D and 3D images");
04162
04163 float *rdata = image->get_data();
04164 int nx = image->get_xsize();
04165 int ny = image->get_ysize();
04166
04167 vector < float >dist = image->calc_radial_dist(nx / 2, 0, 1,0);
04168
04169 float midx = (float)((int)nx/2);
04170 float midy = (float)((int)ny/2);
04171
04172 size_t c = 0;
04173 if (image->get_ndim() == 2) {
04174 for (int y = 0; y < ny; y++) {
04175 for (int x = 0; x < nx; x++, c++) {
04176 #ifdef _WIN32
04177 float r = (float) _hypot(x - midx, y - midy);
04178 #else
04179 float r = (float) hypot(x - midx, y - midy);
04180 #endif //_WIN32
04181
04182
04183 int i = (int) floor(r);
04184 r -= i;
04185 if (i >= 0 && i < nx / 2 - 1) {
04186 rdata[c] = dist[i] * (1.0f - r) + dist[i + 1] * r;
04187 }
04188 else if (i < 0) {
04189 rdata[c] = dist[0];
04190 }
04191 else {
04192 rdata[c] = 0;
04193 }
04194 }
04195 }
04196 }
04197 else if (image->get_ndim() == 3) {
04198 int nz = image->get_zsize();
04199 float midz = (float)((int)nz/2);
04200 float r;
04201 int i;
04202 for (int z = 0; z < nz; ++z) {
04203 for (int y = 0; y < ny; ++y) {
04204 for (int x = 0; x < nx; ++x, ++c) {
04205
04206 r = (float) Util::hypot3(x - midx, y - midy, z - midz);
04207
04208 i = Util::fast_floor(r);
04209 r -= i;
04210 if (i >= 0 && i < nx / 2 - 1) {
04211 rdata[c] = dist[i] * (1.0f - r) + dist[i + 1] * r;
04212 }
04213 else if (i < 0) {
04214 rdata[c] = dist[0];
04215 }
04216 else {
04217 rdata[c] = 0;
04218 }
04219 }
04220 }
04221 }
04222 }
04223
04224 image->update();
04225 }
|
|
|
Definition at line 160 of file processor.cpp. |
1.3.9.1