Giter VIP home page Giter VIP logo

jpeglosslessdecoder's Introduction

JPEGLosslessDecoder

A common DICOM compression format is JPEG Lossless. This format is generally not supported in standard JPEG decoder libraries.

This decoder can read data from the following DICOM transfer syntaxes:

  • 1.2.840.10008.1.2.4.57 JPEG Lossless, Nonhierarchical (Processes 14)
  • 1.2.840.10008.1.2.4.70 JPEG Lossless, Nonhierarchical (Processes 14 [Selection 1])

Usage (raw stream)

JPEGLosslessDecoder decoder = new JPEGLosslessDecoder(compressedBytes);

// single component
int[] decompressedData = decoder.decode()[0];  

// rgb components
final int[][] decompressedData = decoder.decode();
final int[] redData = decompressedData[0];
final int[] greenData = decompressedData[1];
final int[] blueData = decompressedData[2];

Usage (BufferedImage)

JPEGLosslessDecoderWrapper decoder = new JPEGLosslessDecoderWrapper();

//currently supports 24 bit rgb, 16 & 8 bit grayscale
BufferedImage image = decoder.readImage(compressedBytes);

Building

ant build.xml

Acknowledgments

This decoder was originally written by Helmut Dersch. I added support for selection values 2 through 7, contributed bug fixes and code cleanup.

jpeglosslessdecoder's People

Contributors

davegwatson avatar hermannkroll avatar rii-mango avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

jpeglosslessdecoder's Issues

JPEG Lossless, some values exceed the the precision range

Hello,

I've got a problem. I have JPEG Lossless images with 16 bit precision and 1 component (your library and the DICOM information tells me that)

    try {
        //read in test
        FileInputStream inStream = new FileInputStream("test0.pixeldata");
        int avaibleBytes = inStream.available();
        byte[] data = new byte[avaibleBytes];
        inStream.read(data);
        //create decoder here
        JPEGLosslessDecoder decoder = new JPEGLosslessDecoder(data);
        int[][] decoded = decoder.decode();

        // added getFrameHeader in JPEGLosslessDecoder for this prints here
        FrameHeader header = decoder.getFrameHeader();
        System.out.println("Components: " + header.getNumComponents());
        System.out.println("Precision : " + header.getPrecision());


        int min = Integer.MAX_VALUE;
        int max = Integer.MIN_VALUE;
        for(int i = 0; i < decoded[0].length; i++){
            if(min > decoded[0][i]){
                min = decoded[0][i];
            }
            if(max < decoded[0][i]){
                max = decoded[0][i];
            }
        }
        System.out.println("Max value: " + max);
        System.out.println("Min value: " + min);


    } catch(Exception ex){
        ex.printStackTrace();
    }

The console output is:
Components: 1
Precision : 16
Max value: 67007
Min value: 63536

Why does some values exceeds the range of 16 bit precision? I assumed that the values could be wrapped safely by an Java short.

I attached you the image stream from a DICOM file saved to an .pixeldata - file in a .zip.

Best regards & Thanks
Hermann

test0.pixeldata.zip

Integration to "Twelve Monkeys"

Hallo,

nice library. After a couple of hours searched i found this library to decode JPEG Lossless files. My task was to do a own implementation for JPEG Lossless parsing for DICOM files. This code should be contributed to the "TwelveMonkeys" ImageLibrary, which we use in our DICOM Software.
(Github Link for "TwelveMonkeys")

Maybe there is a possibility to integrate your Code into the "TwelveMonkeys" Project? If you want, I can do the implementation. I know you use the MIT license, but i wanted to hear, if its okay for you.

Best regards
Hermann

Format of decompressed bytes?

Hi. Firstly, thank so much for writing this. I'm writing a DICOM parser in a different language (Xojo) and, like many people, managed to read the elements in the DICOM file and be able to generate an image if the PixelData was uncompressed but have struggled to decode lossless JPEG.

I'm attempting to port this Java library to Xojo. I have one question. In the readme it says:

// single component
int[] decompressedData = decoder.decode()[0];

The bytes in decompressedData what format are they? Can I consider them the same as if they were in DICOM's "uncompressed" format. I.e I just need to apply RescaleSlope and RescaleIntercept and windowing to them or have they been decoded to a different JPEG format?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.