ssim.js 4.0.0 → 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/math.d.ts
DELETED
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Generates all basic arithmetic and matrix computations required
|
|
3
|
-
*
|
|
4
|
-
* Most of these methods use plain for loops and reduce nested calls. This results in about ~100x
|
|
5
|
-
* improvement on SSIM computation for 512x512 images on recent versions of node (~v6.7) over
|
|
6
|
-
* implementations using map or reduce.
|
|
7
|
-
*
|
|
8
|
-
* @namespace math
|
|
9
|
-
*/
|
|
10
|
-
import { Matrix } from "./types";
|
|
11
|
-
/**
|
|
12
|
-
* Computes the mean value of a given array. It is the sum of a list of numbers divided by the
|
|
13
|
-
* number of numbers in the list.
|
|
14
|
-
*
|
|
15
|
-
* @method average
|
|
16
|
-
* @param {Number[]} xn - The target array
|
|
17
|
-
* @returns {Number} average - The mean value of all elements within the array
|
|
18
|
-
* @public
|
|
19
|
-
* @memberOf math
|
|
20
|
-
* @since 0.0.1
|
|
21
|
-
*/
|
|
22
|
-
export declare function average(xn: number[]): number;
|
|
23
|
-
/**
|
|
24
|
-
* Computes the sum of a given array. It adds all values within the array and returns the total
|
|
25
|
-
*
|
|
26
|
-
* @method sum
|
|
27
|
-
* @param {Number[]} xn - The target array
|
|
28
|
-
* @returns {Number} sum - The total value
|
|
29
|
-
* @private
|
|
30
|
-
* @memberOf math
|
|
31
|
-
* @since 0.0.1
|
|
32
|
-
*/
|
|
33
|
-
export declare function sum(xn: number[]): number;
|
|
34
|
-
/**
|
|
35
|
-
* Computes the largest integer less than or equal to a given number for each member of a given
|
|
36
|
-
* array.
|
|
37
|
-
*
|
|
38
|
-
* @method floor
|
|
39
|
-
* @param {Number[]} xn - The target array
|
|
40
|
-
* @returns {Number[]} floorArr - An array with the Math.floor value for each element of the target
|
|
41
|
-
* array
|
|
42
|
-
* @private
|
|
43
|
-
* @memberOf math
|
|
44
|
-
* @since 0.0.1
|
|
45
|
-
*/
|
|
46
|
-
export declare function floor(xn: number[]): number[];
|
|
47
|
-
/**
|
|
48
|
-
* Computes the sum of all elements within a matrix
|
|
49
|
-
*
|
|
50
|
-
* @method sum2d
|
|
51
|
-
* @param {Matrix} A - The input matrix
|
|
52
|
-
* @returns {Number} sum - The total value of adding each cell
|
|
53
|
-
* @public
|
|
54
|
-
* @memberOf math
|
|
55
|
-
* @since 0.0.2
|
|
56
|
-
*/
|
|
57
|
-
export declare function sum2d({ data }: Matrix): number;
|
|
58
|
-
/**
|
|
59
|
-
* Adds values of two matrices of the same size or a matrix and a constant
|
|
60
|
-
*
|
|
61
|
-
* @method add2d
|
|
62
|
-
* @param {Matrix} A - The first input matrix
|
|
63
|
-
* @param {Matrix|Number} increase - The second input matrix or the constant value
|
|
64
|
-
* @returns {Matrix} B - A matrix with a cell-by-cell sum of the first and second parameters
|
|
65
|
-
* @public
|
|
66
|
-
* @memberOf math
|
|
67
|
-
* @since 0.0.2
|
|
68
|
-
*/
|
|
69
|
-
export declare function add2d(A: Matrix, increase: Matrix | number): Matrix;
|
|
70
|
-
/**
|
|
71
|
-
* Subtracts values of two matrices of the same size or a matrix and a constant
|
|
72
|
-
*
|
|
73
|
-
* @method subtract2d
|
|
74
|
-
* @param {Matrix} A - The first input matrix
|
|
75
|
-
* @param {Matrix|Number} decrease - The second input matrix or the constant value
|
|
76
|
-
* @returns {Matrix} B - A matrix with a cell-by-cell subtraction of the first parameter minus the
|
|
77
|
-
* second one
|
|
78
|
-
* @public
|
|
79
|
-
* @memberOf math
|
|
80
|
-
*/
|
|
81
|
-
export declare function subtract2d(A: Matrix, decrease: Matrix | number): Matrix;
|
|
82
|
-
/**
|
|
83
|
-
* Divides values of two matrices of the same size or between a matrix and a constant
|
|
84
|
-
*
|
|
85
|
-
* @method divide2d
|
|
86
|
-
* @param {Matrix} A - The first input matrix
|
|
87
|
-
* @param {Matrix|Number} divisor - The second input matrix or the constant value
|
|
88
|
-
* @returns {Matrix} B - A matrix with the cell-by-cell division of the first and second parameters
|
|
89
|
-
* @public
|
|
90
|
-
* @memberOf math
|
|
91
|
-
* @since 0.0.2
|
|
92
|
-
*/
|
|
93
|
-
export declare function divide2d(A: Matrix, divisor: Matrix | number): Matrix;
|
|
94
|
-
/**
|
|
95
|
-
* Multiplies values of two matrices of the same size or between a matrix and a constant
|
|
96
|
-
*
|
|
97
|
-
* @method multiply2d
|
|
98
|
-
* @param {Matrix} A - The first input matrix
|
|
99
|
-
* @param {Matrix|Number} multiplier - The second input matrix or the constant value
|
|
100
|
-
* @returns {Matrix} out - A matrix with the cell-by-cell multiplication of the first and second
|
|
101
|
-
* parameters
|
|
102
|
-
* @public
|
|
103
|
-
* @memberOf math
|
|
104
|
-
* @since 0.0.2
|
|
105
|
-
*/
|
|
106
|
-
export declare function multiply2d(A: Matrix, multiplier: Matrix | number): Matrix;
|
|
107
|
-
/**
|
|
108
|
-
* Generates the cell-by-cell square value of a target matrix
|
|
109
|
-
*
|
|
110
|
-
* @method square2d
|
|
111
|
-
* @param {Matrix} A - The target matrix
|
|
112
|
-
* @returns {Matrix} B - A matrix with squared value of each cell
|
|
113
|
-
* @public
|
|
114
|
-
* @memberOf math
|
|
115
|
-
* @since 0.0.2
|
|
116
|
-
*/
|
|
117
|
-
export declare function square2d(A: Matrix): Matrix;
|
|
118
|
-
/**
|
|
119
|
-
* Calculates the total mean value for a given matrix
|
|
120
|
-
*
|
|
121
|
-
* @method mean2d
|
|
122
|
-
* @param {Matrix} A - The target matrix
|
|
123
|
-
* @returns {Number} mean - The total mean of each cell
|
|
124
|
-
* @public
|
|
125
|
-
* @memberOf math
|
|
126
|
-
* @since 0.0.2
|
|
127
|
-
*/
|
|
128
|
-
export declare function mean2d(A: Matrix): number;
|
|
129
|
-
/**
|
|
130
|
-
* Computes the variance for a given array
|
|
131
|
-
*
|
|
132
|
-
* @method variance
|
|
133
|
-
* @param {Array<Number>} values - The target array
|
|
134
|
-
* @param {Number} [avg=average(values)] - If specified, it will use this values as the average of
|
|
135
|
-
* the array values. If not, it will compute the actual average
|
|
136
|
-
* @returns {Number} varx - The resulting variance value
|
|
137
|
-
* @public
|
|
138
|
-
* @memberOf math
|
|
139
|
-
*/
|
|
140
|
-
export declare function variance(values: number[], avg?: number): number;
|
|
141
|
-
/**
|
|
142
|
-
* Computes the covariance between 2 arrays
|
|
143
|
-
*
|
|
144
|
-
* @method covariance
|
|
145
|
-
* @param {Array<Number>} values1 - The first target array
|
|
146
|
-
* @param {Array<Number>} values2 - The second target array
|
|
147
|
-
* @param {Number} [average1=average(values)] - If specified, it will use this values as the average
|
|
148
|
-
* of the first array. If not, it will compute the actual average
|
|
149
|
-
* @param {Number} [average2=average(values)] - If specified, it will use this values as the average
|
|
150
|
-
* of the second array. If not, it will compute the actual average
|
|
151
|
-
* @returns {Number} cov - The resulting covariance
|
|
152
|
-
* @public
|
|
153
|
-
* @memberOf math
|
|
154
|
-
*/
|
|
155
|
-
export declare function covariance(values1: number[], values2: number[], average1?: number, average2?: number): number;
|
package/dist/math.js
DELETED
|
@@ -1,394 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
/**
|
|
4
|
-
* Computes the mean value of a given array. It is the sum of a list of numbers divided by the
|
|
5
|
-
* number of numbers in the list.
|
|
6
|
-
*
|
|
7
|
-
* @method average
|
|
8
|
-
* @param {Number[]} xn - The target array
|
|
9
|
-
* @returns {Number} average - The mean value of all elements within the array
|
|
10
|
-
* @public
|
|
11
|
-
* @memberOf math
|
|
12
|
-
* @since 0.0.1
|
|
13
|
-
*/
|
|
14
|
-
function average(xn) {
|
|
15
|
-
return sum(xn) / xn.length;
|
|
16
|
-
}
|
|
17
|
-
exports.average = average;
|
|
18
|
-
/**
|
|
19
|
-
* Computes the sum of a given array. It adds all values within the array and returns the total
|
|
20
|
-
*
|
|
21
|
-
* @method sum
|
|
22
|
-
* @param {Number[]} xn - The target array
|
|
23
|
-
* @returns {Number} sum - The total value
|
|
24
|
-
* @private
|
|
25
|
-
* @memberOf math
|
|
26
|
-
* @since 0.0.1
|
|
27
|
-
*/
|
|
28
|
-
function sum(xn) {
|
|
29
|
-
var out = 0;
|
|
30
|
-
for (var x = 0; x < xn.length; x++) {
|
|
31
|
-
out += xn[x];
|
|
32
|
-
}
|
|
33
|
-
return out;
|
|
34
|
-
}
|
|
35
|
-
exports.sum = sum;
|
|
36
|
-
/**
|
|
37
|
-
* Computes the largest integer less than or equal to a given number for each member of a given
|
|
38
|
-
* array.
|
|
39
|
-
*
|
|
40
|
-
* @method floor
|
|
41
|
-
* @param {Number[]} xn - The target array
|
|
42
|
-
* @returns {Number[]} floorArr - An array with the Math.floor value for each element of the target
|
|
43
|
-
* array
|
|
44
|
-
* @private
|
|
45
|
-
* @memberOf math
|
|
46
|
-
* @since 0.0.1
|
|
47
|
-
*/
|
|
48
|
-
function floor(xn) {
|
|
49
|
-
var out = new Array(xn.length);
|
|
50
|
-
for (var x = 0; x < xn.length; x++) {
|
|
51
|
-
out[x] = Math.floor(xn[x]);
|
|
52
|
-
}
|
|
53
|
-
return out;
|
|
54
|
-
}
|
|
55
|
-
exports.floor = floor;
|
|
56
|
-
/**
|
|
57
|
-
* Computes the sum of all elements within a matrix
|
|
58
|
-
*
|
|
59
|
-
* @method sum2d
|
|
60
|
-
* @param {Matrix} A - The input matrix
|
|
61
|
-
* @returns {Number} sum - The total value of adding each cell
|
|
62
|
-
* @public
|
|
63
|
-
* @memberOf math
|
|
64
|
-
* @since 0.0.2
|
|
65
|
-
*/
|
|
66
|
-
function sum2d(_a) {
|
|
67
|
-
var data = _a.data;
|
|
68
|
-
var out = 0;
|
|
69
|
-
for (var x = 0; x < data.length; x++) {
|
|
70
|
-
out += data[x];
|
|
71
|
-
}
|
|
72
|
-
return out;
|
|
73
|
-
}
|
|
74
|
-
exports.sum2d = sum2d;
|
|
75
|
-
/**
|
|
76
|
-
* Adds values of two matrices of the same size
|
|
77
|
-
*
|
|
78
|
-
* @method add2dMx
|
|
79
|
-
* @param {Matrix} A - The first input matrix
|
|
80
|
-
* @param {Matrix} B - The second input matrix
|
|
81
|
-
* @returns {Matrix} out - A matrix with a cell-by-cell sum of `A` and `B`
|
|
82
|
-
* @private
|
|
83
|
-
* @memberOf math
|
|
84
|
-
* @since 0.0.2
|
|
85
|
-
*/
|
|
86
|
-
function add2dMx(_a, _b) {
|
|
87
|
-
var ref1 = _a.data, width = _a.width, height = _a.height;
|
|
88
|
-
var ref2 = _b.data;
|
|
89
|
-
var data = new Array(ref1.length);
|
|
90
|
-
for (var x = 0; x < height; x++) {
|
|
91
|
-
var offset = x * width;
|
|
92
|
-
for (var y = 0; y < width; y++) {
|
|
93
|
-
data[offset + y] = ref1[offset + y] + ref2[offset + y];
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
return {
|
|
97
|
-
data: data,
|
|
98
|
-
width: width,
|
|
99
|
-
height: height
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
/**
|
|
103
|
-
* Subtracts values of second matrix from the first one. It assumes both matrices are of the same
|
|
104
|
-
* size
|
|
105
|
-
*
|
|
106
|
-
* @method subtract2dMx
|
|
107
|
-
* @param {Matrix} A - The first input matrix
|
|
108
|
-
* @param {Matrix} B - The second input matrix
|
|
109
|
-
* @returns {Matrix} out - A matrix with a cell-by-cell subtraction of `A` minus `B`
|
|
110
|
-
* @private
|
|
111
|
-
* @memberOf math
|
|
112
|
-
* @since 0.0.2
|
|
113
|
-
*/
|
|
114
|
-
function subtract2dMx(_a, _b) {
|
|
115
|
-
var ref1 = _a.data, width = _a.width, height = _a.height;
|
|
116
|
-
var ref2 = _b.data;
|
|
117
|
-
var data = new Array(ref1.length);
|
|
118
|
-
for (var x = 0; x < height; x++) {
|
|
119
|
-
var offset = x * width;
|
|
120
|
-
for (var y = 0; y < width; y++) {
|
|
121
|
-
data[offset + y] = ref1[offset + y] - ref2[offset + y];
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
return {
|
|
125
|
-
data: data,
|
|
126
|
-
width: width,
|
|
127
|
-
height: height
|
|
128
|
-
};
|
|
129
|
-
}
|
|
130
|
-
/**
|
|
131
|
-
* Adds a constant value two each matrix cell
|
|
132
|
-
*
|
|
133
|
-
* @method add2dScalar
|
|
134
|
-
* @param {Matrix} A - The first input matrix
|
|
135
|
-
* @param {Number} increase - The value to add
|
|
136
|
-
* @returns {Matrix} B - The cell-by-cell matrix sum of `A` and `increase`
|
|
137
|
-
* @private
|
|
138
|
-
* @memberOf math
|
|
139
|
-
* @since 0.0.2
|
|
140
|
-
*/
|
|
141
|
-
function add2dScalar(_a, increase) {
|
|
142
|
-
var ref = _a.data, width = _a.width, height = _a.height;
|
|
143
|
-
var data = new Array(ref.length);
|
|
144
|
-
for (var x = 0; x < ref.length; x++) {
|
|
145
|
-
data[x] = ref[x] + increase;
|
|
146
|
-
}
|
|
147
|
-
return {
|
|
148
|
-
data: data,
|
|
149
|
-
width: width,
|
|
150
|
-
height: height
|
|
151
|
-
};
|
|
152
|
-
}
|
|
153
|
-
/**
|
|
154
|
-
* Adds values of two matrices of the same size or a matrix and a constant
|
|
155
|
-
*
|
|
156
|
-
* @method add2d
|
|
157
|
-
* @param {Matrix} A - The first input matrix
|
|
158
|
-
* @param {Matrix|Number} increase - The second input matrix or the constant value
|
|
159
|
-
* @returns {Matrix} B - A matrix with a cell-by-cell sum of the first and second parameters
|
|
160
|
-
* @public
|
|
161
|
-
* @memberOf math
|
|
162
|
-
* @since 0.0.2
|
|
163
|
-
*/
|
|
164
|
-
function add2d(A, increase) {
|
|
165
|
-
if (typeof increase === "number") {
|
|
166
|
-
return add2dScalar(A, increase);
|
|
167
|
-
}
|
|
168
|
-
return add2dMx(A, increase);
|
|
169
|
-
}
|
|
170
|
-
exports.add2d = add2d;
|
|
171
|
-
/**
|
|
172
|
-
* Subtracts values of two matrices of the same size or a matrix and a constant
|
|
173
|
-
*
|
|
174
|
-
* @method subtract2d
|
|
175
|
-
* @param {Matrix} A - The first input matrix
|
|
176
|
-
* @param {Matrix|Number} decrease - The second input matrix or the constant value
|
|
177
|
-
* @returns {Matrix} B - A matrix with a cell-by-cell subtraction of the first parameter minus the
|
|
178
|
-
* second one
|
|
179
|
-
* @public
|
|
180
|
-
* @memberOf math
|
|
181
|
-
*/
|
|
182
|
-
function subtract2d(A, decrease) {
|
|
183
|
-
if (typeof decrease === "number") {
|
|
184
|
-
return add2dScalar(A, -decrease);
|
|
185
|
-
}
|
|
186
|
-
return subtract2dMx(A, decrease);
|
|
187
|
-
}
|
|
188
|
-
exports.subtract2d = subtract2d;
|
|
189
|
-
/**
|
|
190
|
-
* Divides each matrix cell by a constant value
|
|
191
|
-
*
|
|
192
|
-
* @method divide2dScalar
|
|
193
|
-
* @param {Matrix} A - The first input matrix
|
|
194
|
-
* @param {Number} divisor - The value to divide by
|
|
195
|
-
* @returns {Matrix} B - The cell-by-cell matrix divison of `A` and `divisor`
|
|
196
|
-
* @private
|
|
197
|
-
* @memberOf math
|
|
198
|
-
* @since 0.0.2
|
|
199
|
-
*/
|
|
200
|
-
function divide2dScalar(_a, divisor) {
|
|
201
|
-
var ref = _a.data, width = _a.width, height = _a.height;
|
|
202
|
-
var data = new Array(ref.length);
|
|
203
|
-
for (var x = 0; x < ref.length; x++) {
|
|
204
|
-
data[x] = ref[x] / divisor;
|
|
205
|
-
}
|
|
206
|
-
return {
|
|
207
|
-
data: data,
|
|
208
|
-
width: width,
|
|
209
|
-
height: height
|
|
210
|
-
};
|
|
211
|
-
}
|
|
212
|
-
/**
|
|
213
|
-
* Divides, cell-by-cell, values of two matrices of the same size
|
|
214
|
-
*
|
|
215
|
-
* @method divide2dMx
|
|
216
|
-
* @param {Matrix} A - The first input matrix
|
|
217
|
-
* @param {Matrix} B - The second input matrix
|
|
218
|
-
* @returns {Matrix} out - A matrix with a cell-by-cell division of `A`/`B`
|
|
219
|
-
* @private
|
|
220
|
-
* @memberOf math
|
|
221
|
-
* @since 0.0.2
|
|
222
|
-
*/
|
|
223
|
-
function divide2dMx(_a, _b) {
|
|
224
|
-
var ref1 = _a.data, width = _a.width, height = _a.height;
|
|
225
|
-
var ref2 = _b.data;
|
|
226
|
-
var data = new Array(ref1.length);
|
|
227
|
-
for (var x = 0; x < ref1.length; x++) {
|
|
228
|
-
data[x] = ref1[x] / ref2[x];
|
|
229
|
-
}
|
|
230
|
-
return {
|
|
231
|
-
data: data,
|
|
232
|
-
width: width,
|
|
233
|
-
height: height
|
|
234
|
-
};
|
|
235
|
-
}
|
|
236
|
-
/**
|
|
237
|
-
* Divides values of two matrices of the same size or between a matrix and a constant
|
|
238
|
-
*
|
|
239
|
-
* @method divide2d
|
|
240
|
-
* @param {Matrix} A - The first input matrix
|
|
241
|
-
* @param {Matrix|Number} divisor - The second input matrix or the constant value
|
|
242
|
-
* @returns {Matrix} B - A matrix with the cell-by-cell division of the first and second parameters
|
|
243
|
-
* @public
|
|
244
|
-
* @memberOf math
|
|
245
|
-
* @since 0.0.2
|
|
246
|
-
*/
|
|
247
|
-
function divide2d(A, divisor) {
|
|
248
|
-
if (typeof divisor === "number") {
|
|
249
|
-
return divide2dScalar(A, divisor);
|
|
250
|
-
}
|
|
251
|
-
return divide2dMx(A, divisor);
|
|
252
|
-
}
|
|
253
|
-
exports.divide2d = divide2d;
|
|
254
|
-
/**
|
|
255
|
-
* Multiplies each matrix cell by a constant value
|
|
256
|
-
*
|
|
257
|
-
* @method multiply2dScalar
|
|
258
|
-
* @param {Matrix} A - The first input matrix
|
|
259
|
-
* @param {Number} multiplier - The value to multiply each cell with
|
|
260
|
-
* @returns {Matrix} B - The cell-by-cell matrix multiplication of `A` and `multiplier`
|
|
261
|
-
* @private
|
|
262
|
-
* @memberOf math
|
|
263
|
-
* @since 0.0.2
|
|
264
|
-
*/
|
|
265
|
-
function multiply2dScalar(_a, multiplier) {
|
|
266
|
-
var ref = _a.data, width = _a.width, height = _a.height;
|
|
267
|
-
var data = new Array(ref.length);
|
|
268
|
-
for (var x = 0; x < ref.length; x++) {
|
|
269
|
-
data[x] = ref[x] * multiplier;
|
|
270
|
-
}
|
|
271
|
-
return {
|
|
272
|
-
data: data,
|
|
273
|
-
width: width,
|
|
274
|
-
height: height
|
|
275
|
-
};
|
|
276
|
-
}
|
|
277
|
-
/**
|
|
278
|
-
* Multiplies, cell-by-cell, values of two matrices of the same size
|
|
279
|
-
*
|
|
280
|
-
* @method multiply2dMx
|
|
281
|
-
* @param {Matrix} A - The first input matrix
|
|
282
|
-
* @param {Matrix} B - The second input matrix
|
|
283
|
-
* @returns {Matrix} out - A matrix with a cell-by-cell multiplication of `A` * `B`
|
|
284
|
-
* @private
|
|
285
|
-
* @memberOf math
|
|
286
|
-
* @since 0.0.2
|
|
287
|
-
*/
|
|
288
|
-
function multiply2dMx(_a, _b) {
|
|
289
|
-
var ref1 = _a.data, width = _a.width, height = _a.height;
|
|
290
|
-
var ref2 = _b.data;
|
|
291
|
-
var data = new Array(ref1.length);
|
|
292
|
-
for (var x = 0; x < ref1.length; x++) {
|
|
293
|
-
data[x] = ref1[x] * ref2[x];
|
|
294
|
-
}
|
|
295
|
-
return {
|
|
296
|
-
data: data,
|
|
297
|
-
width: width,
|
|
298
|
-
height: height
|
|
299
|
-
};
|
|
300
|
-
}
|
|
301
|
-
/**
|
|
302
|
-
* Multiplies values of two matrices of the same size or between a matrix and a constant
|
|
303
|
-
*
|
|
304
|
-
* @method multiply2d
|
|
305
|
-
* @param {Matrix} A - The first input matrix
|
|
306
|
-
* @param {Matrix|Number} multiplier - The second input matrix or the constant value
|
|
307
|
-
* @returns {Matrix} out - A matrix with the cell-by-cell multiplication of the first and second
|
|
308
|
-
* parameters
|
|
309
|
-
* @public
|
|
310
|
-
* @memberOf math
|
|
311
|
-
* @since 0.0.2
|
|
312
|
-
*/
|
|
313
|
-
function multiply2d(A, multiplier) {
|
|
314
|
-
if (typeof multiplier === "number") {
|
|
315
|
-
return multiply2dScalar(A, multiplier);
|
|
316
|
-
}
|
|
317
|
-
return multiply2dMx(A, multiplier);
|
|
318
|
-
}
|
|
319
|
-
exports.multiply2d = multiply2d;
|
|
320
|
-
/**
|
|
321
|
-
* Generates the cell-by-cell square value of a target matrix
|
|
322
|
-
*
|
|
323
|
-
* @method square2d
|
|
324
|
-
* @param {Matrix} A - The target matrix
|
|
325
|
-
* @returns {Matrix} B - A matrix with squared value of each cell
|
|
326
|
-
* @public
|
|
327
|
-
* @memberOf math
|
|
328
|
-
* @since 0.0.2
|
|
329
|
-
*/
|
|
330
|
-
function square2d(A) {
|
|
331
|
-
return multiply2d(A, A);
|
|
332
|
-
}
|
|
333
|
-
exports.square2d = square2d;
|
|
334
|
-
/**
|
|
335
|
-
* Calculates the total mean value for a given matrix
|
|
336
|
-
*
|
|
337
|
-
* @method mean2d
|
|
338
|
-
* @param {Matrix} A - The target matrix
|
|
339
|
-
* @returns {Number} mean - The total mean of each cell
|
|
340
|
-
* @public
|
|
341
|
-
* @memberOf math
|
|
342
|
-
* @since 0.0.2
|
|
343
|
-
*/
|
|
344
|
-
function mean2d(A) {
|
|
345
|
-
return sum2d(A) / A.data.length;
|
|
346
|
-
}
|
|
347
|
-
exports.mean2d = mean2d;
|
|
348
|
-
/**
|
|
349
|
-
* Computes the variance for a given array
|
|
350
|
-
*
|
|
351
|
-
* @method variance
|
|
352
|
-
* @param {Array<Number>} values - The target array
|
|
353
|
-
* @param {Number} [avg=average(values)] - If specified, it will use this values as the average of
|
|
354
|
-
* the array values. If not, it will compute the actual average
|
|
355
|
-
* @returns {Number} varx - The resulting variance value
|
|
356
|
-
* @public
|
|
357
|
-
* @memberOf math
|
|
358
|
-
*/
|
|
359
|
-
function variance(values, avg) {
|
|
360
|
-
if (avg === void 0) { avg = average(values); }
|
|
361
|
-
var varx = 0;
|
|
362
|
-
var i = values.length;
|
|
363
|
-
while (i--) {
|
|
364
|
-
varx += Math.pow((values[i] - avg), 2);
|
|
365
|
-
}
|
|
366
|
-
return varx / values.length;
|
|
367
|
-
}
|
|
368
|
-
exports.variance = variance;
|
|
369
|
-
/**
|
|
370
|
-
* Computes the covariance between 2 arrays
|
|
371
|
-
*
|
|
372
|
-
* @method covariance
|
|
373
|
-
* @param {Array<Number>} values1 - The first target array
|
|
374
|
-
* @param {Array<Number>} values2 - The second target array
|
|
375
|
-
* @param {Number} [average1=average(values)] - If specified, it will use this values as the average
|
|
376
|
-
* of the first array. If not, it will compute the actual average
|
|
377
|
-
* @param {Number} [average2=average(values)] - If specified, it will use this values as the average
|
|
378
|
-
* of the second array. If not, it will compute the actual average
|
|
379
|
-
* @returns {Number} cov - The resulting covariance
|
|
380
|
-
* @public
|
|
381
|
-
* @memberOf math
|
|
382
|
-
*/
|
|
383
|
-
function covariance(values1, values2, average1, average2) {
|
|
384
|
-
if (average1 === void 0) { average1 = average(values1); }
|
|
385
|
-
if (average2 === void 0) { average2 = average(values2); }
|
|
386
|
-
var cov = 0;
|
|
387
|
-
var i = values1.length;
|
|
388
|
-
while (i--) {
|
|
389
|
-
cov += (values1[i] - average1) * (values2[i] - average2);
|
|
390
|
-
}
|
|
391
|
-
return cov / values1.length;
|
|
392
|
-
}
|
|
393
|
-
exports.covariance = covariance;
|
|
394
|
-
//# sourceMappingURL=math.js.map
|
package/dist/math.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"math.js","sourceRoot":"","sources":["../src/math.ts"],"names":[],"mappings":";;AAWA;;;;;;;;;;GAUG;AACH,SAAgB,OAAO,CAAC,EAAY;IAClC,OAAO,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC;AAC7B,CAAC;AAFD,0BAEC;AAED;;;;;;;;;GASG;AACH,SAAgB,GAAG,CAAC,EAAY;IAC9B,IAAI,GAAG,GAAG,CAAC,CAAC;IAEZ,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QAClC,GAAG,IAAI,EAAE,CAAC,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,EAAA,WAAmB,OAAO,CAAC,OAAO,CAAC;IAEnC,IAAI,GAAG,GAAG,CAAC,CAAC;IACZ,IAAI,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC;IAEvB,OAAO,CAAC,EAAE,EAAE;QACV,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC;KAC1D;IAED,OAAO,GAAG,GAAG,OAAO,CAAC,MAAM,CAAC;AAC9B,CAAC;AAdD,gCAcC"}
|
package/dist/matlab/conv2.d.ts
DELETED
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
import { Matrix, Shape } from "../types";
|
|
2
|
-
/**
|
|
3
|
-
* `C = conv2(a,b)` computes the two-dimensional convolution of matrices `a` and `b`. If one of
|
|
4
|
-
* these matrices describes a two-dimensional finite impulse response (FIR) filter, the other matrix
|
|
5
|
-
* is filtered in two dimensions. The size of `c` is determined as follows:
|
|
6
|
-
*
|
|
7
|
-
* ```
|
|
8
|
-
* if [ma,na] = size(a), [mb,nb] = size(b), and [mc,nc] = size(c), then
|
|
9
|
-
* mc = max([ma+mb-1,ma,mb]) and nc = max([na+nb-1,na,nb]).
|
|
10
|
-
* ```
|
|
11
|
-
*
|
|
12
|
-
* `shape` returns a subsection of the two-dimensional convolution, based on one of these values for
|
|
13
|
-
* the parameter:
|
|
14
|
-
*
|
|
15
|
-
* - **full**: Returns the full two-dimensional convolution (default).
|
|
16
|
-
* - **same**: Returns the central part of the convolution of the same size as `a`.
|
|
17
|
-
* - **valid**: Returns only those parts of the convolution that are computed without the
|
|
18
|
-
* zero-padded edges. Using this option, `size(c) === max([ma-max(0,mb-1),na-max(0,nb-1)],0)`
|
|
19
|
-
*
|
|
20
|
-
* @method mxConv2
|
|
21
|
-
* @param {Matrix} a - The first matrix
|
|
22
|
-
* @param {Matrix} b - The second matrix
|
|
23
|
-
* @param {String} [shape='full'] - One of 'full' / 'same' / 'valid'
|
|
24
|
-
* @returns {Matrix} c - Returns the convolution filtered by `shape`
|
|
25
|
-
* @private
|
|
26
|
-
* @memberOf matlab
|
|
27
|
-
*/
|
|
28
|
-
declare function mxConv2({ data: ref, width: refWidth, height: refHeight }: Matrix, b: Matrix, shape?: Shape): Matrix;
|
|
29
|
-
/**
|
|
30
|
-
* `C = boxConv(a,b)` computes the two-dimensional convolution of a matrix `a` and box kernel `b`.
|
|
31
|
-
*
|
|
32
|
-
* The `shape` parameter returns a subsection of the two-dimensional convolution as defined by
|
|
33
|
-
* mxConv2.
|
|
34
|
-
*
|
|
35
|
-
* @method boxConv
|
|
36
|
-
* @param {Matrix} a - The first matrix
|
|
37
|
-
* @param {Matrix} b - The box kernel
|
|
38
|
-
* @param {String} [shape='full'] - One of 'full' / 'same' / 'valid'
|
|
39
|
-
* @returns {Matrix} c - Returns the convolution filtered by `shape`
|
|
40
|
-
* @private
|
|
41
|
-
* @memberOf matlab
|
|
42
|
-
*/
|
|
43
|
-
declare function boxConv(a: Matrix, { data, width, height }: Matrix, shape?: Shape): Matrix;
|
|
44
|
-
/**
|
|
45
|
-
* `C = convn(a,b1, b2)` computes the two-dimensional convolution of matrices `a.*b1.*b2`.
|
|
46
|
-
*
|
|
47
|
-
* The size of `c` is determined as follows:
|
|
48
|
-
*
|
|
49
|
-
* ```
|
|
50
|
-
* if [ma,na] = size(a), [mb] = size(b1), [nb] = size(b2) and [mc,nc] = size(c), then
|
|
51
|
-
* mc = max([ma+mb-1,ma,mb]) and nc = max([na+nb-1,na,nb]).
|
|
52
|
-
* ```
|
|
53
|
-
*
|
|
54
|
-
* `shape` returns a section of the two-dimensional convolution, based on one of these values for
|
|
55
|
-
* the parameter:
|
|
56
|
-
*
|
|
57
|
-
* - **full**: Returns the full two-dimensional convolution (default).
|
|
58
|
-
* - **same**: Returns the central part of the convolution of the same size as `a`.
|
|
59
|
-
* - **valid**: Returns only those parts of the convolution that are computed without the
|
|
60
|
-
* zero-padded edges. Using this option, `size(c) === max([ma-max(0,mb-1),na-max(0,nb-1)],0)`
|
|
61
|
-
*
|
|
62
|
-
* This method mimics Matlab's `convn` method but limited to 2 1 dimensional kernels.
|
|
63
|
-
*
|
|
64
|
-
* @method convn
|
|
65
|
-
* @param {Matrix} a - The first matrix
|
|
66
|
-
* @param {Matrix} b1 - The first 1-D kernel
|
|
67
|
-
* @param {Matrix} b2 - The second 1-D kernel
|
|
68
|
-
* @param {String} [shape='full'] - One of 'full' / 'same' / 'valid'
|
|
69
|
-
* @returns {Matrix} c - Returns the convolution filtered by `shape`
|
|
70
|
-
* @private
|
|
71
|
-
* @memberOf matlab
|
|
72
|
-
*/
|
|
73
|
-
declare function convn(a: Matrix, b1: Matrix, b2: Matrix, shape?: Shape): Matrix;
|
|
74
|
-
/**
|
|
75
|
-
* `C = conv2(a,b)` computes the two-dimensional convolution of matrices `a` and `b`. If one of
|
|
76
|
-
* these matrices describes a two-dimensional finite impulse response (FIR) filter, the other matrix
|
|
77
|
-
* is filtered in two dimensions.
|
|
78
|
-
*
|
|
79
|
-
* The size of `c` is determined as follows:
|
|
80
|
-
*
|
|
81
|
-
* ```
|
|
82
|
-
* if [ma,na] = size(a), [mb,nb] = size(b), and [mc,nc] = size(c), then
|
|
83
|
-
* mc = max([ma+mb-1,ma,mb]) and nc = max([na+nb-1,na,nb]).
|
|
84
|
-
* ```
|
|
85
|
-
*
|
|
86
|
-
* `shape` returns a subsection of the two-dimensional convolution, based on one of these values for
|
|
87
|
-
* the parameter:
|
|
88
|
-
*
|
|
89
|
-
* - **full**: Returns the full two-dimensional convolution (default).
|
|
90
|
-
* - **same**: Returns the central part of the convolution of the same size as `a`.
|
|
91
|
-
* - **valid**: Returns only those parts of the convolution that are computed without the
|
|
92
|
-
* zero-padded edges. Using this option, `size(c) === max([ma-max(0,mb-1),na-max(0,nb-1)],0)`
|
|
93
|
-
*
|
|
94
|
-
* Alternatively, 2 1-D filters may be provided as parameters, following the format:
|
|
95
|
-
* `conv2(a, b1, b2, shape)`. This is similar to Matlab's implementation allowing any number of 1-D
|
|
96
|
-
* filters to be applied but limited to 2
|
|
97
|
-
*
|
|
98
|
-
* This method mimics Matlab's `conv2` method.
|
|
99
|
-
*
|
|
100
|
-
* Given:
|
|
101
|
-
* const A = rand(3);
|
|
102
|
-
* const B = rand(4);
|
|
103
|
-
*
|
|
104
|
-
* @example conv2(A,B); // output is 6-by-6
|
|
105
|
-
* {
|
|
106
|
-
* data: [
|
|
107
|
-
* 0.1838, 0.2374, 0.9727, 1.2644, 0.7890, 0.3750,
|
|
108
|
-
* 0.6929, 1.2019, 1.5499, 2.1733, 1.3325, 0.3096,
|
|
109
|
-
* 0.5627, 1.5150, 2.3576, 3.1553, 2.5373, 1.0602,
|
|
110
|
-
* 0.9986, 2.3811, 3.4302, 3.5128, 2.4489, 0.8462,
|
|
111
|
-
* 0.3089, 1.1419, 1.8229, 2.1561, 1.6364, 0.6841,
|
|
112
|
-
* 0.3287, 0.9347, 1.6464, 1.7928, 1.2422, 0.5423
|
|
113
|
-
* ],
|
|
114
|
-
* width: 6,
|
|
115
|
-
* height: 6
|
|
116
|
-
* }
|
|
117
|
-
*
|
|
118
|
-
* @example conv2(A,B,'same') => // output is the same size as A: 3-by-3
|
|
119
|
-
* {
|
|
120
|
-
* data: [
|
|
121
|
-
* 2.3576, 3.1553, 2.5373,
|
|
122
|
-
* 3.4302, 3.5128, 2.4489,
|
|
123
|
-
* 1.8229, 2.1561, 1.6364
|
|
124
|
-
* ],
|
|
125
|
-
* width: 3,
|
|
126
|
-
* height: 3
|
|
127
|
-
* }
|
|
128
|
-
*
|
|
129
|
-
* @method conv2
|
|
130
|
-
* @param {Array} args - The list of arguments, see `mxConv2` and `convn` for the exact parameters
|
|
131
|
-
* @returns {Matrix} c - Returns the convolution filtered by `shape`
|
|
132
|
-
* @public
|
|
133
|
-
* @memberOf matlab
|
|
134
|
-
* @since 0.0.2
|
|
135
|
-
*/
|
|
136
|
-
export declare function conv2(...args: Parameters<typeof boxConv | typeof convn | typeof mxConv2>): Matrix;
|
|
137
|
-
export {};
|