Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
EMAN::MaskAzProcessor Class Reference

MaskAzProcessor masks out pixels within a specified cylindrical (or circular) arc. More...

#include <processor.h>

Inheritance diagram for EMAN::MaskAzProcessor:
Inheritance graph
Collaboration diagram for EMAN::MaskAzProcessor:
Collaboration graph

Public Member Functions

void process_inplace (EMData *image)
 To process an image in-place. More...
string get_name () const
 Get the processor's name. More...
string get_desc () const
 Get the descrition of this specific processor. More...
TypeDict get_param_types () const
 Get processor parameter information in a dictionary. More...
- Public Member Functions inherited from EMAN::Processor
virtual ~Processor ()
virtual EMDataprocess (const EMData *const image)
 To proccess an image out-of-place. More...
virtual void process_list_inplace (vector< EMData * > &images)
 To process multiple images using the same algorithm. More...
virtual Dict get_params () const
 Get the processor parameters in a key/value dictionary. More...
virtual void set_params (const Dict &new_params)
 Set the processor parameters using a key/value dictionary. More...

Static Public Member Functions

static ProcessorNEW ()
- Static Public Member Functions inherited from EMAN::Processor
static string get_group_desc ()
 Get the description of this group of processors. More...
static void EMFourierFilterInPlace (EMData *fimage, Dict params)
 Compute a Fourier-filter processed image in place. More...
static EMDataEMFourierFilter (EMData *fimage, Dict params)
 Compute a Fourier-processor processed image without altering the original image. More...

Static Public Attributes

static const string NAME = "mask.cylinder"

Additional Inherited Members

