#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 5730 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 5740 of file processor.h. 05741 { 05742 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."; 05743 }
|
|
Get the processor's name. Each processor is identified by a unique name.
Implements EMAN::Processor. Definition at line 5735 of file processor.h. 05736 {
05737 return NAME;
05738 }
|
|
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 5750 of file processor.h. References EMAN::TypeDict::put(). 05751 { 05752 TypeDict d; 05753 d.put("val1", EMObject::FLOAT, "number of pixels to expand"); 05754 d.put("val2", EMObject::FLOAT, "number of Gaussian pixels to expand, following the first expansion"); 05755 return d; 05756 }
|
|
Definition at line 5745 of file processor.h. 05746 { 05747 return new IterBinMaskProcessor(); 05748 }
|
|
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 6464 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(). 06465 { 06466 if (!image) { 06467 LOGWARN("NULL Image"); 06468 return; 06469 } 06470 06471 float val1 = params["val1"]; 06472 float val2 = params["val2"]; 06473 06474 int nx = image->get_xsize(); 06475 int ny = image->get_ysize(); 06476 int nz = image->get_zsize(); 06477 EMData *image2 = new EMData(nx,ny,nz); 06478 06479 // Got a compile warning complaining that these things were never used. Hope I didn't break anything - apologies if so (d.woolford) 06480 // float *dat = image->get_data(); 06481 // float *dat2 = image2->get_data(); 06482 06483 06484 float *d = image->get_data(); 06485 float *d2 = image2->get_data(); 06486 06487 const int nxy = nx * ny; 06488 size_t size = nx * ny * nz; 06489 06490 // TODO: THIS IS EXTREMELY INEFFICIENT 06491 if (nz != 1) { 06492 for (int l = 1; l <= (int) val1+val2; ++l) { 06493 for (size_t i=0; i<size; i++) d2[i]=d[i]; 06494 for (int k = 1; k < nz - 1; ++k) { 06495 for (int j = 1; j < ny - 1; ++j) { 06496 for (int i = 1; i < nx - 1; ++i) { 06497 size_t t = i + j*nx+k*nx*ny; 06498 if (d[t]) continue; 06499 if (d2[t - 1] || d2[t + 1] || d2[t + nx] || d2[t - nx] || d2[t + nxy] || d2[t - nxy]) d[t] = (float) l + 1; 06500 } 06501 } 06502 } 06503 } 06504 } 06505 else { 06506 for (int l = 1; l <= (int) val1+val2; ++l) { 06507 for (size_t i=0; i<size; i++) d2[i]=d[i]; 06508 for (int j = 1; j < ny - 1; ++j) { 06509 for (int i = 1; i < nx - 1; ++i) { 06510 size_t t = i + j * nx; 06511 if (d[t]) continue; 06512 if (d2[t - 1] || d2[t + 1] || d2[t + nx] || d2[t - nx]) d[t] = (float) l + 1; 06513 } 06514 } 06515 } 06516 } 06517 06518 vector<float> vec; 06519 for (int i=0; i<val1+2; i++) vec.push_back(1.0); 06520 for (int i=0; i<val2; i++) { 06521 vec.push_back(exp(-pow(2.0f*i/(val2),2.0f))); 06522 // printf("%f\n",exp(-pow(2.0*i/(val1-val2),2.0))); 06523 } 06524 for (size_t i = 0; i < size; i++) if (d[i]) d[i]=vec[(int)d[i]]; 06525 06526 image->update(); 06527 delete image2; 06528 }
|
|
Definition at line 189 of file processor.cpp. |