简体   繁体   English

将jpg图像作为jpg图像添加到DICOM文件中

[英]Add jpg image as jpg image to DICOM file

Good day, 美好的一天,

I am reading a jpg image and trying to storing it in the DICOM file as jpg. 我正在阅读jpg图像并尝试将其作为jpg存储在DICOM文件中。 I want as little manipulation as possible to prevent any loss or ICC profile changes. 我希望尽可能少的操作来防止任何丢失或ICC配置文件更改。

I've tried: 我试过了:

...
data.Add(DicomTag.TransferSyntaxUID, DicomUID.JPEGLSLossless);

data.Add(DicomTag.PhotometricInterpretation, PhotometricInterpretation.Rgb);
data.Add(DicomTag.SamplesPerPixel, "3");
data.Add(DicomTag.PlanarConfiguration, "0");
data.Add(DicomTag.BitsAllocated, (ushort)8);
data.Add(DicomTag.BitsStored, (ushort)8);
data.Add(DicomTag.HighBit, (ushort)7);
data.Add(DicomTag.PixelRepresentation, "0");
data.Add(DicomTag.BurnedInAnnotation, "NO");
data.Add(DicomTag.LossyImageCompression, "01");
data.Add(DicomTag.LossyImageCompressionRatio, "10");
data.Add(DicomTag.LossyImageCompressionMethod, "ISO_10918_1");
...

DicomPixelData pixelData = DicomPixelData.Create(data, true);

using (System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap(imageFilename))
{
    byte[] pixels = GetPixels(bitmap);
    MemoryByteBuffer buffer = new MemoryByteBuffer(pixels);
    pixelData.AddFrame(buffer);
}

and

using (Image image = Image.FromFile(imageFilename))
{
    byte[] pixels = ImageToByteArray(image);
    MemoryByteBuffer buffer = new MemoryByteBuffer(pixels);
    pixelData.AddFrame(buffer);
}

It appears to be storing the image as BMP since the size of the DICOM file is ballooning beyond belief. 它似乎是将图像存储为BMP,因为DICOM文件的大小超出了预期。

I have tried different combinations of DicomTag.TransferSyntaxUID: 我尝试过DicomTag.TransferSyntaxUID的不同组合:

data.Add(DicomTag.TransferSyntaxUID, DicomUID.JPEGLSLossless);
data.Add(DicomTag.TransferSyntaxUID, DicomUID.JPEGBaseline1);
data.Add(DicomTag.TransferSyntaxUID, DicomUID.JPEGLosslessNonHierarchical14);

Thoughts? 思考?

(note: this was posed on the fo-dicom users group as well) (注意:这也是在fo-dicom用户组中提出的)

We have found the answer: 我们找到了答案:

DicomDataset data = new DicomDataset() { };

changed to: 变成:

DicomDataset data = new DicomDataset(DicomTransferSyntax.JPEGProcess1) { };

This is based on this article: 这是基于这篇文章:

https://github.com/fo-dicom/fo-dicom/issues/553 https://github.com/fo-dicom/fo-dicom/issues/553

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM