我有一个512x512像素的图像堆栈,我使用
使用以下代码生成掩码:
peak_local_max(tmp_frame, min_distance=15,threshold_abs=3000)
提取局部最大值的x和y坐标列表,该函数返回numpy数组中的像素坐标。使用以下代码生成掩码:
def createCircularMask(h, w, center=None, radius=None):
if center is None: # use the middle of the image
center = [int(w/2), int(h/2)]
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])
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
我想在给定的x和y坐标处应用我的掩模,以获取局部极大值周围的像素值之和,并将它们存储在列表中。
然而,我找不到仅允许我在2D数组中给定位置应用掩模的函数?