久久r热视频,国产午夜精品一区二区三区视频,亚洲精品自拍偷拍,欧美日韩精品二区

您的位置:首頁技術文章
文章詳情頁

在python中讀取* .mhd / *。raw格式

瀏覽:3日期:2022-08-07 14:08:13
如何解決在python中讀取* .mhd / *。raw格式?

最簡單的方法是使用SimpleITK(MedPy也將ITK用于.mhd / .raw文件)。命令

pip install SimpleITK

適用于許多python版本。要讀取.mhd /.raw,可以從kaggle使用此代碼

import SimpleITK as sitkimport numpy as np’’’This funciton reads a ’.mhd’ file using SimpleITK and return the image array, origin and spacing of the image.’’’def load_itk(filename): # Reads the image using SimpleITK itkimage = sitk.ReadImage(filename) # Convert the image to a numpy array first and then shuffle the dimensions to get axis in the order z,y,x ct_scan = sitk.GetArrayFromImage(itkimage) # Read the origin of the ct_scan, will be used to convert the coordinates from world to voxel and vice versa. origin = np.array(list(reversed(itkimage.Getorigin()))) # Read the spacing along each dimension spacing = np.array(list(reversed(itkimage.GetSpacing()))) return ct_scan, origin, spacing解決方法

誰能告訴我如何讀取包含python中的 .mhd / .raw文件的數據集的方式?

標簽: Python 編程
相關文章:
主站蜘蛛池模板: 汽车| 兰坪| 分宜县| 平谷区| 广水市| 邻水| 台中县| 石嘴山市| 大名县| 南华县| 合山市| 柳河县| 青铜峡市| 肥西县| 岢岚县| 唐河县| 连山| 大安市| 汤阴县| 南木林县| 连城县| 资兴市| 武胜县| 武功县| 夏河县| 平罗县| 庆城县| 容城县| 屏东市| 哈巴河县| 瑞丽市| 商洛市| 内乡县| 滦平县| 得荣县| 驻马店市| 鹤壁市| 尼勒克县| 安宁市| 江西省| 灵丘县|