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

Static Public Attributes

static const string NAME = "mask.addshells.gauss"

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 5813 of file processor.h.


Member Function Documentation

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 5823 of file processor.h.

05824                 {
05825                         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.";
05826                 }

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 5818 of file processor.h.

References NAME.

05819                 {
05820                         return NAME;
05821                 }

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 5833 of file processor.h.

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

05834                 {
05835                         TypeDict d;
05836                         d.put("val1", EMObject::FLOAT, "number of pixels to expand");
05837                         d.put("val2", EMObject::FLOAT, "number of Gaussian pixels to expand, following the first expansion");
05838                         return d;
05839                 }

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

Definition at line 5828 of file processor.h.

05829                 {
05830                         return new IterBinMaskProcessor();
05831                 }

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 6716 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().

06717 {
06718         if (!image) {
06719                 LOGWARN("NULL Image");
06720                 return;
06721         }
06722 
06723         float val1 = params["val1"];
06724         float val2 = params["val2"];
06725 
06726         int nx = image->get_xsize();
06727         int ny = image->get_ysize();
06728         int nz = image->get_zsize();
06729         EMData *image2 = new EMData(nx,ny,nz);
06730 
06731         // Got a compile warning complaining that these things were never used. Hope I didn't break anything - apologies if so (d.woolford)
06732 //      float *dat = image->get_data();
06733 //      float *dat2 = image2->get_data();
06734 
06735 
06736         float *d = image->get_data();
06737         float *d2 = image2->get_data();
06738 
06739         const int nxy = nx * ny;
06740         size_t size = (size_t)nx * ny * nz;
06741 
06742         // TODO: THIS IS EXTREMELY INEFFICIENT
06743         if (nz != 1) {
06744                 for (int l = 1; l <= (int) val1+val2; ++l) {
06745                         for (size_t i=0; i<size; i++) d2[i]=d[i];
06746                         for (int k = 1; k < nz - 1; ++k) {
06747                                 for (int j = 1; j < ny - 1; ++j) {
06748                                         for (int i = 1; i < nx - 1; ++i) {
06749                                                 size_t t = i + j*nx+(size_t)k*nx*ny;
06750                                                 if (d[t]) continue;
06751                                                 if (d2[t - 1] || d2[t + 1] || d2[t + nx] || d2[t - nx] || d2[t + nxy] || d2[t - nxy]) d[t] = (float) l + 1;
06752                                         }
06753                                 }
06754                         }
06755                 }
06756         }
06757         else {
06758                 for (int l = 1; l <= (int) val1+val2; ++l) {
06759                         for (size_t i=0; i<size; i++) d2[i]=d[i];
06760                         for (int j = 1; j < ny - 1; ++j) {
06761                                 for (int i = 1; i < nx - 1; ++i) {
06762                                         size_t t = i + j * nx;
06763                                         if (d[t]) continue;
06764                                         if (d2[t - 1] || d2[t + 1] || d2[t + nx] || d2[t - nx]) d[t] = (float) l + 1;
06765                                 }
06766                         }
06767                 }
06768         }
06769 
06770         vector<float> vec;
06771         for (int i=0; i<val1+2; i++) vec.push_back(1.0);
06772         for (int i=0; i<val2; i++) {
06773                 vec.push_back(exp(-pow(2.0f*i/(val2),2.0f)));
06774 //              printf("%f\n",exp(-pow(2.0*i/(val1-val2),2.0)));
06775         }
06776         for (size_t i = 0; i < size; ++i) if (d[i]) d[i]=vec[(int)d[i]];
06777 
06778         image->update();
06779         delete image2;
06780 }


Member Data Documentation

const string IterBinMaskProcessor::NAME = "mask.addshells.gauss" [static]

Definition at line 5841 of file processor.h.

Referenced by get_name().


The documentation for this class was generated from the following files:
Generated on Thu May 3 10:10:45 2012 for EMAN2 by  doxygen 1.4.7