Dicom Toolkit (DCMTK) - How to get Window Centre and Width

时间:2016-04-04 17:17:32

标签: c++ opencv dicom mat dcmtk

I am currently using DCMTK in C++. I am quite new to this toolkit but, as I understand it, I should be able to read the window centre and width for normalisation purposes.

I have a DicomImage DCM_image object with my Dicom data. I read the values to an opencv Mat object. However, I now would like to normalise them. The following shows how I am reading and transferring the Data to an opencv Mat.

    DicomImage DCM_image("test.dcm");
    uchar *pixelData = (uchar *)(DCM_image.getOutputData(8));   
    cv::Mat image(int(DCM_image.getHeight()), int(DCM_image.getWidth()), CV_8U, pixelData);

Any help is appreciated. Thanks

1 个答案:

答案 0 :(得分:0)

读取窗口中心和宽度并不困难,但是您需要使用不同的构造函数并将DcmDataset传递给图像。

DcmFileFormat file;
file.loadFile("test.dcm");
DcmDataset* dataset = file.getDataset()
DicomImage image(dataset);
double windowCenter, windowWidth;
dataset->findAndGetFloat64(DcmTagKey(0x0010, 0x1050), windowCenter);
dataset->findAndGetFloat64(DcmTagKey(0x0010, 0x1051), windowWidth);

但实际上我认为在加载时将窗口应用于图像并不是一个好主意。窗口是应该由用户调整的东西。窗口中心和窗口宽度属性允许多个值,可应用于将窗口调整到感兴趣的灰度范围(“VOI”,感兴趣的值)。

如果您真的只想创建窗口图像,可以使用代码从文件内容构造图像,并使用DicomImage提供的createXXXImage方法之一。

HTH