作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
如何从未压缩的DICOM文件读取原始图像数据并将其转储到文件中。我只是将以下代码用于压缩文件。使用dcmtk库
dataSet->findAndGetElement(DCM_PixelData, element);
pixDataElem = OFstatic_cast(DcmPixelData*, element);
DcmPixelSequence *pixelSequence = NULL;
E_TransferSyntax tran_Syntax = EXS_Unknown;
const DcmRepresentationParameter *representation = NULL;
// Find the key that is needed to access the right representation of the data within DCMTK
pixDataElem->getOriginalRepresentationKey(tran_Syntax, representation);
//pixDataElem->getCurrentRepresentationKey(tran_Syntax, representation);
// Access original data representation and get result within pixel sequence
pixDataElem->getEncapsulatedRepresentation(tran_Syntax, representation, pixelSequence);
DcmPixelItem *pixelItem = NULL;
//Access the First frame by skipping the offset table...
pixelSequence->getItem(pixelItem, 1);
Uint8 *pixels = NULL;
pixDataElem = (DcmPixelData*)pixelItem;
pixDataElem->getUint8Array(pixels);
Uint8 *pixels = NULL;
pixDataElem->getUint8Array(pixels);
//Writing the Raw data to a file...
FILE *file;
file = fopen("D:\\DicomImage.jpeg", "wb");
fwrite(pixels, sizeof(char), imageSize, file);
cout << "File write Completed and the File is closed Successfully" << endl;
最佳答案
基本上,您可以使用相同的代码,但无需压缩(实际上是更简单的情况...)
dataSet->findAndGetElement(DCM_PixelData, element);
pixDataElem = OFstatic_cast(DcmPixelData*, element);
Uint8 *pixels = NULL;
pixDataElem->getUint8Array(pixels);
//Writing the Raw data to a file...
FILE *file;
file = fopen("D:\\DicomImage.raw", "wb");
// frameSize is the size of a single frame
fwrite(pixels + frameSize * frameIndex, sizeof(char), frameSize, file);
cout << "File write Completed and the File is closed Successfully" << endl;
关于c++ - 如何从dicom文件读取二进制数据?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60259660/
我是一名优秀的程序员,十分优秀!