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

Segment a volume about:homeinto subvolumes based on a center separation value. More...

#include <processor.h>

Inheritance diagram for EMAN::DistanceSegmentProcessor:
Inheritance graph
Collaboration diagram for EMAN::DistanceSegmentProcessor:
Collaboration graph

Public Member Functions

string get_name () const
 Get the processor's name. More...
virtual EMDataprocess (const EMData *const image)
 To proccess an image out-of-place. More...
void process_inplace (EMData *image)
 To process an image in-place. More...
TypeDict get_param_types () const
 Get processor parameter information in a dictionary. More...
string get_desc () const
 Get the descrition of this specific processor. More...
- Public Member Functions inherited from EMAN::Processor
virtual ~Processor ()
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 = "segment.distance"

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

Segment a volume about:homeinto subvolumes based on a center separation value.

For linear densities such as skeletons this should fill linear regions with uniformly separated points

Steve Ludtke

Definition at line 1703 of file processor.h.

Member Function Documentation

◆ get_desc()

string EMAN::DistanceSegmentProcessor::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 1729 of file processor.h.

1730 {
1731 return "Segments a volume into pieces separated by distances in the specified range.";
1732 }

◆ get_name()

string EMAN::DistanceSegmentProcessor::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 1706 of file processor.h.

1707 {
1708 return NAME;
1709 }
static const string NAME
Definition: processor.h:1734

References NAME.

◆ get_param_types()

TypeDict EMAN::DistanceSegmentProcessor::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 1714 of file processor.h.

1715 {
1716 TypeDict d ;
1717 d.put("thr",EMObject::FLOAT,"Optional : Isosurface threshold value. Pixels below this will not be segment centers (default = 0.9)");
1718 d.put("minsegsep",EMObject::FLOAT,"Required: Minimum segment separation in pixels. Segments too close will trigger a reseed");
1719 d.put("maxsegsep",EMObject::FLOAT,"Required: Maximum segment separation in pixels. Segments too close will trigger a reseed");
1720 d.put("verbose",EMObject::INT,"Be verbose while running");
1721 return d;
1722 }
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::FLOAT, EMAN::EMObject::INT, and EMAN::TypeDict::put().

◆ NEW()

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

Definition at line 1724 of file processor.h.

1725 {
1726 return new DistanceSegmentProcessor();
1727 }
Segment a volume about:homeinto subvolumes based on a center separation value.
Definition: processor.h:1704

◆ process()

EMData * DistanceSegmentProcessor::process ( const EMData *const  image)

To proccess an image out-of-place.

For those processors which can only be processed out-of-place, override this function to give the right behavior.

imageThe image will be copied, actual process happen on copy of image.
the image processing result, may or may not be the same size of the input image

Reimplemented from EMAN::Processor.

Definition at line 1595 of file processor.cpp.