- Public Types inherited from EMAN::Processor
enum  fourier_filter_types {
 Fourier filter Processor type enum. More...
- Protected Attributes inherited from EMAN::Processor
Dict params

Detailed Description

MaskAzProcessor masks out pixels within a specified cylindrical (or circular) arc.

phi1angle in degrees ccw from the x-axis. Starting angle to be set to 0.
phi2Ending angle to be set to 0
dxModify mask center by dx relative to the default center nx/2
dyModify mask center by dy relative to the default center ny/2

Definition at line 3667 of file processor.h.

Member Function Documentation

◆ get_desc()

string EMAN::MaskAzProcessor::get_desc ( ) const

Get the descrition of this specific processor.

This function must be overwritten by a subclass.

The description of this processor.

Implements EMAN::Processor.

Definition at line 3685 of file processor.h.

3686 {
3687 return "Masks out an angular arc in circular/cylindrical coordinates with a sharp edge.";
3688 }

◆ get_name()

string EMAN::MaskAzProcessor::get_name ( ) const

Get the processor's name.

Each processor is identified by a unique name.

The processor's name.

Implements EMAN::Processor.

Definition at line 3678 of file processor.h.

3679 {
3680 return NAME;
3681 }
static const string NAME
Definition: processor.h:3683

References NAME.

◆ get_param_types()

TypeDict EMAN::MaskAzProcessor::get_param_types ( ) const

Get processor parameter information in a dictionary.

Each parameter has one record in the dictionary. Each record contains its name, data-type, and description.

A dictionary containing the parameter info.

Reimplemented from EMAN::Processor.

Definition at line 3690 of file processor.h.

3691 {
3692 TypeDict d;
3694 d.put("phicen", EMObject::FLOAT,"Angle in degrees ccw from the x-axis. Center of the region to NOT set to zero.");
3695 d.put("phirange", EMObject::FLOAT,"Angle in degrees. Region phicen+-phirange will not be zeroed");
3696 d.put("phitrirange", EMObject::FLOAT,"Angle in degrees. With phitriangle, width outside phirange to fall from 1 to 0.");
3697 d.put("phitriangle", EMObject::BOOL, "If set mask will fall from 1 at phicen+-phirange to 0 at +-phitrirange");
3698 d.put("cx", EMObject::FLOAT,"Mask X center. Default nx/2");
3699 d.put("cy", EMObject::FLOAT,"Mask Y center. Default ny/2");
3700 d.put("zmin", EMObject::FLOAT,"Minimum Z to include");
3701 d.put("zmax", EMObject::FLOAT,"Maximum Z to include");
3702 d.put("ztriangle", EMObject::FLOAT,"1/2 width in pixels of linear falloff in Z margin. Centered on specified zmin/zmax.");
3703 d.put("inner_radius", EMObject::INT, "inner mask radius. optional. Default 0");
3704 d.put("outer_radius", EMObject::INT, "outer mask radius. optional. Default nx+ny. Negative value -> box radius + outer_radius +1");
3706 return d;
3707 }
TypeDict is a dictionary to store <string, EMObject::ObjectType> pair.
Definition: emobject.h:305
void put(const string &key, EMObject::ObjectType o, const string &desc="")
Definition: emobject.h:330

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

◆ NEW()

static Processor * EMAN::MaskAzProcessor::NEW ( )

Definition at line 3673 of file processor.h.

3674 {
3675 return new MaskAzProcessor();
3676 }
MaskAzProcessor masks out pixels within a specified cylindrical (or circular) arc.
Definition: processor.h:3668

◆ process_inplace()

void MaskAzProcessor::process_inplace ( EMData image)

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.

imageThe image to be processed.

Implements EMAN::Processor.

Definition at line 2336 of file processor.cpp.

2336 {
2337 if (image->is_complex()) throw ImageFormatException("MaskAzProcessor: target image must be real");
2339 int nx=image->get_xsize();
2340 int ny=image->get_ysize();
2341 int nz=image->get_zsize();
2343 float phicen = params.set_default("phicen",0.0f)*M_PI/180.0;
2344 phicen=Util::angle_norm_pi(phicen);
2345 float phirange = params.set_default("phirange",180.0f)*M_PI/180.0;
2346 float phitrirange = params.set_default("phitrirange",0.0f)*M_PI/180.0;
2347 int phitriangle = params.set_default("phitriangle",0);
2348 float cx = params.set_default("cx",nx/2);
2349 float cy = params.set_default("cy",ny/2);
2350 float zmin = params.set_default("zmin",0);
2351 float zmax = params.set_default("zmax",nz);
2352 float ztri = params.set_default("ztriangle",0.0f);
2353 float inner_radius = params.set_default("inner_radius",0.0f);
2354 float outer_radius = params.set_default("outer_radius",nx+ny);
2356 for (int x=0; x<nx; x++) {
2357 for (int y=0; y<ny; y++) {
2358 float az=atan2(y-cy,x-cx);
2359 float az2=az-M_PI*2.0f;
2360 float az3=az+M_PI*2.0f;
2361 float r=hypot(y-cy,x-cx);
2362 float val=0.0f;
2363 if (r>inner_radius&&r<=outer_radius) {
2364 float as=Util::angle_sub_2pi(az,phicen);
2365 if (as<phirange) val=1.0f;
2366 else if (!phitriangle || as>phirange+phitrirange) val=0.0f;
2367 else val=1.0-(as-phirange)/float(phitrirange);
2368 }
2369 if (r==0 && inner_radius<=0) val=1.0;
2371 for (int z=0; z<nz; z++) {
2372 if (z<zmin-ztri || z>zmax+ztri) image->mult_value_at_fast(x,y,z,0);
2373 else if (z>=zmin+ztri && z<=zmax-ztri) image->mult_value_at_fast(x,y,z,val);
2374 else if (z>=zmin-ztri && z<=zmin+ztri) image->mult_value_at_fast(x,y,z,val*((z-zmin)/(2.0f*ztri)+0.5));
2375 else image->mult_value_at_fast(x,y,z,val*((zmax-z)/(2.0f*ztri)+0.5));
2376 }
2377 }
2378 }
type set_default(const string &key, type val)
Default setting behavior This can be achieved using a template - d.woolford Jan 2008 (before there wa...
Definition: emobject.h:569
static float angle_norm_pi(float in)
Normalize an angle in radians so it is in the -pi to pi range.
Definition: util.h:1051
static float angle_sub_2pi(float x, float y)
Calculate the difference of 2 angles and makes the equivalent result to be less than Pi.
Definition: util.h:1066
#define ImageFormatException(desc)
Definition: exception.h:147
#define y(i, j)
Definition: projector.cpp:1516
#define x(i)
Definition: projector.cpp:1517

References EMAN::Util::angle_norm_pi(), EMAN::Util::angle_sub_2pi(), ImageFormatException, EMAN::Processor::params, EMAN::Dict::set_default(), x, and y.

Member Data Documentation


const string MaskAzProcessor::NAME = "mask.cylinder"

Definition at line 3683 of file processor.h.

Referenced by get_name().

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