cornerstonejs / cornerstone

JavaScript library to display interactive medical images including but not limited to DICOM
https://docs.cornerstonejs.org/
MIT License
2.04k stars 598 forks source link

Does WebGL work for layers? #563

Open MaksimShymko opened 2 years ago

MaksimShymko commented 2 years ago

cornerstone-core version: 2.6.0

I've faced the issue that images added with addLayer don't use WebGL. There is a code in the internal function drawImageSync which adds conditional branching:

if (layers && layers.length) {
  // render when layers specified
  drawCompositeImage(enabledElement, invalidated);
} else if (image) { // render when layers not specified

Currently, WebGL works only for displayImage function. But it isn't possible to combine multiple images on the same canvas with displayImage.

  1. Is there any workaround to use multiple layers with WebGL?
  2. Do you have plans to add WebGL support for layers in the nearest future?
shanebenlolo commented 2 years ago

I don't have an answer to your question, but I am curious what you are trying to accomplish with the layersApi, perhaps there is a different workaround

MaksimShymko commented 2 years ago

@shanebenlolo I want to display a CT scan and can perform windowing, panning, and zooming operations. Also, I want to put a png image overlay on top of the CT scan. CT scan and overlay should be synchronized during panning and zooming.

I am considering three solutions:

Maybe there is another approach that mitigates all cons?

shanebenlolo commented 2 years ago

Have you considered using the react-vtkjs-viewport? https://react-vtkjs-viewport.netlify.app/