根据[4]中的定义:

CT 的特点是能够分辨人体组织密度的轻微差别,所采用的标准是根据各种组织对X 线的线性吸收系数(μ值) 来决定的。

[5]中提到了一个公式:

所以比赛中的dicom的灰度值需要转化为CT值。

CT值的物理意义就是CT射线照了你的身体,辐射经过你的身体时的辐射强度的衰减程度。

-----------------------------------------------------------------------------------------------------------------------------

[1]中对CT图像的windowing的定义:]

Windowing, also known as grey-level mappingcontrast stretchinghistogram modification or contrast enhancement is the process in which the CT image greyscale component of an image is manipulated via the CT numbers; doing this will change the appearance of the picture to highlight particular structures. The brightness of the image is, adjusted via the window level. The contrast is adjusted via the window width.

说白了就是灰度映射为辐射强度,然后提高对比度

根据[2],dicom里面,如果给出了intercept和slope,就认为灰度值和辐射强度之间的转化是线性关系.

否则就是非线性关系,是否是线性关系可以根据对dicom的数据读取来判断(下面的代码输出内容中有)

然后是过滤处理资料:

也就是根据Hu(CT)值来筛选我们想要的部位的图片,其他部位全部抹黑或者抹白(对应代码中的img_min或者img_max),目的是为了增加对比度.

下面来自[3]的代码,这个代码是用来进行windowing操作和滤波的:

# Viewing Dicom CT images with correct  windowingCT image values correspond to [Hounsfield units](https://en.wikipedia.org/wiki/Hounsfield_scale) (HU).
But the values stored in CT Dicoms are not Hounsfield units,
but instead a scaled version.
To extract the Hounsfield units we need to apply a linear transformation,
which can be deduced from the Dicom tags.Once we have transformed the pixel values to Hounsfield units, we can apply a *windowing*:
the usual values for a head CT are a center of 40 and a width of 80, but we can also extract this from the Dicom headers.
from glob import glob
import os
import pandas as pd
import numpy as np
import re
from PIL import Image
import seaborn as sns
from random import randrange#checnking the input files
print(os.listdir("../input/rsna-intracranial-hemorrhage-detection/"))## Load Data
#reading all dcm files into train and text
train = sorted(glob("../input/rsna-intracranial-hemorrhage-detection/stage_1_train_images/*.dcm"))
test = sorted(glob("../input/rsna-intracranial-hemorrhage-detection/stage_1_test_images/*.dcm"))
print("train files: ", len(train))
print("test files: ", len(test))pd.reset_option('max_colwidth')
train_df = pd.read_csv('../input/rsna-intracranial-hemorrhage-detection/stage_1_train.csv')def window_image(img, window_center,window_width, intercept, slope):img = (img*slope +intercept)#灰度值转化为CT辐射强度,转化后的结果其实可以理解为"医用像素值"img_min = window_center - window_width//2 # "-"后面的先计算img_max = window_center + window_width//2
#     下面其实是一个滤波器,过滤掉噪音img[img<img_min] = img_minimg[img>img_max] = img_maxreturn img
# 这里的img是一个二维矩阵def get_first_of_dicom_field_as_int(x):#get x[0] as in int is x is a 'pydicom.multival.MultiValue', otherwise get int(x)if type(x) == pydicom.multival.MultiValue:#如果有很多个值return int(x[0])else:return int(x)def get_windowing(data):
#     下面是获取dicom数据库中某个图片的各个参数的方式,并不是坐标dicom_fields = [data[('0028','1050')].value, #window centerdata[('0028','1051')].value, #window widthdata[('0028','1052')].value, #interceptdata[('0028','1053')].value] #slope
#     上面的这个种(0028,1053)在资料中被称为Tagreturn [get_first_of_dicom_field_as_int(x) for x in dicom_fields]import pydicom
#图片数据库
import matplotlib.pyplot as plt
print(len(train))
case = 199
# train是个list类型
data = pydicom.dcmread(train[case]) #指定某张照片plt.imshow(img, cmap=plt.cm.bone)
print("-------------------------------------1--------------------------------")
window_center , window_width, intercept, slope = get_windowing(data)#从dicom数据库中获取data的参数#displaying the image
img = pydicom.read_file(train[case]).pixel_arrayimg = window_image(img, window_center, window_width, intercept, slope)#windowing操作以及过滤噪声
plt.imshow(img, cmap=plt.cm.bone)
plt.grid(False)
print("---------------------------------------2------------------------------")
print(data)

