Welcome Guest! To enable all features, please Login or Register.



Last Go to last post Unread Go to first unread post
#1 Posted : Thursday, February 8, 2018 5:29:15 PM(UTC)
Nick Villalobos

Groups: Registered
Posts: 119

Was thanked: 4 time(s) in 4 post(s)

Below you will see a code snippet on creating a Dicom file as well as adding the Pixel Data/RasterImage to the element in the DataSet. When creating the DataSet, you need to make sure that the SOP Instance UID is a unique ID.


static DicomDataSet CreateDicomFromImage(RasterImage image)
         DicomDataSet ds = new DicomDataSet();
         //initialize the DicomDataSet as secondary capture
         ds.Initialize(DicomClassType.SCImageStorage, DicomDataSetInitializeFlags.AddMandatoryElementsOnly | DicomDataSetInitializeFlags.ExplicitVR);

         //add patient name
         ds.InsertElementAndSetValue(DicomTag.PatientID, "Patient Name");

         //set the UIDs for the DICOM File
         ds.InsertElementAndSetValue(DicomTag.SeriesInstanceUID, "insert UID here");
         ds.InsertElementAndSetValue(DicomTag.StudyInstanceUID, "insert UID here");
         ds.InsertElementAndSetValue(DicomTag.SOPInstanceUID, "insert UID here");

         //Set the Image Type to Derived, since this is not created from a primary capture device
         ds.InsertElementAndSetValue(DicomTag.ImageType, "DERIVED");

         //insert Pixel data element and insert the RasterImage
         var pixelData = ds.InsertElement(null, false, DicomTag.PixelData, DicomVRType.UN, false, 0);
         ds.InsertImage(pixelData, image, 0, DicomImageCompressionType.None, DicomImagePhotometricInterpretationType.Monochrome2, 16, 2, DicomSetImageFlags.None);

         return ds;
Nick Villalobos
Developer Support Engineer
LEAD Technologies, Inc.


Try the latest version of LEADTOOLS for free for 60 days by downloading the evaluation: https://www.leadtools.com/downloads

Wanna join the discussion? Login to your LEADTOOLS Support accountor Register a new forum account.

You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Powered by YAF.NET | YAF.NET © 2003-2024, Yet Another Forum.NET
This page was generated in 0.047 seconds.