Class 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
     }
     
    • Constructor Summary

      Constructors 
      Constructor Description
      DicomDecoder()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int getFrameCount​(byte[] dicomData)
      Returns the number of frames in the DICOM data.
      int getFrameCount​(java.io.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​(java.io.File dicomFile)
      Returns the number of frames in the DICOM data.
      java.awt.image.BufferedImage read​(byte[] dicomData)
      Make NO assumptions about type of BufferedImage type returned as this may change
      java.awt.image.BufferedImage read​(int frameNumber, byte[] dicomData)
      Please Note: frameNumber should start from 1
      java.awt.image.BufferedImage read​(int frameNumber, java.io.File dicomFile)
      Please Note: frameNumber should start from 1
      java.awt.image.BufferedImage read​(java.io.File dicomFile)
      Make NO assumptions about type of BufferedImage type returned as this may change
      java.awt.image.BufferedImage readImageAt​(int imageNumber, byte[] dicomData)
      Please Note: imageNumber should start from 0
      java.awt.image.BufferedImage readImageAt​(int imageNumber, java.io.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

        setMetadata
    • Constructor Detail

      • DicomDecoder

        public DicomDecoder()
    • Method Detail

      • read

        public java.awt.image.BufferedImage read​(byte[] dicomData)
                                          throws java.lang.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:
        java.lang.Exception
      • read

        public java.awt.image.BufferedImage read​(java.io.File dicomFile)
                                          throws java.lang.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:
        java.lang.Exception
      • readImageAt

        public java.awt.image.BufferedImage readImageAt​(int imageNumber,
                                                        java.io.File dicomFile)
                                                 throws java.lang.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:
        java.lang.Exception
      • readImageAt

        public java.awt.image.BufferedImage readImageAt​(int imageNumber,
                                                        byte[] dicomData)
                                                 throws java.lang.Exception
        Please Note: imageNumber should start from 0

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

        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:
        java.lang.Exception
      • read

        public java.awt.image.BufferedImage read​(int frameNumber,
                                                 java.io.File dicomFile)
                                          throws java.lang.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:
        java.lang.Exception
      • read

        public java.awt.image.BufferedImage read​(int frameNumber,
                                                 byte[] dicomData)
                                          throws java.lang.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:
        java.lang.Exception
      • getFrameCount

        public int getFrameCount​(byte[] dicomData)
                          throws java.io.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:
        java.io.IOException
      • getFrameCount

        public int getFrameCount​(java.io.File dicomFile)
                          throws java.io.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:
        java.io.IOException
      • getImageCount

        public int getImageCount​(byte[] dicomData)
                          throws java.io.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:
        java.io.IOException
      • getImageCount

        public int getImageCount​(java.io.File dicomFile)
                          throws java.io.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:
        java.io.IOException