你的文件包含垃圾(二进制0的一堆)后偏移0x1480aa
(在像素数据属性的某处)。如果没有正确报告错误,您对工具包有什么期望?
由设计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
其有效期与NUM像素数据中的碎片:
$ gdcmdump sample_failed_correct.dcm | grep Item | grep "ff.d8" | wc
21 126 2856
如何使用代码重写文件?我试图将'imagereader.GetFile()'传递给ImageWriter,并且结果文件是空的。由于'imagereader.Read()'失败,它不会返回任何图像。 – rg11
@ rg11更新了我的答案。只需将'gdcm :: File'传递给'gdcm :: Writer' – malat
非常感谢。有效。 – rg11