Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Developing DICOM Viewers for Real World Applications

7 Jan 2013 1  
LEADTOOLS Medical Imaging SDKs alleviate this issue by leveraging more than 20 years of imaging development experience and offer a high-level, programmer friendly and feature packed DICOM Viewer Control.

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.

Introduction

Medical Imaging applications involving the display of DICOM images are more complicated than what first meets the eye. Of course, there are countless ways to simply display images, but your clients in the healthcare profession expect and demand certain specifications and features from the application you develop for them, especially as it pertains to viewing DICOM images.

LEADTOOLS Medical Imaging SDKs alleviate this issue by leveraging more than 20 years of imaging development experience and offer a high-level, programmer friendly and feature packed DICOM Viewer Control. LEAD Technologies has worked with countless clients and has incorporated all of the industry-standard features as well as many advanced features most third-party SDKs do not offer. In addition to the peace of mind afforded by its comprehensive set of features tested and proven in real world applications, its ease-of-use will save you bundles of time and money in the development process.

Key DICOM Viewer Features in LEADTOOLS SDKs

  • Fully customizable Cell and Subcell layout
  • Automated image synchronization for viewing multiple series
  • Display overlay information on the images
  • Supports patient orientation, localization, MPR and reference lines
  • Built-in tools for:
    • Measurement (ruler, snap ruler, protractor, statistics, probe)
    • Image Display (window level, zoom, pan, magnifying glass, spatial locator, user spy glass)
    • Image Alpha (Sigmoid, Exponential, Logarithmic)
    • Annotations (text, arrow, rectangle, ellipse, cobb angle, custom, etc.)
    • Region of interest (magic wand, nudge, shrink, etc.)
  • Specialized diagnostic evaluation tools such as PET-CT fusion
  • Integrates directly with LEADTOOLS Medical 3D SDK Technology
  • Options for low-memory usage when viewing large studies
  • Built-in ruler that adjusts based on the DPI of the image and the zoom, scale factor and custom calibration settings
  • Low level programmatic access for customization and event handling

SDK Products that Include DICOM Viewer Technology

The DICOM Viewer Code

There are standard features that every DICOM image viewer should have such as window level, scroll, zoom, multiple frame layouts, etc. The LEADTOOLS MedicalViewer control sets itself apart by making these common features incredibly easy to use and implement. It includes many overloaded functions, giving you as much or little control over the process as you would like. In the example below, we specify a filename, a boolean telling it to fit the image to the cell, and the number of rows and columns to display the subcells for multi-frame images.

// Create cell, set options and add image
MedicalViewerMultiCell cell = new MedicalViewerMultiCell(
   _codecs.Load(strFile),
   true,
   nRows,
   nCols);

// Add the cell to the viewer
_medicalViewer.Cells.Add(cell);

Radiologists and healthcare professionals require many tools for collaborating with each other and reaching their diagnosis. Window level, stack, zoom, annotations and more are all basic requirements which involve a heavy amount of event handling, image processing, and image display manipulation. To use these features in LEADTOOLS, you only need two functions: AddAction and SetAction. The first, AddAction, tells the viewer cell which actions are available for use. Then SetAction assigns one of the added actions to a mouse event and will be called any time the user desires to switch tools.

// Add the actions we want to make available to the user
cell.AddAction(MedicalViewerActionType.WindowLevel);
cell.AddAction(MedicalViewerActionType.Scale);
cell.AddAction(MedicalViewerActionType.Offset);
cell.AddAction(MedicalViewerActionType.Stack);
cell.AddAction(MedicalViewerActionType.AnnotationLine);
cell.AddAction(MedicalViewerActionType.AnnotationRectangle);
cell.AddAction(MedicalViewerActionType.AnnotationEllipse);
cell.AddAction(MedicalViewerActionType.AnnotationText);

// Assign some actions added actions to a mouse button
cell.SetAction(MedicalViewerActionType.WindowLevel,
   MedicalViewerMouseButtons.Left, MedicalViewerActionFlags.Active);
cell.SetAction(MedicalViewerActionType.Offset,
   MedicalViewerMouseButtons.Right, MedicalViewerActionFlags.Active);
cell.SetAction(MedicalViewerActionType.Scale,
   MedicalViewerMouseButtons.Middle, MedicalViewerActionFlags.Active);
cell.SetAction(MedicalViewerActionType.Stack,
   MedicalViewerMouseButtons.Wheel, MedicalViewerActionFlags.Active);

Finally, nearly every DICOM viewer application utilizes some form of metadata overlay. Once again, LEADTOOLS is as programmer-friendly as it could get with using a single function, SetTag, to add metadata tags to any cell or subcell. This encompasses both static tags dynamic tags that change with the viewer actions such as window level, zoom scale and frame number.

