LEADTOOLS Support
Medical
Medical SDK Examples
HOW TO: Create a Dicom file and insert a RasterImage
 
        
            
      
          
            
               
                  #1
                  Posted
                  :
               
               Thursday, February 8, 2018 5:29:15 PM(UTC)
               
             
            
          
       
      
         
            
               
                  
                  
                  
              
                
               
            
            
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.
Code:
static DicomDataSet CreateDicomFromImage(RasterImage image)
      {
         DicomEngine.Startup();
         DicomDataSet ds = new DicomDataSet();
         ds.Reset();
         
         //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. 

 
             
          
       
       
     
            
         
  
 
         
        
        
    
LEADTOOLS Support
Medical
Medical SDK Examples
HOW TO: Create a Dicom file and insert a RasterImage
 
    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.