public class RegionMergeTree
extends java.lang.Object
markMerge(int, int). Then after all the regions which are to be merged are marked call
performMerge(boofcv.struct.image.GrayS32, org.ddogleg.struct.GrowQueue_I32).
Internally a disjoint-set forest tree graph is maintained using an array. When two regions are marked to be merged
(set-union) path-compression is done. After merging hsa finished, the graph is fully compressed so that all nodes
point to their root directly. Then the output is computed.| Modifier and Type | Field and Description |
|---|---|
protected org.ddogleg.struct.GrowQueue_I32 |
mergeList |
protected org.ddogleg.struct.GrowQueue_I32 |
rootID |
protected org.ddogleg.struct.GrowQueue_I32 |
tmpMemberCount |
| Constructor and Description |
|---|
RegionMergeTree() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
flowIntoRootNode(org.ddogleg.struct.GrowQueue_I32 regionMemberCount)
For each region in the merge list which is not a root node, find its root node and add to the root node
its member count and set the index in mergeList to the root node.
|
void |
initializeMerge(int numRegions)
Must call before any other functions.
|
protected void |
markMerge(int regionA,
int regionB)
This function will mark two regions for merger.
|
void |
performMerge(boofcv.struct.image.GrayS32 pixelToRegion,
org.ddogleg.struct.GrowQueue_I32 regionMemberCount)
Merges regions together and updates the provided data structures for said changes.
|
protected void |
setToRootNodeNewID(org.ddogleg.struct.GrowQueue_I32 regionMemberCount)
Does much of the work needed to remove the redundant segments that are being merged into their root node.
|
protected org.ddogleg.struct.GrowQueue_I32 mergeList
protected org.ddogleg.struct.GrowQueue_I32 tmpMemberCount
protected org.ddogleg.struct.GrowQueue_I32 rootID
public void initializeMerge(int numRegions)
numRegions - Total number of regions.public void performMerge(boofcv.struct.image.GrayS32 pixelToRegion,
org.ddogleg.struct.GrowQueue_I32 regionMemberCount)
pixelToRegion - (Input/Output) Image used to convert pixel location in region ID. Modified.regionMemberCount - (Input/Output) List containing how many pixels belong to each region. Modified.protected void flowIntoRootNode(org.ddogleg.struct.GrowQueue_I32 regionMemberCount)
protected void setToRootNodeNewID(org.ddogleg.struct.GrowQueue_I32 regionMemberCount)
protected void markMerge(int regionA,
int regionB)
This function will mark two regions for merger. Equivalent to set-union operation.
If the two regions have yet to be merged into any others then regionB will become a member of regionA. Otherwise a quick heck is done to see if they are already marked for merging. If that fails it will traverse down the tree for each region until it gets to their roots. If the roots are not the same then they are merged. Either way the path is updated such that the quick check will pass.