in utils.py [0:0]
def create_circular_mask(h, w, center=None, radius=None):
"""Create a boolean mask selecting a circular region (e.g. in an image)
Sourced from the following StackOverflow post, with tweaks:
https://stackoverflow.com/a/44874588/13352657
"""
if center is None: # use the middle of the image
center = (int(w/2), int(h/2))
elif np.all(np.array(center) <= 1.): # Convert fractional to absolute
center = (np.array((w, h)) * center).astype(int)
if radius is None: # use the smallest distance between the center and image walls
radius = min(center[0], center[1], w-center[0], h-center[1])
elif radius < 1.: # Convert fractional to absolute
radius = min(w, h) * radius
Y, X = np.ogrid[:h, :w]
dist_from_center = np.sqrt((X - center[0])**2 + (Y-center[1])**2)
mask = dist_from_center <= radius
return mask