Open zzzhello opened 1 year ago
@sedghi
Thanks for including me. Why are we setting the halfLut_offset and size to those values? (especially the luSize)
'2048' and '4097' is not a good codding habit, I just use them for the example, sorry for that.
Why 'halfLut_offset '? Because 'image data value' can be negative and halfLut's table index should always be positive,we can use 'halfLut_offset ' to map 'image data value' to halfLut's table index. You can use min value or 'scaleOffsets.offset' to replace 'halfLut_offset '
Why 'luSize'? 'luSize' is lut table length, it can be range of the data value( max - min), you can use 'scaleOffsets.scale'
how to get 'scaleOffsets.offset' and 'scaleOffsets.scale' ? We can refer function 'create3DFilterableFromDataArray' in Texture.js, the values are cached ,no need to recompute.
Thanks for explanation, I guess it makes sense a lot
@zzzhello would you mind creating a PR ?
@zzzhello would you mind creating a PR ?
Sure, i would be happy to.
High-level description
The function toHalf is very time-consuming, although it has been optimized in version v27.3.0(https://github.com/kitware/vtk-js/commit/f38460cce8bc63b483d30840ce939978ed607420).
I think we can use a lookup table(e.g. halfLut = new Uint16Array(lutSize)) to replace function 'toHalf'. This can save at least twice or more time in chrome(300ms vs 100ms).
Steps to reproduce
Here is the code snippet(function 'updateArrayDataType' is in file '\OpenGL\Texture.js')
Detailed Current Behavior
N/A
Environment