#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 5854 of file processor.h.
virtual string EMAN::IterBinMaskProcessor::get_desc | ( | ) | const [inline, virtual] |
Get the descrition of this specific processor.
This function must be overwritten by a subclass.
Implements EMAN::Processor.
Definition at line 5864 of file processor.h.
05865 { 05866 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."; 05867 }
virtual string EMAN::IterBinMaskProcessor::get_name | ( | ) | const [inline, virtual] |
Get the processor's name.
Each processor is identified by a unique name.
Implements EMAN::Processor.
Definition at line 5859 of file processor.h.
References NAME.
05860 { 05861 return NAME; 05862 }
virtual TypeDict EMAN::IterBinMaskProcessor::get_param_types | ( | ) | const [inline, virtual] |
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 5874 of file processor.h.
References EMAN::EMObject::FLOAT, and EMAN::TypeDict::put().
05875 { 05876 TypeDict d; 05877 d.put("val1", EMObject::FLOAT, "number of pixels to expand"); 05878 d.put("val2", EMObject::FLOAT, "number of Gaussian pixels to expand, following the first expansion"); 05879 return d; 05880 }
static Processor* EMAN::IterBinMaskProcessor::NEW | ( | ) | [inline, static] |
Definition at line 5869 of file processor.h.
05870 { 05871 return new IterBinMaskProcessor(); 05872 }
void IterBinMaskProcessor::process_inplace | ( | EMData * | image | ) | [virtual] |
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.
image | The image to be processed. |
Implements EMAN::Processor.
Definition at line 6796 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().
06797 { 06798 if (!image) { 06799 LOGWARN("NULL Image"); 06800 return; 06801 } 06802 06803 float val1 = params["val1"]; 06804 float val2 = params["val2"]; 06805 06806 int nx = image->get_xsize(); 06807 int ny = image->get_ysize(); 06808 int nz = image->get_zsize(); 06809 EMData *image2 = new EMData(nx,ny,nz); 06810 06811 // Got a compile warning complaining that these things were never used. Hope I didn't break anything - apologies if so (d.woolford) 06812 // float *dat = image->get_data(); 06813 // float *dat2 = image2->get_data(); 06814 06815 06816 float *d = image->get_data(); 06817 float *d2 = image2->get_data(); 06818 06819 const int nxy = nx * ny; 06820 size_t size = (size_t)nx * ny * nz; 06821 06822 // TODO: THIS IS EXTREMELY INEFFICIENT 06823 if (nz != 1) { 06824 for (int l = 1; l <= (int) val1+val2; ++l) { 06825 for (size_t i=0; i<size; i++) d2[i]=d[i]; 06826 for (int k = 1; k < nz - 1; ++k) { 06827 for (int j = 1; j < ny - 1; ++j) { 06828 for (int i = 1; i < nx - 1; ++i) { 06829 size_t t = i + j*nx+(size_t)k*nx*ny; 06830 if (d[t]) continue; 06831 if (d2[t - 1] || d2[t + 1] || d2[t + nx] || d2[t - nx] || d2[t + nxy] || d2[t - nxy]) d[t] = (float) l + 1; 06832 } 06833 } 06834 } 06835 } 06836 } 06837 else { 06838 for (int l = 1; l <= (int) val1+val2; ++l) { 06839 for (size_t i=0; i<size; i++) d2[i]=d[i]; 06840 for (int j = 1; j < ny - 1; ++j) { 06841 for (int i = 1; i < nx - 1; ++i) { 06842 size_t t = i + j * nx; 06843 if (d[t]) continue; 06844 if (d2[t - 1] || d2[t + 1] || d2[t + nx] || d2[t - nx]) d[t] = (float) l + 1; 06845 } 06846 } 06847 } 06848 } 06849 06850 vector<float> vec; 06851 for (int i=0; i<val1+2; i++) vec.push_back(1.0); 06852 for (int i=0; i<val2; i++) { 06853 vec.push_back(exp(-pow(2.0f*i/(val2),2.0f))); 06854 // printf("%f\n",exp(-pow(2.0*i/(val1-val2),2.0))); 06855 } 06856 for (size_t i = 0; i < size; ++i) if (d[i]) d[i]=vec[(int)d[i]]; 06857 06858 image->update(); 06859 delete image2; 06860 }
const string IterBinMaskProcessor::NAME = "mask.addshells.gauss" [static] |