#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 4368 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 4383 of file processor.h. 04384 {
04385 return "Makes image circularly/spherically symmetric.";
04386 }
|
|
|
Get the processor's name. Each processor is identified by a unique name.
Implements EMAN::Processor. Definition at line 4373 of file processor.h. 04374 {
04375 return NAME;
04376 }
|
|
|
Definition at line 4378 of file processor.h. 04379 {
04380 return new RotationalAverageProcessor();
04381 }
|
|
|
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 4126 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. 04127 {
04128 if (!image || image->is_complex()) {
04129 LOGWARN("only works on real image. do nothing.");
04130 return;
04131 }
04132
04133 if (image->get_ndim() <= 0 || image->get_ndim() > 3) throw ImageDimensionException("radial average processor only works for 2D and 3D images");
04134
04135 float *rdata = image->get_data();
04136 int nx = image->get_xsize();
04137 int ny = image->get_ysize();
04138
04139 vector < float >dist = image->calc_radial_dist(nx / 2, 0, 1,0);
04140
04141 float midx = (float)((int)nx/2);
04142 float midy = (float)((int)ny/2);
04143
04144 size_t c = 0;
04145 if (image->get_ndim() == 2) {
04146 for (int y = 0; y < ny; y++) {
04147 for (int x = 0; x < nx; x++, c++) {
04148 #ifdef _WIN32
04149 float r = (float) _hypot(x - midx, y - midy);
04150 #else
04151 float r = (float) hypot(x - midx, y - midy);
04152 #endif //_WIN32
04153
04154
04155 int i = (int) floor(r);
04156 r -= i;
04157 if (i >= 0 && i < nx / 2 - 1) {
04158 rdata[c] = dist[i] * (1.0f - r) + dist[i + 1] * r;
04159 }
04160 else if (i < 0) {
04161 rdata[c] = dist[0];
04162 }
04163 else {
04164 rdata[c] = 0;
04165 }
04166 }
04167 }
04168 }
04169 else if (image->get_ndim() == 3) {
04170 int nz = image->get_zsize();
04171 float midz = (float)((int)nz/2);
04172 float r;
04173 int i;
04174 for (int z = 0; z < nz; ++z) {
04175 for (int y = 0; y < ny; ++y) {
04176 for (int x = 0; x < nx; ++x, ++c) {
04177
04178 r = (float) Util::hypot3(x - midx, y - midy, z - midz);
04179
04180 i = Util::fast_floor(r);
04181 r -= i;
04182 if (i >= 0 && i < nx / 2 - 1) {
04183 rdata[c] = dist[i] * (1.0f - r) + dist[i + 1] * r;
04184 }
04185 else if (i < 0) {
04186 rdata[c] = dist[0];
04187 }
04188 else {
04189 rdata[c] = 0;
04190 }
04191 }
04192 }
04193 }
04194 }
04195
04196 image->update();
04197 }
|
|
|
Definition at line 154 of file processor.cpp. |
1.3.9.1