cornerstone3D icon indicating copy to clipboard operation
cornerstone3D copied to clipboard

[Bug] Image does not rendered in proper way (GPU rendering)

Open Max-Kharitonov opened this issue 1 year ago • 10 comments

Describe the Bug

In case if we are using CPU rendering it works fine, but in case GPU this image inverted. Please see attached anonimized file DICOM sample Issue with Invertion.zip

Steps to Reproduce

run GPU rendering image

run CPU rendering image

The current behavior

Image inverted and not rendered in proper way

The expected behavior

Image should be rendered in the correct way and the result should not depend on the rendering type.

OS

Windows 10, Mac os

Node version

v18.14.1

Browser

Chrome 120.0.6099.131

Max-Kharitonov avatar Jan 05 '24 10:01 Max-Kharitonov

old cornerstone was rendering it correctly in and OHIF v2 CleanShot 2024-01-10 at 09 07 48

sedghi avatar Jan 10 '24 14:01 sedghi

@sedghi any updates?

Max-Kharitonov avatar Jan 12 '24 15:01 Max-Kharitonov

No not yet

sedghi avatar Jan 12 '24 16:01 sedghi

Hi @sedghi , Our customer is facing this issue, Would your team please help to check that or any clue we can address?

tuongleit avatar Jan 15 '24 08:01 tuongleit

@sedghi

could this issue related to function toLowHighRange(
  windowWidth: number,
  windowCenter: number
): {
  lower: number;
  upper: number;
} {
  const delta = 0.001; // small value to prevent zero width
  const lower = windowCenter - 0.5 - (windowWidth - 1) / 2;
  let upper = windowCenter - 0.5 + (windowWidth - 1) / 2;

  // upper and lower should be non equal (upper should be bigger than lower)
  if (upper - lower < delta) {
    upper = lower + delta;
  }
  return { lower, upper };
}

export { toWindowLevel, toLowHighRange };

Upper and lower should be non equal (upper should be bigger than lower). and for this image we have Window Width: 1 Window Center: -2

so as a result lower === upper === -2.5

Max-Kharitonov avatar Jan 23 '24 15:01 Max-Kharitonov

The display is still not perfect with the change suggested by @Max-Kharitonov, but it is a lot better. The issue is that the vtk colorTransferFunction doesn't seem to correctly deal with the case when the window width is set to 1 (threshold value) or we are encountering a rounding issue.

s2ramana avatar Jan 23 '24 21:01 s2ramana

@s2ramana I fixed some issue with window level recently can you check again?

sedghi avatar Feb 20 '24 17:02 sedghi

@sedghi which PR was this changed made in?

s2ramana avatar Feb 20 '24 17:02 s2ramana

@sedghi still reproducible

Max-Kharitonov avatar Feb 26 '24 13:02 Max-Kharitonov

@sedghi could you please take a look? https://github.com/cornerstonejs/cornerstone3D/pull/1135

Max-Kharitonov avatar Mar 01 '24 08:03 Max-Kharitonov