Adjusting WindowWidth And Level using ExplicitVOILUT property
.NET version Demo code to show the usage of the DicomImage property (ExplicitVOILUT) by generating and applying a LookupTable that has been calculated based on the standard DICOM windowing formula for calculating a Lookup table.
This example code assumes min and max as the range of values you need to handle in input data (anything beyond that is mapped to the first/last value) and for screen display it defaults to 8 bit output.
Calculate windowing width and level from Image pixel data
Calculating windowing width and level from Image pixel data can be done via accessing the raw pixel data and applying your own algorithm or via the DicomObjects method SetDefaultWindows of the DicomImage object. The problem with this, however, is that there will be no correct values as the best values depend on which area of the image contains the anatomical region the user is interested in looking at (which is why viewer applications always have the tools to change them).
This article explains how to get the fastest performance for cine images such as cardiac angiograms
For multi-frame images, DicomObjects has several mechanisms to make best use of the facilities available in any PC, but fast display of cine images is a challenging task, and the optimum method will differ from one PC to another depending on the amount of RAM, the speed of the disk, the type of display card, and the nature, compression and size of the images themselves.
For plain radiographs (conventional x-rays), the size recorded on the film is always larger than the size of the object being imaged, due to an effect called geometric magnification. Moreover, as shown in the diagram below, the amount of magnification varies for different objects, depending on their distance from the film, so it is NOT in general possible to “correct” for such magnification without knowing the distance of the object from the film.
How DicomObjects handles Width and Level values
The Width and Level properties of an image are unusual, in that they are both stored as a part of the image, and are also transient DicomImage properties, regularly adjusted by users. This page explains the relationship between the persistent and transient values.
How to Invert a DicomImage
By “invert”, most people mean change black to white and visa versa, and this can be done by a simple line of code.
How to implement a Magnifying Glass in DicomObjects
It is possible to implement a magnifying glass tool in DicomObjects.NET.This functionality can be achieved by using a second DicomImage which is a copy of the original image (scaled, zoomed and scrolled accordingly) and overlaying onto the original image. Because the new image is a “Clone” of the original, it shares the same underlying DataSet, and it therefore uses negligible memory and takes a tiny amount of time to create.
How to show Grid in DicomViewer
Perhaps we might have done this internally and make a new DicomViewer ‘ShowGrid’ property. But that way the end users may lose some flexibilities in setting the grid style (width, color etc.etc.). For now if you would like to show the rows/columns grid before loading up any image, you can do so using the following VB code (or translate it into something else that you are using) : DicomObjects.
Implement Centered Zoom in DicomObjects.NET
Implementing the Centered Zoom function in DicomObjects is simple and easy.
Initialising an image to the viewer size (stretch and scroll)
It is often useful to zoom and scroll an image to fill the viewer on first load. The quick way of doing this is by using StretchMode method i.e.
DicomObjects.NET GetSelectedImage().StretchMode = DicomObjects.Enums.StretchModes.StretchCentred; However if StretchMode is used it doesn’t allow the image to be scrolled or zoomed. To overcome this problem it is possible to save the scroll and zoom values used by the StretchMode , then remove the StretchMode and apply them to the image.
The LabelType “Formatted” in .NET version of DicomObjects provides a very useful way to access the value of any DicomImage property. For property which has a shortcut name, you can just put the name of the property within a pair of square brackets. You can also specify the “Group” and “Element” of any particular attribute. The code shows how to use the formatted label.
We have to admit the term “Bitmap” is a bit confusing for most people. It is actually a DICOM term for “map of bits”, not the common Bitmap graph. What you have for label type Bitmap is a collection of dots, positions of which are specified in the Points property of that label object:
Say you want to create the following logo at the top left hand corner of the viewer using bitmap(/img/kb/DoBitMap2.
Making a copy of the image as displayed
DicomObjects.NET In order to use PrinterImage to make a complete copy of the image as displayed in the viewer, it is necessary to:
Use the latest version of DicomObjects Calculate the size of the area being displayed Find the actual zoom of the image as currently displayed Scale the current size up to the equivalent in image units (divide by zoom) Likewise scale the image’s Offset to create correct position for the image in the new rectangle Call PrinterImage Note that the zoom used int he final PrinterImage call does not need to be the same as used above, and a higher quality output can be obtained by setting it to 1 (or higher to allow DicomObjects to do any interpolation), but that you may wish to modify the font size of any labels to compensate.