cornerstoneWADOImageLoader icon indicating copy to clipboard operation
cornerstoneWADOImageLoader copied to clipboard

support web-workers for jpeg-8 color using built-in features 'createImageBitmap' and 'OffscreenCanvas' for enhanced performance

Open Zaid-Safadi opened this issue 5 years ago • 0 comments

For JPEGBaseline8BitColor images the decoder currently uses the img element and HTML Canvas by converting binary image data to Base64 to support the decoding. https://github.com/cornerstonejs/cornerstoneWADOImageLoader/blob/master/src/imageLoader/decodeJPEGBaseline8BitColor.js#L30

This process:

  1. Prevent using web-workers as DOM elements can't be used/created there
  2. May suffer from performance issues when binary data is large and converting to base64

A better approach is using the new native JavaScript features 'createImageBitmap' and 'OffscreenCanvas' -when supported- to decode the image and run it in a web-worker:

  1. OffscreenCanvas in web-wroker is will improve the performance as suggested by several posts such as: https://developers.google.com/web/updates/2018/08/offscreen-canvas
  2. No need to convert the image binary data to base64 when using the createImageBitmap method
  3. We can now take advantage of web-workers

Zaid-Safadi avatar Oct 31 '20 15:10 Zaid-Safadi