/** * DicomParser.js * Version 0.5 * Author: BabuHussain */ function DicomParser(inputBuffer,reader) { this.inputBuffer=inputBuffer; this.reader=reader; this.parseAll=parseAll; this.index = 0; this.pixelBuffer; this.bitsStored; this.pixelRepresentation; this.minPix; this.maxPix; this.imgData = null; } function getPixelBuffer() { return this.pixelBuffer; } function parseAll() { // var imgPixelSpacing = this.readTag(24,0,17,100,"ImagerPixelSpacing"); var monochrome1 = this.readTag(40,0,4,0,"PhotometricInterpretation"); var rows = this.readTagAsNumber(40,0,16,0,"Rows"); var columns = this.readTagAsNumber(40,0,17,0,"Columns"); var pxlSpacing = this.readTag(40,0,48,0,"PixelSpacing"); this.bitsStored = this.readTagAsNumber(40,0,1,1,"BitsStored"); this.pixelRepresentation = this.readTagAsNumber(40,0,3,1,"PixelRepresentation"); var wc = this.readTag(40,0,80,16,"windowCenter"); var ww = this.readTag(40,0,81,16,"windowWidth"); var rescale_Intercept = this.readTag(40,0,82,16,"rescaleIntercept"); var rescale_slope = this.readTag(40,0,83,16,"rescaleSlope"); // this.imgData={"monochrome1":monochrome1=="MONOCHROME1","BitsStored":this.bitsStored,"PixelRepresentation":this.pixelRepresentation,"windowCenter":wc!=undefined? wc[0] : wc,"windowWidth":ww!=undefined ? ww[0] : ww,"rescaleIntercept":rescale_Intercept!=undefined?rescale_Intercept:0.0 ,"rescaleSlope":rescale_slope!=undefined ?rescale_slope:1.0,"nativeRows":rows,"nativeColumns":columns,"pixelSpacing":pxlSpacing,"imagerPixelSpacing":imgPixelSpacing}; this.imgData={"monochrome1":monochrome1=="MONOCHROME1","BitsStored":this.bitsStored,"PixelRepresentation":this.pixelRepresentation,"windowCenter":wc!=undefined? wc[0] : wc,"windowWidth":ww!=undefined ? ww[0] : ww,"rescaleIntercept":rescale_Intercept!=undefined?rescale_Intercept:0.0 ,"rescaleSlope":rescale_slope!=undefined ?rescale_slope:1.0,"nativeRows":rows,"nativeColumns":columns,"pixelSpacing":pxlSpacing}; this.moveToPixelDataTag(); this.readImage(); } DicomParser.prototype.readTag=function(firstContent,secondContent,thirdContent,fourthContent,tagName) { var i=this.index; for(; i8) { this.pixelBuffer = new Uint16Array(this.reader.getBytes(this.index).buffer); } else if(this.pixelRepresentation === 1 && this.bitsStored>8) { this.pixelBuffer = new Int16Array(this.reader.getBytes(this.index).buffer); } else { this.pixelBuffer = new Array(); } for(var j=0;j