ssim.js 4.0.1 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CLA.md +66 -0
- package/CONTRIBUTING.md +119 -0
- package/LICENSE +1 -1
- package/LICENSES/LIVE Images Database +18 -0
- package/LICENSES/Subjective quality assessment - IVC database +5 -0
- package/LICENSES/Wang et al SSIM +24 -0
- package/LICENSES/bezkrovny +49 -0
- package/LICENSES/cell2csv +2 -0
- package/LICENSES/obartra-ssim +21 -0
- package/LICENSES/rhys-e +21 -0
- package/README.md +216 -34
- package/dist/bezkrovnySsim.d.ts +5 -19
- package/dist/bezkrovnySsim.js +113 -72
- package/dist/bezkrovnySsim.js.map +1 -1
- package/dist/browser.d.mts +9 -0
- package/dist/browser.d.ts +9 -0
- package/dist/browser.js +37 -0
- package/dist/browser.js.map +1 -0
- package/dist/browser.mjs +742 -0
- package/dist/browser.mjs.map +7 -0
- package/dist/defaults.d.ts +3 -1
- package/dist/defaults.js +14 -4
- package/dist/defaults.js.map +1 -1
- package/dist/gaussian.d.ts +2 -0
- package/dist/gaussian.js +168 -0
- package/dist/gaussian.js.map +1 -0
- package/dist/gaussianSymmetric.d.ts +3 -0
- package/dist/gaussianSymmetric.js +62 -0
- package/dist/gaussianSymmetric.js.map +1 -0
- package/dist/index.d.mts +9 -0
- package/dist/index.d.ts +8 -19
- package/dist/index.js +19 -88
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +718 -0
- package/dist/index.mjs.map +7 -0
- package/dist/options.d.ts +2 -0
- package/dist/options.js +60 -0
- package/dist/options.js.map +1 -0
- package/dist/originalSsim.d.ts +3 -26
- package/dist/originalSsim.js +5 -57
- package/dist/originalSsim.js.map +1 -1
- package/dist/pixels.d.ts +5 -0
- package/dist/pixels.js +157 -0
- package/dist/pixels.js.map +1 -0
- package/dist/prepare.d.ts +7 -0
- package/dist/prepare.js +48 -0
- package/dist/prepare.js.map +1 -0
- package/dist/referenceSsim.d.ts +4 -0
- package/dist/referenceSsim.js +59 -0
- package/dist/referenceSsim.js.map +1 -0
- package/dist/result.d.ts +2 -0
- package/dist/result.js +20 -0
- package/dist/result.js.map +1 -0
- package/dist/ssim.d.ts +3 -21
- package/dist/ssim.js +4 -126
- package/dist/ssim.js.map +1 -1
- package/dist/ssim.web.js +2 -2
- package/dist/ssim.web.js.map +7 -1
- package/dist/types.d.ts +27 -7
- package/dist/weberSsim.d.ts +19 -0
- package/dist/weberSsim.js +119 -0
- package/dist/weberSsim.js.map +1 -0
- package/package.json +116 -1
- package/src/bezkrovnySsim.ts +133 -67
- package/src/browser.ts +49 -0
- package/src/defaults.ts +16 -6
- package/src/gaussian.ts +228 -0
- package/src/gaussianSymmetric.ts +95 -0
- package/src/index.ts +47 -96
- package/src/options.ts +74 -0
- package/src/originalSsim.ts +9 -79
- package/src/pixels.ts +198 -0
- package/src/prepare.ts +73 -0
- package/src/referenceSsim.ts +71 -0
- package/src/result.ts +23 -0
- package/src/ssim.ts +9 -168
- package/src/types.ts +44 -15
- package/src/weberSsim.ts +132 -0
- package/dist/downsample.d.ts +0 -12
- package/dist/downsample.js +0 -70
- package/dist/downsample.js.map +0 -1
- package/dist/math.d.ts +0 -155
- package/dist/math.js +0 -394
- package/dist/math.js.map +0 -1
- package/dist/matlab/conv2.d.ts +0 -137
- package/dist/matlab/conv2.js +0 -250
- package/dist/matlab/conv2.js.map +0 -1
- package/dist/matlab/filter2.d.ts +0 -18
- package/dist/matlab/filter2.js +0 -53
- package/dist/matlab/filter2.js.map +0 -1
- package/dist/matlab/fspecial.d.ts +0 -39
- package/dist/matlab/fspecial.js +0 -102
- package/dist/matlab/fspecial.js.map +0 -1
- package/dist/matlab/imfilter.d.ts +0 -24
- package/dist/matlab/imfilter.js +0 -84
- package/dist/matlab/imfilter.js.map +0 -1
- package/dist/matlab/index.d.ts +0 -23
- package/dist/matlab/index.js +0 -29
- package/dist/matlab/index.js.map +0 -1
- package/dist/matlab/internal/numbers.d.ts +0 -14
- package/dist/matlab/internal/numbers.js +0 -28
- package/dist/matlab/internal/numbers.js.map +0 -1
- package/dist/matlab/mod.d.ts +0 -21
- package/dist/matlab/mod.js +0 -27
- package/dist/matlab/mod.js.map +0 -1
- package/dist/matlab/normpdf.d.ts +0 -36
- package/dist/matlab/normpdf.js +0 -55
- package/dist/matlab/normpdf.js.map +0 -1
- package/dist/matlab/ones.d.ts +0 -15
- package/dist/matlab/ones.js +0 -22
- package/dist/matlab/ones.js.map +0 -1
- package/dist/matlab/padarray.d.ts +0 -37
- package/dist/matlab/padarray.js +0 -349
- package/dist/matlab/padarray.js.map +0 -1
- package/dist/matlab/rgb2gray.d.ts +0 -15
- package/dist/matlab/rgb2gray.js +0 -58
- package/dist/matlab/rgb2gray.js.map +0 -1
- package/dist/matlab/skip2d.d.ts +0 -34
- package/dist/matlab/skip2d.js +0 -55
- package/dist/matlab/skip2d.js.map +0 -1
- package/dist/matlab/sub.d.ts +0 -17
- package/dist/matlab/sub.js +0 -33
- package/dist/matlab/sub.js.map +0 -1
- package/dist/matlab/transpose.d.ts +0 -18
- package/dist/matlab/transpose.js +0 -34
- package/dist/matlab/transpose.js.map +0 -1
- package/dist/matlab/zeros.d.ts +0 -15
- package/dist/matlab/zeros.js +0 -22
- package/dist/matlab/zeros.js.map +0 -1
- package/dist/version.d.ts +0 -2
- package/dist/version.js +0 -5
- package/dist/version.js.map +0 -1
- package/src/downsample.ts +0 -81
- package/src/math.ts +0 -447
- package/src/matlab/conv2.ts +0 -272
- package/src/matlab/filter2.ts +0 -52
- package/src/matlab/fspecial.ts +0 -107
- package/src/matlab/imfilter.ts +0 -93
- package/src/matlab/index.ts +0 -23
- package/src/matlab/internal/numbers.ts +0 -28
- package/src/matlab/mod.ts +0 -23
- package/src/matlab/normpdf.ts +0 -57
- package/src/matlab/ones.ts +0 -19
- package/src/matlab/padarray.ts +0 -375
- package/src/matlab/rgb2gray.ts +0 -65
- package/src/matlab/skip2d.ts +0 -58
- package/src/matlab/sub.ts +0 -38
- package/src/matlab/transpose.ts +0 -33
- package/src/matlab/zeros.ts +0 -19
- package/src/types/bmp-js.d.ts +0 -1
- package/src/version.ts +0 -2
package/dist/matlab/rgb2gray.js
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
/**
|
|
4
|
-
* For an array of pixels of the form [r, g, b] it returns the equivalent grayscale color. These
|
|
5
|
-
* values are not derived from ITU's recommendation of [0.2126, 0.7152, 0.0722] for [r, g, b] but on
|
|
6
|
-
* Matlab's implementation of [0.2989, 0.5870, 0.1140]
|
|
7
|
-
*
|
|
8
|
-
* Note that values are rounded to ensure an exact match with the original results. I think
|
|
9
|
-
* rounding them would NOT lead to higher accuracy since the exact values for RGB to grayscale
|
|
10
|
-
* conversion are somewhat arbitrary (as examplified by the differences between ITU and Matlab).
|
|
11
|
-
* ± 0.5 pixel differences won't be perceptible for the human eye and will have a small impact on
|
|
12
|
-
* SSIM. Based on some sample data changes were of the order of 10^-3.
|
|
13
|
-
*
|
|
14
|
-
* @method luma
|
|
15
|
-
* @param {Number} r - The red pixel value
|
|
16
|
-
* @param {Number} g - The green pixel value
|
|
17
|
-
* @param {Number} b - The blue pixel value
|
|
18
|
-
* @returns {Number} lumaValue - The value of the luminance for the [r,g,b] pixel
|
|
19
|
-
* @private
|
|
20
|
-
* @memberOf matlab
|
|
21
|
-
* @since 0.0.2
|
|
22
|
-
*/
|
|
23
|
-
function luma(r, g, b) {
|
|
24
|
-
return Math.round(0.29894 * r + 0.58704 * g + 0.11402 * b);
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Converts an imageData object of { width, height, data } into a 2d matrix [row, column]
|
|
28
|
-
* where the value is the grayscale equivalent of the rgb input.
|
|
29
|
-
*
|
|
30
|
-
* This method mimics Matlab's `rgb2gray` method
|
|
31
|
-
*
|
|
32
|
-
* @method rgb2gray
|
|
33
|
-
* @param {Matrix | ImageData} imageData - The input imageData
|
|
34
|
-
* @returns {Object} grayscale - A grayscale representation of the input image
|
|
35
|
-
* @public
|
|
36
|
-
* @memberOf matlab
|
|
37
|
-
* @since 0.0.2
|
|
38
|
-
*/
|
|
39
|
-
function rgb2gray(_a) {
|
|
40
|
-
var d = _a.data, width = _a.width, height = _a.height;
|
|
41
|
-
var data = new Array(width * height);
|
|
42
|
-
for (var j = 0; j < height; j++) {
|
|
43
|
-
for (var i = 0; i < width; i++) {
|
|
44
|
-
var grayIndex = i + j * width;
|
|
45
|
-
var imgIndex = grayIndex * 4;
|
|
46
|
-
data[grayIndex] = luma(d[imgIndex], d[imgIndex + 1], d[imgIndex + 2]
|
|
47
|
-
// d[imgIndex + 3] // ignore alpha channel
|
|
48
|
-
);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
return {
|
|
52
|
-
data: data,
|
|
53
|
-
width: width,
|
|
54
|
-
height: height
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
exports.rgb2gray = rgb2gray;
|
|
58
|
-
//# sourceMappingURL=rgb2gray.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"rgb2gray.js","sourceRoot":"","sources":["../../src/matlab/rgb2gray.ts"],"names":[],"mappings":";;AAEA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,SAAS,IAAI,CAAC,CAAS,EAAE,CAAS,EAAE,CAAS;IAC3C,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,GAAG,CAAC,GAAG,OAAO,GAAG,CAAC,GAAG,OAAO,GAAG,CAAC,CAAC,CAAC;AAC7D,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,SAAgB,QAAQ,CAAC,EAIJ;QAHnB,WAAO,EACP,gBAAK,EACL,kBAAM;IAEN,IAAM,IAAI,GAAG,IAAI,KAAK,CAAC,KAAK,GAAG,MAAM,CAAC,CAAC;IAEvC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,EAAE,CAAC,EAAE,EAAE;QAC/B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,EAAE,CAAC,EAAE,EAAE;YAC9B,IAAM,SAAS,GAAG,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;YAChC,IAAM,QAAQ,GAAG,SAAS,GAAG,CAAC,CAAC;YAE/B,IAAI,CAAC,SAAS,CAAC,GAAG,IAAI,CACpB,CAAC,CAAC,QAAQ,CAAC,EACX,CAAC,CAAC,QAAQ,GAAG,CAAC,CAAC,EACf,CAAC,CAAC,QAAQ,GAAG,CAAC,CAAC;YACf,0CAA0C;aAC3C,CAAC;SACH;KACF;IACD,OAAO;QACL,IAAI,MAAA;QACJ,KAAK,OAAA;QACL,MAAM,QAAA;KACP,CAAC;AACJ,CAAC;AAzBD,4BAyBC"}
|
package/dist/matlab/skip2d.d.ts
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { Matrix } from "../types";
|
|
2
|
-
/**
|
|
3
|
-
* Generates a matrix based on input `mx` but excluding items based on their modulo and their
|
|
4
|
-
* position in the original matrix.
|
|
5
|
-
*
|
|
6
|
-
* It's a crude implementation of Matlab's `A(1:f:end,1:f:end)` syntax where the first parameter
|
|
7
|
-
* is the matrix, the next one is an array describing the rows to skip [start position, every `f`
|
|
8
|
-
* elements an end position] and the last one follows the same syntax for columns.
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
* ```
|
|
12
|
-
* img1(1:f:end,1:f:end)
|
|
13
|
-
*
|
|
14
|
-
* ```
|
|
15
|
-
*
|
|
16
|
-
* becomes:
|
|
17
|
-
*
|
|
18
|
-
* ```
|
|
19
|
-
* skip2d(img1, [0, f, img1.length], [0, f, img1[0].length])
|
|
20
|
-
* ```
|
|
21
|
-
*
|
|
22
|
-
* Note that the start index is 0 since, unlike Matlab's, arrays start at 0. Also, unlike in Matlab,
|
|
23
|
-
* `f` must be an integer greater than or equal to 1.
|
|
24
|
-
*
|
|
25
|
-
* @method skip2d
|
|
26
|
-
* @param {Matrix} A - The input matrix
|
|
27
|
-
* @param {Array<number>} - start row, every row, end row
|
|
28
|
-
* @param {Array<number>} - start col, every col, end col
|
|
29
|
-
* @returns {Matrix} B - The downsized matrix
|
|
30
|
-
* @public
|
|
31
|
-
* @memberOf matlab
|
|
32
|
-
* @since 0.0.2
|
|
33
|
-
*/
|
|
34
|
-
export declare function skip2d(A: Matrix, [startRow, everyRow, endRow]: [number, number, number], [startCol, everyCol, endCol]: [number, number, number]): Matrix;
|
package/dist/matlab/skip2d.js
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
/**
|
|
4
|
-
* Generates a matrix based on input `mx` but excluding items based on their modulo and their
|
|
5
|
-
* position in the original matrix.
|
|
6
|
-
*
|
|
7
|
-
* It's a crude implementation of Matlab's `A(1:f:end,1:f:end)` syntax where the first parameter
|
|
8
|
-
* is the matrix, the next one is an array describing the rows to skip [start position, every `f`
|
|
9
|
-
* elements an end position] and the last one follows the same syntax for columns.
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
* ```
|
|
13
|
-
* img1(1:f:end,1:f:end)
|
|
14
|
-
*
|
|
15
|
-
* ```
|
|
16
|
-
*
|
|
17
|
-
* becomes:
|
|
18
|
-
*
|
|
19
|
-
* ```
|
|
20
|
-
* skip2d(img1, [0, f, img1.length], [0, f, img1[0].length])
|
|
21
|
-
* ```
|
|
22
|
-
*
|
|
23
|
-
* Note that the start index is 0 since, unlike Matlab's, arrays start at 0. Also, unlike in Matlab,
|
|
24
|
-
* `f` must be an integer greater than or equal to 1.
|
|
25
|
-
*
|
|
26
|
-
* @method skip2d
|
|
27
|
-
* @param {Matrix} A - The input matrix
|
|
28
|
-
* @param {Array<number>} - start row, every row, end row
|
|
29
|
-
* @param {Array<number>} - start col, every col, end col
|
|
30
|
-
* @returns {Matrix} B - The downsized matrix
|
|
31
|
-
* @public
|
|
32
|
-
* @memberOf matlab
|
|
33
|
-
* @since 0.0.2
|
|
34
|
-
*/
|
|
35
|
-
function skip2d(A, _a, _b) {
|
|
36
|
-
var startRow = _a[0], everyRow = _a[1], endRow = _a[2];
|
|
37
|
-
var startCol = _b[0], everyCol = _b[1], endCol = _b[2];
|
|
38
|
-
var width = Math.ceil((endCol - startCol) / everyCol);
|
|
39
|
-
var height = Math.ceil((endRow - startRow) / everyRow);
|
|
40
|
-
var data = new Array(width * height);
|
|
41
|
-
for (var i = 0; i < height; i++) {
|
|
42
|
-
for (var j = 0; j < width; j++) {
|
|
43
|
-
var Ai = startRow + i * everyRow;
|
|
44
|
-
var Aj = startCol + j * everyCol;
|
|
45
|
-
data[i * width + j] = A.data[Ai * A.width + Aj];
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
return {
|
|
49
|
-
data: data,
|
|
50
|
-
width: width,
|
|
51
|
-
height: height
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
exports.skip2d = skip2d;
|
|
55
|
-
//# sourceMappingURL=skip2d.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"skip2d.js","sourceRoot":"","sources":["../../src/matlab/skip2d.ts"],"names":[],"mappings":";;AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,SAAgB,MAAM,CACpB,CAAS,EACT,EAAsD,EACtD,EAAsD;QADrD,gBAAQ,EAAE,gBAAQ,EAAE,cAAM;QAC1B,gBAAQ,EAAE,gBAAQ,EAAE,cAAM;IAE3B,IAAM,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,GAAG,QAAQ,CAAC,GAAG,QAAQ,CAAC,CAAC;IACxD,IAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,GAAG,QAAQ,CAAC,GAAG,QAAQ,CAAC,CAAC;IACzD,IAAM,IAAI,GAAG,IAAI,KAAK,CAAC,KAAK,GAAG,MAAM,CAAC,CAAC;IAEvC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,EAAE,CAAC,EAAE,EAAE;QAC/B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,EAAE,CAAC,EAAE,EAAE;YAC9B,IAAM,EAAE,GAAG,QAAQ,GAAG,CAAC,GAAG,QAAQ,CAAC;YACnC,IAAM,EAAE,GAAG,QAAQ,GAAG,CAAC,GAAG,QAAQ,CAAC;YAEnC,IAAI,CAAC,CAAC,GAAG,KAAK,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC,KAAK,GAAG,EAAE,CAAC,CAAC;SACjD;KACF;IAED,OAAO;QACL,IAAI,MAAA;QACJ,KAAK,OAAA;QACL,MAAM,QAAA;KACP,CAAC;AACJ,CAAC;AAvBD,wBAuBC"}
|
package/dist/matlab/sub.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { Matrix } from "../types";
|
|
2
|
-
/**
|
|
3
|
-
* Crops the matrix and returns a window at position `[x,y]` of size `[xlen, ylen]` from the input
|
|
4
|
-
* matrix
|
|
5
|
-
*
|
|
6
|
-
* @method sub
|
|
7
|
-
* @param {Matrix} A - The input matrix
|
|
8
|
-
* @param {Number} x - The starting x offset
|
|
9
|
-
* @param {Number} height - The vertical size of the window
|
|
10
|
-
* @param {Number} y - The starting y offset
|
|
11
|
-
* @param {Number} width - The horizontal size of the window
|
|
12
|
-
* @returns {Matrix} B - The generated subwindow from matrix `c`
|
|
13
|
-
* @public
|
|
14
|
-
* @memberOf matlab
|
|
15
|
-
* @since 0.0.2
|
|
16
|
-
*/
|
|
17
|
-
export declare function sub({ data: ref, width: refWidth }: Matrix, x: number, height: number, y: number, width: number): Matrix;
|
package/dist/matlab/sub.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
/**
|
|
4
|
-
* Crops the matrix and returns a window at position `[x,y]` of size `[xlen, ylen]` from the input
|
|
5
|
-
* matrix
|
|
6
|
-
*
|
|
7
|
-
* @method sub
|
|
8
|
-
* @param {Matrix} A - The input matrix
|
|
9
|
-
* @param {Number} x - The starting x offset
|
|
10
|
-
* @param {Number} height - The vertical size of the window
|
|
11
|
-
* @param {Number} y - The starting y offset
|
|
12
|
-
* @param {Number} width - The horizontal size of the window
|
|
13
|
-
* @returns {Matrix} B - The generated subwindow from matrix `c`
|
|
14
|
-
* @public
|
|
15
|
-
* @memberOf matlab
|
|
16
|
-
* @since 0.0.2
|
|
17
|
-
*/
|
|
18
|
-
function sub(_a, x, height, y, width) {
|
|
19
|
-
var ref = _a.data, refWidth = _a.width;
|
|
20
|
-
var data = new Array(width * height);
|
|
21
|
-
for (var i = 0; i < height; i++) {
|
|
22
|
-
for (var j = 0; j < width; j++) {
|
|
23
|
-
data[i * width + j] = ref[(y + i) * refWidth + x + j];
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
return {
|
|
27
|
-
data: data,
|
|
28
|
-
width: width,
|
|
29
|
-
height: height
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
exports.sub = sub;
|
|
33
|
-
//# sourceMappingURL=sub.js.map
|
package/dist/matlab/sub.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sub.js","sourceRoot":"","sources":["../../src/matlab/sub.ts"],"names":[],"mappings":";;AAEA;;;;;;;;;;;;;;GAcG;AACH,SAAgB,GAAG,CACjB,EAAsC,EACtC,CAAS,EACT,MAAc,EACd,CAAS,EACT,KAAa;QAJX,aAAS,EAAE,mBAAe;IAM5B,IAAM,IAAI,GAAG,IAAI,KAAK,CAAC,KAAK,GAAG,MAAM,CAAC,CAAC;IAEvC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,EAAE,CAAC,EAAE,EAAE;QAC/B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,EAAE,CAAC,EAAE,EAAE;YAC9B,IAAI,CAAC,CAAC,GAAG,KAAK,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,QAAQ,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;SACvD;KACF;IAED,OAAO;QACL,IAAI,MAAA;QACJ,KAAK,OAAA;QACL,MAAM,QAAA;KACP,CAAC;AACJ,CAAC;AApBD,kBAoBC"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { Matrix } from "../types";
|
|
2
|
-
/**
|
|
3
|
-
* Transposes a vector or a matrix
|
|
4
|
-
*
|
|
5
|
-
* This method mimics Matlab's `transpose` method (which equals to the `A.'` syntax)
|
|
6
|
-
*
|
|
7
|
-
* `B = A.'` returns the nonconjugate transpose of A, that is, interchanges the row and column index
|
|
8
|
-
* for each element.
|
|
9
|
-
*
|
|
10
|
-
* This method does not handle complex or imaginary numbers
|
|
11
|
-
*
|
|
12
|
-
* @method transpose
|
|
13
|
-
* @param {Matrix} A - The matrix to transpose
|
|
14
|
-
* @returns {Matrix} B - The transposed matrix
|
|
15
|
-
* @public
|
|
16
|
-
* @memberOf matlab
|
|
17
|
-
*/
|
|
18
|
-
export declare function transpose({ data: ref, width, height }: Matrix): Matrix;
|
package/dist/matlab/transpose.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
/**
|
|
4
|
-
* Transposes a vector or a matrix
|
|
5
|
-
*
|
|
6
|
-
* This method mimics Matlab's `transpose` method (which equals to the `A.'` syntax)
|
|
7
|
-
*
|
|
8
|
-
* `B = A.'` returns the nonconjugate transpose of A, that is, interchanges the row and column index
|
|
9
|
-
* for each element.
|
|
10
|
-
*
|
|
11
|
-
* This method does not handle complex or imaginary numbers
|
|
12
|
-
*
|
|
13
|
-
* @method transpose
|
|
14
|
-
* @param {Matrix} A - The matrix to transpose
|
|
15
|
-
* @returns {Matrix} B - The transposed matrix
|
|
16
|
-
* @public
|
|
17
|
-
* @memberOf matlab
|
|
18
|
-
*/
|
|
19
|
-
function transpose(_a) {
|
|
20
|
-
var ref = _a.data, width = _a.width, height = _a.height;
|
|
21
|
-
var data = new Array(width * height);
|
|
22
|
-
for (var i = 0; i < height; i++) {
|
|
23
|
-
for (var j = 0; j < width; j++) {
|
|
24
|
-
data[j * height + i] = ref[i * width + j];
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
return {
|
|
28
|
-
data: data,
|
|
29
|
-
height: width,
|
|
30
|
-
width: height
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
exports.transpose = transpose;
|
|
34
|
-
//# sourceMappingURL=transpose.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"transpose.js","sourceRoot":"","sources":["../../src/matlab/transpose.ts"],"names":[],"mappings":";;AAEA;;;;;;;;;;;;;;;GAeG;AACH,SAAgB,SAAS,CAAC,EAAoC;QAAlC,aAAS,EAAE,gBAAK,EAAE,kBAAM;IAClD,IAAM,IAAI,GAAG,IAAI,KAAK,CAAC,KAAK,GAAG,MAAM,CAAC,CAAC;IAEvC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,EAAE,CAAC,EAAE,EAAE;QAC/B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,EAAE,CAAC,EAAE,EAAE;YAC9B,IAAI,CAAC,CAAC,GAAG,MAAM,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,GAAG,KAAK,GAAG,CAAC,CAAC,CAAC;SAC3C;KACF;IAED,OAAO;QACL,IAAI,MAAA;QACJ,MAAM,EAAE,KAAK;QACb,KAAK,EAAE,MAAM;KACd,CAAC;AACJ,CAAC;AAdD,8BAcC"}
|
package/dist/matlab/zeros.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { Matrix } from "../types";
|
|
2
|
-
/**
|
|
3
|
-
* Create a matrix of all zeros
|
|
4
|
-
*
|
|
5
|
-
* This method mimics Matlab's `zeros` method
|
|
6
|
-
*
|
|
7
|
-
* @method zeros
|
|
8
|
-
* @param {Number} height - The height of the matrix (rows)
|
|
9
|
-
* @param {Number} [width=height] - The width of the matrix (columns)
|
|
10
|
-
* @returns {Matrix} B - An n-by-m matrix of zeros
|
|
11
|
-
* @public
|
|
12
|
-
* @memberOf matlab
|
|
13
|
-
* @since 0.0.2
|
|
14
|
-
*/
|
|
15
|
-
export declare function zeros(height: number, width?: number): Matrix;
|
package/dist/matlab/zeros.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
var numbers_1 = require("./internal/numbers");
|
|
4
|
-
/**
|
|
5
|
-
* Create a matrix of all zeros
|
|
6
|
-
*
|
|
7
|
-
* This method mimics Matlab's `zeros` method
|
|
8
|
-
*
|
|
9
|
-
* @method zeros
|
|
10
|
-
* @param {Number} height - The height of the matrix (rows)
|
|
11
|
-
* @param {Number} [width=height] - The width of the matrix (columns)
|
|
12
|
-
* @returns {Matrix} B - An n-by-m matrix of zeros
|
|
13
|
-
* @public
|
|
14
|
-
* @memberOf matlab
|
|
15
|
-
* @since 0.0.2
|
|
16
|
-
*/
|
|
17
|
-
function zeros(height, width) {
|
|
18
|
-
if (width === void 0) { width = height; }
|
|
19
|
-
return numbers_1.numbers(height, width, 0);
|
|
20
|
-
}
|
|
21
|
-
exports.zeros = zeros;
|
|
22
|
-
//# sourceMappingURL=zeros.js.map
|
package/dist/matlab/zeros.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"zeros.js","sourceRoot":"","sources":["../../src/matlab/zeros.ts"],"names":[],"mappings":";;AACA,8CAA6C;AAE7C;;;;;;;;;;;;GAYG;AACH,SAAgB,KAAK,CAAC,MAAc,EAAE,KAAsB;IAAtB,sBAAA,EAAA,cAAsB;IAC1D,OAAO,iBAAO,CAAC,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;AACnC,CAAC;AAFD,sBAEC"}
|
package/dist/version.d.ts
DELETED
package/dist/version.js
DELETED
package/dist/version.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":";;AAAa,QAAA,IAAI,GAAG,QAAQ,CAAA;AACf,QAAA,OAAO,GAAG,6BAA6B,CAAC"}
|
package/src/downsample.ts
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Implements downsampling logic
|
|
3
|
-
*
|
|
4
|
-
* @namespace downsample
|
|
5
|
-
*/
|
|
6
|
-
import { divide2d, sum2d } from "./math";
|
|
7
|
-
import { imfilter, ones, skip2d } from "./matlab";
|
|
8
|
-
import { Matrix, Options } from "./types";
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* For a given 2D filter `filter`, downsize image `pixels` by a factor of `f`.
|
|
12
|
-
*
|
|
13
|
-
* @method imageDownsample
|
|
14
|
-
* @param {Matrix} pixels - The matrix to downsample
|
|
15
|
-
* @param {Matrix} filter - The filter to convolve the image with
|
|
16
|
-
* @param {number} f - The downsampling factor (`image size / f`)
|
|
17
|
-
* @returns {Matrix} imdown - The downsampled, filtered image
|
|
18
|
-
* @private
|
|
19
|
-
* @memberOf downsample
|
|
20
|
-
*/
|
|
21
|
-
function imageDownsample(pixels: Matrix, filter: Matrix, f: number): Matrix {
|
|
22
|
-
const imdown = imfilter(pixels, filter, "symmetric", "same");
|
|
23
|
-
|
|
24
|
-
return skip2d(imdown, [0, f, imdown.height], [0, f, imdown.width]);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Downsamples images greater than `maxSize` pixels on the smallest direction. If neither image
|
|
29
|
-
* exceeds these dimensions they are returned as they are.
|
|
30
|
-
*
|
|
31
|
-
* It replicates the same logic than the original matlab scripts
|
|
32
|
-
*
|
|
33
|
-
* @method originalDownsample
|
|
34
|
-
* @param {Matrix} pixels1 - The first matrix to downsample
|
|
35
|
-
* @param {Matrix} pixels2 - The second matrix to downsample
|
|
36
|
-
* @param {number} [maxSize=256] - The maximum size on the smallest dimension
|
|
37
|
-
* @returns {[Matrix, Matrix]} ssim_map - A matrix containing the map of computed SSIMs
|
|
38
|
-
* @private
|
|
39
|
-
* @memberOf downsample
|
|
40
|
-
*/
|
|
41
|
-
function originalDownsample(
|
|
42
|
-
pixels1: Matrix,
|
|
43
|
-
pixels2: Matrix,
|
|
44
|
-
maxSize = 256
|
|
45
|
-
): [Matrix, Matrix] {
|
|
46
|
-
const factor = Math.min(pixels1.width, pixels2.height) / maxSize;
|
|
47
|
-
const f = Math.round(factor);
|
|
48
|
-
|
|
49
|
-
if (f > 1) {
|
|
50
|
-
let lpf = ones(f);
|
|
51
|
-
|
|
52
|
-
lpf = divide2d(lpf, sum2d(lpf));
|
|
53
|
-
|
|
54
|
-
pixels1 = imageDownsample(pixels1, lpf, f);
|
|
55
|
-
pixels2 = imageDownsample(pixels2, lpf, f);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
return [pixels1, pixels2];
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Determines the downsizing algorithm to implement (if any) to the reference and target images
|
|
63
|
-
*
|
|
64
|
-
* @method downsample
|
|
65
|
-
* @param {[Matrix, Matrix]} pixels - The first and second matrices to downsample
|
|
66
|
-
* @param {Object} options - The inputs options object
|
|
67
|
-
* @returns {[Matrix, Matrix]} pixels - An array containing the 2 downsized images
|
|
68
|
-
* @public
|
|
69
|
-
* @memberOf downsample
|
|
70
|
-
*/
|
|
71
|
-
export function downsample(
|
|
72
|
-
pixels: [Matrix, Matrix],
|
|
73
|
-
options: Options
|
|
74
|
-
): [Matrix, Matrix] {
|
|
75
|
-
if (options.downsample === "original") {
|
|
76
|
-
return originalDownsample(pixels[0], pixels[1], options.maxSize);
|
|
77
|
-
}
|
|
78
|
-
// else if options.downsample === 'fast' -> the image is downsampled when read (readpixels.js)
|
|
79
|
-
// else do not downsample
|
|
80
|
-
return pixels;
|
|
81
|
-
}
|