栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

python 3D医学图像可视化

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

python 3D医学图像可视化

使用simpleitk库读取dicom图像,使用mayavi库和tvtk库可视化3d灰度图像

from mayavi import mlab
import SimpleITK as sitk
from tvtk.util.ctf import ColorTransferFunction, PiecewiseFunction

# image_path = 'xxx'
img = sitk.ReadImage(img_path)
img_arr = sitk.GetArrayFromImage(img)
C, H, W = img_arr.shape
print("img shape =", img_arr.shape)  # C, H, W
img_arr = img_arr[:C, :H, :W//2]


## mayavi
# 表面绘制
# mlab.contour3d(img_arr)

# 体绘制
vol = mlab.pipeline.volume(mlab.pipeline.scalar_field(img_arr), name='3d-ultrasound')

ctf = ColorTransferFunction()                       # 该函数决定体绘制的颜色、灰度等
vol._ctf = ctf
vol._volume_property.set_color(ctf)                 #进行更改,体绘制的colormap及color
vol.update_ctf = True

otf = PiecewiseFunction()
otf.add_point(20,0.2)
vol._otf = otf
vol._volume_property.set_scalar_opacity(otf)

# mlab.volume_slice(img_arr, colormap='gray',
#                   plane_orientation='z_axes', slice_index=W//2)          # 设定z轴切面

mlab.show()

参考:

Python,利用Mayavi进行标量医学图像的三维体绘制_Jesse He的博客-CSDN博客

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/1026842.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号