最近一直在做实验,所以好久没有更新了,先把上周做的一些小的实验贴出来供大家分享。
在医生诊断时,是会将CT图像调整成不同的窗来处理的。比如说肺部CT吧,肺窗(窗宽为2000,窗位为-400)用于看小的肺结节;腹部窗(窗宽400,窗位40)用于看大的肺结节和纵隔淋巴结,还有骨窗。所以在处理CT图像的时候会需要选择不同的窗,那么怎么来使得你的.dcm文件.IMA文件.mhd文件以不同的窗宽窗位显示:# -*- coding=utf-8 -*-
import dicom
import os
import cv2
import numpy
from os.pathimport splitext
def getfile(file):
dcm = dicom.read_file(file)
img2 = dcm.pixel_array * dcm.RescaleSlope + dcm.RescaleIntercept
return img2def get_window_size(window_type):
if window_type =='lung':
center = -500
width =2000
elif window_type =='abdomen':
center =40
width =400
elif window_type =='bone':
center =300
width =2000
return center, widt