C# 将jpg图像作为jpg图像添加到DICOM文件
你好 我正在读取jpg图像,并试图将其作为jpg存储在DICOM文件中。我希望尽可能少的操纵,以防止任何损失或ICC配置文件的更改 我试过:C# 将jpg图像作为jpg图像添加到DICOM文件,c#,dicom,fo-dicom,C#,Dicom,Fo Dicom,你好 我正在读取jpg图像,并试图将其作为jpg存储在DICOM文件中。我希望尽可能少的操纵,以防止任何损失或ICC配置文件的更改 我试过: ... data.Add(DicomTag.TransferSyntaxUID, DicomUID.JPEGLSLossless); data.Add(DicomTag.PhotometricInterpretation, PhotometricInterpretation.Rgb); data.Add(DicomTag.SamplesPerPixel,
...
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);
}
它似乎将图像存储为BMP,因为DICOM文件的大小膨胀得难以置信
我尝试了DicomTag.TransferSyntaxUID的不同组合:
data.Add(DicomTag.TransferSyntaxUID, DicomUID.JPEGLSLossless);
data.Add(DicomTag.TransferSyntaxUID, DicomUID.JPEGBaseline1);
data.Add(DicomTag.TransferSyntaxUID, DicomUID.JPEGLosslessNonHierarchical14);
想法
(注意:这也是fo dicom用户组提出的)我们找到了答案:
DicomDataset data = new DicomDataset() { };
改为:
DicomDataset data = new DicomDataset(DicomTransferSyntax.JPEGProcess1) { };
这是基于这篇文章的:
顺便说一下,在DICOM中,彩色图像的ICC配置文件必须与像素数据(即JPEG流)分开存储。