def maskfill_edgeinclude(a, iterations=1, erode=False):
import scipy.ndimage as ndimage
a = checkma(a)
if erode:
a = mask_islands(a, iterations=1)
#This is the dilation version
#newmask = ~np.ma.getmaskarray(a)
#newmask = ndimage.morphology.binary_dilation(newmask, iterations=iterations)
#newmask = ndimage.morphology.binary_dilation(~newmask, iterations=iterations)
#And the erosion version
newmask = np.ma.getmaskarray(a)
newmask = ndimage.morphology.binary_erosion(newmask, iterations=iterations)
newmask = ndimage.morphology.binary_dilation(newmask, iterations=iterations)
return newmask
#This is an alternative to the ma.notmasked_edges
#Note: probably faster/simpler to contour the mask
评论列表
文章目录