Pankaj
Pankaj

Reputation: 53

how to use opendicom.net library for dicom processing

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

Upvotes: 3

Views: 4580

Answers (3)

user1602496
user1602496

Reputation: 31

Here are the files that you are requesting for.

dataElementDictionary.LoadFrom("**dicom-elements-2004.dic**",
         DictionaryFileFormat.BinaryFile);
        uidDictionary.LoadFrom("**dicom-uids-2004.dic**",
        DictionaryFileFormat.BinaryFile); 

It is there in the below specified path in the location DicomTagSeeker-source.zip\DicomTagSeeker\bin\Debug\libraries\dictionary

Dicom Tag Seeker

Upvotes: -1

ZSH
ZSH

Reputation: 913

i know this is an old question but i came across this and opened a file using openDicom.NEt just now

 var columns = df.PixelData.Columns;
 var rows = df.PixelData.Rows;
 int displayStride = ((int)columns * PixelFormats.Gray16.BitsPerPixel + 7) / 8; //truncating
 var fromArr = df.PixelData.ToBytesArray()[0];

 theImage.Source = BitmapSource.Create((int)columns, (int)rows, 96, 96,
                   PixelFormats.Gray16, null, fromArr, displayStride);

Upvotes: 0

Anders Gustafsson
Anders Gustafsson

Reputation: 15971

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.

Upvotes: 3

Related Questions