国产成人精品亚洲777人妖,欧美日韩精品一区视频,最新亚洲国产,国产乱码精品一区二区亚洲

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

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

瀏覽:4日期: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 編程
相關文章:
主站蜘蛛池模板: 晋江市| 涞源县| 天台县| 泽州县| 克拉玛依市| 周口市| 巴林右旗| 新干县| 邵武市| 蓝田县| 奉新县| 镇远县| 易门县| 奉化市| 汉寿县| 莆田市| 城口县| 柯坪县| 寻甸| 萝北县| 左云县| 盖州市| 永善县| 招远市| 贵德县| 轮台县| 钟祥市| 石城县| 嘉义县| 鄂伦春自治旗| 炉霍县| 庆云县| 涞源县| 马尔康县| 湟源县| 高青县| 丰城市| 方山县| 乌拉特后旗| 清丰县| 红河县|