@@ -30,12 +30,14 @@ function generateLinearVOILUT (windowWidth, windowCenter) {
3030/**
3131 * Generate a non-linear volume of interest lookup table
3232 *
33- * @param {LUT } voiLUT Volume of Interest Lookup Table Object
33+ * @param {LUT } voiLUT Volume of Interest Lookup Table Object
34+ * @param {Boolean } roundModalityLUTValues Do a Math.round of modality lut to compute non linear voilut
35+
3436 *
3537 * @returns {VOILUTFunction } VOI LUT mapping function
3638 * @memberof VOILUT
3739 */
38- function generateNonLinearVOILUT ( voiLUT ) {
40+ function generateNonLinearVOILUT ( voiLUT , roundModalityLUTValues ) {
3941 // We don't trust the voiLUT.numBitsPerEntry, mainly thanks to Agfa!
4042 const bitsPerEntry = Math . max ( ...voiLUT . lut ) . toString ( 2 ) . length ;
4143 const shift = bitsPerEntry - 8 ;
@@ -49,8 +51,10 @@ function generateNonLinearVOILUT (voiLUT) {
4951 } else if ( modalityLutValue >= maxValueMapped ) {
5052 return maxValue ;
5153 }
52-
53- return voiLUT . lut [ modalityLutValue - voiLUT . firstValueMapped ] >> shift ;
54+ if ( roundModalityLUTValues )
55+ return voiLUT . lut [ Math . round ( modalityLutValue ) - voiLUT . firstValueMapped ] >> shift ;
56+ else
57+ return voiLUT . lut [ modalityLutValue - voiLUT . firstValueMapped ] >> shift ;
5458 } ;
5559}
5660
@@ -61,13 +65,14 @@ function generateNonLinearVOILUT (voiLUT) {
6165 * @param {Number } windowWidth Window Width
6266 * @param {Number } windowCenter Window Center
6367 * @param {LUT } [voiLUT] Volume of Interest Lookup Table Object
68+ * @param {Boolean } roundModalityLUTValues Do a Math.round of modality lut to compute non linear voilut
6469 *
6570 * @return {VOILUTFunction } VOI LUT mapping function
6671 * @memberof VOILUT
6772 */
68- export default function ( windowWidth , windowCenter , voiLUT ) {
73+ export default function ( windowWidth , windowCenter , voiLUT , roundModalityLUTValues ) {
6974 if ( voiLUT ) {
70- return generateNonLinearVOILUT ( voiLUT ) ;
75+ return generateNonLinearVOILUT ( voiLUT , roundModalityLUTValues ) ;
7176 }
7277
7378 return generateLinearVOILUT ( windowWidth , windowCenter ) ;
0 commit comments