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, and I would appreciate hearing your input in the comments below.
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.
In my case, I 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