Class HfsSegment
- Namespace
- OpenCvSharp.Hfs
- Assembly
- OpenCvSharp.dll
Hierarchical Feature Selection for Efficient Image Segmentation.
This algorithm is executed in 3 stages: first, the SLIC (simple linear iterative clustering) algorithm is used to obtain the superpixels of the input image. Second, each superpixel is viewed as a node in a graph, and the EGB (Efficient Graph-based Image Segmentation) algorithm is used to merge some of the nodes, obtaining a coarser segmentation, followed by a post process that merges small regions into their nearby region. Third, the algorithm exploits a similar mechanism to further merge the small regions obtained in the second stage into an even coarser segmentation.
public class HfsSegment : Algorithm, IDisposable
- Inheritance
-
HfsSegment
- Implements
- Inherited Members
Properties
- MinRegionSizeI
This parameter is used in the second stage. After the EGB segmentation, regions that have fewer pixels than this parameter will be merged into its adjacent region.
- MinRegionSizeII
This parameter is used in the third stage. It serves the same purpose as MinRegionSizeI.
- NumSlicIter
This parameter is used in the first stage. It describes how many iterations to perform when executing SLIC.
- SegEgbThresholdI
This parameter is used in the second stage. It is a constant used to threshold weights of the edge when merging adjacent nodes when applying EGB algorithm. The segmentation result tends to have more regions remained if this value is large and vice versa.
- SegEgbThresholdII
This parameter is used in the third stage. It serves the same purpose as SegEgbThresholdI.
- SlicSpixelSize
This parameter is used in the first stage (the SLIC stage). It describes the size of each superpixel when initializing SLIC. Every superpixel approximately has slicSpixelSize x slicSpixelSize pixels in the beginning.
- SpatialWeight
This parameter is used in the first stage (the SLIC stage). It describes how important the role of position is when calculating the distance between each pixel and its center. The exact formula to calculate the distance is colorDistance + spatialWeight * spatialDistance. The segmentation result tends to have more local consistency if this value is larger.
Methods
- Create(int, int, float, int, float, int, float, int, int)
Creates a HfsSegment object.
- PerformSegmentCpu(InputArray, bool)
Do segmentation with the CPU. This method is only implemented for reference; it is highly not recommended to use it.
- PerformSegmentGpu(InputArray, bool)
Do segmentation on the GPU. This method falls back to the CPU implementation when OpenCV was not built with CUDA support.