org.dcm4che2.imageioimpl.plugins.dcm
Class DicomImageReader

java.lang.Object
  extended by javax.imageio.ImageReader
      extended by org.dcm4che2.imageioimpl.plugins.dcm.DicomImageReader

public class DicomImageReader
extends javax.imageio.ImageReader

Since:
Sep 2, 2006
Version:
$Revision$ $Date$
Author:
Gunter Zeilinger

Field Summary
protected  boolean compressed
           
protected  javax.imageio.ImageReader reader
           
protected  java.lang.String tsuid
          Store the transfer syntax locally in case it gets modified to re-write the image
 
Fields inherited from class javax.imageio.ImageReader
availableLocales, ignoreMetadata, input, locale, minIndex, originatingProvider, progressListeners, seekForwardOnly, updateListeners, warningListeners, warningLocales
 
Constructor Summary
protected DicomImageReader(javax.imageio.spi.ImageReaderSpi originatingProvider)
           
 
Method Summary
 boolean canReadRaster()
           
protected  void copyReadParam(javax.imageio.ImageReadParam src, javax.imageio.ImageReadParam dst)
           
protected  javax.imageio.ImageTypeSpecifier createImageTypeSpecifier()
          Create an image type specifier for the entire image
static java.awt.image.BufferedImage createRGBBufferedImage(int destWidth, int destHeight)
          Creates a BufferedImage with a custom color model that can be used to store 3 channel RGB data in a byte array data buffer
 void dispose()
           
 java.lang.Float getAutoWindowCenter()
          Exposes the window center value that was determined during the last read(int, ImageReadParam) call.
 java.lang.Float getAutoWindowWidth()
          Exposes the window width value that was determined during the last read(int, ImageReadParam) call.
 javax.imageio.ImageReadParam getDefaultReadParam()
           
 int getHeight(int imageIndex)
           
 javax.imageio.metadata.IIOMetadata getImageMetadata(int imageIndex)
          Gets any image specific meta data.
 java.util.Iterator<javax.imageio.ImageTypeSpecifier> getImageTypes(int imageIndex)
           
 int getNumImages(boolean allowSearch)
          Returns the number of regular images in the study.
 javax.imageio.metadata.IIOMetadata getStreamMetadata()
          Return a DicomStreamMetaData object that includes the DICOM header.
 int getWidth(int imageIndex)
           
protected  void initImageReader(int imageIndex)
          Sets the input for the image reader.
protected  void postDecompress()
           
 java.awt.image.BufferedImage read(int imageIndex, javax.imageio.ImageReadParam param)
          Reads the provided image as a buffered image.
 byte[] readBytes(int imageIndex, javax.imageio.ImageReadParam param)
          Reads the bytes for the given image as raw data.
 java.awt.image.Raster readRaster(int imageIndex, javax.imageio.ImageReadParam param)
          Read the raw raster data from the image, without any LUTs being applied.
 void reset()
           
 void setInput(java.lang.Object input, boolean seekForwardOnly, boolean ignoreMetadata)
           
static java.awt.image.BufferedImage subsampleRGB(java.awt.image.BufferedImage src, java.awt.Rectangle sourceRegion, int subSampleX, int subSampleY)
          Sub-samples RGB buffered images when the reader doesn't support it.
 
Methods inherited from class javax.imageio.ImageReader
abort, abortRequested, addIIOReadProgressListener, addIIOReadUpdateListener, addIIOReadWarningListener, checkReadParamBandSettings, clearAbortRequest, computeRegions, getAspectRatio, getAvailableLocales, getDestination, getFormatName, getImageMetadata, getInput, getLocale, getMinIndex, getNumThumbnails, getOriginatingProvider, getRawImageType, getSourceRegion, getStreamMetadata, getThumbnailHeight, getThumbnailWidth, getTileGridXOffset, getTileGridYOffset, getTileHeight, getTileWidth, hasThumbnails, isIgnoringMetadata, isImageTiled, isRandomAccessEasy, isSeekForwardOnly, processImageComplete, processImageProgress, processImageStarted, processImageUpdate, processPassComplete, processPassStarted, processReadAborted, processSequenceComplete, processSequenceStarted, processThumbnailComplete, processThumbnailPassComplete, processThumbnailPassStarted, processThumbnailProgress, processThumbnailStarted, processThumbnailUpdate, processWarningOccurred, processWarningOccurred, read, readAll, readAll, readAsRenderedImage, readerSupportsThumbnails, readThumbnail, readTile, readTileRaster, removeAllIIOReadProgressListeners, removeAllIIOReadUpdateListeners, removeAllIIOReadWarningListeners, removeIIOReadProgressListener, removeIIOReadUpdateListener, removeIIOReadWarningListener, setInput, setInput, setLocale
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

compressed

protected boolean compressed

reader

protected javax.imageio.ImageReader reader

tsuid

protected java.lang.String tsuid
Store the transfer syntax locally in case it gets modified to re-write the image

Constructor Detail

DicomImageReader

protected DicomImageReader(javax.imageio.spi.ImageReaderSpi originatingProvider)
Method Detail

setInput

public void setInput(java.lang.Object input,
                     boolean seekForwardOnly,
                     boolean ignoreMetadata)
