在解析dicom图像过程中常常遇到经过压缩的DICOM图像,不能直接读取。
想要读取的话,需要解码
DJDecoderRegistration::registerCodecs(); // register JPEG codecs
还有释放线程
DJDecoderRegistration::cleanup();
DCMTK官网给出了JPEG格式压缩的DCM文件解压缩的方法(http://support.dcmtk.org/docs/mod_dcmjpeg.html),代码摘录如下:
DJDecoderRegistration::registerCodecs(); // register JPEG codecs DcmFileFormat fileformat; if (fileformat.loadFile("test_jpeg.dcm").good()) { DcmDataset *dataset = fileformat.getDataset(); // decompress data set if compressed dataset->chooseRepresentation(EXS_LittleEndianExplicit, NULL); // check if everything went well if (dataset->canWriteXfer(EXS_LittleEndianExplicit)) { fileformat.saveFile("test_decompressed.dcm", EXS_LittleEndianExplicit); } } DJDecoderRegistration::cleanup(); // deregister JPEG codecs
相关博客:
https://my.oschina.net/zssure/blog/354760
DCMTK 开源库的学习笔记2:直接操作dcm文件中像素数据的尝试
https://blog.csdn.net/fanhenghui/article/details/78626909
dcmtk压缩解压缩注意的地方
https://blog.csdn.net/m_buddy/article/details/53117427
解压缩读取Dicom图片(彩色)及显示
http://blog.sina.com.cn/s/blog_71f90cdf0100pfbu.html
DICOM Object基本概念(包含具体压缩UID)
3、Pixel data介绍
Pixel data is treated the same as all other attributes
(7FE0,0010) - Pixel Data tag
Pixel data的存储方式,包括:未压缩,压缩(无损、有损压缩)
影像的Transfer Syntax UID (0002,0010)決定了影像的存储方式,比如:
未压缩:
Implicit VR Little Endian:
Default Transfer Syntax for DICOM 1.2.840.10008.1.2
Explicit VR Little Endian 1.2.840.10008.1.2.1
Explicit VR Big Endian 1.2.840.10008.1.2.2
无损压缩:
JPEG Lossless :
Default Transfer Syntax for Lossless JPEG
ImageCompression 1.2.840.10008.1.2.4.70
JPEG 2000 Image Compression
(Lossless Only) 1.2.840.10008.1.2.4.90
RLE Lossless 1.2.840.10008.1.2.5
有损压缩:
Default Transfer Syntax for Lossy
JPEG 12 Bit Image Compression
1.2.840.10008.1.2.4.51
LOSSY(8 bit) 1.2.840.10008.1.2.4.50
动态:
MPEG2 image Compression 1.2.840.10008.1.2.4.100