上述代码运行后会输出dicom的信息以及一张颅内图片的预览:

---------------------------------------2------------------------------
(0008, 0018) SOP Instance UID                    UI: ID_00145de6f
(0008, 0060) Modality                            CS: 'CT'
(0010, 0020) Patient ID                          LO: 'ID_e58c888d'
(0020, 000d) Study Instance UID                  UI: ID_c69165e24e
(0020, 000e) Series Instance UID                 UI: ID_49ed8e3bef
(0020, 0010) Study ID                            SH: ''
(0020, 0032) Image Position (Patient)            DS: ['-125.000000', '-124.697983', '223.549103']
(0020, 0037) Image Orientation (Patient)         DS: ['1.000000', '0.000000', '0.000000', '0.000000', '0.927184', '-0.374607']
(0028, 0002) Samples per Pixel                   US: 1
(0028, 0004) Photometric Interpretation          CS: 'MONOCHROME2'
(0028, 0010) Rows                                US: 512
(0028, 0011) Columns                             US: 512
(0028, 0030) Pixel Spacing                       DS: ['0.488281', '0.488281']
(0028, 0100) Bits Allocated                      US: 16
(0028, 0101) Bits Stored                         US: 16
(0028, 0102) High Bit                            US: 15
(0028, 0103) Pixel Representation                US: 1
(0028, 1050) Window Center                       DS: "30"
(0028, 1051) Window Width                        DS: "80"
(0028, 1052) Rescale Intercept                   DS: "-1024"
(0028, 1053) Rescale Slope                       DS: "1"
(7fe0, 0010) Pixel Data                          OW: Array of 524288 elements

## Visualize Sample Images

TRAIN_IMG_PATH = "../input/rsna-intracranial-hemorrhage-detection/stage_1_train_images/"
TEST_IMG_PATH = "../input/rsna-intracranial-hemorrhage-detection/stage_1_test_images/"def view_images(images, title = '', aug = None):width = 5height = 2fig, axs = plt.subplots(height, width, figsize=(15,5))for im in range(0, height * width):data = pydicom.read_file(os.path.join(TRAIN_IMG_PATH,images[im]+ '.dcm'))image = data.pixel_arraywindow_center , window_width, intercept, slope = get_windowing(data)#从dicom中获取参数image_windowed = window_image(image, window_center, window_width, intercept, slope)i = im // widthj = im % widthaxs[i,j].imshow(image_windowed, cmap=plt.cm.bone) axs[i,j].axis('off')plt.suptitle(title)plt.show()
train_df['image'] = train_df['ID'].str.slice(stop=12)#因为图片名称的前半部分是ID
train_df['diagnosis'] = train_df['ID'].str.slice(start=13)#因为图片名称的后半部分是出血类型print("------------------------------------从下面开始每个类型的图片都看十张------------------------------------------------------")view_images(train_df[(train_df['diagnosis'] == 'epidural') & (train_df['Label'] == 1)][:10].image.values, title = 'Images with epidural')

下面代码与上面一句类似,都是浏览图片(结果略)

view_images(train_df[(train_df['diagnosis'] == 'intraparenchymal') & (train_df['Label'] == 1)][:10].image.values, title = 'Images with intraparenchymal')view_images(train_df[(train_df['diagnosis'] == 'intraventricular')& (train_df['Label'] == 1)][:10].image.values, title = 'Images with intraventricular')view_images(train_df[(train_df['diagnosis'] == 'subarachnoid')& (train_df['Label'] == 1)][:10].image.values, title = 'Images with subarachnoid')s'] == 'subdural') & (train_df['Label'] == 1)][:10].image.values, title = 'Images with subarachnoid')

Reference:

[1]https://radiopaedia.org/articles/windowing-ct

[2]https://stackoverflow.com/questions/10193971/rescale-slope-and-rescale-intercept

[3]https://www.kaggle.com/omission/eda-view-dicom-images-with-correct-windowing

[4]http://www.xctmr.com/baike/ct/d054abd3bf1a96110b623e4cc2b58575.html

[5]https://baike.baidu.com/item/CT值单位/15635363

