Blobs.perimeter_hull#
- Blobs.perimeter_hull(**kwargs: Any) Any#
Convex hull of blob’s perimeter
- Parameters:
clockwise (bool) – direction of travel for computing the hull, defaults to clockwise
- Returns:
Perimeter, one point per column
- Return type:
ndarray(2,N) or list of ndarray(2,N)
The result is a convex perimeter that minimally contains the blob.
Example:
>>> from machinevisiontoolbox import Image >>> im = Image.Read('shark2.png') >>> blobs = im.blobs() >>> blobs[0].perimeter.shape (2, 471) >>> blobs[0].perimeter_hull(5).shape (2, 21) >>> np.set_printoptions(threshold=10) >>> blobs[0].perimeter_hull() array([[367, 361, 358, ..., 444, 442, 370], [300, 303, 305, ..., 369, 304, 300]], shape=(2, 21), dtype=int32)
To compute parameters of the area enclosed by the convex hull we can first convert it to a
Polygon2object:>>> from spatialmath import Polygon2 >>> poly = Polygon2(blobs[0].perimeter_hull(), close=True) >>> poly.area() np.float64(11056.5) >>> poly.moment(1, 0) # first moment np.float64(-4180916.3333333335)
(
Source code,png,hires.png,pdf)
Note
The perimeter is not closed, that is, the first and last point are not the same.