您的文件在偏移量0x1480aa(在像素数据属性中的某个位置)之后包含垃圾(一堆二进制 0)。如果没有正确报告错误,您对工具包有什么期望?
根据设计,GDCM 仍会加载任何内容,直到出现错误。因此,如果您在代码中删除 new Exception,您可以决定(例如)将 imagereader.GetFile() 传递给 gdcm::Writer 并将文件重写为干净的 DICOM。
顺便说一句,我无法访问Radiant 软件,但我觉得很奇怪,在这种情况下它并不表示错误。
我检查过 DCMTK 和 dicom3tools,它们都报告了解析问题。
使用 gdcm 命令行工具,您几乎可以使用以下方法重写文件:
$ gdcmconv -I sample_failed.dcm sample_failed_correct.dcm
由于您的输入数据集无效,GDCM(错误地)相信看到一个属性,您可以使用以下方法将其删除:
$ gdcmanon --dumb --remove 0,0 sample_failed_correct.dcm sample_failed_correct_clean.dcm
然后:
$ gdcminfo sample_failed_correct.dcm
MediaStorage is 1.2.840.10008.5.1.4.1.1.3.1 [Ultrasound Multi-frame Image Storage]
TransferSyntax is 1.2.840.10008.1.2.4.50 [JPEG Baseline (Process 1): Default Transfer Syntax for Lossy JPEG 8 Bit Image Compression]
NumberOfDimensions: 3
Dimensions: (800,600,21)
SamplesPerPixel :3
BitsAllocated :8
BitsStored :8
HighBit :7
PixelRepresentation:0
ScalarType found :UINT8
PhotometricInterpretation: YBR_FULL_422
PlanarConfiguration: 0
TransferSyntax: 1.2.840.10008.1.2.4.50
Origin: (0,0,0)
Spacing: (0.0106324,0.0106324,1)
DirectionCosines: (1,0,0,0,1,0)
Rescale Intercept/Slope: (0,1)
Orientation Label: AXIAL
这与像素数据中的片段数有效:
$ gdcmdump sample_failed_correct.dcm | grep Item | grep "ff.d8" | wc
21 126 2856