#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 5737 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 5747 of file processor.h. 05748 { 05749 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."; 05750 }
|
|
Get the processor's name. Each processor is identified by a unique name.
Implements EMAN::Processor. Definition at line 5742 of file processor.h. 05743 {
05744 return NAME;
05745 }
|
|
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 5757 of file processor.h. References EMAN::TypeDict::put(). 05758 { 05759 TypeDict d; 05760 d.put("val1", EMObject::FLOAT, "number of pixels to expand"); 05761 d.put("val2", EMObject::FLOAT, "number of Gaussian pixels to expand, following the first expansion"); 05762 return d; 05763 }
|
|
Definition at line 5752 of file processor.h. 05753 { 05754 return new IterBinMaskProcessor(); 05755 }
|
|
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 6558 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(). 06559 { 06560 if (!image) { 06561 LOGWARN("NULL Image"); 06562 return; 06563 } 06564 06565 float val1 = params["val1"]; 06566 float val2 = params["val2"]; 06567 06568 int nx = image->get_xsize(); 06569 int ny = image->get_ysize(); 06570 int nz = image->get_zsize(); 06571 EMData *image2 = new EMData(nx,ny,nz); 06572 06573 // Got a compile warning complaining that these things were never used. Hope I didn't break anything - apologies if so (d.woolford) 06574 // float *dat = image->get_data(); 06575 // float *dat2 = image2->get_data(); 06576 06577 06578 float *d = image->get_data(); 06579 float *d2 = image2->get_data(); 06580 06581 const int nxy = nx * ny; 06582 size_t size = (size_t)nx * ny * nz; 06583 06584 // TODO: THIS IS EXTREMELY INEFFICIENT 06585 if (nz != 1) { 06586 for (int l = 1; l <= (int) val1+val2; ++l) { 06587 for (size_t i=0; i<size; i++) d2[i]=d[i]; 06588 for (int k = 1; k < nz - 1; ++k) { 06589 for (int j = 1; j < ny - 1; ++j) { 06590 for (int i = 1; i < nx - 1; ++i) { 06591 size_t t = i + j*nx+(size_t)k*nx*ny; 06592 if (d[t]) continue; 06593 if (d2[t - 1] || d2[t + 1] || d2[t + nx] || d2[t - nx] || d2[t + nxy] || d2[t - nxy]) d[t] = (float) l + 1; 06594 } 06595 } 06596 } 06597 } 06598 } 06599 else { 06600 for (int l = 1; l <= (int) val1+val2; ++l) { 06601 for (size_t i=0; i<size; i++) d2[i]=d[i]; 06602 for (int j = 1; j < ny - 1; ++j) { 06603 for (int i = 1; i < nx - 1; ++i) { 06604 size_t t = i + j * nx; 06605 if (d[t]) continue; 06606 if (d2[t - 1] || d2[t + 1] || d2[t + nx] || d2[t - nx]) d[t] = (float) l + 1; 06607 } 06608 } 06609 } 06610 } 06611 06612 vector<float> vec; 06613 for (int i=0; i<val1+2; i++) vec.push_back(1.0); 06614 for (int i=0; i<val2; i++) { 06615 vec.push_back(exp(-pow(2.0f*i/(val2),2.0f))); 06616 // printf("%f\n",exp(-pow(2.0*i/(val1-val2),2.0))); 06617 } 06618 for (size_t i = 0; i < size; ++i) if (d[i]) d[i]=vec[(int)d[i]]; 06619 06620 image->update(); 06621 delete image2; 06622 }
|
|
Definition at line 194 of file processor.cpp. |