了解DICOM图像中的BPP [英] Understanding the BPP inside DICOM images

查看:135
本文介绍了了解DICOM图像中的BPP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

几天以来,我一直在使用FO-DICOM处理DICOM文件。

I'm working with DICOM files since a few days, using FO-DICOM.

我正在使用一组dicom文件进行测试,而我一直在打印光度学解释和每像素样本值,以更好地了解我正在处理哪种类型的图像。

I'm using a set of dicom files for my tests, and I've been printing the "Photometric Interpretation" and the "Sample Per Pixel" values, to have a better understanding of what kind of images I'm working with.

结果是,光度解释为 MONOCHROME2,每像素样本为 1。

The result was "MONOCHROME2" for the Photometric Interpretation, and "1" for the Sample Per Pixel.

通过阅读标准的第3部分,我了解到MONOCHROME2代表一个灰度,从黑色开始为其最小值。

What I understood by reading the part3 of the standard is that MONOCHROME2 represent a gray scale, starting from black for its minimum values.

但是,每像素采样数到底是多少?我以为这代表了每个像素的字节(而不是位数)的数量(逻辑上,每像素有8个 bits 可以显示灰度等级吗?)

But what is the Sample Per Pixel exactly? I thought this was representing the number of bytes (and not bits) per pixel (that would be logic to have 8 bits per pixel for a scale of gray right?)

但是我的问题是实际上我的图像似乎有32 bpp。
我正在处理512 * 512像素的图像,并将其转换为字节数组。所以我期待的是512 * 512 = 262144字节的数组。
但是我得到了1048630字节的数组(比4 * 262144多一点)

But my problem here is that actually, my images seem to have 32 bpp. I'm working with 512*512 pixels images, and I converted them into byte arrays. So I was expecting arrays of 512*512=262144 bytes. But I get arrays of 1048630 bytes (which is a bit more than 4*262144)

有人有解释吗?

编辑:

以下是我的一些数据:

PhotometricInterpretation=MONOCHROME2
SamplePerPixel=1
BitsAllocated=16
BitsStored=12
HighBit=11
PixelRepresentation=0
NumberOfFrames=0


推荐答案

属性( 0028,0002) SamplesPerPixel 仅指彩色图像,并告诉您图像中存在的平面数(例如RGB为3),因此您有

The attribute (0028,0002) SamplesPerPixel refers to color images only and tells you the number of planes which are present in the image (e.g. 3 for RGB), so you have

PhotometricInterpretation=RGB
SamplesPerPixel=3

每个像素有8位(我将在下面重新访问BPP)。只要您具有 PhotometricInterpretation = MONOCHROME1或MONOCHROME2,您就可以期望 SamplesPerPixel 为1。

With 8 bits per pixel (I will revisit BPP below). As long as you have PhotometricInterpretation = MONOCHROME1 or MONOCHROME2, you can expect the SamplesPerPixel to be 1 and nothing else.

您必须考虑的是每个像素的位数:

What you do have to take into consideration is the number of bits per pixel:

BitsAllocated (0028,0100)
BitsStored (0028,0101)
HighBit (0028,0102)

这些告诉您使用多少位来编码像素值( BitsAllocated ),以及其中哪些位真正包含灰度信息( BitsStored HighBit )。 HighBit 从零开始,通常但不一定= BitsStored-1

These tell you how many bits are used to encode a pixel value (BitsAllocated) and which of these bits really contain grayscale information (BitsStored, HighBit). HighBit is zero-based and usually but not necessarily = BitsStored-1

一个例子来说明这一点:对于CT图像,通常以hounsfield单位表示灰度值,范围从-1000到+3000。这些由以2字节对齐方式存储的12位表示,因此

An example to illustrate this: For CT images, it is very common to express gray values in hounsfield units which range from -1000 to +3000. These are represented by 12 bits which are stored with a 2-byte-alignment, so

BitsAllocated (0028,0100) = 16
BitsStored (0028,0101) = 12
HighBit (0028,0102) = 11

另一个自由度是 PixelRepresentation ,它告诉您像素数据是编码为无符号(0)还是2s补码(1)。我都看过CT图像,但是对于除CT以外的其他图像类型,带符号的像素数据非常少见。

Another degree of freedom is PixelRepresentation which tells you if the pixel data is encoded unsigned (0) or in 2s complement (1). I have seen both for CT images, however signed pixel data is rather unusual for image types other than CT.

在您的示例中,我假设分配的位== 32或(不太可能)您的数据集包含多个图像(帧),因此 NumberOfFrames(0028,0008)>1。如果没有帧数,您可以放心地假设只有一帧。

In your example, I would assume that Bits Allocated == 32 or (not very likely) that you have a dataset containing multiple images ('frames'), so NumberOfFrames (0028,0008) > 1. If Number of Frames is absent, you can safely assume to have only one frame.

我在这里稍微简化了一点,尤其是关于彩色图像,但是我认为这已经足够复杂了;-)。基本上,DICOM可以提供任何可想像的自由度来编码像素数据并在标头中描述编码。

I have over-simplified a bit here, especially about color images but I think this is complicated enough ;-). Basically, DICOM offers any thinkable degree of freedom to encode pixel data and describe the encoding in the header.

我想我建议您看一下DCMTK中的内容。最近的帖子。 DicomImage类具有一个不错的接口( getInterData()),该接口关心所有内容,并以规范化格式提供从DICOM文件读取的像素数据。

I think I have recommended you to have a look at the DCMTK in a recent post. The DicomImage class features a nice interface (getInterData()) which cares about all that stuff and provides the pixel data read from a DICOM file in a normalized format.

:随时在此处发布数据集的DICOM转储,我将对其进行介绍并告诉您如何解释像素数据。

: Feel free to post a DICOM dump of your dataset here, I would have a look at it and tell you how to interpret the pixel data.

这篇关于了解DICOM图像中的BPP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