我正在尝试通过 Open CV 中的斑点检测来识别脑肿瘤,但到目前为止,Open CV 只能检测到大脑 MRI 中的微小圆圈,而不能检测到肿瘤本身。
代码如下:
import cv2
from cv2 import SimpleBlobDetector_create, SimpleBlobDetector_Params
import numpy as np
# Read image
def blobber(filename):
im = cv2.imread(filename, cv2.IMREAD_GRAYSCALE)
# Set up the detector with default parameters.
detector = cv2.SimpleBlobDetector_create()
params = cv2.SimpleBlobDetector_Params()
# Filter by Area.
params.filterByArea = True
params.minArea = 50
# Filter by Circularity
params.filterByCircularity = True
params.minCircularity = 0
# Filter by Convexity
params.filterByConvexity = True
params.minConvexity = 0.1
# Create a detector with the parameters
ver = (cv2.__version__).split('.')
if int(ver[0]) < 3 :
detector = cv2.SimpleBlobDetector(params)
else :
detector = cv2.SimpleBlobDetector_create(params)
# Detect blobs.
keypoints = detector.detect(im)
# Draw detected blobs as red circles.
# cv2.DRAW_MATCHES_FLAGS_DRAW_RICH_KEYPOINTS ensures the size of the circle corresponds to the size of blob
im_with_keypoints = cv2.drawKeypoints(im,keypoints,np.array([]),(0,0,255),cv2.DRAW_MATCHES_FLAGS_DRAW_RICH_KEYPOINTS)
# Show keypoints
cv2.imshow("Keypoints", im_with_keypoints)
cv2.waitKey(0)
当我向程序提供黑白对比大脑图像时,会发生以下情况(我对大脑进行了对比,因此肿瘤将显示为黑色,而大脑的其余部分大部分为白色):
无论如何,肿瘤都不是一个完美的圆形,但它显然是大脑中最大的“斑点”。打开CV无法拾取它,我怀疑是因为它有黑色外壳和白色核心。只有当我选择一个更容易区分的肿瘤,没有大的白色内核时,它才能拾取肿瘤。 有什么建议吗?我需要能够将这些斑点(一旦它们准确工作)从原始图片中剥离出来,并使用它们的关键点从每个切片中的 2D 肿瘤重建大脑中的整个 3D 肿瘤。我离这一步有点远,但这个斑点检测器问题是 2D 和 3D 之间的关键联系。感谢所有帮助!