Skip to content

Commit a5b88bc

Browse files
authored
feat: Add preScale parameters to the image (#413)
1 parent 0797922 commit a5b88bc

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

src/imageLoader/createImage.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -196,18 +196,19 @@ function createImage(imageId, pixelData, transferSyntax, options = {}) {
196196
columnPixelSpacing: imagePlaneModule.columnPixelSpacing,
197197
columns: imageFrame.columns,
198198
height: imageFrame.rows,
199+
preScale: imageFrame.preScale,
199200
intercept: modalityLutModule.rescaleIntercept
200201
? modalityLutModule.rescaleIntercept
201202
: 0,
203+
slope: modalityLutModule.rescaleSlope
204+
? modalityLutModule.rescaleSlope
205+
: 1,
202206
invert: imageFrame.photometricInterpretation === 'MONOCHROME1',
203207
minPixelValue: imageFrame.smallestPixelValue,
204208
maxPixelValue: imageFrame.largestPixelValue,
205209
rowPixelSpacing: imagePlaneModule.rowPixelSpacing,
206210
rows: imageFrame.rows,
207211
sizeInBytes: imageFrame.pixelData.byteLength,
208-
slope: modalityLutModule.rescaleSlope
209-
? modalityLutModule.rescaleSlope
210-
: 1,
211212
width: imageFrame.columns,
212213
windowCenter: voiLutModule.windowCenter
213214
? voiLutModule.windowCenter[0]

src/shared/decodeImageFrame.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,12 @@ function postProcessDecodedPixels(imageFrame, options, start) {
227227
typeof rescaleSlope === 'number' &&
228228
typeof rescaleIntercept === 'number'
229229
) {
230-
scaleArray(pixelDataArray, scalingParameters);
230+
if (scaleArray(pixelDataArray, scalingParameters)) {
231+
imageFrame.preScale = {
232+
scaled: true,
233+
scalingParameters,
234+
};
235+
}
231236
}
232237
}
233238

src/shared/scaling/scaleArray.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,6 @@ export default function scaleArray(array, scalingParameters) {
1515
array[i] = array[i] * rescaleSlope + rescaleIntercept;
1616
}
1717
}
18+
19+
return true;
1820
}

0 commit comments

Comments
 (0)