4

我正在尝试使用 Grassroots DICOM (GDCM) 库在我的简单 c++ 应用程序中读取包含在 DICOM 文件中的图像的像素值。读取文件元数据时,我得到有关图片的以下信息:

Bits allocated: 16
Bits Stored: 16
High Bit: 15
Unsigned or signed: 1
Samples pr pixel: 1
Dimensions: 2
Dimension values: 256x256
Pixel Representation: 1
SamplesPerPixel: 1
ScalarType: INT16
PhotometricInterpretation: MONOCHROME2
Pixel buffer length: 131072

鉴于图像的分辨率为 256x256 并且是 MONOCHROME2 类型,我预计像素缓冲区长度为 256x256=65536 个元素,但实际上它是 131072 个元素长。

如果我使用 MATLAB 来导入像素数据,我会得到 0 - 850 范围内的 65536 个值,其中 0 是黑色,850 是白色。

当我查看从我的 c++ 应用程序中的 GDCM 读数获得的像素缓冲区时,像素缓冲区是 131072 个元素,其中每个偶数索引元素在 -128 到 +127 范围内,每个奇数索引元素在 0-3 范围内。像这样:

Exerpt:    

PixelBuffer[120] = -35
PixelBuffer[121] = 0
PixelBuffer[122] = 51
PixelBuffer[123] = 2
PixelBuffer[124] = 71
PixelBuffer[125] = 2
PixelBuffer[126] = 9
PixelBuffer[127] = 2
PixelBuffer[128] = -80
PixelBuffer[129] = 2
PixelBuffer[130] = 87
PixelBuffer[131] = 3
PixelBuffer[132] = 121
PixelBuffer[133] = 3
PixelBuffer[134] = -27
PixelBuffer[135] = 2
PixelBuffer[136] = 27
PixelBuffer[137] = 2
PixelBuffer[138] = -111
PixelBuffer[139] = 1
PixelBuffer[140] = 75
PixelBuffer[141] = 1
PixelBuffer[142] = 103 

这种价值观的排列意味着什么?这是单色图像的某种典型像素表示吗?我一直在“谷歌图像像素结构”和类似的东西,但找不到我要找的东西。是否有一些资源可以帮助我理解这种值的排列以及它们与每个像素的关系?

4

1 回答 1

1

我使用此代码读取 16 位 MONOCHROME2 Dicom 文件:

byte[] signedData = new byte[2];
        List<int> tempInt = new List<int>();
        List<ushort> returnValue = new List<ushort>();

        for (i = 0; i < PixelBuffer.Length; ++i)
        {
            i1 = i * 2;
            signedData[0] = PixelBuffer[i1];
            signedData[1] = PixelBuffer[i1 + 1];
            short sVal = System.BitConverter.ToInt16(signedData, 0);

            int pixVal = (int)(sVal * rescaleSlope + rescaleIntercept);

            tempInt.Add(pixVal);
        }

        int minPixVal = tempInt.Min();
        SignedImage = false;
        if (minPixVal < 0) SignedImage = true;

        foreach (int pixel in tempInt)
        {
            ushort val;
            if (SignedImage)
                val = (ushort)(pixel - short.MinValue);
            else
            {
                if (pixel > ushort.MaxValue) val = ushort.MaxValue;
                else val = (ushort)(pixel);
            }

            returnValue.Add(val);
        }
于 2016-10-25T10:01:13.583 回答