1597 EMData * result = image->copy();
1599 float thr = params.set_default("thr",0.9f);
1600 float minsegsep = params.set_default("minsegsep",5.0f);
1601 float maxsegsep = params.set_default("maxsegsep",5.1f);
1602 int verbose = params.set_default("verbose",0);
1604 vector<Pixel> pixels=image->calc_highest_locations(thr);
1606 vector<float> centers(3); // only 1 to start
1607 int nx=image->get_xsize();
1608 int ny=image->get_ysize();
1609 int nz=image->get_zsize();
1610// int nxy=nx*ny;
1612 // seed the process with the highest valued point
1613 centers[0]=(float)pixels[0].x;
1614 centers[1]=(float)pixels[0].y;
1615 centers[2]=(float)pixels[0].z;
1616 pixels.erase(pixels.begin());
1618 // outer loop. We add one center per iteration
1619 // This is NOT a very efficient algorithm, it assumes points are fairly sparse
1620 while (pixels.size()>0) {
1621 // iterate over pixels until we find a new center (then stop), delete any 'bad' pixels
1622 // no iterators because we remove elements
1624 for (unsigned int i=0; i<pixels.size(); i++) {
1626 Pixel p=pixels[i];
1627 // iterate over existing centers to see if this pixel should be removed ... technically we only should need to check the last center
1628 for (unsigned int j=0; j<centers.size(); j+=3) {
1629 float d=Util::hypot3(centers[j]-p.x,centers[j+1]-p.y,centers[j+2]-p.z);
1630 if (d<minsegsep) { // conflicts with existing center, erase
1631 pixels.erase(pixels.begin()+i);
1632 i--;
1633 break;
1634 }
1635 }
1636 }
1638 int found=0;
1639 for (unsigned int i=0; i<pixels.size() && found==0; i++) {
1640 Pixel p=pixels[i];
1642 // iterate again to see if this may be a new valid center. Start at the end so we tend to build chains
1643 for (unsigned int j=centers.size()-3; j>0; j-=3) {
1644 float d=Util::hypot3(centers[j]-p.x,centers[j+1]-p.y,centers[j+2]-p.z);
1645 if (d<maxsegsep) { // we passed minsegsep question already, so we know we're in the 'good' range
1646 centers.push_back((float)p.x);
1647 centers.push_back((float)p.y);
1648 centers.push_back((float)p.z);
1649 pixels.erase(pixels.begin()+i); // in the centers list now, don't need it any more
1650 found=1;
1651 break;
1652 }
1653 }
1654 }
1656 // If we went through the whole list and didn't find one, we need to reseed again
1657 if (!found && pixels.size()) {
1658 if (verbose) printf("New chain\n");
1659 centers.push_back((float)pixels[0].x);
1660 centers.push_back((float)pixels[0].y);
1661 centers.push_back((float)pixels[0].z);
1662 pixels.erase(pixels.begin());
1663 }
1665 if (verbose) printf("%d points found\n",(int)(centers.size()/3));
1666 }
1668 // after we have our list of centers classify pixels
1669 for (int z=0; z<nz; z++) {
1670 for (int y=0; y<ny; y++) {
1671 for (int x=0; x<nz; x++) {
1672 if (image->get_value_at(x,y,z)<thr) {
1673 result->set_value_at(x,y,z,-1.0); //below threshold -> -1 (unclassified)
1674 continue;
1675 }
1676 int bcls=-1; // best matching class
1677 float bdist=(float)(nx+ny+nz); // distance for best class
1678 for (unsigned int c=0; c<centers.size()/3; c++) {
1679 float d=Util::hypot3(x-centers[c*3],y-centers[c*3+1],z-centers[c*3+2]);
1680 if (d<bdist) { bdist=d; bcls=c; }
1681 }
1682 result->set_value_at(x,y,z,(float)bcls); // set the pixel to the class number
1683 }
1684 }
1685 }
1687 result->set_attr("segment_centers",centers);
1689 return result;
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
EMData stores an image's data and defines core image processing routines.
Definition: emdata.h:82
Pixel describes a 3D pixel's coordinates and its intensity value.
Definition: geometry.h:452
static float hypot3(int x, int y, int z)
Euclidean distance function in 3D: f(x,y,z) = sqrt(x*x + y*y + z*z);.
Definition: util.h:827
#define y(i, j)
Definition: projector.cpp:1516
#define x(i)
Definition: projector.cpp:1517

References EMAN::Util::hypot3(), EMAN::Processor::params, EMAN::Dict::set_default(), EMAN::Pixel::x, x, EMAN::Pixel::y, y, and EMAN::Pixel::z.

◆ process_inplace()

void DistanceSegmentProcessor::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 1588 of file processor.cpp.

1590 printf("Process inplace not implemented. Please use process.\n");
1591 return;

Member Data Documentation


const string DistanceSegmentProcessor::NAME = "segment.distance"

Definition at line 1734 of file processor.h.

Referenced by get_name().

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