Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | List of all members
SegmentStatisticsOp Class Reference

Computes statistics of segments: area, centroid, horizontality, verticality, variance and elongation. Segment is an area of connected pixels. More...

#include <SegmentStatisticsOp.h>

Inheritance diagram for SegmentStatisticsOp:
Inheritance graph
[legend]
Collaboration diagram for SegmentStatisticsOp:
Collaboration graph
[legend]

Public Member Functions

 SegmentStatisticsOp (const std::string &statistics="d", double min=1, double max=255, double scale=1.0, double offset=0)
 Default constructor.
 
 SegmentStatisticsOp (const SegmentStatisticsOp &op)
 
void getDstConf (const ImageConf &src, ImageConf &dst) const
 Resizes dst, ensures src area and channel count for each stat. .
 
virtual void traverseChannels (const ImageTray< const Channel > &src, ImageTray< Channel > &dst) const
 
- Public Member Functions inherited from ImageOp
virtual void process (const ImageFrame &src, Image &dst) const
 Main interface. Typically splits processing to each channel.
 
virtual void process (Image &dst) const override final
 Run this modifier for an image.
 
virtual void process (const ImageFrame &src, const ImageFrame &srcWeight, Image &dst, Image &dstWeight) const
 
virtual void process (const ImageTray< const Channel > &src, ImageTray< Image > &dst, bool checkOverlap=true) const
 Run the operator on a series of images. Geometry and type may be changed. UNDER CONSTR.
 
virtual void traverseChannel (const Channel &src, Channel &dst) const
 Apply to single channel.
 
virtual void traverseChannel (const Channel &src, const Channel &srcAlpha, Channel &dst, Channel &dstAlpha) const
 Apply to single channel with alpha.
 
virtual void makeCompatible (const ImageConf &src, Image &dst) const
 Depending on the operator, modifies the geometry and type of dst.
 
virtual void makeCompatible2 (const ImageFrame &src1, const ImageFrame &src2, Image &dst) const
 Modifies the geometry and type of dst to fit the computation result.
 
virtual void help (std::ostream &ostr=std::cout) const
 Prints name, description and parameters using BeanLike::toOStr(). Virtual, so derived classes may extend output.
 
- Public Member Functions inherited from ImageMod
virtual int srcAlpha () const
 Tell if alpha channel(s) is required in input.
 
virtual void traverseChannels (ImageTray< Channel > &dst) const
 Run this modifier for a set of channels.
 
virtual void traverseChannel (Channel &dst) const
 Run this modifier for an image frame.
 
virtual void traverseChannel (Channel &dst, Channel &dstAlpha) const
 Run this modifier for an image frame.
 
virtual void traverseChannels (ImageFrame &dst) const
 Converts dst to ImageTray<Channel> and calls traverseFrame(ImageTray<Channel> &) .
 
- Public Member Functions inherited from BeanLike
 BeanLike (const BeanLike &b)
 Copy constructor. Re-links parameters to the member variables of this (new) instance.
 
 BeanLike (const std::string &name, const std::string &description="")
 Constructor.
 
virtual const std::string & getName () const
 Return the name of an instance.
 
virtual const std::string & getDescription () const
 Return a brief description.
 
bool hasParameters () const
 Tells if any parameters have been linked (registered) for this bean.
 
template<class F >
F getParameter (const std::string &p) const
 Gets a single parameter.
 
const map_t & getParameters () const
 Returns the parameter map (const access).
 
map_t & getParameters ()
 Returns the parameter map.
 
template<class F >
void setParametersFromEntries (const F &args)
 Sets several parameters at once from a sequence of key-value pairs.
 
void setParameters (std::initializer_list< Variable::init_pair_t > args)
 Grants access to (if above hidden)
 
virtual void setParameters (const std::string &p, char assignmentSymbol='=', char separatorSymbol=0)
 Sets comma-separated parameters in a predetermined order "a,b,c" or by specifing them "b=2".
 
template<class T >
void setParameters (const std::map< std::string, T > &args)
 Set parameters.
 
template<class T >
void setParameters (const SmartMap< T > &args)
 Set parameters.
 
void setParameter (const std::string &p, const Castable &value)
 Sets a single parameter.
 
template<class T >
void setParameter (const std::string &p, const VariableT< T > &value)
 
template<class F >
void setParameter (const std::string &p, const F &value)
 Sets a single parameter.
 
template<class F >
void setParameter (const std::string &p, std::initializer_list< F > value)
 Sets a single parameter.
 
BeanLike & operator= (const BeanLike &b)
 Assigns the parameter values of another bean (by key) to this one's own parameters.
 
virtual std::ostream & toStream (std::ostream &ostr, bool compact=true) const
 Prints the name, description and current parameter values.
 

Public Attributes

std::string statistics
 
- Public Attributes inherited from SegmentOp
Range< double > intensity
 
bool clearDst
 
std::string functorStr
 
- Public Attributes inherited from ImageMod
bool physicalScale
 

Additional Inherited Members

- Public Types inherited from BeanLike
typedef ReferenceMap map_t
 Reference map type used to store this bean's parameters (name -> linked variable).
 
- Protected Member Functions inherited from SegmentOp
 SegmentOp (const std::string &name, const std::string &description)
 
 SegmentOp (const std::string &name, const std::string &description, const drain::UnaryFunctor &ftor)
 
const UnaryFunctor & getFunctor (double scale=0.0, double bias=0.0) const
 Retrieve functor to process the result: either the functor defined as functorStr or member functor (identity by default).
 