Overrides:
setInput in class javax.imageio.ImageReader

dispose

public void dispose()
Overrides:
dispose in class javax.imageio.ImageReader

reset

public void reset()
Overrides:
reset in class javax.imageio.ImageReader

getDefaultReadParam

public javax.imageio.ImageReadParam getDefaultReadParam()
Overrides:
getDefaultReadParam in class javax.imageio.ImageReader

getStreamMetadata

public javax.imageio.metadata.IIOMetadata getStreamMetadata()
                                                     throws java.io.IOException
Return a DicomStreamMetaData object that includes the DICOM header. WARNING: If this class is used to read directly from a cache or other location that contains uncorrected data, the DICOM header will have the uncorrected data as well. That is, assume the DB has some fixes to patient demographics. These will not usually be applied to the DICOM files directly, so you can get the wrong information from the header. This is not an issue if you know the DICOM is up to date, or if you use the DB information as authoritative.

Specified by:
getStreamMetadata in class javax.imageio.ImageReader
Throws:
java.io.IOException

getImageMetadata

public javax.imageio.metadata.IIOMetadata getImageMetadata(int imageIndex)
                                                    throws java.io.IOException
Gets any image specific meta data. This should return the image specific blocks for enhanced multi-frame, but currently it merely returns null.

Specified by:
getImageMetadata in class javax.imageio.ImageReader
Throws:
java.io.IOException

getNumImages

public int getNumImages(boolean allowSearch)
                 throws java.io.IOException
Returns the number of regular images in the study. This excludes overlays.

Specified by:
getNumImages in class javax.imageio.ImageReader
Throws:
java.io.IOException

initImageReader

protected void initImageReader(int imageIndex)
                        throws java.io.IOException
Sets the input for the image reader.

Parameters:
imageIndex - The Dicom frame index, or overlay number
Throws:
java.io.IOException

createImageTypeSpecifier

protected javax.imageio.ImageTypeSpecifier createImageTypeSpecifier()
Create an image type specifier for the entire image


getHeight

public int getHeight(int imageIndex)
              throws java.io.IOException
Specified by:
getHeight in class javax.imageio.ImageReader
Throws:
java.io.IOException

getWidth

public int getWidth(int imageIndex)
             throws java.io.IOException
Specified by:
getWidth in class javax.imageio.ImageReader
Throws:
java.io.IOException

getAutoWindowCenter

public java.lang.Float getAutoWindowCenter()
Exposes the window center value that was determined during the last read(int, ImageReadParam) call.

Returns:
the window center value, or null if auto windowing was not applied.

getAutoWindowWidth

public java.lang.Float getAutoWindowWidth()
Exposes the window width value that was determined during the last read(int, ImageReadParam) call.

Returns:
the window width value, or null if auto windowing was not applied.

getImageTypes

public java.util.Iterator<javax.imageio.ImageTypeSpecifier> getImageTypes(int imageIndex)
                                                                   throws java.io.IOException
Specified by:
getImageTypes in class javax.imageio.ImageReader
Throws:
java.io.IOException

canReadRaster

public boolean canReadRaster()
Overrides:
canReadRaster in class javax.imageio.ImageReader

readRaster

public java.awt.image.Raster readRaster(int imageIndex,
                                        javax.imageio.ImageReadParam param)
                                 throws java.io.IOException
Read the raw raster data from the image, without any LUTs being applied. Cannot read overlay data, as it isn't clear what the raster format should be for those.

Overrides:
readRaster in class javax.imageio.ImageReader
Throws:
java.io.IOException

read

public java.awt.image.BufferedImage read(int imageIndex,
                                         javax.imageio.ImageReadParam param)
                                  throws java.io.IOException
Reads the provided image as a buffered image. It is possible to read image overlays by providing the 0x60000000 number associated with the overlay. Otherwise, the imageIndex must be in the range 0..numberOfFrames-1, or 0 for a single frame image. Overlays can be read from PR objects or other types of objects in addition to image objects. param can be used to sepecify GSPS to apply to the image, or to override the default window level values, or to return the raw image.

Specified by:
read in class javax.imageio.ImageReader
Throws:
java.io.IOException

subsampleRGB

public static java.awt.image.BufferedImage subsampleRGB(java.awt.image.BufferedImage src,
                                                        java.awt.Rectangle sourceRegion,
                                                        int subSampleX,
                                                        int subSampleY)
Sub-samples RGB buffered images when the reader doesn't support it.


createRGBBufferedImage

public static java.awt.image.BufferedImage createRGBBufferedImage(int destWidth,
                                                                  int destHeight)
Creates a BufferedImage with a custom color model that can be used to store 3 channel RGB data in a byte array data buffer


readBytes

public byte[] readBytes(int imageIndex,
                        javax.imageio.ImageReadParam param)
                 throws java.io.IOException
Reads the bytes for the given image as raw data. Useful when copying the image data unchanged to a new file/location etc, but some values are being changed in the header, or some images are being excluded.

Throws:
java.io.IOException

copyReadParam

protected void copyReadParam(javax.imageio.ImageReadParam src,
                             javax.imageio.ImageReadParam dst)

postDecompress

protected void postDecompress()


Copyright © 2011 dcm4che. All Rights Reserved.