我正在努力检测显微镜图像中的细胞,如下图所示。由于显微镜载玻片上的瑕疵,通常会绘制出虚假的轮廓,例如下图中图例下方的那个。
我目前正在使用this solution进行清理。这是基本思想。
# Create image of background
blank = np.zeros(image.shape[0:2])
background_image = cv2.drawContours(blank.copy(),background_contour,1,-1)
for i,c in enumerate(contours):
# Create image of contour
contour_image = cv2.drawContours(blank.copy(),contours,i,-1)
# Create image of focal contour + background
total_image = np.where(background_image+contour_image>0,0)
# Check if contour is outside postive space
if total_image.sum() > background_image.sum():
continue
这按预期工作;如果total_image
的区域大于background_image
的区域,则c
必须在关注区域之外。但是绘制所有这些轮廓非常慢,并且检查数千个轮廓需要花费数小时。 是否有更有效的方法来检查轮廓是否重叠,而无需绘制轮廓?