Comparing version 3.0.0 to 3.1.0
133
dist/ssim.js
@@ -1,2 +0,131 @@ | ||
!function(t,i){"object"==typeof exports&&"object"==typeof module?module.exports=i(require("canvas"),require("fs"),require("https")):"function"==typeof define&&define.amd?define(["canvas","fs","https"],i):"object"==typeof exports?exports.ssim=i(require("canvas"),require("fs"),require("https")):t.ssim=i(t.canvas,t.fs,t.https)}(this,function(t,i,r){return function(t){function i(e){if(r[e])return r[e].exports;var n=r[e]={i:e,l:!1,exports:{}};return t[e].call(n.exports,n,n.exports,i),n.l=!0,n.exports}var r={};return i.m=t,i.c=r,i.i=function(t){return t},i.d=function(t,i,r){Object.defineProperty(t,i,{configurable:!1,enumerable:!0,get:r})},i.n=function(t){var r=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(r,"a",r),r},i.o=function(t,i){return Object.prototype.hasOwnProperty.call(t,i)},i.p="",i(i.s=72)}([function(t,i){function r(t){return e(t)/t.length}function e(t){for(var i=0,r=0;r<t.length;r++)i+=t[r];return i}function n(t){for(var i=new Array(t.length),r=0;r<t.length;r++)i[r]=Math.floor(t[r]);return i}function o(t){for(var i=t.data,r=0,e=0;e<i.length;e++)r+=i[e];return r}function a(t,i){for(var r=t.data,e=t.width,n=t.height,o=i.data,a=new Array(r.length),h=0;h<n;h++)for(var s=h*e,f=0;f<e;f++)a[s+f]=r[s+f]+o[s+f];return{data:a,width:e,height:n}}function h(t,i){for(var r=t.data,e=t.width,n=t.height,o=i.data,a=new Array(r.length),h=0;h<n;h++)for(var s=h*e,f=0;f<e;f++)a[s+f]=r[s+f]-o[s+f];return{data:a,width:e,height:n}}function s(t,i){for(var r=t.data,e=t.width,n=t.height,o=new Array(r.length),a=0;a<r.length;a++)o[a]=r[a]+i;return{data:o,width:e,height:n}}function f(t,i){return"number"==typeof i?s(t,i):a(t,i)}function u(t,i){return"number"==typeof i?s(t,-i):h(t,i)}function d(t,i){for(var r=t.data,e=t.width,n=t.height,o=new Array(r.length),a=0;a<r.length;a++)o[a]=r[a]/i;return{data:o,width:e,height:n}}function c(t,i){for(var r=t.data,e=t.width,n=t.height,o=i.data,a=new Array(r.length),h=0;h<r.length;h++)a[h]=r[h]/o[h];return{data:a,width:e,height:n}}function p(t,i){return"number"==typeof i?d(t,i):c(t,i)}function l(t,i){for(var r=t.data,e=t.width,n=t.height,o=new Array(r.length),a=0;a<r.length;a++)o[a]=r[a]*i;return{data:o,width:e,height:n}}function v(t,i){for(var r=t.data,e=t.width,n=t.height,o=i.data,a=new Array(r.length),h=0;h<r.length;h++)a[h]=r[h]*o[h];return{data:a,width:e,height:n}}function m(t,i){return"number"==typeof i?l(t,i):v(t,i)}function w(t){return m(t,t)}function g(t){return o(t)/t.data.length}function y(t){for(var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:r(t),e=0,n=t.length;n--;)e+=Math.pow(t[n]-i,2);return e/t.length}function b(t,i){for(var e=arguments.length>2&&void 0!==arguments[2]?arguments[2]:r(t),n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:r(i),o=0,a=t.length;a--;)o+=(t[a]-e)*(i[a]-n);return o/t.length}t.exports={add2d:f,average:r,covariance:b,divide2d:p,floor:n,mean2d:g,multiply2d:m,square2d:w,subtract2d:u,sum:e,sum2d:o,variance:y}},function(t,i,r){var e=r(17),n=e.conv2,o=r(18),a=o.filter2,h=r(57),s=h.fspecial,f=r(58),u=f.imfilter,d=r(59),c=d.normpdf,p=r(21),l=p.ones,v=r(22),m=v.padarray,w=r(60),g=w.rgb2gray,y=r(61),b=y.skip2d,x=r(23),I=x.sub,E=r(62),S=E.transpose,M=r(24),j=M.zeros;t.exports={conv2:n,filter2:a,fspecial:s,imfilter:u,normpdf:c,ones:l,padarray:m,rgb2gray:g,skip2d:b,sub:I,transpose:S,zeros:j}},function(t,i){t.exports=function(t){try{return!!t()}catch(t){return!0}}},function(t,i){var r=t.exports="undefined"!=typeof window&&window.Math==Math?window:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")();"number"==typeof __g&&(__g=r)},function(t,i){var r=t.exports={version:"2.4.0"};"number"==typeof __e&&(__e=r)},function(t,i,r){t.exports=!r(2)(function(){return 7!=Object.defineProperty({},"a",{get:function(){return 7}}).a})},function(t,i){var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t};t.exports=function(t){return"object"===("undefined"==typeof t?"undefined":r(t))?null!==t:"function"==typeof t}},function(t,i){t.exports=function(t){if(void 0==t)throw TypeError("Can't call method on "+t);return t}},function(t,i,r){var e=r(3),n=r(4),o=r(10),a=r(46),h=r(35),s="prototype",f=function t(i,r,f){var u,d,c,p,l=i&t.F,v=i&t.G,m=i&t.S,w=i&t.P,g=i&t.B,y=v?e:m?e[r]||(e[r]={}):(e[r]||{})[s],b=v?n:n[r]||(n[r]={}),x=b[s]||(b[s]={});v&&(f=r);for(u in f)d=!l&&y&&void 0!==y[u],c=(d?y:f)[u],p=g&&d?h(c,e):w&&"function"==typeof c?h(Function.call,c):c,y&&a(y,u,c,i&t.U),b[u]!=c&&o(b,u,p),w&&x[u]!=c&&(x[u]=c)};e.core=n,f.F=1,f.G=2,f.S=4,f.P=8,f.B=16,f.W=32,f.U=64,f.R=128,t.exports=f},function(t,i){var r={}.hasOwnProperty;t.exports=function(t,i){return r.call(t,i)}},function(t,i,r){var e=r(40),n=r(45);t.exports=r(5)?function(t,i,r){return e.f(t,i,n(1,r))}:function(t,i,r){return t[i]=r,t}},function(t,i,r){var e=r(34);t.exports=Object("z").propertyIsEnumerable(0)?Object:function(t){return"String"==e(t)?t.split(""):Object(t)}},function(t,i,r){var e=r(42),n=r(37);t.exports=Object.keys||function(t){return e(t,n)}},function(t,i){var r=Math.ceil,e=Math.floor;t.exports=function(t){return isNaN(t=+t)?0:(t>0?e:r)(t)}},function(t,i,r){var e=r(11),n=r(7);t.exports=function(t){return e(n(t))}},function(t,i,r){var e=r(7);t.exports=function(t){return Object(e(t))}},function(t,i){var r=0,e=Math.random();t.exports=function(t){return"Symbol(".concat(void 0===t?"":t,")_",(++r+e).toString(36))}},function(t,i,r){function e(t,i){for(var r=t.data,e=t.width,n=t.height,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"full",a=e+i.width-1,s=n+i.height-1,f=c(s,a),u=f.data,d=0;d<i.height;d++)for(var p=0;p<i.width;p++){var l=i.data[d*i.width+p];if(l)for(var v=0;v<n;v++)for(var m=0;m<e;m++)u[(v+d)*a+m+p]+=r[v*e+m]*l}var w={data:u,width:a,height:s};return h(w,o,n,i.height,e,i.width)}function n(t,i){var r=i.data,e=i.width,n=i.height,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"full",h=l(n,1),s=l(1,e),f=a(t,h,s,o);return m(f,r[0])}function o(t){for(var i=t.data,r=i[0],e=1;e<i.length;e++)if(i[e]!==r)return!1;return!0}function a(t,i,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"full",o=Math.max(i.height,i.width),a=Math.max(r.height,r.width),s=e(t,i,"full"),f=e(s,r,"full");return h(f,n,t.height,o,t.width,a)}function h(t,i,r,e,n,o){if("full"===i)return t;if("same"===i){var a=Math.ceil((t.height-r)/2),h=Math.ceil((t.width-n)/2);return u(t,a,r,h,n)}return u(t,e-1,r-e+1,o-1,n-o+1)}function s(){for(var t=arguments.length,i=Array(t),r=0;r<t;r++)i[r]=arguments[r];return i[2]&&i[2].data?a.apply(void 0,i):o(i[1])?n.apply(void 0,i):e.apply(void 0,i)}var f=r(23),u=f.sub,d=r(24),c=d.zeros,p=r(21),l=p.ones,v=r(0),m=v.multiply2d;t.exports={conv2:s}},function(t,i,r){function e(t){for(var i=t.data,r=t.width,e=t.height,n=new Array(i.length),o=0;o<e;o++)for(var a=0;a<r;a++)n[o*r+a]=i[(e-1-o)*r+r-1-a];return{data:n,width:r,height:e}}function n(t,i){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"same";return a(i,e(t),r)}var o=r(17),a=o.conv2;t.exports={filter2:n}},function(t,i){function r(t,i,r){for(var e=i*t,n=new Array(e),o=0;o<e;o++)n[o]=r;return{data:n,width:i,height:t}}t.exports={numbers:r}},function(t,i){function r(t,i){return t-i*Math.floor(t/i)}t.exports={mod:r}},function(t,i,r){function e(t){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t;return o(t,i,1)}var n=r(19),o=n.numbers;t.exports={ones:e}},function(t,i,r){function e(t){for(var i=t.data,r=t.width,e=t.height,n=new Array(i.length),o=0;o<e;o++)for(var a=0;a<r;a++)n[o*r+a]=i[o*r+r-1-a];return{data:n,width:r,height:e}}function n(t){for(var i=t.data,r=t.width,e=t.height,n=new Array(i.length),o=0;o<e;o++)for(var a=0;a<r;a++)n[o*r+a]=i[(e-1-o)*r+a];return{data:n,width:r,height:e}}function o(t,i){for(var r=t.width+i.width,e=new Array(t.height*r),n=0;n<t.height;n++){for(var o=0;o<t.width;o++)e[n*r+o]=t.data[n*t.width+o];for(var a=0;a<i.width;a++)e[n*r+a+t.width]=i.data[n*i.width+a]}return{data:e,width:r,height:t.height}}function a(t,i){return{data:t.data.concat(i.data),height:t.height+i.height,width:t.width}}function h(t,i){for(var r=t.width+2*i,n=new Array(r*t.height),a=o(t,e(t)),h=0;h<t.height;h++)for(var s=-i;s<t.width+i;s++)n[h*r+s+i]=a.data[h*a.width+p(s,a.width)];return{data:n,width:r,height:t.height}}function s(t,i){for(var r=a(t,n(t)),e=t.height+2*i,o=new Array(t.width*e),h=-i;h<t.height+i;h++)for(var s=0;s<t.width;s++)o[(h+i)*t.width+s]=r.data[p(h,r.height)*t.width+s];return{data:o,width:t.width,height:e}}function f(t,i){for(var r=d(i,2),e=r[0],n=r[1],o=t.width+2*n,a=t.height+2*e,h=new Array(o*a),s=-e;s<0;s++){for(var f=-n;f<0;f++)h[(s+e)*o+f+n]=t.data[(Math.abs(s)-1)*t.width+Math.abs(f)-1];for(var u=0;u<t.width;u++)h[(s+e)*o+u+n]=t.data[(Math.abs(s)-1)*t.width+u];for(var c=t.width;c<t.width+n;c++)h[(s+e)*o+c+n]=t.data[(Math.abs(s)-1)*t.width+2*t.width-c-1]}for(var p=0;p<t.height;p++){for(var l=-n;l<0;l++)h[(p+e)*o+l+n]=t.data[p*t.width+Math.abs(l)-1];for(var v=0;v<t.width;v++)h[(p+e)*o+v+n]=t.data[p*t.width+v];for(var m=t.width;m<t.width+n;m++)h[(p+e)*o+m+n]=t.data[p*t.width+2*t.width-m-1]}for(var w=t.height;w<t.height+e;w++){for(var g=-n;g<0;g++)h[(w+e)*o+g+n]=t.data[(2*t.height-w-1)*t.width+Math.abs(g)-1];for(var y=0;y<t.width;y++)h[(w+e)*o+y+n]=t.data[(2*t.height-w-1)*t.width+y];for(var b=t.width;b<t.width+n;b++)h[(w+e)*o+b+n]=t.data[(2*t.height-w-1)*t.width+2*t.width-b-1]}return{data:h,width:o,height:a}}function u(t,i){var r=d(i,2),e=r[0],n=r[1];return t.height>=e&&t.width>=n?f(t,[e,n]):s(h(t,n),e)}var d=function(){function t(t,i){var r=[],e=!0,n=!1,o=void 0;try{for(var a,h=t[Symbol.iterator]();!(e=(a=h.next()).done)&&(r.push(a.value),!i||r.length!==i);e=!0);}catch(t){n=!0,o=t}finally{try{!e&&h.return&&h.return()}finally{if(n)throw o}}return r}return function(i,r){if(Array.isArray(i))return i;if(Symbol.iterator in Object(i))return t(i,r);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),c=r(20),p=c.mod;t.exports={padarray:u}},function(t,i){function r(t,i,r,e,n){for(var o=t.data,a=t.width,h=new Array(n*r),s=0;s<r;s++)for(var f=0;f<n;f++)h[s*n+f]=o[(e+s)*a+i+f];return{data:h,width:n,height:r}}t.exports={sub:r}},function(t,i,r){function e(t){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t;return o(t,i,0)}var n=r(19),o=n.numbers;t.exports={zeros:e}},function(t,i,r){function e(t){if(Object.keys(t).forEach(function(t){if(!(t in U))throw new Error('"'+t+'" is not a valid option')}),"k1"in t&&("number"!=typeof t.k1||t.k1<0))throw new Error("Invalid k1 value. Default is "+U.k1);if("k2"in t&&("number"!=typeof t.k2||t.k2<0))throw new Error("Invalid k2 value. Default is "+U.k2);if(!(t.ssim in P))throw new Error("Invalid ssim option (use: "+Object.keys(P).join(", ")+")")}function n(t){return new d.Promise(function(i){var r=Object.assign({},U,t);e(r),i(r)})}function o(t){var i=c(t,3),r=i[0],e=i[1],n=i[2];if(r.width!==e.width||r.height!==e.height)throw new Error("Image dimensions do not match");return[r,e,n]}function a(t){var i=c(t,3),r=i[0],e=i[1],n=i[2];return[m(r),m(e),n]}function h(t){var i=c(t,3),r=i[0],e=i[1],n=i[2],o=j([r,e],n);return[o[0],o[1],n]}function s(t){var i=c(t,3),r=i[0],e=i[1],n=i[2];return P[n.ssim](r,e,n)}function f(t,i){if(!t)throw new Error("Missing image parameter");return"fast"===i.downsample?l(t,d.Promise,i.maxSize):l(t,d.Promise)}function u(t,i,r){return d.Promise.all([f(t,r),f(i,r)]).then(function(t){return[t[0],t[1],r]})}function d(t,i,r){var e=(new Date).getTime();return n(r).then(function(r){return u(t,i,r)}).then(o).then(a).then(h).then(s).then(function(t){return{ssim_map:t,mssim:g(t),performance:(new Date).getTime()-e}})}var c=function(){function t(t,i){var r=[],e=!0,n=!1,o=void 0;try{for(var a,h=t[Symbol.iterator]();!(e=(a=h.next()).done)&&(r.push(a.value),!i||r.length!==i);e=!0);}catch(t){n=!0,o=t}finally{try{!e&&h.return&&h.return()}finally{if(n)throw o}}return r}return function(i,r){if(Array.isArray(i))return i;if(Symbol.iterator in Object(i))return t(i,r);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),p=r(64),l=p.readpixels,v=r(1),m=v.rgb2gray,w=r(0),g=w.mean2d,y=r(65),b=y.ssim,x=r(63),I=x.originalSsim,E=r(55),S=E.bezkrovnySsim,M=r(56),j=M.downsample,U=r(68),k=r(67),z=k.version,A=r(54),P={fast:b,original:I,bezkrovny:S};d.Promise=this.Promise||A,d.ssim=d,d.version=z,t.exports=d},function(t,i,r){var e=r(8);e(e.S+e.F,"Object",{assign:r(39)})},function(t,i,r){var e=r(15),n=r(12);r(44)("keys",function(){return function(t){return n(e(t))}})},function(t,i,r){var e=r(30),n=r(29);t.exports={encode:e,decode:n}},function(t,i){function r(t,i){if(this.pos=0,this.buffer=t,this.is_with_alpha=!!i,this.flag=this.buffer.toString("utf-8",0,this.pos+=2),"BM"!=this.flag)throw new Error("Invalid BMP File");this.parseHeader(),this.parseBGR()}r.prototype.parseHeader=function(){if(this.fileSize=this.buffer.readUInt32LE(this.pos),this.pos+=4,this.reserved=this.buffer.readUInt32LE(this.pos),this.pos+=4,this.offset=this.buffer.readUInt32LE(this.pos),this.pos+=4,this.headerSize=this.buffer.readUInt32LE(this.pos),this.pos+=4,this.width=this.buffer.readUInt32LE(this.pos),this.pos+=4,this.height=this.buffer.readUInt32LE(this.pos),this.pos+=4,this.planes=this.buffer.readUInt16LE(this.pos),this.pos+=2,this.bitPP=this.buffer.readUInt16LE(this.pos),this.pos+=2,this.compress=this.buffer.readUInt32LE(this.pos),this.pos+=4,this.rawSize=this.buffer.readUInt32LE(this.pos),this.pos+=4,this.hr=this.buffer.readUInt32LE(this.pos),this.pos+=4,this.vr=this.buffer.readUInt32LE(this.pos),this.pos+=4,this.colors=this.buffer.readUInt32LE(this.pos),this.pos+=4,this.importantColors=this.buffer.readUInt32LE(this.pos),this.pos+=4,16===this.bitPP&&this.is_with_alpha&&(this.bitPP=15),this.bitPP<15){var t=0===this.colors?1<<this.bitPP:this.colors;this.palette=new Array(t);for(var i=0;i<t;i++){var r=this.buffer.readUInt8(this.pos++),e=this.buffer.readUInt8(this.pos++),n=this.buffer.readUInt8(this.pos++),o=this.buffer.readUInt8(this.pos++);this.palette[i]={red:n,green:e,blue:r,quad:o}}}},r.prototype.parseBGR=function(){this.pos=this.offset;try{var t="bit"+this.bitPP,i=this.width*this.height*4;this.data=new Buffer(i),this[t]()}catch(t){console.log("bit decode error:"+t)}},r.prototype.bit1=function(){for(var t=Math.ceil(this.width/8),i=t%4,r=this.height-1;r>=0;r--){for(var e=0;e<t;e++)for(var n=this.buffer.readUInt8(this.pos++),o=r*this.width*4+8*e*4,a=0;a<8&&8*e+a<this.width;a++){var h=this.palette[n>>7-a&1];this.data[o+4*a]=h.blue,this.data[o+4*a+1]=h.green,this.data[o+4*a+2]=h.red,this.data[o+4*a+3]=255}0!=i&&(this.pos+=4-i)}},r.prototype.bit4=function(){for(var t=Math.ceil(this.width/2),i=t%4,r=this.height-1;r>=0;r--){for(var e=0;e<t;e++){var n=this.buffer.readUInt8(this.pos++),o=r*this.width*4+2*e*4,a=n>>4,h=15&n,s=this.palette[a];if(this.data[o]=s.blue,this.data[o+1]=s.green,this.data[o+2]=s.red,this.data[o+3]=255,2*e+1>=this.width)break;s=this.palette[h],this.data[o+4]=s.blue,this.data[o+4+1]=s.green,this.data[o+4+2]=s.red,this.data[o+4+3]=255}0!=i&&(this.pos+=4-i)}},r.prototype.bit8=function(){for(var t=this.width%4,i=this.height-1;i>=0;i--){for(var r=0;r<this.width;r++){var e=this.buffer.readUInt8(this.pos++),n=i*this.width*4+4*r;if(e<this.palette.length){var o=this.palette[e];this.data[n]=o.blue,this.data[n+1]=o.green,this.data[n+2]=o.red,this.data[n+3]=255}else this.data[n]=255,this.data[n+1]=255,this.data[n+2]=255,this.data[n+3]=255}0!=t&&(this.pos+=4-t)}},r.prototype.bit15=function(){for(var t=this.width%3,i=parseInt("11111",2),r=i,e=this.height-1;e>=0;e--){for(var n=0;n<this.width;n++){var o=this.buffer.readUInt16LE(this.pos);this.pos+=2;var a=(o&r)/r*255|0,h=(o>>5&r)/r*255|0,s=(o>>10&r)/r*255|0,f=o>>15?255:0,u=e*this.width*4+4*n;this.data[u]=s,this.data[u+1]=h,this.data[u+2]=a,this.data[u+3]=f}this.pos+=t}},r.prototype.bit16=function(){for(var t=this.width%3,i=parseInt("11111",2),r=i,e=parseInt("111111",2),n=e,o=this.height-1;o>=0;o--){for(var a=0;a<this.width;a++){var h=this.buffer.readUInt16LE(this.pos);this.pos+=2;var s=255,f=(h&r)/r*255|0,u=(h>>5&n)/n*255|0,d=(h>>11)/r*255|0,c=o*this.width*4+4*a;this.data[c]=d,this.data[c+1]=u,this.data[c+2]=f,this.data[c+3]=s}this.pos+=t}},r.prototype.bit24=function(){for(var t=this.height-1;t>=0;t--){for(var i=0;i<this.width;i++){var r=this.buffer.readUInt8(this.pos++),e=this.buffer.readUInt8(this.pos++),n=this.buffer.readUInt8(this.pos++),o=t*this.width*4+4*i;this.data[o]=n,this.data[o+1]=e,this.data[o+2]=r,this.data[o+3]=255}this.pos+=this.width%4}},r.prototype.bit32=function(){for(var t=this.height-1;t>=0;t--){for(var i=0;i<this.width;i++){var r=this.buffer.readUInt8(this.pos++),e=this.buffer.readUInt8(this.pos++),n=this.buffer.readUInt8(this.pos++),o=this.buffer.readUInt8(this.pos++),a=t*this.width*4+4*i;this.data[a]=n,this.data[a+1]=e,this.data[a+2]=r,this.data[a+3]=o}this.pos+=this.width%4}},r.prototype.getData=function(){return this.data},t.exports=function(t){var i=new r(t);return{data:i.getData(),width:i.width,height:i.height}}},function(t,i){function r(t){this.buffer=t.data,this.width=t.width,this.height=t.height,this.extraBytes=this.width%4,this.rgbSize=this.height*(3*this.width+this.extraBytes),this.headerInfoSize=40,this.data=[],this.flag="BM",this.reserved=0,this.offset=54,this.fileSize=this.rgbSize+this.offset,this.planes=1,this.bitPP=24,this.compress=0,this.hr=0,this.vr=0,this.colors=0,this.importantColors=0}r.prototype.encode=function(){var t=new Buffer(this.offset+this.rgbSize);this.pos=0,t.write(this.flag,this.pos,2),this.pos+=2,t.writeUInt32LE(this.fileSize,this.pos),this.pos+=4,t.writeUInt32LE(this.reserved,this.pos),this.pos+=4,t.writeUInt32LE(this.offset,this.pos),this.pos+=4,t.writeUInt32LE(this.headerInfoSize,this.pos),this.pos+=4,t.writeUInt32LE(this.width,this.pos),this.pos+=4,t.writeUInt32LE(this.height,this.pos),this.pos+=4,t.writeUInt16LE(this.planes,this.pos),this.pos+=2,t.writeUInt16LE(this.bitPP,this.pos),this.pos+=2,t.writeUInt32LE(this.compress,this.pos),this.pos+=4,t.writeUInt32LE(this.rgbSize,this.pos),this.pos+=4,t.writeUInt32LE(this.hr,this.pos),this.pos+=4,t.writeUInt32LE(this.vr,this.pos),this.pos+=4,t.writeUInt32LE(this.colors,this.pos),this.pos+=4,t.writeUInt32LE(this.importantColors,this.pos),this.pos+=4;for(var i=0,r=3*this.width+this.extraBytes,e=this.height-1;e>=0;e--){for(var n=0;n<this.width;n++){var o=this.pos+e*r+3*n;t[o+2]=this.buffer[i++],t[o+1]=this.buffer[i++],t[o]=this.buffer[i++],i++}if(this.extraBytes>0){var a=this.pos+e*r+3*this.width;t.fill(0,a,a+this.extraBytes)}}return t},t.exports=function(t,i){"undefined"==typeof i&&(i=100);var e=new r(t),n=e.encode();return{data:n,width:t.width,height:t.height}}},function(t,i){t.exports=function(t){if("function"!=typeof t)throw TypeError(t+" is not a function!");return t}},function(t,i,r){var e=r(6);t.exports=function(t){if(!e(t))throw TypeError(t+" is not an object!");return t}},function(t,i,r){var e=r(14),n=r(50),o=r(49);t.exports=function(t){return function(i,r,a){var h,s=e(i),f=n(s.length),u=o(a,f);if(t&&r!=r){for(;f>u;)if(h=s[u++],h!=h)return!0}else for(;f>u;u++)if((t||u in s)&&s[u]===r)return t||u||0;return!t&&-1}}},function(t,i){var r={}.toString;t.exports=function(t){return r.call(t).slice(8,-1)}},function(t,i,r){var e=r(31);t.exports=function(t,i,r){if(e(t),void 0===i)return t;switch(r){case 1:return function(r){return t.call(i,r)};case 2:return function(r,e){return t.call(i,r,e)};case 3:return function(r,e,n){return t.call(i,r,e,n)}}return function(){return t.apply(i,arguments)}}},function(t,i,r){var e=r(6),n=r(3).document,o=e(n)&&e(n.createElement);t.exports=function(t){return o?n.createElement(t):{}}},function(t,i){t.exports="constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf".split(",")},function(t,i,r){t.exports=!r(5)&&!r(2)(function(){return 7!=Object.defineProperty(r(36)("div"),"a",{get:function(){return 7}}).a})},function(t,i,r){"use strict";var e=r(12),n=r(41),o=r(43),a=r(15),h=r(11),s=Object.assign;t.exports=!s||r(2)(function(){var t={},i={},r=Symbol(),e="abcdefghijklmnopqrst";return t[r]=7,e.split("").forEach(function(t){i[t]=t}),7!=s({},t)[r]||Object.keys(s({},i)).join("")!=e})?function(t,i){for(var r=a(t),s=arguments.length,f=1,u=n.f,d=o.f;s>f;)for(var c,p=h(arguments[f++]),l=u?e(p).concat(u(p)):e(p),v=l.length,m=0;v>m;)d.call(p,c=l[m++])&&(r[c]=p[c]);return r}:s},function(t,i,r){var e=r(32),n=r(38),o=r(51),a=Object.defineProperty;i.f=r(5)?Object.defineProperty:function(t,i,r){if(e(t),i=o(i,!0),e(r),n)try{return a(t,i,r)}catch(t){}if("get"in r||"set"in r)throw TypeError("Accessors not supported!");return"value"in r&&(t[i]=r.value),t}},function(t,i){i.f=Object.getOwnPropertySymbols},function(t,i,r){var e=r(9),n=r(14),o=r(33)(!1),a=r(47)("IE_PROTO");t.exports=function(t,i){var r,h=n(t),s=0,f=[];for(r in h)r!=a&&e(h,r)&&f.push(r);for(;i.length>s;)e(h,r=i[s++])&&(~o(f,r)||f.push(r));return f}},function(t,i){i.f={}.propertyIsEnumerable},function(t,i,r){var e=r(8),n=r(4),o=r(2);t.exports=function(t,i){var r=(n.Object||{})[t]||Object[t],a={};a[t]=i(r),e(e.S+e.F*o(function(){r(1)}),"Object",a)}},function(t,i){t.exports=function(t,i){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:i}}},function(t,i,r){var e=r(3),n=r(10),o=r(9),a=r(16)("src"),h="toString",s=Function[h],f=(""+s).split(h);r(4).inspectSource=function(t){return s.call(t)},(t.exports=function(t,i,r,h){var s="function"==typeof r;s&&(o(r,"name")||n(r,"name",i)),t[i]!==r&&(s&&(o(r,a)||n(r,a,t[i]?""+t[i]:f.join(String(i)))),t===e?t[i]=r:h?t[i]?t[i]=r:n(t,i,r):(delete t[i],n(t,i,r)))})(Function.prototype,h,function(){return"function"==typeof this&&this[a]||s.call(this)})},function(t,i,r){var e=r(48)("keys"),n=r(16);t.exports=function(t){return e[t]||(e[t]=n(t))}},function(t,i,r){var e=r(3),n="__core-js_shared__",o=e[n]||(e[n]={});t.exports=function(t){return o[t]||(o[t]={})}},function(t,i,r){var e=r(13),n=Math.max,o=Math.min;t.exports=function(t,i){return t=e(t),t<0?n(t+i,0):o(t,i)}},function(t,i,r){var e=r(13),n=Math.min;t.exports=function(t){return t>0?n(e(t),9007199254740991):0}},function(t,i,r){var e=r(6);t.exports=function(t,i){if(!e(t))return t;var r,n;if(i&&"function"==typeof(r=t.toString)&&!e(n=r.call(t)))return n;if("function"==typeof(r=t.valueOf)&&!e(n=r.call(t)))return n;if(!i&&"function"==typeof(r=t.toString)&&!e(n=r.call(t)))return n;throw TypeError("Can't convert object to primitive value")}},function(t,i){"use strict";var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t};t.exports=function(t){var i=new Uint8Array(t);if(!(i&&i.length>1))return null;if(255===i[0]&&216===i[1]&&255===i[2])return{ext:"jpg",mime:"image/jpeg"};if(137===i[0]&&80===i[1]&&78===i[2]&&71===i[3])return{ext:"png",mime:"image/png"};if(71===i[0]&&73===i[1]&&70===i[2])return{ext:"gif",mime:"image/gif"};if(87===i[8]&&69===i[9]&&66===i[10]&&80===i[11])return{ext:"webp",mime:"image/webp"};if(70===i[0]&&76===i[1]&&73===i[2]&&70===i[3])return{ext:"flif",mime:"image/flif"};if((73===i[0]&&73===i[1]&&42===i[2]&&0===i[3]||77===i[0]&&77===i[1]&&0===i[2]&&42===i[3])&&67===i[8]&&82===i[9])return{ext:"cr2",mime:"image/x-canon-cr2"};if(73===i[0]&&73===i[1]&&42===i[2]&&0===i[3]||77===i[0]&&77===i[1]&&0===i[2]&&42===i[3])return{ext:"tif",mime:"image/tiff"};if(66===i[0]&&77===i[1])return{ext:"bmp",mime:"image/bmp"};if(73===i[0]&&73===i[1]&&188===i[2])return{ext:"jxr",mime:"image/vnd.ms-photo"};if(56===i[0]&&66===i[1]&&80===i[2]&&83===i[3])return{ext:"psd",mime:"image/vnd.adobe.photoshop"};if(80===i[0]&&75===i[1]&&3===i[2]&&4===i[3]&&109===i[30]&&105===i[31]&&109===i[32]&&101===i[33]&&116===i[34]&&121===i[35]&&112===i[36]&&101===i[37]&&97===i[38]&&112===i[39]&&112===i[40]&&108===i[41]&&105===i[42]&&99===i[43]&&97===i[44]&&116===i[45]&&105===i[46]&&111===i[47]&&110===i[48]&&47===i[49]&&101===i[50]&&112===i[51]&&117===i[52]&&98===i[53]&&43===i[54]&&122===i[55]&&105===i[56]&&112===i[57])return{ext:"epub",mime:"application/epub+zip"};if(80===i[0]&&75===i[1]&&3===i[2]&&4===i[3]&&77===i[30]&&69===i[31]&&84===i[32]&&65===i[33]&&45===i[34]&&73===i[35]&&78===i[36]&&70===i[37]&&47===i[38]&&109===i[39]&&111===i[40]&&122===i[41]&&105===i[42]&&108===i[43]&&108===i[44]&&97===i[45]&&46===i[46]&&114===i[47]&&115===i[48]&&97===i[49])return{ext:"xpi",mime:"application/x-xpinstall"};if(!(80!==i[0]||75!==i[1]||3!==i[2]&&5!==i[2]&&7!==i[2]||4!==i[3]&&6!==i[3]&&8!==i[3]))return{ext:"zip",mime:"application/zip"};if(117===i[257]&&115===i[258]&&116===i[259]&&97===i[260]&&114===i[261])return{ext:"tar",mime:"application/x-tar"};if(82===i[0]&&97===i[1]&&114===i[2]&&33===i[3]&&26===i[4]&&7===i[5]&&(0===i[6]||1===i[6]))return{ext:"rar",mime:"application/x-rar-compressed"};if(31===i[0]&&139===i[1]&&8===i[2])return{ext:"gz",mime:"application/gzip"};if(66===i[0]&&90===i[1]&&104===i[2])return{ext:"bz2",mime:"application/x-bzip2"};if(55===i[0]&&122===i[1]&&188===i[2]&&175===i[3]&&39===i[4]&&28===i[5])return{ext:"7z",mime:"application/x-7z-compressed"};if(120===i[0]&&1===i[1])return{ext:"dmg",mime:"application/x-apple-diskimage"};if(0===i[0]&&0===i[1]&&0===i[2]&&(24===i[3]||32===i[3])&&102===i[4]&&116===i[5]&&121===i[6]&&112===i[7]||51===i[0]&&103===i[1]&&112===i[2]&&53===i[3]||0===i[0]&&0===i[1]&&0===i[2]&&28===i[3]&&102===i[4]&&116===i[5]&&121===i[6]&&112===i[7]&&109===i[8]&&112===i[9]&&52===i[10]&&50===i[11]&&109===i[16]&&112===i[17]&&52===i[18]&&49===i[19]&&109===i[20]&&112===i[21]&&52===i[22]&&50===i[23]&&105===i[24]&&115===i[25]&&111===i[26]&&109===i[27]||0===i[0]&&0===i[1]&&0===i[2]&&28===i[3]&&102===i[4]&&116===i[5]&&121===i[6]&&112===i[7]&&105===i[8]&&115===i[9]&&111===i[10]&&109===i[11]||0===i[0]&&0===i[1]&&0===i[2]&&28===i[3]&&102===i[4]&&116===i[5]&&121===i[6]&&112===i[7]&&109===i[8]&&112===i[9]&&52===i[10]&&50===i[11]&&0===i[12]&&0===i[13]&&0===i[14]&&0===i[15])return{ext:"mp4",mime:"video/mp4"};if(0===i[0]&&0===i[1]&&0===i[2]&&28===i[3]&&102===i[4]&&116===i[5]&&121===i[6]&&112===i[7]&&77===i[8]&&52===i[9]&&86===i[10])return{ext:"m4v",mime:"video/x-m4v"};if(77===i[0]&&84===i[1]&&104===i[2]&&100===i[3])return{ext:"mid",mime:"audio/midi"};if(26===i[0]&&69===i[1]&&223===i[2]&&163===i[3]){var e=function(){var t=i.subarray(4,4100),e=t.findIndex(function(t,i,r){return 66===r[i]&&130===r[i+1]});if(e>=0){var n=function(){var i=e+3,r=function(r){return Array.from(r).every(function(r,e){return t[i+e]===r.charCodeAt(0)})};return r("matroska")?{v:{v:{ext:"mkv",mime:"video/x-matroska"}}}:r("webm")?{v:{v:{ext:"webm",mime:"video/webm"}}}:void 0}();if("object"===("undefined"==typeof n?"undefined":r(n)))return n.v}}();if("object"===("undefined"==typeof e?"undefined":r(e)))return e.v}return 0===i[0]&&0===i[1]&&0===i[2]&&20===i[3]&&102===i[4]&&116===i[5]&&121===i[6]&&112===i[7]?{ext:"mov",mime:"video/quicktime"}:82===i[0]&&73===i[1]&&70===i[2]&&70===i[3]&&65===i[8]&&86===i[9]&&73===i[10]?{ext:"avi",mime:"video/x-msvideo"}:48===i[0]&&38===i[1]&&178===i[2]&&117===i[3]&&142===i[4]&&102===i[5]&&207===i[6]&&17===i[7]&&166===i[8]&&217===i[9]?{ext:"wmv",mime:"video/x-ms-wmv"}:0===i[0]&&0===i[1]&&1===i[2]&&"b"===i[3].toString(16)[0]?{ext:"mpg",mime:"video/mpeg"}:73===i[0]&&68===i[1]&&51===i[2]||255===i[0]&&251===i[1]?{ext:"mp3",mime:"audio/mpeg"}:102===i[4]&&116===i[5]&&121===i[6]&&112===i[7]&&77===i[8]&&52===i[9]&&65===i[10]||77===i[0]&&52===i[1]&&65===i[2]&&32===i[3]?{ext:"m4a",mime:"audio/m4a"}:79===i[28]&&112===i[29]&&117===i[30]&&115===i[31]&&72===i[32]&&101===i[33]&&97===i[34]&&100===i[35]?{ext:"opus",mime:"audio/opus"}:79===i[0]&&103===i[1]&&103===i[2]&&83===i[3]?{ext:"ogg",mime:"audio/ogg"}:102===i[0]&&76===i[1]&&97===i[2]&&67===i[3]?{ext:"flac",mime:"audio/x-flac"}:82===i[0]&&73===i[1]&&70===i[2]&&70===i[3]&&87===i[8]&&65===i[9]&&86===i[10]&&69===i[11]?{ext:"wav",mime:"audio/x-wav"}:35===i[0]&&33===i[1]&&65===i[2]&&77===i[3]&&82===i[4]&&10===i[5]?{ext:"amr",mime:"audio/amr"}:37===i[0]&&80===i[1]&&68===i[2]&&70===i[3]?{ext:"pdf",mime:"application/pdf"}:77===i[0]&&90===i[1]?{ext:"exe",mime:"application/x-msdownload"}:67!==i[0]&&70!==i[0]||87!==i[1]||83!==i[2]?123===i[0]&&92===i[1]&&114===i[2]&&116===i[3]&&102===i[4]?{ext:"rtf",mime:"application/rtf"}:119===i[0]&&79===i[1]&&70===i[2]&&70===i[3]&&(0===i[4]&&1===i[5]&&0===i[6]&&0===i[7]||79===i[4]&&84===i[5]&&84===i[6]&&79===i[7])?{ext:"woff",mime:"application/font-woff"}:119===i[0]&&79===i[1]&&70===i[2]&&50===i[3]&&(0===i[4]&&1===i[5]&&0===i[6]&&0===i[7]||79===i[4]&&84===i[5]&&84===i[6]&&79===i[7])?{ext:"woff2",mime:"application/font-woff"}:76===i[34]&&80===i[35]&&(0===i[8]&&0===i[9]&&1===i[10]||1===i[8]&&0===i[9]&&2===i[10]||2===i[8]&&0===i[9]&&2===i[10])?{ext:"eot",mime:"application/octet-stream"}:0===i[0]&&1===i[1]&&0===i[2]&&0===i[3]&&0===i[4]?{ext:"ttf",mime:"application/font-sfnt"}:79===i[0]&&84===i[1]&&84===i[2]&&79===i[3]&&0===i[4]?{ext:"otf",mime:"application/font-sfnt"}:0===i[0]&&0===i[1]&&1===i[2]&&0===i[3]?{ext:"ico",mime:"image/x-icon"}:70===i[0]&&76===i[1]&&86===i[2]&&1===i[3]?{ext:"flv",mime:"video/x-flv"}:37===i[0]&&33===i[1]?{ext:"ps",mime:"application/postscript"}:253===i[0]&&55===i[1]&&122===i[2]&&88===i[3]&&90===i[4]&&0===i[5]?{ext:"xz",mime:"application/x-xz"}:83===i[0]&&81===i[1]&&76===i[2]&&105===i[3]?{ext:"sqlite",mime:"application/x-sqlite3"}:78===i[0]&&69===i[1]&&83===i[2]&&26===i[3]?{ext:"nes",mime:"application/x-nintendo-nes-rom"}:67===i[0]&&114===i[1]&&50===i[2]&&52===i[3]?{ext:"crx",mime:"application/x-google-chrome-extension"}:77===i[0]&&83===i[1]&&67===i[2]&&70===i[3]||73===i[0]&&83===i[1]&&99===i[2]&&40===i[3]?{ext:"cab",mime:"application/vnd.ms-cab-compressed"}:33===i[0]&&60===i[1]&&97===i[2]&&114===i[3]&&99===i[4]&&104===i[5]&&62===i[6]&&10===i[7]&&100===i[8]&&101===i[9]&&98===i[10]&&105===i[11]&&97===i[12]&&110===i[13]&&45===i[14]&&98===i[15]&&105===i[16]&&110===i[17]&&97===i[18]&&114===i[19]&&121===i[20]?{ext:"deb",mime:"application/x-deb"}:33===i[0]&&60===i[1]&&97===i[2]&&114===i[3]&&99===i[4]&&104===i[5]&&62===i[6]?{ext:"ar",mime:"application/x-unix-archive"}:237===i[0]&&171===i[1]&&238===i[2]&&219===i[3]?{ext:"rpm",mime:"application/x-rpm"}:31===i[0]&&160===i[1]||31===i[0]&&157===i[1]?{ext:"Z",mime:"application/x-compress"}:76===i[0]&&90===i[1]&&73===i[2]&&80===i[3]?{ext:"lz",mime:"application/x-lzip"}:208===i[0]&&207===i[1]&&17===i[2]&&224===i[3]&&161===i[4]&&177===i[5]&&26===i[6]&&225===i[7]?{ext:"msi",mime:"application/x-msi"}:6===i[0]&&14===i[1]&&43===i[2]&&52===i[3]&&2===i[4]&&5===i[5]&&1===i[6]&&1===i[7]&&13===i[8]&&1===i[9]&&2===i[10]&&1===i[11]&&1===i[12]&&2===i[13]?{ext:"mxf",mime:"application/mxf"}:null:{ext:"swf",mime:"application/x-shockwave-flash"}}},function(t,i,r){"use strict";var e=r(52),n=new Set(["jpg","png","gif","webp","tif","bmp","jxr","psd"]);t.exports=function(t){var i=e(t);return n.has(i&&i.ext)?i:null}},function(t,i,r){var e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t};!function(){function i(t){global.setImmediate?setImmediate(t):global.importScripts?setTimeout(t):(n++,o[n]=t,global.postMessage(n,"*"))}function r(t){"use strict";function n(t,i,r,n){if(2==f)return n();if("object"!=("undefined"==typeof u?"undefined":e(u))&&"function"!=typeof u||"function"!=typeof t)n();else try{var o=0;t.call(u,function(t){o++||(u=t,i())},function(t){o++||(u=t,r())})}catch(t){u=t,r()}}function o(){var t;try{t=u&&u.then}catch(t){return u=t,f=2,o()}n(t,function(){f=1,o()},function(){f=2,o()},function(){try{1==f&&"function"==typeof a?u=a(u):2==f&&"function"==typeof h&&(u=h(u),f=1)}catch(t){return u=t,c()}u==s?(u=TypeError(),c()):n(t,function(){c(3)},c,function(){c(1==f&&3)})})}if("function"!=typeof t&&void 0!=t)throw TypeError();if("object"!=e(this)||this&&this.then)throw TypeError();var a,h,s=this,f=0,u=0,d=[];s.promise=s,s.resolve=function(t){ | ||
return a=s.fn,h=s.er,f||(u=t,f=1,i(o)),s},s.reject=function(t){return a=s.fn,h=s.er,f||(u=t,f=2,i(o)),s},s._d=1,s.then=function(t,i){if(1!=this._d)throw TypeError();var e=new r;return e.fn=t,e.er=i,3==f?e.resolve(u):4==f?e.reject(u):d.push(e),e},s.catch=function(t){return s.then(null,t)};var c=function(t){f=t||4,d.map(function(t){3==f&&t.resolve(u)||t.reject(u)})};try{"function"==typeof t&&t(s.resolve,s.reject)}catch(t){s.reject(t)}return s}global=this;var n=1,o={},a=!1;global.setImmediate||global.addEventListener("message",function(t){if(t.source==global)if(a)i(o[t.data]);else{a=!0;try{o[t.data]()}catch(t){}delete o[t.data],a=!1}}),r.resolve=function(t){if(1!=this._d)throw TypeError();return t instanceof r?t:new r(function(i){i(t)})},r.reject=function(t){if(1!=this._d)throw TypeError();return new r(function(i,r){r(t)})},r.all=function(t){function i(r,n){if(n)return e.resolve(n);if(r)return e.reject(r);var o=t.reduce(function(t,i){return i&&i.then?t+1:t},0);0==o&&e.resolve(t),t.map(function(r,e){r&&r.then&&r.then(function(r){return t[e]=r,i(),r},i)})}if(1!=this._d)throw TypeError();if(!(t instanceof Array))return r.reject(TypeError());var e=new r;return i(),e},r.race=function(t){function i(r,n){if(n)return e.resolve(n);if(r)return e.reject(r);var o=t.reduce(function(t,i){return i&&i.then?t+1:t},0);0==o&&e.resolve(t),t.map(function(t,r){t&&t.then&&t.then(function(t){i(null,t)},i)})}if(1!=this._d)throw TypeError();if(!(t instanceof Array))return r.reject(TypeError());if(0==t.length)return new r;var e=new r;return i(),e},r._d=1,t.exports=r}()},function(t,i,r){function e(t,i,r){for(var e=r.windowSize,o=Math.floor(t.width/e),a=Math.floor(t.height/e),h=new Array(o*a),s=0,f=0;f<t.height;f+=e)for(var d=0;d<t.width;d+=e){var c=Math.min(e,t.width-d),p=Math.min(e,t.height-f),l=u(t,d,p,f,c),v=u(i,d,p,f,c);h[s++]=n(l,v,r)}return{data:h,width:o,height:a}}function n(t,i,r){var e=t.data,n=i.data,o=r.bitDepth,f=r.k1,u=r.k2,d=Math.pow(2,o)-1,c=Math.pow(f*d,2),p=Math.pow(u*d,2),l=a(e),v=a(n),m=h(e,l),w=h(n,v),g=s(e,n,l,v),y=(2*l*v+c)*(2*g+p),b=Math.pow(l,2)+Math.pow(v,2)+c,x=m+w+p;return y/(b*x)}var o=r(0),a=o.average,h=o.variance,s=o.covariance,f=r(1),u=f.sub;t.exports={bezkrovnySsim:e}},function(t,i,r){function e(t,i,r){var e=u(t,i,"symmetric","same");return c(e,[0,r,e.height],[0,r,e.width])}function n(t,i){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:256,n=Math.min(t.width,i.height)/r,o=Math.round(n);if(o>1){var a=d(o);a=h(a,s(a)),t=e(t,a,o),i=e(i,a,o)}return[t,i]}function o(t,i){return"original"===i.downsample?n(t[0],t[1],i.maxSize):t}var a=r(0),h=a.divide2d,s=a.sum2d,f=r(1),u=f.imfilter,d=f.ones,c=f.skip2d;t.exports={downsample:o}},function(t,i,r){function e(t){for(var i=2*t+1,r=new Array(Math.pow(i,2)),e=0;e<i;e++)for(var n=0;n<i;n++)r[e*i+n]=Math.pow(e-t,2)+Math.pow(n-t,2);return{data:r,width:i,height:i}}function n(t,i){for(var r=t.data,e=t.width,n=t.height,o=new Array(r.length),a=0;a<r.length;a++)o[a]=Math.exp(-r[a]/(2*Math.pow(i,2)));return{data:o,width:e,height:n}}function o(){var t=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"gaussian",arguments.length>1&&void 0!==arguments[1]?arguments[1]:3),i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1.5;t=(t-1)/2;var r=e(t),o=n(r,i),a=h(o);return s(o,a)}var a=r(0),h=a.sum2d,s=a.divide2d;t.exports={fspecial:o}},function(t,i,r){function e(t,i,r,e){if(t=f(t,d([i/2,r/2]),e),0===h(i,2)&&(t.data=t.data.slice(0,-t.width),t.height--),0===h(r,2)){for(var n=[],o=0;o<t.data.length;o++)(o+1)%t.width!==0&&n.push(t.data[o]);t.data=n,t.width--}return t}function n(t){return"same"===t&&(t="valid"),t}function o(t,i){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"symmetric",o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"same";return t=e(t,i.width,i.height,r),o=n(o),p(i,t,o)}var a=r(20),h=a.mod,s=r(22),f=s.padarray,u=r(0),d=u.floor,c=r(18),p=c.filter2;t.exports={imfilter:o}},function(t,i){function r(t){for(var i=t.data,r=t.width,e=t.height,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,a=2.5066282746310007,h=new Array(i.length),s=0;s<i.length;s++){var f=(i[s]-n)/o;h[s]=Math.exp(-Math.pow(f,2)/2)/(o*a)}return{data:h,width:r,height:e}}t.exports={normpdf:r}},function(t,i){function r(t,i,r){return Math.round(.29894*t+.58704*i+.11402*r)}function e(t){for(var i=t.data,e=t.width,n=t.height,o=new Array(e*n),a=0;a<n;a++)for(var h=0;h<e;h++){var s=h+a*e,f=4*s;o[s]=r(i[f],i[f+1],i[f+2],i[f+3])}return{data:o,width:e,height:n}}t.exports={rgb2gray:e}},function(t,i){function r(t,i,r){for(var n=e(i,3),o=n[0],a=n[1],h=n[2],s=e(r,3),f=s[0],u=s[1],d=s[2],c=Math.ceil((d-f)/u),p=Math.ceil((h-o)/a),l=new Array(c*p),v=0;v<p;v++)for(var m=0;m<c;m++){var w=o+v*a,g=f+m*u;l[v*c+m]=t.data[w*t.width+g]}return{data:l,width:c,height:p}}var e=function(){function t(t,i){var r=[],e=!0,n=!1,o=void 0;try{for(var a,h=t[Symbol.iterator]();!(e=(a=h.next()).done)&&(r.push(a.value),!i||r.length!==i);e=!0);}catch(t){n=!0,o=t}finally{try{!e&&h.return&&h.return()}finally{if(n)throw o}}return r}return function(i,r){if(Array.isArray(i))return i;if(Symbol.iterator in Object(i))return t(i,r);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}();t.exports={skip2d:r}},function(t,i){function r(t){for(var i=t.data,r=t.width,e=t.height,n=new Array(r*e),o=0;o<e;o++)for(var a=0;a<r;a++)n[a*e+o]=i[o*r+a];return{data:n,height:r,width:e}}t.exports={transpose:r}},function(t,i,r){function e(t,i,r){var e=p("gaussian",r.windowSize,1.5),n=Math.pow(2,r.bitDepth)-1,d=Math.pow(r.k1*n,2),l=Math.pow(r.k2*n,2);e=a(e,u(e));var v=c(e,t,"valid"),m=c(e,i,"valid"),w=s(v),g=s(m),y=h(v,m),b=s(t),x=s(i),I=f(c(e,b,"valid"),w),E=f(c(e,x,"valid"),g),S=f(c(e,h(t,i),"valid"),y);if(d>0&&l>0){var M=o(h(y,2),d),j=o(h(S,2),l),U=o(o(w,g),d),k=o(o(I,E),l);return a(h(M,j),h(U,k))}var z=h(y,2),A=h(S,2),P=o(w,g),O=o(I,E);return a(h(z,A),h(P,O))}var n=r(0),o=n.add2d,a=n.divide2d,h=n.multiply2d,s=n.square2d,f=n.subtract2d,u=n.sum2d,d=r(1),c=d.filter2,p=d.fspecial;t.exports={originalSsim:e}},function(t,i,r){function e(t,i){var r=u(t),e=r.ext,n=void 0;if("bmp"===e)n=d.decode(t);else{var o=new f.Image;o.src=t;var a=p(o.width,o.height,i),h=a.width,s=a.height,c=new f(h,s),l=c.getContext("2d");l.drawImage(o,0,0,o.width,o.height,0,0,h,s),n=l.getImageData(0,0,h,s)}return n}function n(t,i){return new i(function(i,r){s.get(t).on("response",function(t){var r=[];t.on("data",function(t){return r.push(t)}),t.on("end",function(){return i(Buffer.concat(r))})}).on("error",r)})}function o(t,i){return new i(function(i,r){h.readFile(t,function(t,e){return t?void r(t):void i(e)})})}function a(t,i){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,a=void 0;return a=Buffer.isBuffer(t)?i.resolve(t):0===t.indexOf("http://")||0===t.indexOf("https://")?n(t,i):o(t,i),a.then(function(t){return e(t,r)})}var h=r(70),s=r(71),f=r(69),u=r(53),d=r(28),c=r(66),p=c.getLimitDimensions;t.exports={readpixels:a}},function(t,i,r){function e(t,i,r){var e=m(n(r.windowSize),0,1.5),h=Math.pow(2,r.bitDepth)-1,s=Math.pow(r.k1*h,2),l=Math.pow(r.k2*h,2);e=f(e,p(e));var g=w(e),y=v(t,e,g,"valid"),b=v(i,e,g,"valid"),x=d(y),I=d(b),E=u(y,b),S=d(t),M=d(i),j=c(v(S,e,g,"valid"),x),U=c(v(M,e,g,"valid"),I),k=c(v(u(t,i),e,g,"valid"),E);return s>0&&l>0?o(E,k,x,I,j,U,s,l):a(E,k,x,I,j,U)}function n(t){for(var i=Math.floor(t/2),r=new Array(2*i+1),e=-i;e<=i;e++)r[e+i]=Math.abs(e);return{data:r,width:r.length,height:1}}function o(t,i,r,e,n,o,a,h){var d=s(u(t,2),a),c=s(u(i,2),h),p=s(s(r,e),a),l=s(s(n,o),h);return f(u(d,c),u(p,l))}function a(t,i,r,e,n,o){var a=u(t,2),h=u(i,2),d=s(r,e),c=s(n,o);return f(u(a,h),u(d,c))}var h=r(0),s=h.add2d,f=h.divide2d,u=h.multiply2d,d=h.square2d,c=h.subtract2d,p=h.sum2d,l=r(1),v=l.conv2,m=l.normpdf,w=l.transpose;t.exports={ssim:e}},function(t,i){function r(t,i,r){if(r&&t>=r&&i>=r){var e=t/i;return e>1?{height:r,width:Math.round(r/e)}:{height:Math.round(r*e),width:r}}return{width:t,height:i}}t.exports={getLimitDimensions:r}},function(t,i){t.exports={type:"deploy",version:"3.0.0"}},function(t,i){t.exports={windowSize:11,k1:.01,k2:.03,bitDepth:8,downsample:"original",ssim:"fast",maxSize:256}},function(i,r){i.exports=t},function(t,i){t.exports=require("fs")},function(t,i){t.exports=require("https")},function(t,i,r){r(27),r(26),t.exports=r(25)}])}); | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
/** | ||
* Implements all ssim-specific logic. | ||
* | ||
* Reproduces the original SSIM matlab scripts. For a direct comparison you may want to check the | ||
* scripts contained within `/assets` | ||
* | ||
* @namespace ssim | ||
*/ | ||
var math_1 = require("./math"); | ||
var matlab_1 = require("./matlab"); | ||
/** | ||
* Generates a SSIM map based on two input image matrices. For images greater than 512 pixels, it | ||
* will downsample by default (unless `options.downsample` is set to falsy). | ||
* | ||
* Images must be a 2-Dimensional grayscale image | ||
* | ||
* This method produces the same exact output than `assets/ssim.m` when running on Matlab. It's | ||
* mathematically equivalent but it is not a line-by-line port. If you want a line-by-line port | ||
* check `originalSsim`. Several performance optimizations have been made here to achieve greater | ||
* performance. | ||
* | ||
* @method ssim | ||
* @param {Matrix} pixels1 - The reference matrix | ||
* @param {Matrix} pixels2 - The second matrix to compare against | ||
* @param {Options} options - The input options parameter | ||
* @returns {Matrix} ssim_map - A matrix containing the map of computed SSIMs | ||
* @public | ||
* @memberOf ssim | ||
*/ | ||
function ssim(pixels1, pixels2, options) { | ||
var w = matlab_1.normpdf(getRange(options.windowSize), 0, 1.5); | ||
var L = Math.pow(2, options.bitDepth) - 1; | ||
var c1 = Math.pow((options.k1 * L), 2); | ||
var c2 = Math.pow((options.k2 * L), 2); | ||
w = math_1.divide2d(w, math_1.sum2d(w)); | ||
var wt = matlab_1.transpose(w); | ||
var μ1 = matlab_1.conv2(pixels1, w, wt, "valid"); | ||
var μ2 = matlab_1.conv2(pixels2, w, wt, "valid"); | ||
var μ1Sq = math_1.square2d(μ1); | ||
var μ2Sq = math_1.square2d(μ2); | ||
var μ12 = math_1.multiply2d(μ1, μ2); | ||
var pixels1Sq = math_1.square2d(pixels1); | ||
var pixels2Sq = math_1.square2d(pixels2); | ||
var σ1Sq = math_1.subtract2d(matlab_1.conv2(pixels1Sq, w, wt, "valid"), μ1Sq); | ||
var σ2Sq = math_1.subtract2d(matlab_1.conv2(pixels2Sq, w, wt, "valid"), μ2Sq); | ||
var σ12 = math_1.subtract2d(matlab_1.conv2(math_1.multiply2d(pixels1, pixels2), w, wt, "valid"), μ12); | ||
if (c1 > 0 && c2 > 0) { | ||
return genSSIM(μ12, σ12, μ1Sq, μ2Sq, σ1Sq, σ2Sq, c1, c2); | ||
} | ||
return genUQI(μ12, σ12, μ1Sq, μ2Sq, σ1Sq, σ2Sq); | ||
} | ||
exports.ssim = ssim; | ||
/** | ||
* Generates a range of distances of size `2n+1` with increments of 1 and centered at 0. | ||
* | ||
* @example `getRange(2) => [2 1 0 1 2] | ||
* @method getRange | ||
* @param {Number} size - The maximum distance from the center | ||
* @returns {Matrix} out - The generated vector | ||
* @private | ||
* @memberOf ssim | ||
*/ | ||
function getRange(size) { | ||
var offset = Math.floor(size / 2); | ||
var data = new Array(offset * 2 + 1); | ||
for (var x = -offset; x <= offset; x++) { | ||
data[x + offset] = Math.abs(x); | ||
} | ||
return { | ||
data: data, | ||
width: data.length, | ||
height: 1 | ||
}; | ||
} | ||
/** | ||
* Generates the ssim_map based on the intermediate values of the convolutions of the input with the | ||
* gaussian filter. | ||
* | ||
* These methods apply when K1 or K2 are not 0 (non UQI) | ||
* | ||
* @method genSSIM | ||
* @param {Matrix} μ12 - The cell-by cell multiplication of both images convolved | ||
* with the gaussian filter | ||
* @param {Matrix} σ12 - The convolution of cell-by cell multiplication of both | ||
* images minus μ12 | ||
* @param {Matrix} μ1Sq - The convolution of image1 with the gaussian filter squared | ||
* @param {Matrix} μ2Sq - The convolution of image2 with the gaussian filter squared | ||
* @param {Matrix} σ1Sq - The convolution of image1^2, minus μ1Sq | ||
* @param {Matrix} σ2Sq - The convolution of image2^2, minus μ2Sq | ||
* @param {Number} c1 - The first stability constant | ||
* @param {Number} c2 - The second stability constant | ||
* @returns {Matrix} ssim_map - The generated map of SSIM values at each window | ||
* @private | ||
* @memberOf ssim | ||
*/ | ||
function genSSIM(μ12, σ12, μ1Sq, μ2Sq, σ1Sq, σ2Sq, c1, c2) { | ||
var num1 = math_1.add2d(math_1.multiply2d(μ12, 2), c1); | ||
var num2 = math_1.add2d(math_1.multiply2d(σ12, 2), c2); | ||
var denom1 = math_1.add2d(math_1.add2d(μ1Sq, μ2Sq), c1); | ||
var denom2 = math_1.add2d(math_1.add2d(σ1Sq, σ2Sq), c2); | ||
return math_1.divide2d(math_1.multiply2d(num1, num2), math_1.multiply2d(denom1, denom2)); | ||
} | ||
/** | ||
* Generates the Universal Quality Index (UQI) ssim_map based on the intermediate values of the | ||
* convolutions of the input with the gaussian filter. | ||
* | ||
* These methods apply when K1 or K2 are 0 (UQI) | ||
* | ||
* @method genUQI | ||
* @param {Matrix} μ12 - The cell-by cell multiplication of both images convolved | ||
* with the gaussian filter | ||
* @param {Matrix} σ12 - The convolution of cell-by cell multiplication of both | ||
* images minus μ12 | ||
* @param {Matrix} μ1Sq - The convolution of image1 with the gaussian filter squared | ||
* @param {Matrix} μ2Sq - The convolution of image2 with the gaussian filter squared | ||
* @param {Matrix} σ1Sq - The convolution of image1^2, minus μ1Sq | ||
* @param {Matrix} σ2Sq - The convolution of image2^2, minus μ2Sq | ||
* @returns {Matrix} ssim_map - The generated map of SSIM values at each window | ||
* @private | ||
* @memberOf ssim | ||
*/ | ||
function genUQI(μ12, σ12, μ1Sq, μ2Sq, σ1Sq, σ2Sq) { | ||
var numerator1 = math_1.multiply2d(μ12, 2); | ||
var numerator2 = math_1.multiply2d(σ12, 2); | ||
var denominator1 = math_1.add2d(μ1Sq, μ2Sq); | ||
var denominator2 = math_1.add2d(σ1Sq, σ2Sq); | ||
return math_1.divide2d(math_1.multiply2d(numerator1, numerator2), math_1.multiply2d(denominator1, denominator2)); | ||
} | ||
//# sourceMappingURL=ssim.js.map |
@@ -1,1 +0,2 @@ | ||
!function(t,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define([],n):"object"==typeof exports?exports.ssim=n():t.ssim=n()}(this,function(){return function(t){function n(e){if(r[e])return r[e].exports;var i=r[e]={i:e,l:!1,exports:{}};return t[e].call(i.exports,i,i.exports,n),i.l=!0,i.exports}var r={};return n.m=t,n.c=r,n.i=function(t){return t},n.d=function(t,n,r){Object.defineProperty(t,n,{configurable:!1,enumerable:!0,get:r})},n.n=function(t){var r=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(r,"a",r),r},n.o=function(t,n){return Object.prototype.hasOwnProperty.call(t,n)},n.p="",n(n.s=67)}([function(t,n){function r(t){return e(t)/t.length}function e(t){for(var n=0,r=0;r<t.length;r++)n+=t[r];return n}function i(t){for(var n=new Array(t.length),r=0;r<t.length;r++)n[r]=Math.floor(t[r]);return n}function o(t){for(var n=t.data,r=0,e=0;e<n.length;e++)r+=n[e];return r}function a(t,n){for(var r=t.data,e=t.width,i=t.height,o=n.data,a=new Array(r.length),u=0;u<i;u++)for(var f=u*e,c=0;c<e;c++)a[f+c]=r[f+c]+o[f+c];return{data:a,width:e,height:i}}function u(t,n){for(var r=t.data,e=t.width,i=t.height,o=n.data,a=new Array(r.length),u=0;u<i;u++)for(var f=u*e,c=0;c<e;c++)a[f+c]=r[f+c]-o[f+c];return{data:a,width:e,height:i}}function f(t,n){for(var r=t.data,e=t.width,i=t.height,o=new Array(r.length),a=0;a<r.length;a++)o[a]=r[a]+n;return{data:o,width:e,height:i}}function c(t,n){return"number"==typeof n?f(t,n):a(t,n)}function h(t,n){return"number"==typeof n?f(t,-n):u(t,n)}function d(t,n){for(var r=t.data,e=t.width,i=t.height,o=new Array(r.length),a=0;a<r.length;a++)o[a]=r[a]/n;return{data:o,width:e,height:i}}function l(t,n){for(var r=t.data,e=t.width,i=t.height,o=n.data,a=new Array(r.length),u=0;u<r.length;u++)a[u]=r[u]/o[u];return{data:a,width:e,height:i}}function s(t,n){return"number"==typeof n?d(t,n):l(t,n)}function v(t,n){for(var r=t.data,e=t.width,i=t.height,o=new Array(r.length),a=0;a<r.length;a++)o[a]=r[a]*n;return{data:o,width:e,height:i}}function p(t,n){for(var r=t.data,e=t.width,i=t.height,o=n.data,a=new Array(r.length),u=0;u<r.length;u++)a[u]=r[u]*o[u];return{data:a,width:e,height:i}}function w(t,n){return"number"==typeof n?v(t,n):p(t,n)}function y(t){return w(t,t)}function m(t){return o(t)/t.data.length}function g(t){for(var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:r(t),e=0,i=t.length;i--;)e+=Math.pow(t[i]-n,2);return e/t.length}function b(t,n){for(var e=arguments.length>2&&void 0!==arguments[2]?arguments[2]:r(t),i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:r(n),o=0,a=t.length;a--;)o+=(t[a]-e)*(n[a]-i);return o/t.length}t.exports={add2d:c,average:r,covariance:b,divide2d:s,floor:i,mean2d:m,multiply2d:w,square2d:y,subtract2d:h,sum:e,sum2d:o,variance:g}},function(t,n,r){var e=r(18),i=e.conv2,o=r(19),a=o.filter2,u=r(55),f=u.fspecial,c=r(56),h=c.imfilter,d=r(57),l=d.normpdf,s=r(22),v=s.ones,p=r(23),w=p.padarray,y=r(58),m=y.rgb2gray,g=r(59),b=g.skip2d,x=r(24),M=x.sub,T=r(60),S=T.transpose,j=r(25),A=j.zeros;t.exports={conv2:i,filter2:a,fspecial:f,imfilter:h,normpdf:l,ones:v,padarray:w,rgb2gray:m,skip2d:b,sub:M,transpose:S,zeros:A}},function(t,n){t.exports=function(t){try{return!!t()}catch(t){return!0}}},function(t,n){var r=t.exports="undefined"!=typeof window&&window.Math==Math?window:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")();"number"==typeof __g&&(__g=r)},function(t,n){var r=t.exports={version:"2.4.0"};"number"==typeof __e&&(__e=r)},function(t,n,r){t.exports=!r(2)(function(){return 7!=Object.defineProperty({},"a",{get:function(){return 7}}).a})},function(t,n){var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t};t.exports=function(t){return"object"===("undefined"==typeof t?"undefined":r(t))?null!==t:"function"==typeof t}},function(t,n,r){(function(t,e){function i(t,n){this._id=t,this._clearFn=n}var o=r(50).nextTick,a=Function.prototype.apply,u=Array.prototype.slice,f={},c=0;n.setTimeout=function(){return new i(a.call(setTimeout,window,arguments),clearTimeout)},n.setInterval=function(){return new i(a.call(setInterval,window,arguments),clearInterval)},n.clearTimeout=n.clearInterval=function(t){t.close()},i.prototype.unref=i.prototype.ref=function(){},i.prototype.close=function(){this._clearFn.call(window,this._id)},n.enroll=function(t,n){clearTimeout(t._idleTimeoutId),t._idleTimeout=n},n.unenroll=function(t){clearTimeout(t._idleTimeoutId),t._idleTimeout=-1},n._unrefActive=n.active=function(t){clearTimeout(t._idleTimeoutId);var n=t._idleTimeout;n>=0&&(t._idleTimeoutId=setTimeout(function(){t._onTimeout&&t._onTimeout()},n))},n.setImmediate="function"==typeof t?t:function(t){var r=c++,e=!(arguments.length<2)&&u.call(arguments,1);return f[r]=!0,o(function(){f[r]&&(e?t.apply(null,e):t.call(null),n.clearImmediate(r))}),r},n.clearImmediate="function"==typeof e?e:function(t){delete f[t]}}).call(n,r(7).setImmediate,r(7).clearImmediate)},function(t,n){t.exports=function(t){if(void 0==t)throw TypeError("Can't call method on "+t);return t}},function(t,n,r){var e=r(3),i=r(4),o=r(11),a=r(44),u=r(33),f="prototype",c=function t(n,r,c){var h,d,l,s,v=n&t.F,p=n&t.G,w=n&t.S,y=n&t.P,m=n&t.B,g=p?e:w?e[r]||(e[r]={}):(e[r]||{})[f],b=p?i:i[r]||(i[r]={}),x=b[f]||(b[f]={});p&&(c=r);for(h in c)d=!v&&g&&void 0!==g[h],l=(d?g:c)[h],s=m&&d?u(l,e):y&&"function"==typeof l?u(Function.call,l):l,g&&a(g,h,l,n&t.U),b[h]!=l&&o(b,h,s),y&&x[h]!=l&&(x[h]=l)};e.core=i,c.F=1,c.G=2,c.S=4,c.P=8,c.B=16,c.W=32,c.U=64,c.R=128,t.exports=c},function(t,n){var r={}.hasOwnProperty;t.exports=function(t,n){return r.call(t,n)}},function(t,n,r){var e=r(38),i=r(43);t.exports=r(5)?function(t,n,r){return e.f(t,n,i(1,r))}:function(t,n,r){return t[n]=r,t}},function(t,n,r){var e=r(32);t.exports=Object("z").propertyIsEnumerable(0)?Object:function(t){return"String"==e(t)?t.split(""):Object(t)}},function(t,n,r){var e=r(40),i=r(35);t.exports=Object.keys||function(t){return e(t,i)}},function(t,n){var r=Math.ceil,e=Math.floor;t.exports=function(t){return isNaN(t=+t)?0:(t>0?e:r)(t)}},function(t,n,r){var e=r(12),i=r(8);t.exports=function(t){return e(i(t))}},function(t,n,r){var e=r(8);t.exports=function(t){return Object(e(t))}},function(t,n){var r=0,e=Math.random();t.exports=function(t){return"Symbol(".concat(void 0===t?"":t,")_",(++r+e).toString(36))}},function(t,n,r){function e(t,n){for(var r=t.data,e=t.width,i=t.height,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"full",a=e+n.width-1,f=i+n.height-1,c=l(f,a),h=c.data,d=0;d<n.height;d++)for(var s=0;s<n.width;s++){var v=n.data[d*n.width+s];if(v)for(var p=0;p<i;p++)for(var w=0;w<e;w++)h[(p+d)*a+w+s]+=r[p*e+w]*v}var y={data:h,width:a,height:f};return u(y,o,i,n.height,e,n.width)}function i(t,n){var r=n.data,e=n.width,i=n.height,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"full",u=v(i,1),f=v(1,e),c=a(t,u,f,o);return w(c,r[0])}function o(t){for(var n=t.data,r=n[0],e=1;e<n.length;e++)if(n[e]!==r)return!1;return!0}function a(t,n,r){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"full",o=Math.max(n.height,n.width),a=Math.max(r.height,r.width),f=e(t,n,"full"),c=e(f,r,"full");return u(c,i,t.height,o,t.width,a)}function u(t,n,r,e,i,o){if("full"===n)return t;if("same"===n){var a=Math.ceil((t.height-r)/2),u=Math.ceil((t.width-i)/2);return h(t,a,r,u,i)}return h(t,e-1,r-e+1,o-1,i-o+1)}function f(){for(var t=arguments.length,n=Array(t),r=0;r<t;r++)n[r]=arguments[r];return n[2]&&n[2].data?a.apply(void 0,n):o(n[1])?i.apply(void 0,n):e.apply(void 0,n)}var c=r(24),h=c.sub,d=r(25),l=d.zeros,s=r(22),v=s.ones,p=r(0),w=p.multiply2d;t.exports={conv2:f}},function(t,n,r){function e(t){for(var n=t.data,r=t.width,e=t.height,i=new Array(n.length),o=0;o<e;o++)for(var a=0;a<r;a++)i[o*r+a]=n[(e-1-o)*r+r-1-a];return{data:i,width:r,height:e}}function i(t,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"same";return a(n,e(t),r)}var o=r(18),a=o.conv2;t.exports={filter2:i}},function(t,n){function r(t,n,r){for(var e=n*t,i=new Array(e),o=0;o<e;o++)i[o]=r;return{data:i,width:n,height:t}}t.exports={numbers:r}},function(t,n){function r(t,n){return t-n*Math.floor(t/n)}t.exports={mod:r}},function(t,n,r){function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t;return o(t,n,1)}var i=r(20),o=i.numbers;t.exports={ones:e}},function(t,n,r){function e(t){for(var n=t.data,r=t.width,e=t.height,i=new Array(n.length),o=0;o<e;o++)for(var a=0;a<r;a++)i[o*r+a]=n[o*r+r-1-a];return{data:i,width:r,height:e}}function i(t){for(var n=t.data,r=t.width,e=t.height,i=new Array(n.length),o=0;o<e;o++)for(var a=0;a<r;a++)i[o*r+a]=n[(e-1-o)*r+a];return{data:i,width:r,height:e}}function o(t,n){for(var r=t.width+n.width,e=new Array(t.height*r),i=0;i<t.height;i++){for(var o=0;o<t.width;o++)e[i*r+o]=t.data[i*t.width+o];for(var a=0;a<n.width;a++)e[i*r+a+t.width]=n.data[i*n.width+a]}return{data:e,width:r,height:t.height}}function a(t,n){return{data:t.data.concat(n.data),height:t.height+n.height,width:t.width}}function u(t,n){for(var r=t.width+2*n,i=new Array(r*t.height),a=o(t,e(t)),u=0;u<t.height;u++)for(var f=-n;f<t.width+n;f++)i[u*r+f+n]=a.data[u*a.width+s(f,a.width)];return{data:i,width:r,height:t.height}}function f(t,n){for(var r=a(t,i(t)),e=t.height+2*n,o=new Array(t.width*e),u=-n;u<t.height+n;u++)for(var f=0;f<t.width;f++)o[(u+n)*t.width+f]=r.data[s(u,r.height)*t.width+f];return{data:o,width:t.width,height:e}}function c(t,n){for(var r=d(n,2),e=r[0],i=r[1],o=t.width+2*i,a=t.height+2*e,u=new Array(o*a),f=-e;f<0;f++){for(var c=-i;c<0;c++)u[(f+e)*o+c+i]=t.data[(Math.abs(f)-1)*t.width+Math.abs(c)-1];for(var h=0;h<t.width;h++)u[(f+e)*o+h+i]=t.data[(Math.abs(f)-1)*t.width+h];for(var l=t.width;l<t.width+i;l++)u[(f+e)*o+l+i]=t.data[(Math.abs(f)-1)*t.width+2*t.width-l-1]}for(var s=0;s<t.height;s++){for(var v=-i;v<0;v++)u[(s+e)*o+v+i]=t.data[s*t.width+Math.abs(v)-1];for(var p=0;p<t.width;p++)u[(s+e)*o+p+i]=t.data[s*t.width+p];for(var w=t.width;w<t.width+i;w++)u[(s+e)*o+w+i]=t.data[s*t.width+2*t.width-w-1]}for(var y=t.height;y<t.height+e;y++){for(var m=-i;m<0;m++)u[(y+e)*o+m+i]=t.data[(2*t.height-y-1)*t.width+Math.abs(m)-1];for(var g=0;g<t.width;g++)u[(y+e)*o+g+i]=t.data[(2*t.height-y-1)*t.width+g];for(var b=t.width;b<t.width+i;b++)u[(y+e)*o+b+i]=t.data[(2*t.height-y-1)*t.width+2*t.width-b-1]}return{data:u,width:o,height:a}}function h(t,n){var r=d(n,2),e=r[0],i=r[1];return t.height>=e&&t.width>=i?c(t,[e,i]):f(u(t,i),e)}var d=function(){function t(t,n){var r=[],e=!0,i=!1,o=void 0;try{for(var a,u=t[Symbol.iterator]();!(e=(a=u.next()).done)&&(r.push(a.value),!n||r.length!==n);e=!0);}catch(t){i=!0,o=t}finally{try{!e&&u.return&&u.return()}finally{if(i)throw o}}return r}return function(n,r){if(Array.isArray(n))return n;if(Symbol.iterator in Object(n))return t(n,r);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),l=r(21),s=l.mod;t.exports={padarray:h}},function(t,n){function r(t,n,r,e,i){for(var o=t.data,a=t.width,u=new Array(i*r),f=0;f<r;f++)for(var c=0;c<i;c++)u[f*i+c]=o[(e+f)*a+n+c];return{data:u,width:i,height:r}}t.exports={sub:r}},function(t,n,r){function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t;return o(t,n,0)}var i=r(20),o=i.numbers;t.exports={zeros:e}},function(t,n,r){function e(t){if(Object.keys(t).forEach(function(t){if(!(t in _))throw new Error('"'+t+'" is not a valid option')}),"k1"in t&&("number"!=typeof t.k1||t.k1<0))throw new Error("Invalid k1 value. Default is "+_.k1);if("k2"in t&&("number"!=typeof t.k2||t.k2<0))throw new Error("Invalid k2 value. Default is "+_.k2);if(!(t.ssim in I))throw new Error("Invalid ssim option (use: "+Object.keys(I).join(", ")+")")}function i(t){return new d.Promise(function(n){var r=Object.assign({},_,t);e(r),n(r)})}function o(t){var n=l(t,3),r=n[0],e=n[1],i=n[2];if(r.width!==e.width||r.height!==e.height)throw new Error("Image dimensions do not match");return[r,e,i]}function a(t){var n=l(t,3),r=n[0],e=n[1],i=n[2];return[w(r),w(e),i]}function u(t){var n=l(t,3),r=n[0],e=n[1],i=n[2],o=A([r,e],i);return[o[0],o[1],i]}function f(t){var n=l(t,3),r=n[0],e=n[1],i=n[2];return I[i.ssim](r,e,i)}function c(t,n){if(!t)throw new Error("Missing image parameter");return"fast"===n.downsample?v(t,d.Promise,n.maxSize):v(t,d.Promise)}function h(t,n,r){return d.Promise.all([c(t,r),c(n,r)]).then(function(t){return[t[0],t[1],r]})}function d(t,n,r){var e=(new Date).getTime();return i(r).then(function(r){return h(t,n,r)}).then(o).then(a).then(u).then(f).then(function(t){return{ssim_map:t,mssim:m(t),performance:(new Date).getTime()-e}})}var l=function(){function t(t,n){var r=[],e=!0,i=!1,o=void 0;try{for(var a,u=t[Symbol.iterator]();!(e=(a=u.next()).done)&&(r.push(a.value),!n||r.length!==n);e=!0);}catch(t){i=!0,o=t}finally{try{!e&&u.return&&u.return()}finally{if(i)throw o}}return r}return function(n,r){if(Array.isArray(n))return n;if(Symbol.iterator in Object(n))return t(n,r);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),s=r(62),v=s.readpixels,p=r(1),w=p.rgb2gray,y=r(0),m=y.mean2d,g=r(63),b=g.ssim,x=r(61),M=x.originalSsim,T=r(53),S=T.bezkrovnySsim,j=r(54),A=j.downsample,_=r(66),E=r(65),k=E.version,O=r(51),I={fast:b,original:M,bezkrovny:S};d.Promise=this.Promise||O,d.ssim=d,d.version=k,t.exports=d},function(t,n,r){var e=r(9);e(e.S+e.F,"Object",{assign:r(37)})},function(t,n,r){var e=r(16),i=r(13);r(42)("keys",function(){return function(t){return i(e(t))}})},function(t,n){t.exports=function(t){if("function"!=typeof t)throw TypeError(t+" is not a function!");return t}},function(t,n,r){var e=r(6);t.exports=function(t){if(!e(t))throw TypeError(t+" is not an object!");return t}},function(t,n,r){var e=r(15),i=r(48),o=r(47);t.exports=function(t){return function(n,r,a){var u,f=e(n),c=i(f.length),h=o(a,c);if(t&&r!=r){for(;c>h;)if(u=f[h++],u!=u)return!0}else for(;c>h;h++)if((t||h in f)&&f[h]===r)return t||h||0;return!t&&-1}}},function(t,n){var r={}.toString;t.exports=function(t){return r.call(t).slice(8,-1)}},function(t,n,r){var e=r(29);t.exports=function(t,n,r){if(e(t),void 0===n)return t;switch(r){case 1:return function(r){return t.call(n,r)};case 2:return function(r,e){return t.call(n,r,e)};case 3:return function(r,e,i){return t.call(n,r,e,i)}}return function(){return t.apply(n,arguments)}}},function(t,n,r){var e=r(6),i=r(3).document,o=e(i)&&e(i.createElement);t.exports=function(t){return o?i.createElement(t):{}}},function(t,n){t.exports="constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf".split(",")},function(t,n,r){t.exports=!r(5)&&!r(2)(function(){return 7!=Object.defineProperty(r(34)("div"),"a",{get:function(){return 7}}).a})},function(t,n,r){"use strict";var e=r(13),i=r(39),o=r(41),a=r(16),u=r(12),f=Object.assign;t.exports=!f||r(2)(function(){var t={},n={},r=Symbol(),e="abcdefghijklmnopqrst";return t[r]=7,e.split("").forEach(function(t){n[t]=t}),7!=f({},t)[r]||Object.keys(f({},n)).join("")!=e})?function(t,n){for(var r=a(t),f=arguments.length,c=1,h=i.f,d=o.f;f>c;)for(var l,s=u(arguments[c++]),v=h?e(s).concat(h(s)):e(s),p=v.length,w=0;p>w;)d.call(s,l=v[w++])&&(r[l]=s[l]);return r}:f},function(t,n,r){var e=r(30),i=r(36),o=r(49),a=Object.defineProperty;n.f=r(5)?Object.defineProperty:function(t,n,r){if(e(t),n=o(n,!0),e(r),i)try{return a(t,n,r)}catch(t){}if("get"in r||"set"in r)throw TypeError("Accessors not supported!");return"value"in r&&(t[n]=r.value),t}},function(t,n){n.f=Object.getOwnPropertySymbols},function(t,n,r){var e=r(10),i=r(15),o=r(31)(!1),a=r(45)("IE_PROTO");t.exports=function(t,n){var r,u=i(t),f=0,c=[];for(r in u)r!=a&&e(u,r)&&c.push(r);for(;n.length>f;)e(u,r=n[f++])&&(~o(c,r)||c.push(r));return c}},function(t,n){n.f={}.propertyIsEnumerable},function(t,n,r){var e=r(9),i=r(4),o=r(2);t.exports=function(t,n){var r=(i.Object||{})[t]||Object[t],a={};a[t]=n(r),e(e.S+e.F*o(function(){r(1)}),"Object",a)}},function(t,n){t.exports=function(t,n){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:n}}},function(t,n,r){var e=r(3),i=r(11),o=r(10),a=r(17)("src"),u="toString",f=Function[u],c=(""+f).split(u);r(4).inspectSource=function(t){return f.call(t)},(t.exports=function(t,n,r,u){var f="function"==typeof r;f&&(o(r,"name")||i(r,"name",n)),t[n]!==r&&(f&&(o(r,a)||i(r,a,t[n]?""+t[n]:c.join(String(n)))),t===e?t[n]=r:u?t[n]?t[n]=r:i(t,n,r):(delete t[n],i(t,n,r)))})(Function.prototype,u,function(){return"function"==typeof this&&this[a]||f.call(this)})},function(t,n,r){var e=r(46)("keys"),i=r(17);t.exports=function(t){return e[t]||(e[t]=i(t))}},function(t,n,r){var e=r(3),i="__core-js_shared__",o=e[i]||(e[i]={});t.exports=function(t){return o[t]||(o[t]={})}},function(t,n,r){var e=r(14),i=Math.max,o=Math.min;t.exports=function(t,n){return t=e(t),t<0?i(t+n,0):o(t,n)}},function(t,n,r){var e=r(14),i=Math.min;t.exports=function(t){return t>0?i(e(t),9007199254740991):0}},function(t,n,r){var e=r(6);t.exports=function(t,n){if(!e(t))return t;var r,i;if(n&&"function"==typeof(r=t.toString)&&!e(i=r.call(t)))return i;if("function"==typeof(r=t.valueOf)&&!e(i=r.call(t)))return i;if(!n&&"function"==typeof(r=t.toString)&&!e(i=r.call(t)))return i;throw TypeError("Can't convert object to primitive value")}},function(t,n){function r(){throw new Error("setTimeout has not been defined")}function e(){throw new Error("clearTimeout has not been defined")}function i(t){if(h===setTimeout)return setTimeout(t,0);if((h===r||!h)&&setTimeout)return h=setTimeout,setTimeout(t,0);try{return h(t,0)}catch(n){try{return h.call(null,t,0)}catch(n){return h.call(this,t,0)}}}function o(t){if(d===clearTimeout)return clearTimeout(t);if((d===e||!d)&&clearTimeout)return d=clearTimeout,clearTimeout(t);try{return d(t)}catch(n){try{return d.call(null,t)}catch(n){return d.call(this,t)}}}function a(){p&&s&&(p=!1,s.length?v=s.concat(v):w=-1,v.length&&u())}function u(){if(!p){var t=i(a);p=!0;for(var n=v.length;n;){for(s=v,v=[];++w<n;)s&&s[w].run();w=-1,n=v.length}s=null,p=!1,o(t)}}function f(t,n){this.fun=t,this.array=n}function c(){}var h,d,l=t.exports={};!function(){try{h="function"==typeof setTimeout?setTimeout:r}catch(t){h=r}try{d="function"==typeof clearTimeout?clearTimeout:e}catch(t){d=e}}();var s,v=[],p=!1,w=-1;l.nextTick=function(t){var n=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)n[r-1]=arguments[r];v.push(new f(t,n)),1!==v.length||p||i(u)},f.prototype.run=function(){this.fun.apply(null,this.array)},l.title="browser",l.browser=!0,l.env={},l.argv=[],l.version="",l.versions={},l.on=c,l.addListener=c,l.once=c,l.off=c,l.removeListener=c,l.removeAllListeners=c,l.emit=c,l.binding=function(t){throw new Error("process.binding is not supported")},l.cwd=function(){return"/"},l.chdir=function(t){throw new Error("process.chdir is not supported")},l.umask=function(){return 0}},function(t,n,r){(function(n,r){var e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t};!function(){function i(t){n.setImmediate?r(t):n.importScripts?setTimeout(t):(a++,u[a]=t,n.postMessage(a,"*"))}function o(t){"use strict";function n(t,n,r,i){if(2==c)return i();if("object"!=("undefined"==typeof h?"undefined":e(h))&&"function"!=typeof h||"function"!=typeof t)i();else try{var o=0;t.call(h,function(t){o++||(h=t,n())},function(t){o++||(h=t,r())})}catch(t){h=t,r()}}function r(){var t;try{t=h&&h.then}catch(t){return h=t,c=2,r()}n(t,function(){c=1,r()},function(){c=2,r()},function(){try{1==c&&"function"==typeof a?h=a(h):2==c&&"function"==typeof u&&(h=u(h),c=1)}catch(t){return h=t,l()}h==f?(h=TypeError(),l()):n(t,function(){l(3)},l,function(){l(1==c&&3)})})}if("function"!=typeof t&&void 0!=t)throw TypeError();if("object"!=e(this)||this&&this.then)throw TypeError();var a,u,f=this,c=0,h=0,d=[];f.promise=f,f.resolve=function(t){return a=f.fn,u=f.er,c||(h=t,c=1,i(r)),f},f.reject=function(t){return a=f.fn,u=f.er,c||(h=t,c=2,i(r)),f},f._d=1,f.then=function(t,n){if(1!=this._d)throw TypeError();var r=new o;return r.fn=t,r.er=n,3==c?r.resolve(h):4==c?r.reject(h):d.push(r),r},f.catch=function(t){return f.then(null,t)};var l=function(t){c=t||4,d.map(function(t){3==c&&t.resolve(h)||t.reject(h)})};try{"function"==typeof t&&t(f.resolve,f.reject)}catch(t){f.reject(t)}return f}n=this;var a=1,u={},f=!1;n.setImmediate||n.addEventListener("message",function(t){if(t.source==n)if(f)i(u[t.data]);else{f=!0;try{u[t.data]()}catch(t){}delete u[t.data],f=!1}}),o.resolve=function(t){if(1!=this._d)throw TypeError();return t instanceof o?t:new o(function(n){n(t)})},o.reject=function(t){if(1!=this._d)throw TypeError();return new o(function(n,r){r(t)})},o.all=function(t){function n(e,i){if(i)return r.resolve(i);if(e)return r.reject(e);var o=t.reduce(function(t,n){return n&&n.then?t+1:t},0);0==o&&r.resolve(t),t.map(function(r,e){r&&r.then&&r.then(function(r){return t[e]=r,n(),r},n)})}if(1!=this._d)throw TypeError();if(!(t instanceof Array))return o.reject(TypeError());var r=new o;return n(),r},o.race=function(t){function n(e,i){if(i)return r.resolve(i);if(e)return r.reject(e);var o=t.reduce(function(t,n){return n&&n.then?t+1:t},0);0==o&&r.resolve(t),t.map(function(t,r){t&&t.then&&t.then(function(t){n(null,t)},n)})}if(1!=this._d)throw TypeError();if(!(t instanceof Array))return o.reject(TypeError());if(0==t.length)return new o;var r=new o;return n(),r},o._d=1,t.exports=o}()}).call(n,r(52),r(7).setImmediate)},function(t,n){var r,e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t};r=function(){return this}();try{r=r||Function("return this")()||(0,eval)("this")}catch(t){"object"===("undefined"==typeof window?"undefined":e(window))&&(r=window)}t.exports=r},function(t,n,r){function e(t,n,r){for(var e=r.windowSize,o=Math.floor(t.width/e),a=Math.floor(t.height/e),u=new Array(o*a),f=0,c=0;c<t.height;c+=e)for(var d=0;d<t.width;d+=e){var l=Math.min(e,t.width-d),s=Math.min(e,t.height-c),v=h(t,d,s,c,l),p=h(n,d,s,c,l);u[f++]=i(v,p,r)}return{data:u,width:o,height:a}}function i(t,n,r){var e=t.data,i=n.data,o=r.bitDepth,c=r.k1,h=r.k2,d=Math.pow(2,o)-1,l=Math.pow(c*d,2),s=Math.pow(h*d,2),v=a(e),p=a(i),w=u(e,v),y=u(i,p),m=f(e,i,v,p),g=(2*v*p+l)*(2*m+s),b=Math.pow(v,2)+Math.pow(p,2)+l,x=w+y+s;return g/(b*x)}var o=r(0),a=o.average,u=o.variance,f=o.covariance,c=r(1),h=c.sub;t.exports={bezkrovnySsim:e}},function(t,n,r){function e(t,n,r){var e=h(t,n,"symmetric","same");return l(e,[0,r,e.height],[0,r,e.width])}function i(t,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:256,i=Math.min(t.width,n.height)/r,o=Math.round(i);if(o>1){var a=d(o);a=u(a,f(a)),t=e(t,a,o),n=e(n,a,o)}return[t,n]}function o(t,n){return"original"===n.downsample?i(t[0],t[1],n.maxSize):t}var a=r(0),u=a.divide2d,f=a.sum2d,c=r(1),h=c.imfilter,d=c.ones,l=c.skip2d;t.exports={downsample:o}},function(t,n,r){function e(t){for(var n=2*t+1,r=new Array(Math.pow(n,2)),e=0;e<n;e++)for(var i=0;i<n;i++)r[e*n+i]=Math.pow(e-t,2)+Math.pow(i-t,2);return{data:r,width:n,height:n}}function i(t,n){for(var r=t.data,e=t.width,i=t.height,o=new Array(r.length),a=0;a<r.length;a++)o[a]=Math.exp(-r[a]/(2*Math.pow(n,2)));return{data:o,width:e,height:i}}function o(){var t=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"gaussian",arguments.length>1&&void 0!==arguments[1]?arguments[1]:3),n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1.5;t=(t-1)/2;var r=e(t),o=i(r,n),a=u(o);return f(o,a)}var a=r(0),u=a.sum2d,f=a.divide2d;t.exports={fspecial:o}},function(t,n,r){function e(t,n,r,e){if(t=c(t,d([n/2,r/2]),e),0===u(n,2)&&(t.data=t.data.slice(0,-t.width),t.height--),0===u(r,2)){for(var i=[],o=0;o<t.data.length;o++)(o+1)%t.width!==0&&i.push(t.data[o]);t.data=i,t.width--}return t}function i(t){return"same"===t&&(t="valid"),t}function o(t,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"symmetric",o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"same";return t=e(t,n.width,n.height,r),o=i(o),s(n,t,o)}var a=r(21),u=a.mod,f=r(23),c=f.padarray,h=r(0),d=h.floor,l=r(19),s=l.filter2;t.exports={imfilter:o}},function(t,n){function r(t){for(var n=t.data,r=t.width,e=t.height,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,a=2.5066282746310007,u=new Array(n.length),f=0;f<n.length;f++){var c=(n[f]-i)/o;u[f]=Math.exp(-Math.pow(c,2)/2)/(o*a)}return{data:u,width:r,height:e}}t.exports={normpdf:r}},function(t,n){function r(t,n,r){return Math.round(.29894*t+.58704*n+.11402*r)}function e(t){for(var n=t.data,e=t.width,i=t.height,o=new Array(e*i),a=0;a<i;a++)for(var u=0;u<e;u++){var f=u+a*e,c=4*f;o[f]=r(n[c],n[c+1],n[c+2],n[c+3])}return{data:o,width:e,height:i}}t.exports={rgb2gray:e}},function(t,n){function r(t,n,r){for(var i=e(n,3),o=i[0],a=i[1],u=i[2],f=e(r,3),c=f[0],h=f[1],d=f[2],l=Math.ceil((d-c)/h),s=Math.ceil((u-o)/a),v=new Array(l*s),p=0;p<s;p++)for(var w=0;w<l;w++){var y=o+p*a,m=c+w*h;v[p*l+w]=t.data[y*t.width+m]}return{data:v,width:l,height:s}}var e=function(){function t(t,n){var r=[],e=!0,i=!1,o=void 0;try{for(var a,u=t[Symbol.iterator]();!(e=(a=u.next()).done)&&(r.push(a.value),!n||r.length!==n);e=!0);}catch(t){i=!0,o=t}finally{try{!e&&u.return&&u.return()}finally{if(i)throw o}}return r}return function(n,r){if(Array.isArray(n))return n;if(Symbol.iterator in Object(n))return t(n,r);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}();t.exports={skip2d:r}},function(t,n){function r(t){for(var n=t.data,r=t.width,e=t.height,i=new Array(r*e),o=0;o<e;o++)for(var a=0;a<r;a++)i[a*e+o]=n[o*r+a];return{data:i,height:r,width:e}}t.exports={transpose:r}},function(t,n,r){function e(t,n,r){var e=s("gaussian",r.windowSize,1.5),i=Math.pow(2,r.bitDepth)-1,d=Math.pow(r.k1*i,2),v=Math.pow(r.k2*i,2);e=a(e,h(e));var p=l(e,t,"valid"),w=l(e,n,"valid"),y=f(p),m=f(w),g=u(p,w),b=f(t),x=f(n),M=c(l(e,b,"valid"),y),T=c(l(e,x,"valid"),m),S=c(l(e,u(t,n),"valid"),g);if(d>0&&v>0){var j=o(u(g,2),d),A=o(u(S,2),v),_=o(o(y,m),d),E=o(o(M,T),v);return a(u(j,A),u(_,E))}var k=u(g,2),O=u(S,2),I=o(y,m),P=o(M,T);return a(u(k,O),u(I,P))}var i=r(0),o=i.add2d,a=i.divide2d,u=i.multiply2d,f=i.square2d,c=i.subtract2d,h=i.sum2d,d=r(1),l=d.filter2,s=d.fspecial;t.exports={originalSsim:e}},function(t,n,r){function e(t,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,e=new Image,i=document.createElement("canvas"),a=i.getContext("2d");return new n(function(n,u){e.onload=function(){var t=o(e.width,e.height,r),f=t.width,c=t.height;return 0===f||0===c?u("Failed to load image"):(i.width=f,i.height=c,a.drawImage(e,0,0,e.width,e.height,0,0,f,c),n(a.getImageData(0,0,f,c)))},e.onerror=u,e.src=t})}var i=r(64),o=i.getLimitDimensions;t.exports={readpixels:e}},function(t,n,r){function e(t,n,r){var e=w(i(r.windowSize),0,1.5),u=Math.pow(2,r.bitDepth)-1,f=Math.pow(r.k1*u,2),v=Math.pow(r.k2*u,2);e=c(e,s(e));var m=y(e),g=p(t,e,m,"valid"),b=p(n,e,m,"valid"),x=d(g),M=d(b),T=h(g,b),S=d(t),j=d(n),A=l(p(S,e,m,"valid"),x),_=l(p(j,e,m,"valid"),M),E=l(p(h(t,n),e,m,"valid"),T);return f>0&&v>0?o(T,E,x,M,A,_,f,v):a(T,E,x,M,A,_)}function i(t){for(var n=Math.floor(t/2),r=new Array(2*n+1),e=-n;e<=n;e++)r[e+n]=Math.abs(e);return{data:r,width:r.length,height:1}}function o(t,n,r,e,i,o,a,u){var d=f(h(t,2),a),l=f(h(n,2),u),s=f(f(r,e),a),v=f(f(i,o),u);return c(h(d,l),h(s,v))}function a(t,n,r,e,i,o){var a=h(t,2),u=h(n,2),d=f(r,e),l=f(i,o);return c(h(a,u),h(d,l))}var u=r(0),f=u.add2d,c=u.divide2d,h=u.multiply2d,d=u.square2d,l=u.subtract2d,s=u.sum2d,v=r(1),p=v.conv2,w=v.normpdf,y=v.transpose;t.exports={ssim:e}},function(t,n){function r(t,n,r){if(r&&t>=r&&n>=r){var e=t/n;return e>1?{height:r,width:Math.round(r/e)}:{height:Math.round(r*e),width:r}}return{width:t,height:n}}t.exports={getLimitDimensions:r}},function(t,n){t.exports={type:"deploy",version:"3.0.0"}},function(t,n){t.exports={windowSize:11,k1:.01,k2:.03,bitDepth:8,downsample:"original",ssim:"fast",maxSize:256}},function(t,n,r){r(28),r(27),t.exports=r(26)}])}); | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.ssim=e():t.ssim=e()}(window,(function(){return function(t){var e={};function r(i){if(e[i])return e[i].exports;var a=e[i]={i:i,l:!1,exports:{}};return t[i].call(a.exports,a,a.exports,r),a.l=!0,a.exports}return r.m=t,r.c=e,r.d=function(t,e,i){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:i})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var i=Object.create(null);if(r.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var a in t)r.d(i,a,function(e){return t[e]}.bind(null,a));return i},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=10)}([function(t,e,r){"use strict";function i(t){return a(t)/t.length}function a(t){for(var e=0,r=0;r<t.length;r++)e+=t[r];return e}function n(t){for(var e=t.data,r=0,i=0;i<e.length;i++)r+=e[i];return r}function d(t,e){for(var r=t.data,i=t.width,a=t.height,n=new Array(r.length),d=0;d<r.length;d++)n[d]=r[d]+e;return{data:n,width:i,height:a}}function o(t,e){return"number"==typeof e?function(t,e){for(var r=t.data,i=t.width,a=t.height,n=new Array(r.length),d=0;d<r.length;d++)n[d]=r[d]*e;return{data:n,width:i,height:a}}(t,e):function(t,e){for(var r=t.data,i=t.width,a=t.height,n=e.data,d=new Array(r.length),o=0;o<r.length;o++)d[o]=r[o]*n[o];return{data:d,width:i,height:a}}(t,e)}Object.defineProperty(e,"__esModule",{value:!0}),e.average=i,e.sum=a,e.floor=function(t){for(var e=new Array(t.length),r=0;r<t.length;r++)e[r]=Math.floor(t[r]);return e},e.sum2d=n,e.add2d=function(t,e){return"number"==typeof e?d(t,e):function(t,e){for(var r=t.data,i=t.width,a=t.height,n=e.data,d=new Array(r.length),o=0;o<a;o++)for(var h=o*i,u=0;u<i;u++)d[h+u]=r[h+u]+n[h+u];return{data:d,width:i,height:a}}(t,e)},e.subtract2d=function(t,e){return"number"==typeof e?d(t,-e):function(t,e){for(var r=t.data,i=t.width,a=t.height,n=e.data,d=new Array(r.length),o=0;o<a;o++)for(var h=o*i,u=0;u<i;u++)d[h+u]=r[h+u]-n[h+u];return{data:d,width:i,height:a}}(t,e)},e.divide2d=function(t,e){return"number"==typeof e?function(t,e){for(var r=t.data,i=t.width,a=t.height,n=new Array(r.length),d=0;d<r.length;d++)n[d]=r[d]/e;return{data:n,width:i,height:a}}(t,e):function(t,e){for(var r=t.data,i=t.width,a=t.height,n=e.data,d=new Array(r.length),o=0;o<r.length;o++)d[o]=r[o]/n[o];return{data:d,width:i,height:a}}(t,e)},e.multiply2d=o,e.square2d=function(t){return o(t,t)},e.mean2d=function(t){return n(t)/t.data.length},e.variance=function(t,e){void 0===e&&(e=i(t));for(var r=0,a=t.length;a--;)r+=Math.pow(t[a]-e,2);return r/t.length},e.covariance=function(t,e,r,a){void 0===r&&(r=i(t)),void 0===a&&(a=i(e));for(var n=0,d=t.length;d--;)n+=(t[d]-r)*(e[d]-a);return n/t.length}},function(t,e,r){"use strict";function i(t){for(var r in t)e.hasOwnProperty(r)||(e[r]=t[r])}Object.defineProperty(e,"__esModule",{value:!0}),i(r(2)),i(r(7)),i(r(11)),i(r(12)),i(r(13)),i(r(3)),i(r(9)),i(r(14)),i(r(15)),i(r(5)),i(r(16)),i(r(6))},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=r(0),a=r(3),n=r(5),d=r(6);function o(t,e,r){var i=t.data,a=t.width,n=t.height;void 0===r&&(r="full");for(var o=a+e.width-1,h=n+e.height-1,u=d.zeros(h,o).data,l=0;l<e.height;l++)for(var c=0;c<e.width;c++){var s=e.data[l*e.width+c];if(s)for(var v=0;v<n;v++)for(var w=0;w<a;w++)u[(v+l)*o+w+c]+=i[v*a+w]*s}return f({data:u,width:o,height:h},r,n,e.height,a,e.width)}function h(t,e,r){var n=e.data,d=e.width,o=e.height;void 0===r&&(r="full");var h=u(t,a.ones(o,1),a.ones(1,d),r);return i.multiply2d(h,n[0])}function u(t,e,r,i){void 0===i&&(i="full");var a=Math.max(e.height,e.width),n=Math.max(r.height,r.width),d=o(t,e,"full");return f(o(d,r,"full"),i,t.height,a,t.width,n)}function f(t,e,r,i,a,d){if("full"===e)return t;if("same"===e){var o=Math.ceil((t.height-r)/2),h=Math.ceil((t.width-a)/2);return n.sub(t,o,r,h,a)}return n.sub(t,i-1,r-i+1,d-1,a-d+1)}e.conv2=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return t[2]&&t[2].data?u.apply(void 0,t):function(t){for(var e=t.data,r=e[0],i=1;i<e.length;i++)if(e[i]!==r)return!1;return!0}(t[1])?h.apply(void 0,t):o.apply(void 0,t)}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=r(4);e.ones=function(t,e){return void 0===e&&(e=t),i.numbers(t,e,1)}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.numbers=function(t,e,r){for(var i=e*t,a=new Array(i),n=0;n<i;n++)a[n]=r;return{data:a,width:e,height:t}}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.sub=function(t,e,r,i,a){for(var n=t.data,d=t.width,o=new Array(a*r),h=0;h<r;h++)for(var u=0;u<a;u++)o[h*a+u]=n[(i+h)*d+e+u];return{data:o,width:a,height:r}}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=r(4);e.zeros=function(t,e){return void 0===e&&(e=t),i.numbers(t,e,0)}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=r(2);e.filter2=function(t,e,r){return void 0===r&&(r="same"),i.conv2(e,function(t){for(var e=t.data,r=t.width,i=t.height,a=new Array(e.length),n=0;n<i;n++)for(var d=0;d<r;d++)a[n*r+d]=e[(i-1-n)*r+r-1-d];return{data:a,width:r,height:i}}(t),r)}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.mod=function(t,e){return t-e*Math.floor(t/e)}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=r(8);function a(t,e){for(var r=t.width+2*e,a=new Array(r*t.height),n=function(t,e){for(var r=t.width+e.width,i=new Array(t.height*r),a=0;a<t.height;a++){for(var n=0;n<t.width;n++)i[a*r+n]=t.data[a*t.width+n];for(n=0;n<e.width;n++)i[a*r+n+t.width]=e.data[a*e.width+n]}return{data:i,width:r,height:t.height}}(t,function(t){for(var e=t.data,r=t.width,i=t.height,a=new Array(e.length),n=0;n<i;n++)for(var d=0;d<r;d++)a[n*r+d]=e[n*r+r-1-d];return{data:a,width:r,height:i}}(t)),d=0;d<t.height;d++)for(var o=-e;o<t.width+e;o++)a[d*r+o+e]=n.data[d*n.width+i.mod(o,n.width)];return{data:a,width:r,height:t.height}}function n(t,e){for(var r=function(t,e){return{data:t.data.concat(e.data),height:t.height+e.height,width:t.width}}(t,function(t){for(var e=t.data,r=t.width,i=t.height,a=new Array(e.length),n=0;n<i;n++)for(var d=0;d<r;d++)a[n*r+d]=e[(i-1-n)*r+d];return{data:a,width:r,height:i}}(t)),a=t.height+2*e,n=new Array(t.width*a),d=-e;d<t.height+e;d++)for(var o=0;o<t.width;o++)n[(d+e)*t.width+o]=r.data[i.mod(d,r.height)*t.width+o];return{data:n,width:t.width,height:a}}e.padarray=function(t,e,r,i){var d=e[0],o=e[1];return t.height>=d&&t.width>=o?function(t,e){for(var r=e[0],i=e[1],a=t.width+2*i,n=t.height+2*r,d=new Array(a*n),o=-r;o<0;o++){for(var h=-i;h<0;h++)d[(o+r)*a+h+i]=t.data[(Math.abs(o)-1)*t.width+Math.abs(h)-1];for(h=0;h<t.width;h++)d[(o+r)*a+h+i]=t.data[(Math.abs(o)-1)*t.width+h];for(h=t.width;h<t.width+i;h++)d[(o+r)*a+h+i]=t.data[(Math.abs(o)-1)*t.width+2*t.width-h-1]}for(o=0;o<t.height;o++){for(h=-i;h<0;h++)d[(o+r)*a+h+i]=t.data[o*t.width+Math.abs(h)-1];for(h=0;h<t.width;h++)d[(o+r)*a+h+i]=t.data[o*t.width+h];for(h=t.width;h<t.width+i;h++)d[(o+r)*a+h+i]=t.data[o*t.width+2*t.width-h-1]}for(o=t.height;o<t.height+r;o++){for(h=-i;h<0;h++)d[(o+r)*a+h+i]=t.data[(2*t.height-o-1)*t.width+Math.abs(h)-1];for(h=0;h<t.width;h++)d[(o+r)*a+h+i]=t.data[(2*t.height-o-1)*t.width+h];for(h=t.width;h<t.width+i;h++)d[(o+r)*a+h+i]=t.data[(2*t.height-o-1)*t.width+2*t.width-h-1]}return{data:d,width:a,height:n}}(t,[d,o]):n(a(t,o),d)}},function(t,e,r){"use strict";var i=this&&this.__assign||function(){return(i=Object.assign||function(t){for(var e,r=1,i=arguments.length;r<i;r++)for(var a in e=arguments[r])Object.prototype.hasOwnProperty.call(e,a)&&(t[a]=e[a]);return t}).apply(this,arguments)};Object.defineProperty(e,"__esModule",{value:!0});var a=r(1),n=r(0),d=r(17),o=r(18),h=r(19),u=r(20),f=r(21),l={fast:d.ssim,original:o.originalSsim,bezkrovny:h.bezkrovnySsim};function c(t){var e=i(i({},f.defaults),t);return function(t){if(Object.keys(t).forEach((function(t){if(!(t in f.defaults))throw new Error('"'+t+'" is not a valid option')})),"k1"in t&&("number"!=typeof t.k1||t.k1<0))throw new Error("Invalid k1 value. Default is "+f.defaults.k1);if("k2"in t&&("number"!=typeof t.k2||t.k2<0))throw new Error("Invalid k2 value. Default is "+f.defaults.k2);if(!(t.ssim in l))throw new Error("Invalid ssim option (use: "+Object.keys(l).join(", ")+")")}(e),e}function s(t,e,r){var i=(new Date).getTime(),d=function(t){var e=t[0],r=t[1],i=t[2];return l[i.ssim](e,r,i)}(function(t){var e=t[0],r=t[1],i=t[2],a=u.downsample([e,r],i);return[a[0],a[1],i]}(function(t){var e=t[0],r=t[1],i=t[2];return[a.rgb2gray(e),a.rgb2gray(r),i]}(function(t){var e=t[0],r=t[1],i=t[2];if(e.width!==r.width||e.height!==r.height)throw new Error("Image dimensions do not match");return[e,r,i]}([t,e,c(r)]))));return{ssim_map:d,mssim:n.mean2d(d),performance:(new Date).getTime()-i}}e.ssim=s,e.default=s},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=r(0);e.fspecial=function(t,e,r){void 0===e&&(e=3),void 0===r&&(r=1.5);var a=function(t,e){for(var r=t.data,i=t.width,a=t.height,n=new Array(r.length),d=0;d<r.length;d++)n[d]=Math.exp(-r[d]/(2*Math.pow(e,2)));return{data:n,width:i,height:a}}(function(t){for(var e=2*t+1,r=new Array(Math.pow(e,2)),i=0;i<e;i++)for(var a=0;a<e;a++)r[i*e+a]=Math.pow(i-t,2)+Math.pow(a-t,2);return{data:r,width:e,height:e}}(e=(e-1)/2),r),n=i.sum2d(a);return i.divide2d(a,n)}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=r(8),a=r(9),n=r(0),d=r(7);e.imfilter=function(t,e,r,o){return void 0===r&&(r="symmetric"),void 0===o&&(o="same"),t=function(t,e,r,d){if(t=a.padarray(t,n.floor([e/2,r/2]),d),0===i.mod(e,2)&&(t.data=t.data.slice(0,-t.width),t.height--),0===i.mod(r,2)){for(var o=[],h=0;h<t.data.length;h++)(h+1)%t.width!=0&&o.push(t.data[h]);t.data=o,t.width--}return t}(t,e.width,e.height,r),o=function(t){return"same"===t&&(t="valid"),t}(o),d.filter2(e,t,o)}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.normpdf=function(t,e,r){var i=t.data,a=t.width,n=t.height;void 0===e&&(e=0),void 0===r&&(r=1);for(var d=new Array(i.length),o=0;o<i.length;o++){var h=(i[o]-e)/r;d[o]=Math.exp(-Math.pow(h,2)/2)/(2.5066282746310007*r)}return{data:d,width:a,height:n}}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.rgb2gray=function(t){for(var e,r,i,a=t.data,n=t.width,d=t.height,o=new Array(n*d),h=0;h<d;h++)for(var u=0;u<n;u++){var f=u+h*n,l=4*f;o[f]=(e=a[l],r=a[l+1],i=a[l+2],Math.round(.29894*e+.58704*r+.11402*i))}return{data:o,width:n,height:d}}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.skip2d=function(t,e,r){for(var i=e[0],a=e[1],n=e[2],d=r[0],o=r[1],h=r[2],u=Math.ceil((h-d)/o),f=Math.ceil((n-i)/a),l=new Array(u*f),c=0;c<f;c++)for(var s=0;s<u;s++){var v=i+c*a,w=d+s*o;l[c*u+s]=t.data[v*t.width+w]}return{data:l,width:u,height:f}}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.transpose=function(t){for(var e=t.data,r=t.width,i=t.height,a=new Array(r*i),n=0;n<i;n++)for(var d=0;d<r;d++)a[d*i+n]=e[n*r+d];return{data:a,height:r,width:i}}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=r(0),a=r(1);e.ssim=function(t,e,r){var n=a.normpdf(function(t){for(var e=Math.floor(t/2),r=new Array(2*e+1),i=-e;i<=e;i++)r[i+e]=Math.abs(i);return{data:r,width:r.length,height:1}}(r.windowSize),0,1.5),d=Math.pow(2,r.bitDepth)-1,o=Math.pow(r.k1*d,2),h=Math.pow(r.k2*d,2);n=i.divide2d(n,i.sum2d(n));var u=a.transpose(n),f=a.conv2(t,n,u,"valid"),l=a.conv2(e,n,u,"valid"),c=i.square2d(f),s=i.square2d(l),v=i.multiply2d(f,l),w=i.square2d(t),g=i.square2d(e),p=i.subtract2d(a.conv2(w,n,u,"valid"),c),y=i.subtract2d(a.conv2(g,n,u,"valid"),s),m=i.subtract2d(a.conv2(i.multiply2d(t,e),n,u,"valid"),v);return o>0&&h>0?function(t,e,r,a,n,d,o,h){var u=i.add2d(i.multiply2d(t,2),o),f=i.add2d(i.multiply2d(e,2),h),l=i.add2d(i.add2d(r,a),o),c=i.add2d(i.add2d(n,d),h);return i.divide2d(i.multiply2d(u,f),i.multiply2d(l,c))}(v,m,c,s,p,y,o,h):function(t,e,r,a,n,d){var o=i.multiply2d(t,2),h=i.multiply2d(e,2),u=i.add2d(r,a),f=i.add2d(n,d);return i.divide2d(i.multiply2d(o,h),i.multiply2d(u,f))}(v,m,c,s,p,y)}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=r(0),a=r(1);e.originalSsim=function(t,e,r){var n=a.fspecial("gaussian",r.windowSize,1.5),d=Math.pow(2,r.bitDepth)-1,o=Math.pow(r.k1*d,2),h=Math.pow(r.k2*d,2);n=i.divide2d(n,i.sum2d(n));var u=a.filter2(n,t,"valid"),f=a.filter2(n,e,"valid"),l=i.square2d(u),c=i.square2d(f),s=i.multiply2d(u,f),v=i.square2d(t),w=i.square2d(e),g=i.subtract2d(a.filter2(n,v,"valid"),l),p=i.subtract2d(a.filter2(n,w,"valid"),c),y=i.subtract2d(a.filter2(n,i.multiply2d(t,e),"valid"),s);if(o>0&&h>0){var m=i.add2d(i.multiply2d(s,2),o),b=i.add2d(i.multiply2d(y,2),h),M=i.add2d(i.add2d(l,c),o),_=i.add2d(i.add2d(g,p),h);return i.divide2d(i.multiply2d(m,b),i.multiply2d(M,_))}var j=i.multiply2d(s,2),O=i.multiply2d(y,2),P=i.add2d(l,c),k=i.add2d(g,p);return i.divide2d(i.multiply2d(j,O),i.multiply2d(P,k))}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=r(0),a=r(1);function n(t,e,r){var a=t.data,n=e.data,d=r.bitDepth,o=r.k1,h=r.k2,u=Math.pow(2,d)-1,f=Math.pow(o*u,2),l=Math.pow(h*u,2),c=i.average(a),s=i.average(n),v=i.variance(a,c),w=i.variance(n,s);return(2*c*s+f)*(2*i.covariance(a,n,c,s)+l)/((Math.pow(c,2)+Math.pow(s,2)+f)*(v+w+l))}e.bezkrovnySsim=function(t,e,r){for(var i=r.windowSize,d=Math.floor(t.width/i),o=Math.floor(t.height/i),h=new Array(d*o),u=0,f=0;f<t.height;f+=i)for(var l=0;l<t.width;l+=i){var c=Math.min(i,t.width-l),s=Math.min(i,t.height-f),v=a.sub(t,l,s,f,c),w=a.sub(e,l,s,f,c);h[u++]=n(v,w,r)}return{data:h,width:d,height:o}}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=r(0),a=r(1);function n(t,e,r){var i=a.imfilter(t,e,"symmetric","same");return a.skip2d(i,[0,r,i.height],[0,r,i.width])}e.downsample=function(t,e){return"original"===e.downsample?function(t,e,r){void 0===r&&(r=256);var d=Math.min(t.width,e.height)/r,o=Math.round(d);if(o>1){var h=a.ones(o);t=n(t,h=i.divide2d(h,i.sum2d(h)),o),e=n(e,h,o)}return[t,e]}(t[0],t[1],e.maxSize):t}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.defaults={windowSize:11,k1:.01,k2:.03,bitDepth:8,downsample:"original",ssim:"fast",maxSize:256}}])})); | ||
//# sourceMappingURL=ssim.web.js.map |
111
package.json
{ | ||
"name": "ssim.js", | ||
"description": "JavaScript implementation of the SSIM algorithm", | ||
"main": "dist/ssim.js", | ||
"browser": "dist/ssim.web.js", | ||
"version": "3.0.0", | ||
"main": "dist/index", | ||
"typings": "dist/index", | ||
"browser": "dist/ssim.web", | ||
"version": "3.1.0", | ||
"scripts": { | ||
"format-all": "git ls-files {src,spec}*.{js,json} | xargs yarn format", | ||
"format": "prettier --write --single-quote --no-semi --trailing-comma es5", | ||
"commit": "git-cz", | ||
"cover": "babel-istanbul cover blue-tape spec/unit/{*,**/*}.spec.js", | ||
"cover:check": "babel-istanbul check", | ||
"test": "blue-tape spec/unit/{*,**/*}.spec.js | tap-dot", | ||
"test:perf": "blue-tape spec/perf/{*,**/*}.spec.js", | ||
"test:web": "node spec/web/sauce.js", | ||
"e2e": "npm-run-all --parallel e2e:*", | ||
"e2e:live": "blue-tape spec/e2e_dist/live.spec.js | tap-dot || exit 1", | ||
"e2e:ivc": "blue-tape spec/e2e_dist/ivc.spec.js | tap-dot || exit 1", | ||
"test:watch": "nodemon node_modules/.bin/blue-tape spec/unit/{*,**/*}.spec.js", | ||
"docs": "jsdoc --pedantic -c .jsdoc . --readme README.md", | ||
"docs:check": "./ci/doc.sh", | ||
"test": "jest --testTimeout=500000", | ||
"lint": "eslint .", | ||
"build": "npm-run-all --parallel build:*", | ||
"build:node": "webpack", | ||
"build:web": "webpack --config webpack.config.web.js", | ||
"build:test": "babel spec/helpers --out-dir spec/helpers_dist/ && babel spec/e2e --out-dir spec/e2e_dist/ && webpack --config webpack.config.web.test.js", | ||
"watch": "webpack --watch", | ||
"codeclimate": "cat ./coverage/lcov.info | codeclimate-test-reporter", | ||
"semantic-release": "semantic-release pre && npm publish && semantic-release post" | ||
"build": "rm -rf dist && tsc && webpack --mode=production", | ||
"semantic-release": "semantic-release" | ||
}, | ||
@@ -48,5 +36,2 @@ "repository": { | ||
}, | ||
"bin": { | ||
"ssim": "./cli.js" | ||
}, | ||
"files": [ | ||
@@ -57,53 +42,37 @@ "package.json", | ||
"src", | ||
"version.js", | ||
"cli.js", | ||
"dist" | ||
], | ||
"homepage": "https://github.com/obartra/ssim#readme", | ||
"dependencies": { | ||
"bmp-js": "^0.0.3", | ||
"canvas": "^1.6.2", | ||
"image-type": "^3.0.0", | ||
"promiz": "^1.0.5", | ||
"yargs": "^6.6.0" | ||
}, | ||
"devDependencies": { | ||
"@bubltechnology/customizable-commit-analyzer": "^1.0.0", | ||
"babel-cli": "^6.22.2", | ||
"babel-core": "^6.22.1", | ||
"babel-istanbul": "^0.12.1", | ||
"babel-loader": "^6.2.10", | ||
"babel-preset-es2015": "^6.22.0", | ||
"babel-preset-es2016": "^6.22.0", | ||
"benchmark": "^2.1.3", | ||
"blue-tape": "^1.0.0", | ||
"codeclimate-test-reporter": "^0.4.0", | ||
"commitizen": "^2.9.5", | ||
"condition-circle": "^1.5.0", | ||
"core-js": "^2.4.1", | ||
"cz-conventional-changelog": "^1.2.0", | ||
"eslint": "^3.14.0", | ||
"eslint-config-airbnb": "^14.0.0", | ||
"eslint-plugin-import": "^2.2.0", | ||
"eslint-plugin-jsx-a11y": "^3.0.2", | ||
"eslint-plugin-react": "^6.9.0", | ||
"http-server": "^0.9.0", | ||
"inchjs": "^0.4.1", | ||
"jsdoc": "^3.4.3", | ||
"json-loader": "^0.5.4", | ||
"ngrok": "^2.2.5", | ||
"nodemon": "^1.11.0", | ||
"npm-install-version": "^6.0.1", | ||
"npm-run-all": "^4.0.1", | ||
"saucelabs": "^1.3.0", | ||
"semantic-release": "^6.3.2", | ||
"semantic-release-cli": "^3.0.3", | ||
"tap-dot": "^1.0.5", | ||
"webdriverio": "^4.6.1", | ||
"webpack": "^2.1.0-beta.27" | ||
"@semantic-release/commit-analyzer": "6.3.3", | ||
"@semantic-release/github": "5.5.5", | ||
"@semantic-release/npm": "5.3.5", | ||
"@types/jest": "24.0.25", | ||
"@types/node": "13.1.1", | ||
"benchmark": "2.1.4", | ||
"bmp-js": "0.1.0", | ||
"canvas": "2.6.1", | ||
"commitizen": "4.0.3", | ||
"condition-circle": "2.0.2", | ||
"core-js": "3.6.1", | ||
"cz-conventional-changelog": "3.0.2", | ||
"eslint": "6.8.0", | ||
"eslint-config-airbnb": "18.0.1", | ||
"eslint-config-prettier": "6.9.0", | ||
"eslint-plugin-import": "2.19.1", | ||
"eslint-plugin-jsx-a11y": "6.2.3", | ||
"eslint-plugin-react": "7.17.0", | ||
"image-type": "4.1.0", | ||
"jest": "24.9.0", | ||
"nodemon": "2.0.2", | ||
"prettier": "1.19.1", | ||
"request": "2.88.0", | ||
"semantic-release": "15.14.0", | ||
"semantic-release-cli": "5.2.3", | ||
"ts-jest": "24.2.0", | ||
"ts-loader": "6.2.1", | ||
"typescript": "3.7.4", | ||
"webpack": "4.41.5", | ||
"webpack-cli": "3.3.10" | ||
}, | ||
"release": { | ||
"verifyConditions": "condition-circle", | ||
"analyzeCommits": "@bubltechnology/customizable-commit-analyzer" | ||
}, | ||
"config": { | ||
@@ -114,2 +83,2 @@ "commitizen": { | ||
} | ||
} | ||
} |
@@ -1,2 +0,2 @@ | ||
[](https://circleci.com/gh/obartra/ssim/tree/master) [](https://codeclimate.com/github/obartra/ssim/coverage) [](https://opensource.org/licenses/MIT) | ||
[](https://circleci.com/gh/obartra/ssim/tree/master) [](https://codeclimate.com/github/obartra/ssim/coverage) [](https://opensource.org/licenses/MIT) [](https://www.npmjs.com/package/ssim.js) | ||
@@ -9,10 +9,10 @@ # SSIM.JS | ||
| | | | | ||
| ------------------------------------ | ------------------------------------- | ------------------------------------- | | ||
| | | | | ||
| ------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------ | | ||
|  |  |  | | ||
| Original, MSE = 0, SSIM = 1 | MSE = 144, SSIM = 0.988 | MSE = 144, SSIM = 0.913 | | ||
| Original, MSE = 0, SSIM = 1 | MSE = 144, SSIM = 0.988 | MSE = 144, SSIM = 0.913 | | ||
|  |  |  | | ||
| MSE = 144, SSIM = 0.840 | MSE = 144, SSIM = 0.694 | MSE = 142, SSIM = 0.662 | | ||
| MSE = 144, SSIM = 0.840 | MSE = 144, SSIM = 0.694 | MSE = 142, SSIM = 0.662 | | ||
*Table extracted from http://www.cns.nyu.edu/~lcv/ssim/* | ||
_Table extracted from http://www.cns.nyu.edu/~lcv/ssim/_ | ||
@@ -25,44 +25,23 @@ ## 🖥 Install | ||
This will install the node, web and CLI versions. | ||
You can also use the web version directly from [unpkg](https://unpkg.com)'s CDN: `https://unpkg.com/ssim.js@{{version}}/dist/ssim.web.js`. | ||
Install it globally (`npm install -g`) to make `ssim` available on your path. | ||
You can also use the web version directly from [unpkg](https://unpkg.com)'s CDN: `https://unpkg.com/ssim.js@{{semver}}`. | ||
## 📝 Usage | ||
[Playground](https://ssim-comparison.gomix.me/) for Node and Web versions. | ||
Check out the [playground](https://ssim-comparison.gomix.me/) for node and web usage examples. | ||
Node: | ||
SSIM.js takes in 2 image buffers and optional options parameter. You can find all options available [here](https://github.com/obartra/ssim/wiki/Usage#options). | ||
```javascript | ||
For examples on how to implement image loading strategies for both node and the web, check out [this wiki page](https://github.com/obartra/ssim/wiki/Node-and-Browsers). | ||
import ssim from 'ssim.js'; | ||
```js | ||
import ssim from "ssim.js"; | ||
ssim('./img1.jpg', './img2.jpg') | ||
.then(({ mssim, performance }) => console.log(`SSIM: ${mssim} (${performance}ms)`)) | ||
.catch(err => console.error('Error generating SSIM', err)); | ||
``` | ||
const img1 = loadImage("./img1.jpg"); | ||
const img2 = loadImage("./img2.jpg"); | ||
Browser: | ||
const { mssim, performance } = ssim(img1, img2); | ||
```html | ||
<script src="https://unpkg.com/ssim.js@^2.0.0"></script> | ||
<script> | ||
ssim('/img1.jpg', '/img2.jpg') | ||
.then(function(out) { | ||
console.log('SSIM:', out.mssim, '(', out.performance, 'ms)'); | ||
}) | ||
.catch(function(err) { | ||
console.error('Error generating SSIM', err); | ||
}); | ||
</script> | ||
console.log(`SSIM: ${mssim} (${performance}ms)`); | ||
``` | ||
CLI: | ||
```shell | ||
$ ./node_modules/.bin/ssim ./img1.jpg ./img2.jpg | ||
``` | ||
## 📖 Documentation | ||
@@ -72,18 +51,13 @@ | ||
The code is fully documented and a hosted version is available [here](https://doclets.io/obartra/ssim/master). | ||
The code is fully documented but feel free to create an issue [here](https://github.com/obartra/ssim/issues/new) if you have any questions. | ||
## 🏁 Metrics | ||
| Process | Status | | ||
|---------------|-----------| | ||
| Code Quality | [](https://codeclimate.com/github/obartra/ssim) [](https://codeclimate.com/github/obartra/ssim) | | ||
| Versioning | [](https://github.com/semantic-release/semantic-release) [](http://commitizen.github.io/cz-cli/) [](https://www.npmjs.com/package/ssim.js) | | ||
| Dependencies | [](https://snyk.io/test/github/obartra/ssim) [](https://david-dm.org/obartra/ssim) | | ||
| Documentation | [](https://inch-ci.org/github/obartra/ssim) | | ||
| Environments |   [](https://saucelabs.com/u/saucessim-master)| | ||
| Process | Status | | ||
| ------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | ||
| Versioning | [](https://github.com/semantic-release/semantic-release) [](http://commitizen.github.io/cz-cli/) | | ||
| Dependencies | [](https://snyk.io/test/github/obartra/ssim) [](https://david-dm.org/obartra/ssim) | | ||
[](https://saucelabs.com/u/saucessim-master) | ||
## 💡 Credits | ||
This project is a direct port of algorithms published by [Wang, et al. 2004](/assets/ssim.pdf) on "Image Quality Assessment: From Error Visibility to Structural Similarity". The original Matlab scripts are available [here](https://ece.uwaterloo.ca/~z70wang/research/iwssim/) with their datasets. To view the steps taken to validate `ssim.js` results, check the [wiki](https://github.com/obartra/ssim/wiki/Results-Validation). |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
318083
0
30
98
4914
0
0
1
61
- Removedbmp-js@^0.0.3
- Removedcanvas@^1.6.2
- Removedimage-type@^3.0.0
- Removedpromiz@^1.0.5
- Removedyargs@^6.6.0
- Removedansi-regex@2.1.1(transitive)
- Removedbmp-js@0.0.3(transitive)
- Removedcamelcase@3.0.0(transitive)
- Removedcanvas@1.6.13(transitive)
- Removedcliui@3.2.0(transitive)
- Removedcode-point-at@1.1.0(transitive)
- Removeddecamelize@1.2.0(transitive)
- Removederror-ex@1.3.2(transitive)
- Removedfile-type@10.11.0(transitive)
- Removedfind-up@1.1.2(transitive)
- Removedfunction-bind@1.1.2(transitive)
- Removedget-caller-file@1.0.3(transitive)
- Removedgraceful-fs@4.2.11(transitive)
- Removedhasown@2.0.2(transitive)
- Removedhosted-git-info@2.8.9(transitive)
- Removedimage-type@3.1.0(transitive)
- Removedinvert-kv@1.0.0(transitive)
- Removedis-arrayish@0.2.1(transitive)
- Removedis-core-module@2.16.1(transitive)
- Removedis-fullwidth-code-point@1.0.0(transitive)
- Removedis-utf8@0.2.1(transitive)
- Removedlcid@1.0.0(transitive)
- Removedload-json-file@1.1.0(transitive)
- Removednan@2.22.2(transitive)
- Removednormalize-package-data@2.5.0(transitive)
- Removednumber-is-nan@1.0.1(transitive)
- Removedos-locale@1.4.0(transitive)
- Removedparse-json@2.2.0(transitive)
- Removedpath-exists@2.1.0(transitive)
- Removedpath-parse@1.0.7(transitive)
- Removedpath-type@1.1.0(transitive)
- Removedpify@2.3.0(transitive)
- Removedpinkie@2.0.4(transitive)
- Removedpinkie-promise@2.0.1(transitive)
- Removedpromiz@1.0.6(transitive)
- Removedread-pkg@1.1.0(transitive)
- Removedread-pkg-up@1.0.1(transitive)
- Removedrequire-directory@2.1.1(transitive)
- Removedrequire-main-filename@1.0.1(transitive)
- Removedresolve@1.22.10(transitive)
- Removedsemver@5.7.2(transitive)
- Removedset-blocking@2.0.0(transitive)
- Removedspdx-correct@3.2.0(transitive)
- Removedspdx-exceptions@2.5.0(transitive)
- Removedspdx-expression-parse@3.0.1(transitive)
- Removedspdx-license-ids@3.0.21(transitive)
- Removedstring-width@1.0.2(transitive)
- Removedstrip-ansi@3.0.1(transitive)
- Removedstrip-bom@2.0.0(transitive)
- Removedsupports-preserve-symlinks-flag@1.0.0(transitive)
- Removedvalidate-npm-package-license@3.0.4(transitive)
- Removedwhich-module@1.0.0(transitive)
- Removedwrap-ansi@2.1.0(transitive)
- Removedy18n@3.2.2(transitive)
- Removedyargs@6.6.0(transitive)
- Removedyargs-parser@4.2.1(transitive)