EMAN::IterBinMaskProcessor Class Reference

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. More...

#include <processor.h>

Inheritance diagram for EMAN::IterBinMaskProcessor:

Inheritance graph
[legend]
Collaboration diagram for EMAN::IterBinMaskProcessor:

Collaboration graph
[legend]

List of all members.

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 ProcessorNEW ()


Detailed Description

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.

Parameters:
val1 number of pixels to expand
val2 number of Gaussian pixels to expand, following the first expansion

Definition at line 5380 of file processor.h.


Member Function Documentation

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.

Parameters:
image The image to be processed.

Implements EMAN::Processor.

Definition at line 6082 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().

06083 {
06084         if (!image) {
06085                 LOGWARN("NULL Image");
06086                 return;
06087         }
06088 
06089         float val1 = params["val1"];
06090         float val2 = params["val2"];
06091 
06092         int nx = image->get_xsize();
06093         int ny = image->get_ysize();
06094         int nz = image->get_zsize();
06095         EMData *image2 = new EMData(nx,ny,nz);
06096 
06097         // Got a compile warning complaining that these things were never used. Hope I didn't break anything - apologies if so (d.woolford)
06098 //      float *dat = image->get_data();
06099 //      float *dat2 = image2->get_data();
06100 
06101 
06102         float *d = image->get_data();
06103         float *d2 = image2->get_data();
06104 
06105         const int nxy = nx * ny;
06106         size_t size = nx * ny * nz;
06107 
06108         // TODO: THIS IS EXTREMELY INEFFICIENT
06109         if (nz != 1) {
06110                 for (int l = 1; l <= (int) val1+val2; ++l) {
06111                         for (size_t i=0; i<size; i++) d2[i]=d[i];
06112                         for (int k = 1; k < nz - 1; ++k) {
06113                                 for (int j = 1; j < ny - 1; ++j) {
06114                                         for (int i = 1; i < nx - 1; ++i) {
06115                                                 size_t t = i + j*nx+k*nx*ny;
06116                                                 if (d[t]) continue;
06117                                                 if (d2[t - 1] || d2[t + 1] || d2[t + nx] || d2[t - nx] || d2[t + nxy] || d2[t - nxy]) d[t] = (float) l + 1;
06118                                         }
06119                                 }
06120                         }
06121                 }
06122         }
06123         else {
06124                 for (int l = 1; l <= (int) val1+val2; ++l) {
06125                         for (size_t i=0; i<size; i++) d2[i]=d[i];
06126                         for (int j = 1; j < ny - 1; ++j) {
06127                                 for (int i = 1; i < nx - 1; ++i) {
06128                                         size_t t = i + j * nx;
06129                                         if (d[t]) continue;
06130                                         if (d2[t - 1] || d2[t + 1] || d2[t + nx] || d2[t - nx]) d[t] = (float) l + 1;
06131                                 }
06132                         }
06133                 }
06134         }
06135 
06136         vector<float> vec;
06137         for (int i=0; i<val1+2; i++) vec.push_back(1.0);
06138         for (int i=0; i<val2; i++) {
06139                 vec.push_back(exp(-pow(2.0f*i/(val2),2.0f)));
06140 //              printf("%f\n",exp(-pow(2.0*i/(val1-val2),2.0)));
06141         }
06142         for (size_t i = 0; i < size; i++) if (d[i]) d[i]=vec[(int)d[i]];
06143 
06144         image->update();
06145         delete image2;
06146 }

virtual string EMAN::IterBinMaskProcessor::get_name (  )  const [inline, virtual]

Get the processor's name.

Each processor is identified by a unique name.

Returns:
The processor's name.

Implements EMAN::Processor.

Definition at line 5385 of file processor.h.

05386                 {
05387                         return "mask.addshells.gauss";
05388                 }

virtual string EMAN::IterBinMaskProcessor::get_desc (  )  const [inline, virtual]

Get the descrition of this specific processor.

This function must be overwritten by a subclass.

Returns:
The description of this processor.

Implements EMAN::Processor.

Definition at line 5390 of file processor.h.

05391                 {
05392                         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.";
05393                 }

static Processor* EMAN::IterBinMaskProcessor::NEW (  )  [inline, static]

Definition at line 5395 of file processor.h.

05396                 {
05397                         return new IterBinMaskProcessor();
05398                 }

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.

Returns:
A dictionary containing the parameter info.

Reimplemented from EMAN::Processor.

Definition at line 5400 of file processor.h.

References EMAN::EMObject::FLOAT, and EMAN::TypeDict::put().

05401                 {
05402                         TypeDict d;
05403                         d.put("val1", EMObject::FLOAT, "number of pixels to expand");
05404                         d.put("val2", EMObject::FLOAT, "number of Gaussian pixels to expand, following the first expansion");
05405                         return d;
05406                 }


The documentation for this class was generated from the following files:

Generated on Sat Nov 21 02:20:36 2009 for EMAN2 by  doxygen 1.5.6