#include <processor.h>


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 () |
| radius | Pixel radius of a ball which is used to seed the flood filling operation | |
| threshold | An isosurface threshold that suitably encases the mass | |
| nshells | The number of dilation operations | |
| nshellsgauss | number of Gaussian pixels to expand, following the dilation operations If true the result of the operation will produce the mask, not the masked volume |
Definition at line 4668 of file processor.h.
| void AutoMask3D2Processor::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 5993 of file processor.cpp.
References abs, EMAN::EMData::get_data(), EMAN::EMData::get_ndim(), EMAN::EMData::get_size(), EMAN::EMData::get_xsize(), EMAN::EMData::get_ysize(), EMAN::EMData::get_zsize(), ImageDimensionException, LOGWARN, EMAN::EMData::mult(), EMAN::Processor::params, EMAN::EMData::process_inplace(), EMAN::Dict::set_default(), EMAN::EMData::set_size(), and EMAN::EMData::update().
05994 { 05995 if (!image) { 05996 LOGWARN("NULL Image"); 05997 return; 05998 } 05999 06000 if (image->get_ndim() != 3) { 06001 throw ImageDimensionException("This processor was only ever designed to work on 3D images."); 06002 } 06003 06004 /* 06005 The mask writing functionality was removed to comply with an EMAN2 policy which dictates that file io is not allowed from within a processor 06006 To get around this just use the return_mask parameter. 06007 string mask_output = params.set_default("write_mask", ""); 06008 if ( mask_output != "") { 06009 if (Util::is_file_exist(mask_output) ) throw InvalidParameterException("The mask output file name already exists. Please remove it if you don't need it."); 06010 if (!EMUtil::is_valid_filename(mask_output)) throw InvalidParameterException("The mask output file name type is invalid or unrecognized"); 06011 } 06012 */ 06013 06014 int radius = params["radius"]; 06015 float threshold = params["threshold"]; 06016 int nshells = params["nshells"]; 06017 int nshellsgauss = params["nshellsgauss"]; 06018 06019 int nx = image->get_xsize(); 06020 int ny = image->get_ysize(); 06021 int nz = image->get_zsize(); 06022 int nxy=nx*ny; 06023 06024 EMData *amask = new EMData(); 06025 amask->set_size(nx, ny, nz); 06026 06027 float *dat = image->get_data(); 06028 float *dat2 = amask->get_data(); 06029 06030 // start with an initial sphere 06031 int i,j,k; 06032 size_t l = 0; 06033 for (k = -nz / 2; k < nz / 2; ++k) { 06034 for (j = -ny / 2; j < ny / 2; ++j) { 06035 for (i = -nx / 2; i < nx / 2; ++i,++l) { 06036 if (abs(k) > radius || abs(j) > radius || abs(i) > radius) continue; 06037 if ( (k * k + j * j + i * i) > (radius*radius) || dat[l] < threshold) continue; 06038 dat2[l] = 1.0f; 06039 } 06040 } 06041 } 06042 06043 // iteratively 'flood fills' the map... recursion would be better 06044 int done=0; 06045 while (!done) { 06046 done=1; 06047 for (k=1; k<nz-1; ++k) { 06048 for (j=1; j<ny-1; ++j) { 06049 for (i=1; i<nx-1; ++i) { 06050 l=i+j*nx+k*nx*ny; 06051 if (dat2[l]) continue; 06052 if (dat[l]>threshold && (dat2[l-1]||dat2[l+1]||dat2[l+nx]||dat2[l-nx]||dat2[l-nxy]||dat2[l+nxy])) { 06053 dat2[l]=1.0; 06054 done=0; 06055 } 06056 } 06057 } 06058 } 06059 } 06060 06061 amask->update(); 06062 06063 amask->process_inplace("mask.addshells.gauss", Dict("val1", nshells, "val2", nshellsgauss)); 06064 06065 bool return_mask = params.set_default("return_mask",false); 06066 if (return_mask) { 06067 // Yes there is probably a much more efficient way of getting the mask itself, but I am only providing a stop gap at the moment. 06068 memcpy(dat,dat2,image->get_size()*sizeof(float)); 06069 } else { 06070 image->mult(*amask); 06071 } 06072 06073 // EMAN2 policy is not to allow file io from with a processor 06074 //if (mask_output != "") { 06075 // amask->write_image(mask_output); 06076 //} 06077 06078 06079 delete amask; 06080 }
| virtual string EMAN::AutoMask3D2Processor::get_name | ( | ) | const [inline, virtual] |
Get the processor's name.
Each processor is identified by a unique name.
Implements EMAN::Processor.
Definition at line 4673 of file processor.h.
| static Processor* EMAN::AutoMask3D2Processor::NEW | ( | ) | [inline, static] |
Definition at line 4678 of file processor.h.
04679 { 04680 return new AutoMask3D2Processor(); 04681 }
| virtual string EMAN::AutoMask3D2Processor::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 4683 of file processor.h.
04684 { 04685 return "Tries to mask out only interesting density using something akin to a flood file approach."; 04686 }
| virtual TypeDict EMAN::AutoMask3D2Processor::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 4688 of file processor.h.
References EMAN::EMObject::BOOL, EMAN::EMObject::FLOAT, EMAN::EMObject::INT, and EMAN::TypeDict::put().
04689 { 04690 TypeDict d; 04691 d.put("radius", EMObject::INT,"Pixel radius of a ball which is used to seed the flood filling operation."); 04692 d.put("threshold", EMObject::FLOAT, "An isosurface threshold that suitably encases the mass."); 04693 d.put("nshells", EMObject::INT, "The number of dilation operations"); 04694 d.put("nshellsgauss", EMObject::INT, "number of Gaussian pixels to expand, following the dilation operations"); 04695 d.put("return_mask", EMObject::BOOL, "If true the result of the operation will produce the mask, not the masked volume."); 04696 return d; 04697 04698 }
1.5.6