All files createImageUdv.js

0% Statements 0/10
100% Branches 0/0
0% Functions 0/3
0% Lines 0/9

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47                                                                                             
import { external } from './externalModules.js';
 
/**
 * creates a cornerstone Image object for the specified UDV object
 *
 * @param imageId - the imageId for this image
 * @param udvObj - a custom UDV image object
 * @returns Cornerstone Image Object
 */
export default function (imageId, udvObj) {
  // extract the attributes we need
  const rows = udvObj.rows;
  const columns = udvObj.columns;
   
  let image;
  
  // Extract the various attributes we need
  image = {
    imageId,
    minPixelValue: udvObj.image.minPixelValue,
    maxPixelValue: udvObj.image.maxPixelValue,
    slope: udvObj.image.slope,
    intercept: udvObj.image.intercept,
    windowCenter: udvObj.image.windowCenter,
    windowWidth: udvObj.image.windowWidth,
    rows,
    columns,
    height: rows,
    width: columns,
    color: udvObj.image.color,
    rgba: udvObj.image.rgba,
    columnPixelSpacing: udvObj.image.columnPixelSpacing,
    rowPixelSpacing: udvObj.image.rowPixelSpacing,
    invert: udvObj.image.invert,
    sizeInBytes: rows * columns * 4
	};    
    
  image.getPixelData = () => udvObj.pixelData;
  image.modalityLUT = udvObj.image.modalityLUT;
  image.voiLUT = udvObj.image.voiLUT;
  image.data = udvObj.image.data;
  
  return new Promise((resolve, reject) => {
    resolve(image);
  });
}