我试图在Open CV中使用斑点检测来识别脑瘤,但到目前为止,Open CV只能检测到脑部核磁共振成像中的小圆圈,而不能检测到肿瘤本身。
代码如下:
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)这是当我给程序提供一个黑白对比的大脑图像时会发生的事情(我对大脑进行了对比,以便肿瘤显示为黑色,而大脑的其余部分大部分是白色的):
无论如何,肿瘤并不是一个完美的圆圈,但它显然是大脑中最大的“斑点”。我怀疑是因为它的外壳是黑色的,内核是白色的,所以Open CV无法识别它。

只有当我选择一个更容易辨别的肿瘤,没有大的白色内核时,它才能拾取肿瘤。

有什么建议吗?我需要能够从原始图片中剥离这些斑点(一旦它们能够准确地工作),并使用它们的关键点从每个切片中的2D肿瘤重建整个大脑中的3D肿瘤。我离这一步还有一段距离,但是这个斑点探测器问题是2D和3D之间的关键纽带。感谢所有的帮助!
发布于 2017-05-08 14:06:36
可能最大的斑点是头骨本身。如果你分散了最大的斑点的注意力,并保留下一个大的东西,使用轮廓作为外部。
https://stackoverflow.com/questions/43440048
复制相似问题