The convex hull is frequently used to process a pixel region.
To find the indices of the outer edge of the convex hull may be accomplished using the distance transform.
I do not claim this to be the most efficient method.
This algorithm gives similar results to Matlab
By definition, the distance transform of all region edge pixels to the background is identically one.
The chamfer distance transform is suitable for smooth regional boundaries, and has significant speed advantages over more brute force approaches that may be more generally applicable for non-smooth boundaries.
Use either masked image arrays or use NaN as a
sentinel value in 2-D array
SciPy ≥ 0.17 is assumed.
import scipy.ndimage as ndi boundary_mask = ndi.distance_transform_cdt(~np.isnan(az), 'taxicab') == 1