Class DicomDecoder

java.lang.Object
com.idrsolutions.image.JDeliImage
com.idrsolutions.image.dicom.DicomDecoder
All Implemented Interfaces:
com.idrsolutions.image.Decoder

public class DicomDecoder extends com.idrsolutions.image.JDeliImage implements com.idrsolutions.image.Decoder
Class reads DICOM images as BufferedImage // Make NO assumptions about the BufferedImage type returned as this may change

Example 1 (Using raw byte data):


 DicomDecoder decoder = new DicomDecoder();
 BufferedImage decodedImage = decoder.read(dicomBytes);
 

Example 2 (Using a File):


 File dicomFile = new File("C:\\path\\to\\file\\image.dcm");
 DicomDecoder decoder = new DicomDecoder();
 BufferedImage decodedImage = decoder.read(dicomFile);
 

Example 3 (multi-page Dicom)


 DicomDecoder decoder = new DicomDecoder();
 final int imageCount = decoder.getImageCount(file);
 for (int i = 0; i< imageCount; i++) {
      BufferedImage decodedImage = decoder.readImageAt(i, file);
      // Insert BufferedImage handling code here
 }
 
  • Field Summary

    Fields inherited from class com.idrsolutions.image.JDeliImage

    bb
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    getFrameCount(byte[] dicomData)
    Returns the number of frames in the DICOM data.
    int
    getFrameCount(File dicomFile)
    Returns the number of frames in the DICOM data.
    int
    getImageCount(byte[] dicomData)
    Returns the number of frames in the DICOM data.
    int
    getImageCount(File dicomFile)
    Returns the number of frames in the DICOM data.
    read(byte[] dicomData)
    Make NO assumptions about type of BufferedImage type returned as this may change
    read(int frameNumber, byte[] dicomData)
    Please Note: frameNumber should start from 1
    read(int frameNumber, File dicomFile)
    Please Note: frameNumber should start from 1
    read(File dicomFile)
    Make NO assumptions about type of BufferedImage type returned as this may change
    readDimension(byte[] dicomData)
    Decodes and returns the width and height of dicom image
    Decodes and returns the width and height of dicom image
    readImageAt(int imageNumber, byte[] dicomData)
    Please Note: imageNumber should start from 0
    readImageAt(int imageNumber, File dicomFile)
    Please Note: imageNumber should start from 0

    Methods inherited from class com.idrsolutions.image.JDeliImage

    optimiseImage

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface com.idrsolutions.image.Decoder

    readEmbeddedThumbnail, readEmbeddedThumbnail, readImageSpecificMetaData, readImageSpecificMetaData, setMetadata
  • Constructor Details

    • DicomDecoder

      public DicomDecoder()
  • Method Details

    • read

      public BufferedImage read(byte[] dicomData) throws Exception
      Make NO assumptions about type of BufferedImage type returned as this may change

      Decodes and returns the DICOM image as a BufferedImage from bytes

      Specified by:
      read in interface com.idrsolutions.image.Decoder
      Parameters:
      dicomData - byte[] containing the DICOM data to be decoded
      Returns:
      BufferedImage The decoded image
      Throws:
      Exception - if an error occurs in reading image
    • read

      public BufferedImage read(File dicomFile) throws Exception
      Make NO assumptions about type of BufferedImage type returned as this may change

      Decodes and returns the DICOM image as a BufferedImage from a File

      Specified by:
      read in interface com.idrsolutions.image.Decoder
      Parameters:
      dicomFile - DICOM File to be decoded into a BufferedImage
      Returns:
      BufferedImage The decoded image
      Throws:
      Exception - if an error occurs in reading image
    • readDimension

      public Rectangle readDimension(File file) throws Exception
      Decodes and returns the width and height of dicom image
      Specified by:
      readDimension in interface com.idrsolutions.image.Decoder
      Parameters:
      file - image image contained in raw data if present
      Returns:
      width and height of image
      Throws:
      IOException - if problem reading image
      Exception
    • readDimension

      public Rectangle readDimension(byte[] dicomData) throws Exception
      Decodes and returns the width and height of dicom image
      Specified by:
      readDimension in interface com.idrsolutions.image.Decoder
      Parameters:
      dicomData - image image contained in raw data if present
      Returns:
      Rectangle width and height of image
      Throws:
      IOException - if problem reading image
      Exception
    • readImageAt

      public BufferedImage readImageAt(int imageNumber, File dicomFile) throws Exception
      Please Note: imageNumber should start from 0

      Decodes and returns the requested DICOM frame image as a BufferedImage from a multi-frame DICOM file.

      Specified by:
      readImageAt in interface com.idrsolutions.image.Decoder
      Parameters:
      imageNumber - image number to be decoded and returned (starting from 0)
      dicomFile - DICOM File to be decoded into a BufferedImage
      Returns:
      BufferedImage The decoded image at the given page number
      Throws:
      Exception - if an error occurs in reading image
    • readImageAt

      public BufferedImage readImageAt(int imageNumber, byte[] dicomData) throws Exception
      Please Note: imageNumber should start from 0

      Decodes and returns the requested DICOM frame image as a BufferedImage from multi-frame DICOM data.

      Specified by:
      readImageAt in interface com.idrsolutions.image.Decoder
      Parameters:
      imageNumber - Frame number to be decoded and returned (starting from 0)
      dicomData - byte[] containing the DICOM data to be decoded into a BufferedImage
      Returns:
      BufferedImage The decoded image at given page number
      Throws:
      Exception - if an error occurs in reading image
    • read

      public BufferedImage read(int frameNumber, File dicomFile) throws Exception
      Please Note: frameNumber should start from 1

      Decodes and returns the requested DICOM frame image as a BufferedImage from a multi-frame DICOM file.

      Parameters:
      frameNumber - Frame number to be decoded and returned (starting from 1)
      dicomFile - DICOM File to be decoded into a BufferedImage
      Returns:
      BufferedImage The decoded image at the given page number
      Throws:
      Exception - if an error occurs in reading image
    • read

      public BufferedImage read(int frameNumber, byte[] dicomData) throws Exception
      Please Note: frameNumber should start from 1

      Decodes and returns the requested DICOM frame image as a BufferedImage from multi-frame DICOM data.

      Parameters:
      frameNumber - Frame number to be decoded and returned (starting from 1)
      dicomData - byte[] containing the DICOM data to be decoded into a BufferedImage
      Returns:
      BufferedImage The decoded image at given page number
      Throws:
      Exception - if an error occurs in reading image
    • getFrameCount

      public int getFrameCount(byte[] dicomData) throws IOException
      Returns the number of frames in the DICOM data.
      Parameters:
      dicomData - byte[] containing the DICOM data
      Returns:
      The number of frames in DICOM data.
      Throws:
      IOException - if an error occurs in reading image
    • getFrameCount

      public int getFrameCount(File dicomFile) throws IOException
      Returns the number of frames in the DICOM data.
      Parameters:
      dicomFile - File containing the DICOM data
      Returns:
      The number of frames in DICOM data.
      Throws:
      IOException - if an error occurs in reading image
    • getImageCount

      public int getImageCount(byte[] dicomData) throws IOException
      Returns the number of frames in the DICOM data.
      Specified by:
      getImageCount in interface com.idrsolutions.image.Decoder
      Parameters:
      dicomData - byte[] containing the DICOM data
      Returns:
      The number of frames in DICOM data.
      Throws:
      IOException - if an error occurs in reading image
    • getImageCount

      public int getImageCount(File dicomFile) throws IOException
      Returns the number of frames in the DICOM data.
      Specified by:
      getImageCount in interface com.idrsolutions.image.Decoder
      Parameters:
      dicomFile - File containing the DICOM data
      Returns:
      The number of frames in DICOM data.
      Throws:
      IOException - if an error occurs in reading image