gpt4 book ai didi

wpf - 加载 Dicom 图像并显示它 - 使用 ClearCanvas 库

转载 作者:行者123 更新时间:2023-12-04 11:45:44 25 4
gpt4 key购买 nike

这是一个非常狭窄和具体的问题,但我知道还有其他人在使用它,所以我会保持双手交叉,并希望你们中的任何人都能提出这个问题。

我正在开发一个 WPF 应用程序,其中一部分是 Dicom 查看器。我们想使用一个 3rd 方组件来处理 Dicom 的东西,而 ClearCanvas 是迄今为止我们印象最好的一个。我们能够加载 Dicom 文件并获取属性,但是我们在将图像数据放在 Image 控件的 Source 属性上以显示它时遇到了问题。任何人都提示如何做到这一点?

这是我用于提取图像数据的代码:

var file = new DicomFile(dicomFilePath);
var patientName = file.DataSet.GetAttribute(DicomTags.PatientsName);
var imageData = file.DataSet.GetAttribute(DicomTags.PixelData);

也尝试过使用 ImageViewer 库,但它仍然是相同的数据..
var localSopDataSource = new LocalSopDataSource(new DicomFile(dicomFilePath));
var patientName = localSopDataSource.File.DataSet.GetAttribute(DicomTags.PatientsName);
var imageData = localSopDataSource.File.DataSet.GetAttribute(DicomTags.PixelData);

最佳答案

好的,我想通了.. 可能还有更多方法可以实现这一点,但这就是我所做的。现在我有一个 Wpf Image 绑定(bind)到提供位图数据的属性。以下是用于提供位图数据的属性。

public BitmapSource CurrentFrameData
{
get
{
LocalSopDataSource _dicomDataSource =
new LocalSopDataSource(_dicomFilePath);
var imageSop = new ImageSop(_dicomDataSource);

IPresentationImage presentationImage =
PresentationImageFactory.Create(imageSop.Frames[CurrentFrame]);

int width = imageSop.Frames[CurrentFrame].Columns;
int height = imageSop.Frames[CurrentFrame].Rows;

Bitmap bmp = presentationImage.DrawToBitmap(width, height);
BitmapSource output = Imaging.CreateBitmapSourceFromHBitmap(
bmp.GetHbitmap(),
IntPtr.Zero,
Int32Rect.Empty,
BitmapSizeOptions.FromWidthAndHeight(width, height));

return output;
}
}

请注意,这是一个非常直接的解决方案。一个可能例如想要做一些事情,比如预加载图片等,以避免滚动多帧图像时负载过重。但是对于“如何显示图像”问题 - 这应该回答它..

关于wpf - 加载 Dicom 图像并显示它 - 使用 ClearCanvas 库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1649358/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com