UNPKG

cornerstone-wado-image-loader

Version:
164 lines (121 loc) 6.48 kB
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>imageLoader/wadouri/getUncompressedImageFrame.js - Documentation</title> <script src="scripts/prettify/prettify.js"></script> <script src="scripts/prettify/lang-css.js"></script> <!--[if lt IE 9]> <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> <link type="text/css" rel="stylesheet" href="styles/prettify.css"> <link type="text/css" rel="stylesheet" href="styles/jsdoc.css"> <script src="scripts/nav.js" defer></script> <meta name="viewport" content="width=device-width, initial-scale=1.0"> </head> <body> <input type="checkbox" id="nav-trigger" class="nav-trigger" /> <label for="nav-trigger" class="navicon-button x"> <div class="navicon"></div> </label> <label for="nav-trigger" class="overlay"></label> <nav > <h2><a href="index.html">Home</a></h2><h3>Global</h3><ul><li><a href="global.html#addTask">addTask</a></li><li><a href="global.html#arrayBufferToString">arrayBufferToString</a></li><li><a href="global.html#cacheSizeInBytes">cacheSizeInBytes</a></li><li><a href="global.html#cancelTask">cancelTask</a></li><li><a href="global.html#decodeAsync">decodeAsync</a></li><li><a href="global.html#framesAreFragmented">framesAreFragmented</a></li><li><a href="global.html#getMinMax">getMinMax</a></li><li><a href="global.html#getNumberString">getNumberString</a></li><li><a href="global.html#getNumberValues">getNumberValues</a></li><li><a href="global.html#getStatistics">getStatistics</a></li><li><a href="global.html#getTransferSyntaxForContentType">getTransferSyntaxForContentType</a></li><li><a href="global.html#getUncompressedImageFrame">getUncompressedImageFrame</a></li><li><a href="global.html#getValue">getValue</a></li><li><a href="global.html#handleMessageFromWorker">handleMessageFromWorker</a></li><li><a href="global.html#handler">handler</a></li><li><a href="global.html#initialize">initialize</a></li><li><a href="global.html#loadCodecs">loadCodecs</a></li><li><a href="global.html#loadWebWorkerTask">loadWebWorkerTask</a></li><li><a href="global.html#registerLoaders">registerLoaders</a></li><li><a href="global.html#registerTaskHandler">registerTaskHandler</a></li><li><a href="global.html#setPixelDataType">setPixelDataType</a></li><li><a href="global.html#setTaskPriority">setTaskPriority</a></li><li><a href="global.html#spawnWebWorker">spawnWebWorker</a></li><li><a href="global.html#startTaskOnWebWorker">startTaskOnWebWorker</a></li><li><a href="global.html#terminate">terminate</a></li><li><a href="global.html#unpackBinaryFrame">unpackBinaryFrame</a></li></ul> </nav> <div id="main"> <h1 class="page-title">imageLoader/wadouri/getUncompressedImageFrame.js</h1> <section> <article> <pre class="prettyprint source linenums"><code>import unpackBinaryFrame from './unpackBinaryFrame.js'; /** * Function to deal with extracting an image frame from an encapsulated data set. */ function getUncompressedImageFrame(dataSet, frameIndex) { const pixelDataElement = dataSet.elements.x7fe00010 || dataSet.elements.x7fe00008; const bitsAllocated = dataSet.uint16('x00280100'); const rows = dataSet.uint16('x00280010'); const columns = dataSet.uint16('x00280011'); let samplesPerPixel = dataSet.uint16('x00280002'); /** * From: http://dicom.nema.org/medical/dicom/current/output/chtml/part03/sect_C.7.6.3.html * * Though the chrominance channels are downsampled, there are still nominally * three channels, hence Samples per Pixel (0028,0002) has a value of 3, not * 2. I.e., for pixel data in a Native (uncompressed) format, the Value Length * of Pixel Data (7FE0,0010) is not: * * Rows (0028,0010) * Columns (0028,0011) * Number of Frames (0028,0008) * * Samples per Pixel (0028,0002) * (⌊(Bits Allocated (0028,0100)-1)/8⌋+1) * * padded to an even length, as it would otherwise be, but rather is: * * Rows (0028,0010) * Columns (0028,0011) * Number of Frames (0028,0008) * 2 * * (⌊(Bits Allocated (0028,0100)-1)/8⌋+1) * * padded to an even length. */ const photometricInterpretation = dataSet.string('x00280004'); if (photometricInterpretation === 'YBR_FULL_422') { samplesPerPixel = 2; console.warn( `Using SamplesPerPixel of 2 for YBR_FULL_422 photometric interpretation. See http://dicom.nema.org/medical/dicom/current/output/chtml/part03/sect_C.7.6.3.html for more information.` ); } const pixelDataOffset = pixelDataElement.dataOffset; const pixelsPerFrame = rows * columns * samplesPerPixel; let frameOffset; if (bitsAllocated === 8) { frameOffset = pixelDataOffset + frameIndex * pixelsPerFrame; if (frameOffset >= dataSet.byteArray.length) { throw new Error('frame exceeds size of pixelData'); } return new Uint8Array( dataSet.byteArray.buffer, frameOffset, pixelsPerFrame ); } else if (bitsAllocated === 16) { frameOffset = pixelDataOffset + frameIndex * pixelsPerFrame * 2; if (frameOffset >= dataSet.byteArray.length) { throw new Error('frame exceeds size of pixelData'); } return new Uint8Array( dataSet.byteArray.buffer, frameOffset, pixelsPerFrame * 2 ); } else if (bitsAllocated === 1) { frameOffset = pixelDataOffset + frameIndex * pixelsPerFrame * 0.125; if (frameOffset >= dataSet.byteArray.length) { throw new Error('frame exceeds size of pixelData'); } return unpackBinaryFrame(dataSet.byteArray, frameOffset, pixelsPerFrame); } else if (bitsAllocated === 32) { frameOffset = pixelDataOffset + frameIndex * pixelsPerFrame * 4; if (frameOffset >= dataSet.byteArray.length) { throw new Error('frame exceeds size of pixelData'); } return new Uint8Array( dataSet.byteArray.buffer, frameOffset, pixelsPerFrame * 4 ); } throw new Error('unsupported pixel format'); } export default getUncompressedImageFrame; </code></pre> </article> </section> </div> <br class="clear"> <footer> Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.7</a> using the <a href="https://github.com/clenemt/docdash">docdash</a> theme. </footer> <script>prettyPrint();</script> <script src="scripts/polyfill.js"></script> <script src="scripts/linenumber.js"></script> </body> </html>