Is there anyone who have used opendicom.net library for dicom image parsing. In sample code it refers below lines:
DataElementDictionary dataElementDictionary = new DataElementDictionary();
UidDictionary uidDictionary = new UidDictionary();
try
{
dataElementDictionary.LoadFrom("**dicom-elements-2004.dic**",
DictionaryFileFormat.BinaryFile);
uidDictionary.LoadFrom("**dicom-uids-2004.dic**",
DictionaryFileFormat.BinaryFile);
}
catch (Exception dictionaryException)
{
//Console.Error.WriteLine ("Problems processing dictionaries:\n" +
// dictionaryException);
return;
}
Where I can get the files dicom-elements-2004.dic and dicom-uids-2004.dic? I didn't get these on the website. Please help
openDICOM.NET is a very simple library for DICOM file processing. The library itself is designed to be relatively platform-agnostic, i.e. it should be possible to build using the .NET Framework as well as Mono in various operating systems. However, out-of-the-box it is not possible to build as a WinRT/Metro library, so unless you have made substantial refactoring I assume that you have compiled the library as a regular C# class library, .NET Framework 4.5?
Assuming that you are really developing a Windows WPF or Forms application, and assuming that you have managed to read a DICOM data set using openDICOM.NET, you should then be able to construct a PixelData object:
var pixelData = new PixelData(dataset);
From the PixelData object you can access the pixel data as arrays of bytes:
byte[][] byteArray = pixelData.ToBytesArray();
You then need to transform the byte two-dimensional array into a one-dimensional array that can be used to construct a bitmap image, by using the following properties of the PixelData object:
Rows
Columns
BitsAllocated
(BitsStored)
In a WPF application you should be able to create a WriteableBitmap object, and in Windows Forms a Bitmap object.
However, openDICOM.NET has not been maintained for many years, and I would strongly recommend that you use a different, more up-to-date library as the basis for your DICOM processing. For example, please have a look at the light-weight library Evil DICOM. Here you have ready-made methods for creating a (Windows Forms) Bitmap, simply create a DICOM image object using the file name and immediately access the corresponding bitmap image:
var imageMtx = new EvilDicom.Image.ImageMatrix(name_of_dicom_file);
var dicomImage = imageMtx.GetImage(slice_numeber);
Evil DICOM currently only works for Windows Forms, but it is probably a relatively small effort to refactor the required classes to use WPF instead.
Other open-source class libraries worth exploring are mdcm and the more recent fo-dicom, both developed by Colby Dillion. At least mdcm provides full WPF support.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With