再会,
我正在读取 jpg 图像并尝试将其作为 jpg 存储在 DICOM 文件中。我希望尽可能少的操作以防止任何丢失或 ICC 配置文件更改。
我试过了:
...
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 用户组上提出的)