我尝试使用以下代码使用GDCM库读取DICOM文件:
gdcm.ImageReader imagereader = new gdcm.ImageReader();
imagereader.SetFileName(@"E:\sample_success.dcm");
if (!imagereader.Read()) throw new Exception("Cannot read dicom file!");对于"sample_success.dcm“文件,我可以很好地读取该文件(success.png)。但是使用"sample_failed.dcm“文件,GDCM会抛出异常,因为它无法读取它。我试图使用其他DICOM查看器(如Radiant )打开该文件,它成功了。我的GDCM有什么问题吗?为什么它看不懂?
我使用GDCM 2.6.5。请找到两个样本这里。
发布于 2016-09-22 12:06:29
您的文件在偏移量0x1480aa之后(在Pixel属性中的某个位置)包含垃圾(一堆二进制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 2856https://stackoverflow.com/questions/39637131
复制相似问题