medimage 发表于 2015-12-4 21:07:14

DCMTK简介六-dcmjpeg程序库

本帖最后由 medimage 于 2015-12-4 21:25 编辑

六、dcmjpeg程序库
dcmjpeg提供了一个压缩/解压缩库以及可用工具。该模块包含一些类,可将DICOM图像对象在非压缩和JPEG压缩表示(传输协议)之间转换。无失真和有失真JPEG处理都被支持。这个模块实现了一族codec(编码解码器,由DcmCodec类派生而来),可以将这些codec在codec list中注册,codec list是由dcmdata模块保存的。
主要接口类:--DJEncoderRegistration: 一个singleton(孤立)类,为所有支持的JPEG处理注册编码器。在djencode.h中定义。--DJDecoderRegistration: 一个singleton(孤立)类,为所有支持的JPEG处理注册解码器。在djdecode.h中定义。--DJCodecEncoder: JPEG编码器的一个抽象codec类。This abstract class contains most of the application logic needed for a dcmdata codec object that implements a JPEG encoder using the DJEncoder interface to the underlying JPEG implementation. This class only supports compression, it neither implements decoding nor transcoding. 在djcodece.h中定义。--DJCodecDecoder: JPEG解码器的一个抽象codec类。This abstract class contains most of the application logic needed for a dcmdata codec object that implements a JPEG decoder using the DJDecoder interface to the underlying JPEG implementation. This class only supports decompression, it neither implements encoding nor transcoding.工具:dcmcjpeg: Encode DICOM file to JPEG transfer syntaxdcmdjpeg: Decode JPEG-compressed DICOM filedcmj2pnm: Convert DICOM images to PGM, PPM, BMP, TIFF or JPEGdcmmkdir: Create a DICOMDIR file举例:--用无失真JPEG压缩一幅DICOM图像文件。DJEncoderRegistration::registerCodecs(); // register JPEG codecsDcmFileFormat fileformat;if (fileformat.loadFile("test.dcm").good()){DcmDataset *dataset = fileformat.getDataset();DcmItem *metaInfo = fileformat.getMetaInfo();DJ_RPLossless params; // codec parameters, we use the defaults// this causes the lossless JPEG version of the dataset to be createddataset->chooseRepresentation(EXS_JPEGProcess14SV1TransferSyntax, ¶ms);// check if everything went wellif (dataset->canWriteXfer(EXS_JPEGProcess14SV1TransferSyntax)){    // force the meta-header UIDs to be re-generated when storing the file    // since the UIDs in the data set may have changed    delete metaInfo->remove(DCM_MediaStorageSOPClassUID);    delete metaInfo->remove(DCM_MediaStorageSOPInstanceUID);    // store in lossless JPEG format    fileformat.saveFile("test_jpeg.dcm", EXS_JPEGProcess14SV1TransferSyntax);}}   DJEncoderRegistration::cleanup(); // deregister JPEG codecs--解压缩一幅JPEG压缩的DICOM图像文件。DJDecoderRegistration::registerCodecs(); // register JPEG codecsDcmFileFormat fileformat;if (fileformat.loadFile("test_jpeg.dcm").good()){DcmDataset *dataset = fileformat.getDataset();// decompress data set if compresseddataset->chooseRepresentation(EXS_LittleEndianExplicit, NULL);// check if everything went wellif (dataset->canWriteXfer(EXS_LittleEndianExplicit)){    fileformat.saveFile("test_decompressed.dcm", EXS_LittleEndianExplicit);}}   
DJDecoderRegistration::cleanup(); // deregister JPEG codecs

medimagedev 发表于 2016-4-22 21:48:08

李孟 发表于 2016-5-10 02:21:56

好贴!

linac 发表于 2016-5-10 21:50:34

高手,厉害,向你学习。

proton 发表于 2016-5-16 01:12:50

正需要,学习学习,谢谢楼主!

medstd 发表于 2016-5-16 11:49:27

LZ高人啊,我来学习了

mdeimage 发表于 2016-5-17 09:34:12

谢谢你的辛苦劳动了!!!

medstd 发表于 2016-5-19 00:51:50

oevko 发表于 2016-5-20 08:29:48

一直在摸索,还是楼主厉害!

dentaldev 发表于 2016-5-20 08:47:49

谢谢大神
页: [1] 2
查看完整版本: DCMTK简介六-dcmjpeg程序库