通过fo-dicom使用灰度软拷贝呈现状态

问题描述 投票:0回答:1

我想使用灰度软拷贝表示状态IOD在DICOM图像上添加标记(例如,图形或文本注释)。>>

我已经创建了这样的DICOM图像对象:

Bitmap bitmap = new Bitmap(path);
            bitmap = GetValidImage(bitmap);
            int rows, columns;
            byte[] pixels = GetPixels(bitmap, out rows, out columns);

            MemoryByteBuffer buffer = new MemoryByteBuffer(pixels);
            DicomDataset imageDataset = new DicomDataset();
            FillDataset(imageDataset);
            DicomDataset annotationdataset = new DicomDataset();
            FillAnnotation(imageDataset, annotationdataset);

            imageDataset.Add(DicomTag.PhotometricInterpretation, PhotometricInterpretation.Rgb.Value);
            imageDataset.Add(DicomTag.Rows, (ushort)rows);
            imageDataset.Add(DicomTag.Columns, (ushort)columns);
            imageDataset.Add(DicomTag.BitsAllocated, (ushort)8);

            DicomPixelData pixelData = DicomPixelData.Create(imageDataset, true);
            pixelData.BitsStored = 8;
            pixelData.SamplesPerPixel = 3;
            pixelData.HighBit = 7;
            pixelData.PixelRepresentation = 0;
            pixelData.PlanarConfiguration = 0;
            pixelData.AddFrame(buffer);



            DicomFile dicomfile = new DicomFile(imageDataset);
            if (File.Exists("test.dcm"))
                File.Delete("test.dcm");
            dicomfile.Save("test.dcm");

然后我创建了一个灰度软拷贝演示状态对象,如下所示:

private static void FillAnnotation(DicomDataset imageDataset, DicomDataset annotationDataset)
        {
            //type 1 attributes.
            annotationDataset.Add(DicomTag.SOPClassUID, DicomUID.GrayscaleSoftcopyPresentationStateStorage);
            annotationDataset.Add(DicomTag.StudyInstanceUID, _studyInstanceUid);
            annotationDataset.Add(DicomTag.SeriesInstanceUID, _seriesInstanceUID);
            annotationDataset.Add(DicomTag.SOPInstanceUID, GenerateUid());

            //type 2 attributes
            annotationDataset.Add(DicomTag.PatientID, _patientId);
            annotationDataset.Add(DicomTag.PatientName, _patientName);
            annotationDataset.Add(DicomTag.PatientBirthDate, _patientBirthDate);
            annotationDataset.Add(DicomTag.PatientSex, _patientSex);
            annotationDataset.Add(DicomTag.StudyDate, _studyDateTime);
            annotationDataset.Add(DicomTag.StudyTime, _studyDateTime);
            annotationDataset.Add(DicomTag.AccessionNumber, _accessionNumber);
            annotationDataset.Add(DicomTag.ReferringPhysicianName, _referringPhysicianName);
            annotationDataset.Add(DicomTag.StudyID, _studyID);
            annotationDataset.Add(DicomTag.SeriesNumber, _seriesNumber);
            //annotationDataset.Add(DicomTag.ModalitiesInStudy, "CR");
            annotationDataset.Add(DicomTag.Modality, _modality);
            annotationDataset.Add(DicomTag.Manufacturer, _manufacturer);
            annotationDataset.Add(DicomTag.PresentationCreationDate, _presentationCreationDateTime);
            annotationDataset.Add(DicomTag.PresentationCreationTime, _presentationCreationDateTime);

            DicomDataset serie = new DicomDataset();
            serie.Add(DicomTag.SeriesInstanceUID, _seriesInstanceUID);
            serie.Add(DicomTag.ReferencedImageSequence, imageDataset);

            annotationDataset.Add(DicomTag.ReferencedSeriesSequence, serie);


            DicomDataset displayedArea = new DicomDataset();
            displayedArea.Add(DicomTag.DisplayedAreaTopLeftHandCorner, "50\\50");
            displayedArea.Add(DicomTag.DisplayedAreaBottomRightHandCorner, "100\\100");
            displayedArea.Add(DicomTag.PresentationSizeMode, "SCALE TO FIT");

            annotationDataset.Add(DicomTag.DisplayedAreaSelectionSequence, displayedArea);

            annotationDataset.Add(DicomTag.ICCProfile, Byte.Parse("00000001"));

        }

我不太了解这两个对象如何相互连接?

我想使用灰度软拷贝表示状态IOD在DICOM图像上添加标记(例如,图形或文本注释)。我已经创建了一个DICOM图像对象,如下所示:位图...

c# dicom fo-dicom
1个回答
© www.soinside.com 2019 - 2024. All rights reserved.