#include <processor.h>
Inheritance diagram for EMAN::IterBinMaskProcessor:


Public Member Functions | |
| virtual void | process_inplace (EMData *image) |
| To process an image in-place. | |
| virtual string | get_name () const |
| Get the processor's name. | |
| virtual string | get_desc () const |
| Get the descrition of this specific processor. | |
| virtual TypeDict | get_param_types () const |
| Get processor parameter information in a dictionary. | |
Static Public Member Functions | |
| Processor * | NEW () |
Static Public Attributes | |
| const string | NAME = "mask.addshells.gauss" |
| val1 | number of pixels to expand | |
| val2 | number of Gaussian pixels to expand, following the first expansion |
Definition at line 5699 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 5709 of file processor.h. 05710 {
05711 return "Iterative expansion of a binary mask, val1 is number of pixels to expand, if val2!=0 will make a soft Gaussian edge starting after val2 pixels.";
05712 }
|
|
|
Get the processor's name. Each processor is identified by a unique name.
Implements EMAN::Processor. Definition at line 5704 of file processor.h. 05705 {
05706 return NAME;
05707 }
|
|
|
Get processor parameter information in a dictionary. Each parameter has one record in the dictionary. Each record contains its name, data-type, and description.
Reimplemented from EMAN::Processor. Definition at line 5719 of file processor.h. References EMAN::TypeDict::put(). 05720 {
05721 TypeDict d;
05722 d.put("val1", EMObject::FLOAT, "number of pixels to expand");
05723 d.put("val2", EMObject::FLOAT, "number of Gaussian pixels to expand, following the first expansion");
05724 return d;
05725 }
|
|
|
Definition at line 5714 of file processor.h. 05715 {
05716 return new IterBinMaskProcessor();
05717 }
|
|
|
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 6530 of file processor.cpp. References EMAN::EMData::get_data(), EMAN::EMData::get_xsize(), EMAN::EMData::get_ysize(), EMAN::EMData::get_zsize(), LOGWARN, nx, ny, t, and EMAN::EMData::update(). 06531 {
06532 if (!image) {
06533 LOGWARN("NULL Image");
06534 return;
06535 }
06536
06537 float val1 = params["val1"];
06538 float val2 = params["val2"];
06539
06540 int nx = image->get_xsize();
06541 int ny = image->get_ysize();
06542 int nz = image->get_zsize();
06543 EMData *image2 = new EMData(nx,ny,nz);
06544
06545 // Got a compile warning complaining that these things were never used. Hope I didn't break anything - apologies if so (d.woolford)
06546 // float *dat = image->get_data();
06547 // float *dat2 = image2->get_data();
06548
06549
06550 float *d = image->get_data();
06551 float *d2 = image2->get_data();
06552
06553 const int nxy = nx * ny;
06554 size_t size = (size_t)nx * ny * nz;
06555
06556 // TODO: THIS IS EXTREMELY INEFFICIENT
06557 if (nz != 1) {
06558 for (int l = 1; l <= (int) val1+val2; ++l) {
06559 for (size_t i=0; i<size; i++) d2[i]=d[i];
06560 for (int k = 1; k < nz - 1; ++k) {
06561 for (int j = 1; j < ny - 1; ++j) {
06562 for (int i = 1; i < nx - 1; ++i) {
06563 size_t t = i + j*nx+(size_t)k*nx*ny;
06564 if (d[t]) continue;
06565 if (d2[t - 1] || d2[t + 1] || d2[t + nx] || d2[t - nx] || d2[t + nxy] || d2[t - nxy]) d[t] = (float) l + 1;
06566 }
06567 }
06568 }
06569 }
06570 }
06571 else {
06572 for (int l = 1; l <= (int) val1+val2; ++l) {
06573 for (size_t i=0; i<size; i++) d2[i]=d[i];
06574 for (int j = 1; j < ny - 1; ++j) {
06575 for (int i = 1; i < nx - 1; ++i) {
06576 size_t t = i + j * nx;
06577 if (d[t]) continue;
06578 if (d2[t - 1] || d2[t + 1] || d2[t + nx] || d2[t - nx]) d[t] = (float) l + 1;
06579 }
06580 }
06581 }
06582 }
06583
06584 vector<float> vec;
06585 for (int i=0; i<val1+2; i++) vec.push_back(1.0);
06586 for (int i=0; i<val2; i++) {
06587 vec.push_back(exp(-pow(2.0f*i/(val2),2.0f)));
06588 // printf("%f\n",exp(-pow(2.0*i/(val1-val2),2.0)));
06589 }
06590 for (size_t i = 0; i < size; ++i) if (d[i]) d[i]=vec[(int)d[i]];
06591
06592 image->update();
06593 delete image2;
06594 }
|
|
|
Definition at line 189 of file processor.cpp. |
1.3.9.1