我需要找到图像中下方肿瘤的位置,即大脑的左侧或右侧。
我尝试使用轮廓线并加了边缘以检测侧面,但似乎不适用于我的输出。
# Find Canny edges
edged = cv2.Canny(img, 30, 200)
cv2.waitKey(0)
# Finding Contours
# Use a copy of the image e.g. edged.copy()
# since findContours alters the image
contours, hierarchy = cv2.findContours(edged,
cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_NONE)
cv2.imshow('Canny Edges After Contouring', edged)
cv2.waitKey(0)
print("Number of Contours found = " + str(len(contours)))
# Draw all contours
# -1 signifies drawing all contours
cv2.drawContours(img, contours, -1, (0, 255, 0), 3)
canny
和findContours
不是解决此类问题的好方法。如果您想要一个简单的解决方案,只需使用阈值方法。大津门槛也会给你一个很好的结果。