Package boofcv.alg.segmentation.ms
Class MergeSmallRegions<T extends ImageBase<T>>
java.lang.Object
boofcv.alg.segmentation.ms.RegionMergeTree
boofcv.alg.segmentation.ms.MergeSmallRegions<T>
- All Implemented Interfaces:
Stoppable
Finds regions which are too small and merges them with a neighbor that is the most similar to it and connected.
The process is repeated until there are no more regions below the size threshold. How similar two neighbors are
is determined using each region's average color. Connectivity is determined using a 4-connect rule.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.ddogleg.struct.Stoppable
Stoppable.Stopped
-
Field Summary
Modifier and TypeFieldDescriptionprotected ComputeRegionMeanColor<T>
protected Point2D_I32[]
protected int
protected DogArray<MergeSmallRegions.Node>
protected DogArray_B
protected DogArray_I32
Fields inherited from class boofcv.alg.segmentation.ms.RegionMergeTree
mergeList, rootID, stopRequested, tmpMemberCount
-
Constructor Summary
ConstructorDescriptionMergeSmallRegions
(int minimumSize, ConnectRule rule, ComputeRegionMeanColor<T> computeColor) Constructor -
Method Summary
Modifier and TypeMethodDescriptionprotected void
adjacentBorder
(GrayS32 pixelToRegion) protected void
adjacentInner4
(GrayS32 pixelToRegion) protected void
adjacentInner8
(GrayS32 pixelToRegion) protected void
findAdjacentRegions
(GrayS32 pixelToRegion) Go through each pixel in the image and examine its neighbors according to a 4-connect rule.void
process
(T image, GrayS32 pixelToRegion, DogArray_I32 regionMemberCount, DogArray<float[]> regionColor) Merges together smaller regions.protected void
selectMerge
(int pruneId, FastAccess<float[]> regionColor) Examine edges for the specified node and select node which it is the best match for it to merge withvoid
setMinimumSize
(int minimumSize) protected boolean
setupPruneList
(DogArray_I32 regionMemberCount) Identifies which regions are to be pruned based on their member counts.Methods inherited from class boofcv.alg.segmentation.ms.RegionMergeTree
flowIntoRootNode, initializeMerge, isStopRequested, markMerge, performMerge, requestStop, setToRootNodeNewID
-
Field Details
-
minimumSize
protected int minimumSize -
computeColor
-
segmentPruneFlag
-
segmentToPruneID
-
pruneGraph
-
connect
-
-
Constructor Details
-
MergeSmallRegions
Constructor- Parameters:
minimumSize
- Minimum number of pixels a region must have for it to not be pruned.computeColor
- Computes the color of each region
-
-
Method Details
-
setMinimumSize
public void setMinimumSize(int minimumSize) -
process
public void process(T image, GrayS32 pixelToRegion, DogArray_I32 regionMemberCount, DogArray<float[]> regionColor) Merges together smaller regions. Segmented image, region member count, and region color are all updated.- Parameters:
image
- Input image. Used to compute color of each regionpixelToRegion
- (input/output) Segmented image with the ID of each region. Modified.regionMemberCount
- (input/output) Number of members in each region Modified.regionColor
- (Output) Storage for colors of each region. Will contains the color of each region on output.
-
setupPruneList
Identifies which regions are to be pruned based on their member counts. Then sets up data structures for graph and converting segment ID to prune ID.- Returns:
- true If elements need to be pruned and false if not.
-
findAdjacentRegions
Go through each pixel in the image and examine its neighbors according to a 4-connect rule. If one of the pixels is in a region that is to be pruned mark them as neighbors. The image is traversed such that the number of comparisons is minimized. -
adjacentInner4
-
adjacentInner8
-
adjacentBorder
-
selectMerge
Examine edges for the specified node and select node which it is the best match for it to merge with- Parameters:
pruneId
- The prune Id of the segment which is to be merged into another segmentregionColor
- List of region colors
-