我正在与DCMTK3.6.1库做斗争,现在我遇到了一个常见的情况:访问DICOM映像的压缩数据像素。
正如库的作者在这里建议的那样,AccessingCompressedData,这是获取压缩数据的正确方法。
此代码可以工作,但它们从创建数据集的文件开始。在我的代码中,我用这种方式填充了数据集。
status = data->putAndInsertUint8Array(DCM_PixelData, pSource, sizeBuffer);其中pSource包含我的UNcompressed像素数据。在此之后,我添加了Image标签(第28组),然后用
status = data->chooseRepresentation(EXS_JPEGProcess14SV1, ¶m);从这个数据集开始,我想访问压缩的数据。
status = data->findAndGetElement(DCM_PixelData, element);
DcmPixelData *dpix = NULL;
dpix = OFstatic_cast(DcmPixelData*, element);
/* Since we have compressed data, we must utilize DcmPixelSequence
in order to access it in raw format, e. g. for decompressing it
with an external library.
*/
DcmPixelSequence *dseq = NULL;
E_TransferSyntax xferSyntax = EXS_Unknown;
const DcmRepresentationParameter *rep = NULL;
// Find the key that is needed to access the right representation of the data within DCMTK
dpix->getOriginalRepresentationKey(xferSyntax, rep);
// Access original data representation and get result within pixel sequence
status = dpix->getEncapsulatedRepresentation(xferSyntax, rep, dseq);
Uint32 length;
if (status.good())
{
DcmPixelItem* pixitem = NULL;
// Access first frame (skipping offset table)
dseq->getItem(pixitem, 1);
if (pixitem == NULL)
return 1;
Uint8* pixData = NULL;
// Get the length of this pixel item (i.e. fragment, i.e. most of the time, the lenght of the frame)
length = pixitem->getLength();
if (length == 0)
return 1;
// Finally, get the compressed data for this pixel item
status = pixitem->getUint8Array(pixData);
// Metto i Pixel Data compressi su pSorgCompr
pSorgCompr = (LPBYTE)pixData;
}
////////////////////////////
DJEncoderRegistration::cleanup();
DJDecoderRegistration::cleanup();但是row status = dpix->getEncapsulatedRepresentation(xferSyntax,rep,dseq);使用错误"Pixel表示未找到“重新进行失败,我不明白为什么。
如果在访问压缩数据之前,我使用fileformat.saveFile("compressedPixelData.dcm",EXS_JPEGProcess14SV1保存压缩文件,那么接下来我将使用= fileformat.loadFile("compressedPixelData.dcm");,加载该文件,这一切都是完美的。
就像加载文件函数解决了问题,我不知道怎么做,也许会填充一些标签?
在调用chooseRepresentation函数之前填充的标记是:
发布于 2015-02-02 14:22:55
好吧,也许已经解决了的问题。我添加了istructions
dataset->removeAllButCurrentRepresentations(); 在访问压缩像素数据之前。
我也可以用PixelData->removeAllButCurrentRepresentations();代替以前的指令,并以同样的方式工作.
但我真的不明白为什么会起作用..。你能解释一下吗?谢谢
发布于 2015-02-02 16:32:14
在DICOM中,压缩帧与未压缩(本机)帧不同地存储在像素数据元素(7FE0,0010)下。以下是DICOM中压缩图像编码的基本概念。
封装的像素流(压缩图像数据)被分割成一个或多个片段(项目)在像素数据元素(7FE0,0010)下的顶层数据集。在封装编码中,像素数据元素是一个序列,它包含两个或多个项目元素(片段),每个片段(项元素)都有自己的显式长度。此外,封装格式支持单帧和多帧图像编码.帧可以完全包含在单个片段(项)中,也可以跨越多个片段。封装像素流的片段序列由分隔符终止。
编码像素数据流之前项目序列中的第一项(FFFE,E000)通常是空的,或者可以包含基本偏移表项,该项将字节偏移保存到项目序列中每个帧的第一个片段的项目标记的第一个字节。
因此,当您想从DICOM数据集中提取压缩像素流时,需要跳过pixel数据序列下的第一个Item元素。我希望这有助于理解您引用的文档。详情请参阅DICOM标准PS 3.5附件A。
https://stackoverflow.com/questions/28219632
复制相似问题