// Add some tags to show some information and metadata
cell.SetTag(4, MedicalViewerTagAlignment.TopLeft,
   MedicalViewerTagType.Frame);
cell.SetTag(6, MedicalViewerTagAlignment.TopLeft,
   MedicalViewerTagType.Scale);
cell.SetTag(2, MedicalViewerTagAlignment.BottomLeft,
   MedicalViewerTagType.WindowLevelData);
cell.SetTag(1, MedicalViewerTagAlignment.BottomLeft,
   MedicalViewerTagType.FieldOfView);

Some of the most important metadata comes from the vast amount of information within the DICOM Data Set itself. LEADTOOLS is an indispensible tool for extracting that information and putting it to meaningful use. Below, we use the DicomDataSet object to get the patient’s name and image orientation information.

// Get some information from the DICOM Data Set and 
DicomDataSet ds = new DicomDataSet();
ds.Load(strFile, DicomDataSetLoadFlags.LoadAndClose);

// Get the patients name
string strPatientName =
   ds.GetValue<string>(DicomTag.PatientName, string.Empty);
cell.SetTag(1, MedicalViewerTagAlignment.TopRight,
   MedicalViewerTagType.UserData, strPatientName);

// Get the patient's image orientation
// There might be some other tags depending on the modality but
// this is all that's needed for these example images
DicomElement element = ds.FindFirstElement(null,
   DicomTag.ImageOrientationPatient, true);
if (element != null && element.Length > 0)
{
   double[] doubleArray; doubleArray = ds.GetDoubleValue(element,
      0, 6);
   cell.ImageOrientation = new float[] { 
      (float)doubleArray[0], 
      (float)doubleArray[1], 
      (float)doubleArray[2], 
      (float)doubleArray[3], 
      (float)doubleArray[4], 
      (float)doubleArray[5] };

   // Now we set the orientation values with the orientation tags
   cell.SetTag(0, MedicalViewerTagAlignment.TopCenter,
      MedicalViewerTagType.TopOrientation);
   cell.SetTag(0, MedicalViewerTagAlignment.BottomCenter,
      MedicalViewerTagType.BottomOrientation);
   cell.SetTag(0, MedicalViewerTagAlignment.LeftCenter, 
      MedicalViewerTagType.LeftOrientation);
   cell.SetTag(0, MedicalViewerTagAlignment.RightCenter,
      MedicalViewerTagType.RightOrientation);
}

There you have it. In only about 50 lines of code, you can add a fully functional, feature-packed DICOM Viewer to your application that any healthcare professional would be happy to use.

Fusion: An Advanced Example

The LEADTOOLS DICOM Viewer doesn’t stop with the basics. There are many advanced features that would require a hefty amount of customization and low-level programming with other medical imaging SDKs. Due to LEAD Technologies’ extensive research and industry experience in knowing what medical professionals desire, LEADTOOLS makes it possible to add these features with only a few lines of code.

One such technology is Fusion. This is most commonly used with PET and CT images, but DICOM images from any modality can be used. In the example below, we show how to implement a basic fusion using CT and MR.

// Add two cells to the viewer
AddCell(_strMRImage, 1, 1);
AddCell(_strCTImage, 1, 1);

// Get the cell on the right
MedicalViewerMultiCell cell =
   (MedicalViewerMultiCell)_medicalViewer.Cells[1];

// Create a new fusion object, this object will hold the image
// that will be fused with the original image
MedicalViewerFusion fusion = new MedicalViewerFusion();

// Set some properties to control how the fusion will work
fusion.FusedImage = _codecs.Load(_strMRImage);
fusion.FusionScale = 0.5f;
fusion.ColorPalette = MedicalViewerPaletteType.RedHot;
cell.SubCells[0].Fusion.Add(fusion);

// adjust some tags for the cell
cell.SetTag(0, 1, MedicalViewerTagAlignment.BottomRight,
   MedicalViewerTagType.UserData, "FUSION EX. ID 230-36-5448");

Conclusion

LEADTOOLS provides developers with access to the world’s best performing and most stable imaging libraries in an easy-to-use, high-level programming interface enabling rapid development of business-critical applications.

The DICOM Viewer is only one of the many technologies LEADTOOLS has to offer. For more information on our other products, be sure to visit our home page, download a free fully functioning evaluation SDK, and take advantage of our free technical support during your evaluation.

Download the Full DICOM Viewer Example

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

Support

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 (sales@leadtools.com) or call us at 704-332-5532.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here