Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

EMAN::TomoTiltEdgeMaskProcessor Class Reference

A processor designed specifically for tomographic tilt series data. More...

#include <processor.h>

Inheritance diagram for EMAN::TomoTiltEdgeMaskProcessor:

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

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 TypeDict get_param_types () const
 Get processor parameter information in a dictionary.
virtual string get_desc () const
 Get the descrition of this specific processor.

Static Public Member Functions

ProcessorNEW ()

Static Public Attributes

const string NAME = "tomo.tiltedgemask"

Detailed Description

A processor designed specifically for tomographic tilt series data.

This processors masks out 'mass' in tilted images that is not present in the zero-tilt (0 degrees) image. It does this based on the tilt angle. The tilt angle can be extracted from the image metadata (stored as the euler_alt attribute), or it may be specified explicitly (specifying the angle is the default behavior). The masked out regions at both sides of the image are set to 0 by default, but can also be set to the mean of the nearest non-masked data edge (in the y direction), or similarly the mean of both non-masked data edges on either side of the image. A gaussian fall-off is optional (but off by default).

Author:
David Woolford <woolford@bcm.edu>
Date:
01/10/2008
Parameters:
biedgemean Mutually exclusive of edgemean. Experimental. Causes the pixels in the masked out areas to take the average value of both the left and right edge pixel strips
edgemean Mutually exclusive of biedgemean. Masked pixels values assume the mean edge pixel value, independently, for both sides of the image
angle The angle that the image is, with respect to the zero tilt image
angle_fim Read fim as 'from image metadata' - this causes the altitude angle stored in by the image object (i.e. as extracted from the header, as currently stored in memory) to be used as the angle. This overrides the angle argument
gauss_falloff Causes the edge masking to have a smooth Gaussian fall-off - this parameter specifies how many pixels the fall-off will proceed over. Default is 0
gauss_sigma The sigma of the Gaussian function used to smooth the edge fall-off (functional form is exp(-(pixel distance)^2/sigma^2)

Definition at line 6766 of file processor.h.


Member Function Documentation

virtual string EMAN::TomoTiltEdgeMaskProcessor::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 6793 of file processor.h.

06794                 {
06795                         return "Masks the part of the image which is not present in the 0-tilt image. Masked areas can be 0 or set to the edgemean (of the nearest or both edges). Masked areas can also have a Gaussian fall-off to make the appearance smooth.";
06796                 }

virtual string EMAN::TomoTiltEdgeMaskProcessor::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 6771 of file processor.h.

06772                 {
06773                         return NAME;
06774                 }

virtual TypeDict EMAN::TomoTiltEdgeMaskProcessor::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 6781 of file processor.h.

References EMAN::TypeDict::put().

06782                 {
06783                         TypeDict d;
06784                         d.put("biedgemean", EMObject::BOOL, "Mutually  exclusive of edgemean. Experimental. Causes the pixels in the masked out areas to take the average value of both the left and right edge pixel strips");
06785                         d.put("edgemean", EMObject::BOOL, "Mutually  exclusive of biedgemean. Masked pixels values assume the mean edge pixel value, independently, for both sides of the image.");
06786                         d.put("angle", EMObject::INT, "The angle that the image is, with respect to the zero tilt image");
06787                         d.put("gauss_falloff",EMObject::INT, "Causes the edge masking to have a smooth Gaussian fall-off - this parameter specifies how many pixels the fall-off will proceed over. Default is 0.");
06788                         d.put("gauss_sigma",EMObject::FLOAT,"The sigma of the Gaussian function used to smooth the edge fall-off (functional form is exp(-(pixel distance)^2/sigma^2)");
06789                         d.put("angle_fim",EMObject::BOOL,"Read fim as 'from image metadata' - this causes the altitude angle stored in by the image object (i.e. as extracted from the header, as currently stored in memory) to be used as the angle. This overrides the angle argument");
06790                         return d;
06791                 }

Processor* EMAN::TomoTiltEdgeMaskProcessor::NEW  )  [inline, static]
 

Definition at line 6776 of file processor.h.

06777                 {
06778                         return new TomoTiltEdgeMaskProcessor();
06779                 }

void TomoTiltEdgeMaskProcessor::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 9545 of file processor.cpp.

References EMAN::EMData::get_attr(), EMAN::Transform::get_params(), EMAN::EMData::get_value_at(), EMAN::EMData::get_xsize(), EMAN::EMData::get_ysize(), InvalidParameterException, nx, ny, EMAN::EMData::process_inplace(), EMAN::Dict::set_default(), EMAN::EMData::set_value_at(), t, and EMAN::EMData::update().

