def getArrayRegion(self, arr, img=None):
"""
Return the result of ROI.getArrayRegion() masked by the elliptical shape
of the ROI. Regions outside the ellipse are set to 0.
"""
# TODO: get right area for pseudosquare
arr = pg.ROI.getArrayRegion(self, arr, img)
if arr is None or arr.shape[0] == 0 or arr.shape[1] == 0:
return None
w = arr.shape[0]
h = arr.shape[1]
# generate an ellipsoidal mask
mask = np.fromfunction(lambda x,y: ((((x+0.5)/((w/2.)))-1)**2+ (
((y+0.5)/((h/2.)))-1)**2)**0.5 < self._ratioEllispeRectangle, (w, h))
return arr * mask
评论列表
文章目录