Code Monkey home page Code Monkey logo

jpeglosslessdecoderjs's Introduction

JPEGLosslessDecoderJS

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

API and more examples

var decoder = new jpeg.lossless.Decoder();
var output = decoder.decompress(buffer [, offset [, length]]);

// Parameters
// {ArrayBuffer} buffer
// {Number} offset offset into buffer (default = 0)
// {Number} length length of buffer (default = end of JPEG block)

// Returns
// {ArrayBuffer} output (size = cols * rows * bytesPerComponent * numComponents)

Install

Get a packaged source file from the release folder:

Or install via NPM:

npm install jpeg-lossless-decoder-js

Testing

npm test

Building

npm run build

This will output lossless.js and lossless-min.js alongside declaration files and source maps to /release.

Acknowledgments

This decoder was originally written by Helmut Dersch for Java. I added support for selection values 2 through 7, contributed bug fixes and ported to JavaScript.

Also thanks to @jens-ox for modernizing this package to TypeScript.

jpeglosslessdecoderjs's People

Contributors

chafey avatar jens-ox avatar martinezmj-ims avatar rii-mango avatar yvoronenko-reflexion avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jpeglosslessdecoderjs's Issues

performance

I use JPEG Lossless to load some CT data ( 1900 x 2500 x 80).
Each frames takes about 600ms to be decoded, so my total loading time is about 600ms x 80 frames, which is huge.

Is there any way to improve performance somehow?

I do the following for each frame:

    let byteOutput = bitsAllocated <= 8 ? 1 : 2;
    let decoder = new Jpeg.lossless.Decoder();
    let decompressedData = decoder.decode(encodedPixelData.buffer, encodedPixelData.byteOffset, encodedPixelData.length, byteOutput);

Strange decoding behavior ?

I have some DICOM with OCT Scans composed of 49 frames.

The first frame is decoded correctly but it doesn't seem to work for the rest of the images ? Frames are contained in fragments.

screenshot from 2018-12-10 15-16-59

Some of my code :

    offset = pixelDataElement.fragments[frame].position;
    frameSize = pixelDataElement.fragments[frame].length;

    pixelData = new Uint8Array(dataset.byteArray.buffer, offset, frameSize); //get compressed data
    pixelData = new Uint8Array(decoder.decompress(pixelData)); //decompress

Non GPL License possible?

Hello,

Congratulations on this great effort! I would love to add this to the cornerstone project which is licensed under MIT - would it be possible to dual license this library so there is no conflict?

Chris

Global 'jpeg' variable lost in latest NPM build.

Installed latest 2.0.5 version from NPM and missed 'jpeg' variable.

<script src="../node_modules/jpeg-lossless-decoder-js/release/current/lossless.js"></script>
<script>
const decoder = new jpeg .lossless .Decoder ();
// oops no 'jpeg' variable
</script>

NPM package

Thanks a lot for you excellent work! Would it be possible to publish it as a package on NPM?

Support RGB data

Currently, this decoder collapses RGB data into single component intensity data. The original code supported returning RGB data, so it shouldn't be hard to add this...

Version 2.1.0 is broken version 2.0.7 works

node:internal/modules/cjs/loader:444
      throw err;
      ^

Error: Cannot find module '/usr/src/app/node_modules/jpeg-lossless-decoder-js/build/main.js'. Please verify that the package.json has a valid "main" entry
    at tryPackage (node:internal/modules/cjs/loader:436:19)
    at Module._findPath (node:internal/modules/cjs/loader:678:18)
    at Module._resolveFilename (node:internal/modules/cjs/loader:1061:27)
    at Module._load (node:internal/modules/cjs/loader:920:27)
    at Module.require (node:internal/modules/cjs/loader:1141:19)
    at require (node:internal/modules/cjs/helpers:110:18)
    at Object.<anonymous> (/usr/src/app/node_modules/daikon/src/image.js:14:48)
    at Module._compile (node:internal/modules/cjs/loader:1254:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1308:10)
    at Module.load (node:internal/modules/cjs/loader:1117:32) {
  code: 'MODULE_NOT_FOUND',
  path: '/usr/src/app/node_modules/jpeg-lossless-decoder-js/package.json',
  requestPath: 'jpeg-lossless-decoder-js'
}

npm test fails

Tests did not pass.

pedro@debian:~/node_modules/jpeg-lossless-decoder-js$ npm test

> [email protected] test /home/pedro/node_modules/jpeg-lossless-decoder-js
> mocha tests


/home/pedro/node_modules/jpeg-lossless-decoder-js/src/decoder.js:137
        throw new Error("Not a JPEG file");
              ^
Error: Not a JPEG file
    at jpeg.lossless.Decoder.decode (/home/pedro/node_modules/jpeg-lossless-decoder-js/src/decoder.js:137:15)
    at Object.<anonymous> (/home/pedro/node_modules/jpeg-lossless-decoder-js/tests/driver-sel1-oldapi.js:33:22)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at /home/pedro/node_modules/mocha/lib/mocha.js:230:27
    at Array.forEach (native)
    at Mocha.loadFiles (/home/pedro/node_modules/mocha/lib/mocha.js:227:14)
    at Mocha.run (/home/pedro/node_modules/mocha/lib/mocha.js:513:10)
    at Object.<anonymous> (/home/pedro/node_modules/mocha/bin/_mocha:480:18)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10)
    at startup (node.js:119:16)
    at node.js:906:3
npm ERR! Test failed.  See above for more details.
npm WARN This failure might be due to the use of legacy binary "node"
npm WARN For further explanations, please read
/usr/share/doc/nodejs/README.Debian
 
npm ERR! not ok code 0

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.