c# DSA影像转jpg
安装fo-dicom.Desktop包
<package id="fo-dicom.Desktop" version="4.0.8" targetFramework="net461" />
将DSA影像转图片
注意DSA影像可能包含多帧图像,如下可以获取DICOM文件包含的帧数
int numberOfFrames = file.Dataset.GetSingleValueOrDefault(DicomTag.NumberOfFrames, 1);
完整代码如下:
static void Main(string[] args)
{
Stopwatch stopwat = new Stopwatch();
stopwat.Start();
var file = DicomFile.Open(@"D:\image\1.6.21482.6910.7278.1692665344057\1.6.21482.6910.7278.1692665344057\1.3.46.670589.29.447743947205581333714583628648052\1.3.46.670589.29.447743947205581333714583629648050822104401020.dcm");
int numberOfFrames = file.Dataset.GetSingleValueOrDefault<int>(DicomTag.NumberOfFrames, 1);
for (int i = 0; i < numberOfFrames; i++)
{
var dicomImage = new DicomImage(file.Dataset);
dicomImage.RenderImage(i).AsClonedBitmap().Save($"F:\\Data\\{i}.jpeg", ImageFormat.Jpeg);
}
stopwat.Stop();
Console.WriteLine($"数据转换完成{stopwat.ElapsedMilliseconds}毫秒");
Console.ReadLine();
}