Created
November 2, 2010 20:32
-
-
Save rcd/660248 to your computer and use it in GitHub Desktop.
basic DICOM file operations
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Dicom; | |
using Dicom.Data; | |
namespace Dicom.Examples { | |
static void Main() { | |
Debug.InitializeConsoleDebugLogger(); | |
// register compression codecs | |
DicomCodec.RegisterCodecs(); | |
DicomCodec.RegisterExternalCodecs(".", "Dicom.Codec.*.dll"); | |
// load DICOM tag dictionaries | |
if (File.Exists("dicom.dic")) | |
DcmDictionary.ImportDictionary("dicom.dic"); | |
else | |
DcmDictionary.LoadInternalDictionary(); | |
if (File.Exists("private.dic")) | |
DcmDictionary.ImportDictionary("private.dic"); | |
// load DICOM file | |
DicomFileFormat ff = new DicomFileFormat(); | |
ff.Load(@"test.dcm", DicomReadOptions.AllowSeekingForContext); | |
// print dataset to log | |
Debug.Log.Info(ff.Dataset.Dump()); | |
// get study instance uid | |
string studyuid = ff.Dataset.GetString(DicomTags.StudyInstanceUID, null); | |
// print studyuid to log | |
Debug.Log.Info("Study UID: {0}", studyuid); | |
// set patient id | |
ff.Dataset.SetString(DicomTags.PatientID, "12345"); | |
// lossless compress image | |
ff.ChangeTransferSytnax(DicomTransferSyntax.JPEGProcess14SV1, null); | |
// save DICOM file | |
ff.Save(@"out.dcm", DicomWriteOptions.Default); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment