#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 | |
static Processor * | NEW () |
Static Public Attributes | |
static 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 5771 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 5781 of file processor.h. 05782 { 05783 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."; 05784 }
|
|
Get the processor's name. Each processor is identified by a unique name.
Implements EMAN::Processor. Definition at line 5776 of file processor.h. References NAME. 05777 { 05778 return NAME; 05779 }
|
|
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 5791 of file processor.h. References EMAN::EMObject::FLOAT, and EMAN::TypeDict::put(). 05792 { 05793 TypeDict d; 05794 d.put("val1", EMObject::FLOAT, "number of pixels to expand"); 05795 d.put("val2", EMObject::FLOAT, "number of Gaussian pixels to expand, following the first expansion"); 05796 return d; 05797 }
|
|
Definition at line 5786 of file processor.h. 05787 { 05788 return new IterBinMaskProcessor(); 05789 }
|
|
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 6602 of file processor.cpp. References EMAN::EMData::get_data(), EMAN::EMData::get_xsize(), EMAN::EMData::get_ysize(), EMAN::EMData::get_zsize(), LOGWARN, EMAN::Processor::params, t, and EMAN::EMData::update(). 06603 { 06604 if (!image) { 06605 LOGWARN("NULL Image"); 06606 return; 06607 } 06608 06609 float val1 = params["val1"]; 06610 float val2 = params["val2"]; 06611 06612 int nx = image->get_xsize(); 06613 int ny = image->get_ysize(); 06614 int nz = image->get_zsize(); 06615 EMData *image2 = new EMData(nx,ny,nz); 06616 06617 // Got a compile warning complaining that these things were never used. Hope I didn't break anything - apologies if so (d.woolford) 06618 // float *dat = image->get_data(); 06619 // float *dat2 = image2->get_data(); 06620 06621 06622 float *d = image->get_data(); 06623 float *d2 = image2->get_data(); 06624 06625 const int nxy = nx * ny; 06626 size_t size = nx * ny * nz; 06627 06628 // TODO: THIS IS EXTREMELY INEFFICIENT 06629 if (nz != 1) { 06630 for (int l = 1; l <= (int) val1+val2; ++l) { 06631 for (size_t i=0; i<size; i++) d2[i]=d[i]; 06632 for (int k = 1; k < nz - 1; ++k) { 06633 for (int j = 1; j < ny - 1; ++j) { 06634 for (int i = 1; i < nx - 1; ++i) { 06635 size_t t = i + j*nx+k*nx*ny; 06636 if (d[t]) continue; 06637 if (d2[t - 1] || d2[t + 1] || d2[t + nx] || d2[t - nx] || d2[t + nxy] || d2[t - nxy]) d[t] = (float) l + 1; 06638 } 06639 } 06640 } 06641 } 06642 } 06643 else { 06644 for (int l = 1; l <= (int) val1+val2; ++l) { 06645 for (size_t i=0; i<size; i++) d2[i]=d[i]; 06646 for (int j = 1; j < ny - 1; ++j) { 06647 for (int i = 1; i < nx - 1; ++i) { 06648 size_t t = i + j * nx; 06649 if (d[t]) continue; 06650 if (d2[t - 1] || d2[t + 1] || d2[t + nx] || d2[t - nx]) d[t] = (float) l + 1; 06651 } 06652 } 06653 } 06654 } 06655 06656 vector<float> vec; 06657 for (int i=0; i<val1+2; i++) vec.push_back(1.0); 06658 for (int i=0; i<val2; i++) { 06659 vec.push_back(exp(-pow(2.0f*i/(val2),2.0f))); 06660 // printf("%f\n",exp(-pow(2.0*i/(val1-val2),2.0))); 06661 } 06662 for (size_t i = 0; i < size; i++) if (d[i]) d[i]=vec[(int)d[i]]; 06663 06664 image->update(); 06665 delete image2; 06666 }
|
|
Definition at line 5799 of file processor.h. Referenced by get_name(). |