- Protected Member Functions inherited from ImageOp
 ImageOp (const std::string &name=__FUNCTION__, const std::string &description="")
 
 ImageOp (const ImageOp &op)
 
virtual bool processOverlappingWithTemp (const ImageFrame &src, Image &dst) const
 
virtual bool processOverlappingWithTemp (const ImageTray< const Channel > &src, ImageTray< Image > &dst) const
 
bool traverseOverlappingWithTemp (const Channel &src, Channel &dst) const
 
bool traverseOverlappingWithTemp (const Channel &src, const Channel &srcWeight, Channel &dst, Channel &dstWeight) const
 
void traverseChannelsEqually (const ImageTray< const Channel > &src, ImageTray< Channel > &dst) const
 Calls processWithTemp() if the frames overlap.
 
void traverseChannelsRepeated (const ImageTray< const Channel > &src, ImageTray< Channel > &dst) const
 Recycle channels until all dst channels completed.
 
void traverseChannelsSeparately (const ImageTray< const Channel > &src, ImageTray< Channel > &dst) const
 Process each (src,dst) channel pair independently. Raise error if their counts differ.
 
void traverseAsChannelTrays (const ImageFrame &src, ImageFrame &dst) const
 Redirect to processing as trays. This is the opposite of processChannels...() functions.
 
void traverseAsChannelTrays (const ImageFrame &src, const ImageFrame &srcWeight, ImageFrame &dst, ImageFrame &dstWeight) const
 Redirect to processing as trays. This is the opposite of processChannels...() functions.
 
virtual void initializeParameters (const ImageFrame &src, const ImageFrame &dst) const
 Set applicable internal parameters before calling traverse().
 
virtual void initializeParameters (const ImageFrame &src, const ImageFrame &src2, const ImageFrame &dst) const
 Set applicable internal parameters before calling traverse().
 
- Protected Member Functions inherited from ImageMod
 ImageMod (const std::string &name=__FUNCTION__, const std::string &description="")
 
 ImageMod (const ImageMod &op)
 
virtual void processChannelsSeparately (ImageTray< Channel > &dst) const
 Run this modifier by calling traverseChannel(Channel &) for each image.
 
virtual void initialize (Image &dst) const
 Modifies the geometry and the type of dst such that traverseChannel(Channel &) can be called.
 
virtual void initializeAlpha (const Image &srcAlpha, Image &dstAlpha) const
 Modifies the geometry and the type of dst such that traverseChannel(Channel &) can be called.
 
- Protected Member Functions inherited from BeanLike
virtual void storeLastArguments (const std::string &p)
 Called after setParameters()
 
virtual void updateBean () const
 Called after setParameters()
 
- Static Protected Member Functions inherited from ImageOp
static void adaptCoordinateHandler (const Channel &src, CoordinateHandler2D &handler)
 
- Protected Attributes inherited from SegmentOp
LocalCloner< UnaryFunctor > unicloner
 
const drain::IdentityFunctor identityFtor
 
const drain::UnaryFunctor & functor
 
- Protected Attributes inherited from BeanLike
const std::string name
 Name of this bean, typically also the name of the (derived) class.
 
const std::string description
 Brief, human-readable description of this bean.
 
map_t parameters
 Parameters (name -> linked variable), typically linked to member variables of the derived class.
 

Detailed Description

Computes statistics of segments: area, centroid, horizontality, verticality, variance and elongation. Segment is an area of connected pixels.

Most descriptors have unscaled and scaled (normalized) versions, distinguished with uppercase and lowercase letters.

For example, the unscaled area is obtained with 'A':

drainage shapes.png --iSegmentStats A,64 -o segmentStat-area.png

Respectively, the scaled area is obtained with 'a'.

drainage shapes.png --iSegmentStats a,64,functor=FuzzyStep:0.5:0.75 -o segmentStat-areaRel.png
A simple linear transition from 0 to 1 .
Definition Fuzzy.h:170

The relative vertical position can be computed similarly, with 'y'.

drainage shapes.png --iSegmentStats x,64,functor=FuzzyStep:100:0 -o segmentStat-x.png
drainage shapes.png --iSegmentStats h,64 -o segmentStat-horz.png
drainage shapes.png --iSegmentStats v,64 -o segmentStat-vert.png
drainage shapes.png --iSegmentStats e,32 -o segmentStat-elong.png
drainage shapes.png --iSegmentStats s,32,functor=FuzzyStepsoid:0:10 -o segmentStat-variance.png
A smooth step function between 0.0 and 1.0. Increasing (decreasing) with positive (negative) width....
Definition Fuzzy.h:654

Several statistics can be computed simultaneously simply. For example, elongation (e), slimness (l) and y-coordinate (y):

drainage shapes.png --iSegmentStats ely,64:255 -o segmentStat-ely.png

Member Function Documentation

◆ getDstConf()

void getDstConf ( const ImageConf &  src,
ImageConf &  dst 
) const
virtual

Resizes dst, ensures src area and channel count for each stat. .

Todo: check view-images?

Reimplemented from ImageOp.

◆ traverseChannels()

void traverseChannels ( const ImageTray< const Channel > &  src,
ImageTray< Channel > &  dst 
) const
virtual

TODO: should use the actual types of src and dst.

TODO: handle std::exceptions better

Phase 1: pick statistic

Phase 2: mapping (ie. scale the statistic)

Reimplemented from ImageOp.


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