基于matlab的脑瘤mr图像处理_MRI(脑肿瘤)图像处理与分割、颅骨切除

我需要图像分割的帮助。我有脑部肿瘤的核磁共振图像。我需要从核磁共振中取出头盖骨,然后只分割肿瘤。我怎么能用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]))

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

谢谢你的回答。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值