09546 {
09547         bool biedgemean = params.set_default("biedgemean", false);
09548         bool edgemean = params.set_default("edgemean", false);
09549         // You can only do one of these - so if someone specifies them both the code complains loudly
09550         if (biedgemean && edgemean) throw InvalidParameterException("The edgemean and biedgemean options are mutually exclusive");
09551 
09552         bool fim = params.set_default("angle_fim", false);
09553         float alt;
09554         if ( fim ) {
09555                 Transform* t = (Transform*)image->get_attr("xform.projection");
09556                 Dict d = t->get_params("eman");
09557                 alt = (float) d["alt"];
09558                 if(t) {delete t; t=0;}
09559         }
09560         else alt = params.set_default("angle", 0.0f);
09561 
09562 
09563         float cosine = cos(alt*M_PI/180.0f);
09564 
09565         // Zero the edges
09566         int nx = image->get_xsize();
09567         int ny = image->get_ysize();
09568         int x_clip = static_cast<int>( (float) nx * ( 1.0 - cosine ) / 2.0);
09569 
09570         float x1_edge_mean = 0.0;
09571         float x2_edge_mean = 0.0;
09572 
09573         if ( biedgemean )
09574         {
09575                 float edge_mean = 0.0;
09576 
09577                 // Accrue the pixel densities on the side strips
09578                 for ( int i = 0; i < ny; ++i ) {
09579                         edge_mean += image->get_value_at(x_clip, i );
09580                         edge_mean += image->get_value_at(nx - x_clip-1, i );
09581                 }
09582                 // Now make it so the mean is stored
09583                 edge_mean /= 2*ny;
09584 
09585                 // Now shift pixel values accordingly
09586                 for ( int i = 0; i < ny; ++i ) {
09587                         for ( int j = nx-1; j >= nx - x_clip; --j) {
09588                                 image->set_value_at(j,i,edge_mean);
09589                         }
09590                         for ( int j = 0; j < x_clip; ++j) {
09591                                 image->set_value_at(j,i,edge_mean);
09592                         }
09593                 }
09594                 x1_edge_mean = edge_mean;
09595                 x2_edge_mean = edge_mean;
09596         }
09597         else if (edgemean)
09598         {
09599                 for ( int i = 0; i < ny; ++i ) {
09600                         x1_edge_mean += image->get_value_at(x_clip, i );
09601                         x2_edge_mean += image->get_value_at(nx - x_clip-1, i );
09602                 }
09603                 x1_edge_mean /= ny;
09604                 x2_edge_mean /= ny;
09605 
09606                 for ( int i = 0; i < ny; ++i ) {
09607                         for ( int j = 0; j < x_clip; ++j) {
09608                                 image->set_value_at(j,i,x1_edge_mean);
09609                         }
09610                         for ( int j = nx-1; j >= nx - x_clip; --j) {
09611                                 image->set_value_at(j,i,x2_edge_mean);
09612                         }
09613                 }
09614         }
09615         else
09616         {
09617                 // The edges are just zeroed -
09618                 Dict zero_dict;
09619                 zero_dict["x0"] = x_clip;
09620                 zero_dict["x1"] = x_clip;
09621                 zero_dict["y0"] = 0;
09622                 zero_dict["y1"] = 0;
09623                 image->process_inplace( "mask.zeroedge2d", zero_dict );
09624         }
09625 
09626         int gauss_rad = params.set_default("gauss_falloff", 0);
09627         if ( gauss_rad != 0)
09628         {
09629                 // If the gaussian falloff distance is greater than x_clip, it will technically
09630                 // go beyond the image boundaries. Thus we clamp gauss_rad so this cannot happen.
09631                 // Therefore, there is potential here for (benevolent) unexpected behavior.
09632                 if ( gauss_rad > x_clip ) gauss_rad = x_clip;
09633 
09634                 float gauss_sigma = params.set_default("gauss_sigma", 3.0f);
09635                 if ( gauss_sigma < 0 ) throw InvalidParameterException("Error - you must specify a positive, non-zero gauss_sigma");
09636                 float sigma = (float) gauss_rad/gauss_sigma;
09637 
09638                 GaussianFunctoid gf(sigma);
09639 
09640                 for ( int i = 0; i < ny; ++i ) {
09641 
09642                         float left_value = image->get_value_at(x_clip, i );
09643                         float scale1 = left_value-x1_edge_mean;
09644 
09645                         float right_value = image->get_value_at(nx - x_clip - 1, i );
09646                         float scale2 = right_value-x2_edge_mean;
09647 
09648                         for ( int j = 1; j < gauss_rad; ++j )
09649                         {
09650                                 image->set_value_at(x_clip-j, i, scale1*gf((float)j)+x1_edge_mean );
09651                                 image->set_value_at(nx - x_clip + j-1, i, scale2*gf((float)j)+x2_edge_mean);
09652                         }
09653                 }
09654         }
09655 
09656         image->update();
09657 }


Member Data Documentation

const string TomoTiltEdgeMaskProcessor::NAME = "tomo.tiltedgemask" [static]
 

Definition at line 213 of file processor.cpp.


The documentation for this class was generated from the following files:
Generated on Tue Jun 11 13:49:15 2013 for EMAN2 by  doxygen 1.3.9.1