using System.Windows.Media.Imaging; using FellowOakDicom; using FellowOakDicom.Imaging; using FellowOakDicom.Imaging.Codec; using FellowOakDicom.Imaging.Render; using Livia.Utility; namespace DicomViewer.Models; internal class DicomDataTuple { public BitmapImage Image { get; } private readonly IPixelData _pixelData; private readonly DicomDataset _dataset; public DicomDataTuple(string path, int frame = 0) { _dataset = DicomFile.Open(path).Clone(DicomTransferSyntax.ImplicitVRLittleEndian).Dataset; Image = new DicomImage(_dataset).RenderImage(frame).AsClonedBitmap().ToBitmapImage(); _pixelData = PixelDataFactory.Create(DicomPixelData.Create(_dataset), frame); } public double GetPixel(int x, int y) { return _pixelData.GetPixel(x, y) * _dataset.GetSingleValueOrDefault(DicomTag.RescaleSlope, 1.0) + _dataset.GetSingleValueOrDefault(DicomTag.RescaleIntercept, 0); } }