我需要图像分割的帮助。我有脑部肿瘤的核磁共振图像。我需要从核磁共振中取出头盖骨,然后只分割肿瘤。我怎么能用python呢?图像处理。我试过做轮廓,但我不知道如何找到和删除最大的轮廓,只得到没有头骨的大脑。

非常感谢。def get_brain(img):

row_size = img.shape[0]

col_size = img.shape[1]

mean = np.mean(img)

std = np.std(img)

img = img - mean

img = img / std

middle = img[int(col_size / 5):int(col_size / 5 * 4), int(row_size / 5):int(row_size / 5 * 4)]

mean = np.mean(middle)

max = np.max(img)

min = np.min(img)

img[img == max] = mean

img[img == min] = mean

kmeans = KMeans(n_clusters=2).fit(np.reshape(middle, [np.prod(middle.shape), 1]))

centers = sorted(kmeans.cluster_centers_.flatten())

threshold = np.mean(centers)

thresh_img = np.where(img < threshold, 1.0, 0.0) # threshold the image

eroded = morphology.erosion(thresh_img, np.ones([3, 3]))

dilation = morphology.dilation(eroded, np.ones([5, 5]))

这些图像与我看到的类似:

谢谢你的回答。

Logo

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。

更多推荐