org.dcm4che2.image
Class OverlayUtils

java.lang.Object
  extended by org.dcm4che2.image.OverlayUtils

public class OverlayUtils
extends java.lang.Object

Provides utility methods to extract overlay information from DICOM files.

Author:
bwallace

Constructor Summary
OverlayUtils()
           
 
Method Summary
static int extractFrameNumber(int imageIndex)
          Extra the frame number portion of the overlay number/imageIndex value.
static java.awt.image.BufferedImage extractOverlay(DicomObject ds, int overlayNumber, javax.imageio.ImageReader reader, java.lang.String rgbs)
          Read an overlay image or region instead of a regular image.
static int getOverlayHeight(DicomObject ds, int overlayNumber)
          Reads the height of the overlay - needs to be done separately from the primary width even though they are supposed to be identical, as a stand alone overlay won't have any width/height except in the overlay tags.
static int getOverlayWidth(DicomObject ds, int overlayNumber)
          Reads the width of the overlay - needs to be done separately from the primary width even though they are supposed to be identical, as a stand alone overlay won't have any width/height except in the overlay tags.
static boolean isOverlay(int imageIndex)
          Returns true if the given frame number references an overlay - that is, is the form 0x60xx yyyy where xx is the overlay number, and yyyy is the overlay frame number.
protected static byte[] padToFixRowByteBoundary(byte[] unpaddedData, int rows, int cols)
          This method is used for soon-to-be-rasterized bit arrays that are contained within byte arrays (e.g.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OverlayUtils

public OverlayUtils()
Method Detail

isOverlay

public static boolean isOverlay(int imageIndex)
Returns true if the given frame number references an overlay - that is, is the form 0x60xx yyyy where xx is the overlay number, and yyyy is the overlay frame number. xx must be even.

Parameters:
imageIndex -
Returns:
true if this is an overlay frame.

extractFrameNumber

public static int extractFrameNumber(int imageIndex)
Extra the frame number portion of the overlay number/imageIndex value.

Parameters:
imageIndex -
Returns:

extractOverlay

public static java.awt.image.BufferedImage extractOverlay(DicomObject ds,
                                                          int overlayNumber,
                                                          javax.imageio.ImageReader reader,
                                                          java.lang.String rgbs)
                                                   throws java.io.IOException
Read an overlay image or region instead of a regular image. Specify the overlayNumber by the 0x60xx 0000 number. This will return a bitmap overlay, in the colour specified. The image reader isn't required unless overlays encoded in the high bits are being read.

Parameters:
ds - is a DicomObject to read the overlay from.
overlayNumber - - of the form 0x60xx yyyy where xx is the overlay index and yyyy is the frame index
reader - is the image reader used to extract the raster for the high bits
rgb - is the colour to apply, can be null to use black & white overlays.
Returns:
A single bit buffered image, transparent except in the given colour where bits are 1.
Throws:
java.io.IOException - only if an image from the image reader is attempted and throws an exception.

padToFixRowByteBoundary

protected static byte[] padToFixRowByteBoundary(byte[] unpaddedData,
                                                int rows,
                                                int cols)
This method is used for soon-to-be-rasterized bit arrays that are contained within byte arrays (e.g. certain overlays). This method accepts a byte array (containing the bit array) and fixes the byte array so that the beginnings of rows in the bit array coincide with byte-boundaries. This method pads (with 0's) and logically forward bit shifts across byte boundaries as necessary to accomplish this fix.

Parameters:
unpaddedData - The byte array containing the bit array to be padded as necessary
rows - The height of the image in pixels
cols - The width of the image in pixels
Returns:
The byte array fixed to have bit-level row beginnings coincide with byte array boundaries

getOverlayWidth

public static int getOverlayWidth(DicomObject ds,
                                  int overlayNumber)
Reads the width of the overlay - needs to be done separately from the primary width even though they are supposed to be identical, as a stand alone overlay won't have any width/height except in the overlay tags.

Parameters:
overlayNumber -
Returns:
The width in pixels of the given overlay.
Throws:
java.io.IOException

getOverlayHeight

public static int getOverlayHeight(DicomObject ds,
                                   int overlayNumber)
Reads the height of the overlay - needs to be done separately from the primary width even though they are supposed to be identical, as a stand alone overlay won't have any width/height except in the overlay tags.

Parameters:
overlayNumber -
Returns:


Copyright © 2011 dcm4che. All Rights Reserved.