CT流程与CT图像的windowing操作(转载+整理)相关推荐

  1. ct是计算机软件分析报告吗,ct影像工作站|ct诊断报告系统|ct图文工作站|dicom软件系统|技易科技-医学影像软件网...

    ct影像工作站 ct医学影像工作站的常见名称:ct工作站.CT图文报告系统. ct影像工作站 .ct影像软件等. ct影像工作站与CT设备连接,获取影像,辅助医师管理病历.书 写诊断报告,统计分析,并 ...

  2. ct与x光的哪个辐射大_胸片、CT、PET/CT哪个辐射大?结果你很难猜到

    来自广东的胡女士问:我今天50岁了,一直有心血管疾病,半月前出现咳嗽症状,住院治疗了半个月,前后照了3次CT,听说频繁照CT会致癌,这是真的吗? CT致癌一说,小艾早有耳闻,具体实情是怎样的?今天我们 ...

  3. 计算机ct检查,什么是CT检查?CT检查设备介绍

    什么是CT检查呢?CT是现如今最为普遍的医学影像影响检查途径,在治疗各类疾病上起着重要和不能代替的作用.今天,不如就来一起了解了解CT检查的原理和设备都有怎样的吧. 什么是CT检查 CT是用X线束对人 ...

  4. 理解图像中卷积操作的含义

    原文地址:https://blog.csdn.net/chaipp0607/article/details/72236892?locationNum=9&fps=1 上文用生动的例子来解释卷积 ...

  5. MATLAB图像取点操作

    %% 图像取点操作 % 读入图片 y=imread('数据.bmp'); imshow(y)%显示该图  set(gcf,'outerposition',get(0,'screensize'));%使 ...

  6. matlab对像素邻域操作,matlab图像的邻域操作与块操作

    1.图像的滑动邻域操作. 邻域操作是指将每个输入的像素值以及其某个邻域的像素值结合处理而得到对应的输出像素值的过程.邻域通常形状规则.如2*2,2*3之类. 滑动邻域操作一次处理一个像素. 对于m*n ...

  7. opencv学习记录——(5)图像像素的操作

    1.先补充几点opencv的相关知识点 1.1  通过Scalar来设置颜色 Scalar(b1, b2, b3, b4),前面的三个参数是依次设置BGR的,和RGB相反,第四个参数设置图片的透明度. ...

  8. 卷积 对图像进行卷积操作 卷积神经网络

    目录 卷积 对图像进行卷积操作 卷积神经网络 卷积(Filtering) 池化(下采样)(Pooling) 修正线性单元(Rectified Linear Units)(ReLus激活函数) 全连接层 ...

  9. 利用python进行png图像的读写操作

    利用python进行png图像的读写操作 最近遇到了对png灰度图像进行读取,并统计图像中众数的需求,现将代码记录如下.ps:适用于单波段图,形如(X,Y). 1.导入需要的包 import matp ...

最新文章

  1. Python 极简实现 IoU
  2. opencv Canny边缘检测用法
  3. 【组合数学】生成函数 ( 求和性质 )
  4. iOS开发UITableView随笔
  5. 在天气预报中应用机器学习
  6. 小学五年级计算机二课活动记录,小学五年级主题班会的活动记录
  7. 编写一个C程序,实现以下功能:编写一个函数decTobin(int n),该函数能将一个十进制数n转换成二进制数,输入13 输出 1101。在main函数中输入整数n,调用函数,输出它的二进制
  8. 【Python】第一个程序---Helloworld!
  9. PyRobot开辟 AI 机器人框架
  10. C/C++ typedef用法!
  11. 一块硬盘做服务器,服务器4块硬盘做raid几
  12. 【zer0pts CTF 2022】 Anti-Fermat
  13. 送货记账软件网络版怎么用
  14. 如何在PPT中嵌入交互式图表?LightningChart助力炫酷展示
  15. Magento相关产品(Related Product)推荐销售(Up-sells)和交叉销售(Cross-sells)
  16. 记一次美版苹果手机购买经历
  17. 四叉树 java 实现
  18. 经典乱码“烫烫烫”和“屯屯屯”
  19. 射频链路隔直电容选择
  20. php学籍信息管理系统心得_php学生信息管理系统

热门文章

  1. MarkdownPad官方网站
  2. awk的sub函数和gsub函数的用法
  3. [Buzz.Today]2013.03.28
  4. 经典插花的教训 PKU 1157
  5. 再赠邓超明(帮别人名字作诗)
  6. uniapp h5 页面 解决 ios 长按无法保存图片问题(安卓支持此功能)--实现移动端长按保存图片
  7. 微信小程序 navigateTo 传对象参数
  8. 抛物线运动JavaScript实现
  9. Weex Project (npm run android)-Error: Error: Command failed
  10. Vue项目如何实现国际化?分享一下基于vue-i18n实现国际化的经验