java.lang.Object
imagingbook.common.regions.BinaryRegionSegmentation
- Direct Known Subclasses:
BreadthFirstSegmentation
,DepthFirstSegmentation
,RecursiveSegmentation
,RegionContourSegmentation
,SequentialSegmentation
Performs region segmentation on a given binary image. See Ch. 8 of [1] for additional details. This class is
abstract, since the implementation depends on the concrete region segmentation algorithm being used. Concrete
implementations (subclasses of this class) are BreadthFirstSegmentation
, DepthFirstSegmentation
,
RecursiveSegmentation
, SequentialSegmentation
, RegionContourSegmentation
. Most of the work is
done by the constructor(s). If the segmentation has failed for some reason getRegions()
returns
null
.
[1] W. Burger, M.J. Burge, Digital Image Processing – An Algorithmic Introduction, 3rd ed, Springer (2022).
- Version:
- 2021/12/22
- See Also:
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionint
Returns the height of the segmented image.int
getLabel
(int u, int v) Returns the label number for the specified image coordinate.int
Returns the maximum label assigned by this segmentation.int
Returns the minimum label assigned by this segmentation.getRegion
(int label) Finds the region associated to the specified label ornull
if no region for that label exists.getRegion
(int u, int v) Returns theBinaryRegion
instance associated with the given image position ornull
if the segmentation contains no region covering the given position.Returns an unsorted list of all regions associated with this region labeling.getRegions
(boolean sort) Returns a (optionally sorted) list of all regions associated with this region labeling.int
getWidth()
Returns the width of the segmented image.boolean
Returns true if the segmentation did complete successfully, false otherwise.
-
Field Details
-
DefaultNeighborhoodT
The default neighborhood type.
-
-
Method Details
-
getWidth
Returns the width of the segmented image.- Returns:
- the width of the segmented image
-
getHeight
Returns the height of the segmented image.- Returns:
- the height of the segmented image
-
getMinLabel
Returns the minimum label assigned by this segmentation.- Returns:
- the minimum label
-
getMaxLabel
Returns the maximum label assigned by this segmentation.- Returns:
- the maximum label
-
isSegmented
Returns true if the segmentation did complete successfully, false otherwise.- Returns:
- true if segmentation was successful
-
getRegions
Returns an unsorted list of all regions associated with this region labeling. The returned list is empty if no regions were detected. See alsogetRegions(boolean)
.- Returns:
- a (possibly empty) list of detected regions
-
getRegions
Returns a (optionally sorted) list of all regions associated with this region labeling. The returned list is empty if no regions were detected.- Parameters:
sort
- settrue
to sort regions by size (largest regions first).- Returns:
- the list of detected regions or
null
if the segmentation has failed.
-
getLabel
Returns the label number for the specified image coordinate. -1 is returned for out-of-image coordinates.- Parameters:
u
- the horizontal coordinate.v
- the vertical coordinate.- Returns:
- the label number for the given position or -1 if outside the image
-
getRegion
Finds the region associated to the specified label ornull
if no region for that label exists.- Parameters:
label
- the region's label number- Returns:
- the region object associated with the given label or
null
if it does not exist
-
getRegion
Returns theBinaryRegion
instance associated with the given image position ornull
if the segmentation contains no region covering the given position.- Parameters:
u
- the horizontal position.v
- the vertical position.- Returns:
- The associated
BinaryRegion
object ornull
if thisBinaryRegionSegmentation
has no region at the given position.
-