// xraysim server var proc = require('child_process'); var http = require('http') var fs = require('fs') var Path = require('path') var execSync = require("child_process").execSync; var tiff = require('./UTIF') var binary = "./xraysim" log=console.log if (!fs.rmSync) fs.rmSync = function (path,options) { log('Deleting '+path) execSync('rm -rf '+path); } // gamma scaled by xraysim? function decodeTIFF(file) { var data = Buffer.from(fs.readFileSync(file,'binary'),'binary'); // log(file,data.length,typeof data) var ifd = tiff.decode(data); tiff.decodeImage(data,ifd[0]); if (!ifd[0].width || !ifd[0].height) throw Error("TIFF decoding failed"); var image = { width : ifd[0].width, height : ifd[0].height, data : new Uint32Array(new Uint8Array(ifd[0].data).buffer), depth : 1, type : 'UINT32', } var min,max min = max = image.data[0];for(var i=1;i (x)); if (offset