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

Update generateLut.js #572

Open tapin13 opened 2 years ago

tapin13 commented 2 years ago

After issue on bug described in issue https://github.com/cornerstonejs/cornerstone/issues/559

On Ipad, Mac (Chrome, FF) After function vlutfn(mlutfn(storedValue)) we got result like 0.99609375 or 1.9921875. Result must be int (variable lut is Uint8ClampedArray). Most of time we got round 0.99609375 to 1 and 1.9921875 to 2. But sometimes we got 0.99609375 to 0 and 1.9921875 to 1. Math.round fix this problem.

swederik commented 2 years ago

My issue with this is that generateLUT is called very often (every time window/level is changed, for example), and so if this rounding operation is not necessary it may hurt performance.

What kind of VOI LUTs are you using that is causing this issue? Can you post the VOI LUT and Modality LUTs that are causing this?

tapin13 commented 2 years ago

VOI LUT and Modality LUTs I send undefined. So it use function generateLinearVOILUT.

About performance, anyway function return float. So js engine make implicit cast to int.