Generate convex hull image from binary image
CH = bwconvhull(BW)
CH = bwconvhull(BW,method)
CH = bwconvhull(BW,'objects',conn)
Read a grayscale image into the workspace. Convert it into a binary image and calculate the union binary convex hull. Finally, calculate the objects convex hull and display all the images in one figure window.
subplot(2,2,1); I = imread('coins.png'); imshow(I); title('Original'); subplot(2,2,2); BW = I > 100; imshow(BW); title('Binary'); subplot(2,2,3); CH = bwconvhull(BW); imshow(CH); title('Union Convex Hull'); subplot(2,2,4); CH_objects = bwconvhull(BW,'objects'); imshow(CH_objects); title('Objects Convex Hull');
BW— Input binary image
Input binary image, specified as a 2-D logical array.
method— Method used to compute the convex hull
Method used to compute the convex hull, specified as one of the following:
|Compute the convex hull of all foreground objects, treating them as a single object|
|Compute the convex hull of each connected component of |
conn— Connectivity (only used when the method specified is
4| 3-by-3 matrix of 0s and 1s
Connectivity, specified as either of the following scalar values. The
parameter is only valid when the
|Two-dimensional, four-connected neighborhood|
|Two-dimensional, eight-connected neighborhood.|
You can also define connectivity in a more general way by using
a 3-by-3 matrix of
The 1-valued elements define neighborhood locations relative to
conn must be symmetric about its
CH— Binary mask of the convex hull of all foreground objects in the input image
Binary mask of the convex hull of all foreground objects in the input image, returned as a 2-D logical array.