Click here to Skip to main content
15,743,609 members
Articles / Web Development / HTML5
Posted 2 Sep 2014


4 bookmarked

DICOM Images and Metadata with LEADTOOLS

2 Sep 2014CPOL4 min read
LEADTOOLS includes comprehensive support for DICOM in each of its programming interfaces including .NET (used in the examples below), CDLL, C++ Class Library, HTML5 / JavaScript, WinRT, iOS, Android and more.

This article is in the Product Showcase section for our sponsors at CodeProject. These articles are intended to provide you with information on products and services that we consider useful and of value to developers.


Digital healthcare is a booming industry all over the world and the benefits of electronically stored medical records and images are being recognized and adopted at an increasing rate every day. Its importance has even reached the level to which governments are handing out large sums of money to invest in and encourage the development of this infrastructure. One of the most important building blocks of digital healthcare is the DICOM standard that deals with images.

Though DICOM is a complex standard with a huge specification, much of its complexity derives from defining the various flavors for different medical specialties and laying down rules for using and sharing the image and image-related reports in a global, digital healthcare network in an interoperable way. This white paper will show how to use the LEADTOOLS DICOM SDK to break through these complexities with its programmer-friendly and powerful toolkit.


LEADTOOLS includes comprehensive support for DICOM in each of its programming interfaces including .NET (used in the examples below), CDLL, C++ Class Library, HTML5 / JavaScript, WinRT, iOS, Android and more. LEADTOOLS helps you follow all of the many rules of the DICOM standard and abstracts DICOM data sets to a simple, understandable collection of tags and images.

Working with DICOM Metadata (Tags)

Everything in a DICOM file is stored in a tag (or element). The majority of these tags store metadata relating to the patient, his or her medical procedure, and the imaging device and its settings. For example, when a patient comes in for an X-ray, the DICOM data set will store the patient's name, birth date, gender, etc. In addition, there will be procedure-related information such as the date, time, physician's name, modality and more. Using the LEADTOOLS DicomDataSet class, it is easy to find the desired DicomElement and retrieve its value.

using (DicomDataSet ds = new DicomDataSet())
   ds.Load(strDicomFileName, DicomDataSetLoadFlags.None);
   DicomElement element = ds.FindFirstElement(null, DicomTag.PatientName, false);
   if (element != null)
      strPatientName = ds.GetStringValue(element, 0);

If this same patient has another procedure later on, such as an MRI, a new DICOM data set will be created with the same patient information but with different procedure metadata. When a physician looks up this patient in their database or PACS (Picture Archiving and Communication System) all of the studies for this patient will be tied together in a neat, hierarchical manner.

LEADTOOLS also includes a high-level DICOM Editor control with tooltips, selection list and data validation. It greatly simplifies code associated with displaying and accepting user input for the detailed information stored in a DICOM data set. The DICOM Editor control also offers visual cues regarding the tag requirements to aid the user in creating valid DICOM data sets.

Image 1

Working with DICOM Images

The other primary aspect of DICOM is storing digital medical images. A DICOM data set can store one or more images within its PixelData element. In a similar fashion to retrieving any other metadata, the image is decoded by first finding the PixelData element and then decoding that element into an image with the GetImage function. GetImage has several overloads and provides options for common operations such as applying the Modality LUT and VOI LUT transformation for proper display.

using (DicomDataSet ds = new DicomDataSet())
   ds.Load(strDicomFileName, DicomDataSetLoadFlags.None);
   DicomElement element = ds.FindFirstElement(null, DicomTag.PixelData, true);
   if (element != null)
      RasterImage image = ds.GetImage(element, 0, 0, RasterByteOrder.Gray,
         DicomGetImageFlags.AutoApplyModalityLut | DicomGetImageFlags.AutoApplyVoiLut);
      _medicalViewer.Cells.Add(new MedicalViewerCell(image));

The LEADTOOLS Medical Image Viewer, or Display Container, is a specialized viewing control with many built-in tools for radiologists and physicians such as window level, annotations, region processing, metadata display and more. More importantly, an image series (represented by either a multi-page image or multiple single-image files) can be stacked, laid out in a grid, played as cine animation, and so on. This is an essential feature and design for any modality that generates image slices such as an MRI or CT. The majority of these features can be set and modified with only a single line of code.

The Medical Viewer control is made available to programmers in several interfaces and high-level abstractions that will cater to a broad variety of developers. To get a head start, consider using one of LEADTOOLS' OEM-ready sample applications for HTML5 / JavaScript, IE Rich Clients and the Medical Workstation Framework which use the Medical Viewer control and incorporate a fully-featured user interface, database and PACS integration. On top of that, the source code for these applications is provided for easy customization and branding, meaning you can develop a fully operational DICOM viewing application in minimal time.

Image 2


LEADTOOLS Medical Imaging SDKs take the complex world of DICOM and present developers with an easy to use and understand programming interface for a variety of platforms and languages. In addition to handling loading, saving, editing DICOM metadata and displaying DICOM images, LEADTOOLS includes support for all of your medical imaging needs including DICOM Communication, PACS, Zero-footprint HTML5 Web Viewing and more.

Download the Full DICOM Images and Metadata Example

You can download the fully functional demo which includes the features discussed above. To run this example you will need the following:

  • LEADTOOLS free 60 day evaluation
  • Visual Studio 2008 or later
  • Browse to the LEADTOOLS Examples folder (e.g. C:\LEADTOOLS 18\Examples\) where you can find example projects for this and many more technologies in LEADTOOLS


Need help getting this sample up and going? Contact our support team for free technical support! For pricing or licensing questions, you can contact our sales team ( or call us at 704-332-5532.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Written By
Help desk / Support LEAD Technologies, Inc.
United States United States
Since 1990, LEAD has established itself as the world's leading provider of software development toolkits for document, medical, multimedia, raster and vector imaging. LEAD's flagship product, LEADTOOLS, holds the top position in every major country throughout the world and boasts a healthy, diverse customer base and strong list of corporate partners including some of the largest and most influential organizations from around the globe. For more information, contact or
This is a Organisation (No members)

Comments and Discussions

QuestionPixelData Pin
Ian A Davidson10-Dec-20 3:58
Ian A Davidson10-Dec-20 3:58 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.