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/conv2.js
DELETED
|
@@ -1,250 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
var math_1 = require("../math");
|
|
4
|
-
var ones_1 = require("./ones");
|
|
5
|
-
var sub_1 = require("./sub");
|
|
6
|
-
var zeros_1 = require("./zeros");
|
|
7
|
-
/**
|
|
8
|
-
* `C = conv2(a,b)` computes the two-dimensional convolution of matrices `a` and `b`. If one of
|
|
9
|
-
* these matrices describes a two-dimensional finite impulse response (FIR) filter, the other matrix
|
|
10
|
-
* is filtered in two dimensions. The size of `c` is determined as follows:
|
|
11
|
-
*
|
|
12
|
-
* ```
|
|
13
|
-
* if [ma,na] = size(a), [mb,nb] = size(b), and [mc,nc] = size(c), then
|
|
14
|
-
* mc = max([ma+mb-1,ma,mb]) and nc = max([na+nb-1,na,nb]).
|
|
15
|
-
* ```
|
|
16
|
-
*
|
|
17
|
-
* `shape` returns a subsection of the two-dimensional convolution, based on one of these values for
|
|
18
|
-
* the parameter:
|
|
19
|
-
*
|
|
20
|
-
* - **full**: Returns the full two-dimensional convolution (default).
|
|
21
|
-
* - **same**: Returns the central part of the convolution of the same size as `a`.
|
|
22
|
-
* - **valid**: Returns only those parts of the convolution that are computed without the
|
|
23
|
-
* zero-padded edges. Using this option, `size(c) === max([ma-max(0,mb-1),na-max(0,nb-1)],0)`
|
|
24
|
-
*
|
|
25
|
-
* @method mxConv2
|
|
26
|
-
* @param {Matrix} a - The first matrix
|
|
27
|
-
* @param {Matrix} b - The second matrix
|
|
28
|
-
* @param {String} [shape='full'] - One of 'full' / 'same' / 'valid'
|
|
29
|
-
* @returns {Matrix} c - Returns the convolution filtered by `shape`
|
|
30
|
-
* @private
|
|
31
|
-
* @memberOf matlab
|
|
32
|
-
*/
|
|
33
|
-
function mxConv2(_a, b, shape) {
|
|
34
|
-
var ref = _a.data, refWidth = _a.width, refHeight = _a.height;
|
|
35
|
-
if (shape === void 0) { shape = "full"; }
|
|
36
|
-
var cWidth = refWidth + b.width - 1;
|
|
37
|
-
var cHeight = refHeight + b.height - 1;
|
|
38
|
-
var data = zeros_1.zeros(cHeight, cWidth).data;
|
|
39
|
-
/**
|
|
40
|
-
* Computing the convolution is the most computentionally intensive task for SSIM and we do it
|
|
41
|
-
* several times.
|
|
42
|
-
*
|
|
43
|
-
* This section has been optimized for performance and readability suffers.
|
|
44
|
-
*/
|
|
45
|
-
for (var r1 = 0; r1 < b.height; r1++) {
|
|
46
|
-
for (var c1 = 0; c1 < b.width; c1++) {
|
|
47
|
-
var br1c1 = b.data[r1 * b.width + c1];
|
|
48
|
-
if (br1c1) {
|
|
49
|
-
for (var i = 0; i < refHeight; i++) {
|
|
50
|
-
for (var j = 0; j < refWidth; j++) {
|
|
51
|
-
data[(i + r1) * cWidth + j + c1] += ref[i * refWidth + j] * br1c1;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
var c = {
|
|
58
|
-
data: data,
|
|
59
|
-
width: cWidth,
|
|
60
|
-
height: cHeight
|
|
61
|
-
};
|
|
62
|
-
return reshape(c, shape, refHeight, b.height, refWidth, b.width);
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* `C = boxConv(a,b)` computes the two-dimensional convolution of a matrix `a` and box kernel `b`.
|
|
66
|
-
*
|
|
67
|
-
* The `shape` parameter returns a subsection of the two-dimensional convolution as defined by
|
|
68
|
-
* mxConv2.
|
|
69
|
-
*
|
|
70
|
-
* @method boxConv
|
|
71
|
-
* @param {Matrix} a - The first matrix
|
|
72
|
-
* @param {Matrix} b - The box kernel
|
|
73
|
-
* @param {String} [shape='full'] - One of 'full' / 'same' / 'valid'
|
|
74
|
-
* @returns {Matrix} c - Returns the convolution filtered by `shape`
|
|
75
|
-
* @private
|
|
76
|
-
* @memberOf matlab
|
|
77
|
-
*/
|
|
78
|
-
function boxConv(a, _a, shape) {
|
|
79
|
-
var data = _a.data, width = _a.width, height = _a.height;
|
|
80
|
-
if (shape === void 0) { shape = "full"; }
|
|
81
|
-
var b1 = ones_1.ones(height, 1);
|
|
82
|
-
var b2 = ones_1.ones(1, width);
|
|
83
|
-
var out = convn(a, b1, b2, shape);
|
|
84
|
-
return math_1.multiply2d(out, data[0]);
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* Determines whether all values in an array are the same so that the kernel can be treated as a box
|
|
88
|
-
* kernel
|
|
89
|
-
*
|
|
90
|
-
* @method isBoxKernel
|
|
91
|
-
* @param {Matrix} a - The input matrix
|
|
92
|
-
* @returns {Boolean} boxKernel - Returns true if all values in the matrix are the same, false
|
|
93
|
-
* otherwise
|
|
94
|
-
* @private
|
|
95
|
-
* @memberOf matlab
|
|
96
|
-
*/
|
|
97
|
-
function isBoxKernel(_a) {
|
|
98
|
-
var data = _a.data;
|
|
99
|
-
var expected = data[0];
|
|
100
|
-
for (var i = 1; i < data.length; i++) {
|
|
101
|
-
if (data[i] !== expected) {
|
|
102
|
-
return false;
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
return true;
|
|
106
|
-
}
|
|
107
|
-
/**
|
|
108
|
-
* `C = convn(a,b1, b2)` computes the two-dimensional convolution of matrices `a.*b1.*b2`.
|
|
109
|
-
*
|
|
110
|
-
* The size of `c` is determined as follows:
|
|
111
|
-
*
|
|
112
|
-
* ```
|
|
113
|
-
* if [ma,na] = size(a), [mb] = size(b1), [nb] = size(b2) and [mc,nc] = size(c), then
|
|
114
|
-
* mc = max([ma+mb-1,ma,mb]) and nc = max([na+nb-1,na,nb]).
|
|
115
|
-
* ```
|
|
116
|
-
*
|
|
117
|
-
* `shape` returns a section of the two-dimensional convolution, based on one of these values for
|
|
118
|
-
* the parameter:
|
|
119
|
-
*
|
|
120
|
-
* - **full**: Returns the full two-dimensional convolution (default).
|
|
121
|
-
* - **same**: Returns the central part of the convolution of the same size as `a`.
|
|
122
|
-
* - **valid**: Returns only those parts of the convolution that are computed without the
|
|
123
|
-
* zero-padded edges. Using this option, `size(c) === max([ma-max(0,mb-1),na-max(0,nb-1)],0)`
|
|
124
|
-
*
|
|
125
|
-
* This method mimics Matlab's `convn` method but limited to 2 1 dimensional kernels.
|
|
126
|
-
*
|
|
127
|
-
* @method convn
|
|
128
|
-
* @param {Matrix} a - The first matrix
|
|
129
|
-
* @param {Matrix} b1 - The first 1-D kernel
|
|
130
|
-
* @param {Matrix} b2 - The second 1-D kernel
|
|
131
|
-
* @param {String} [shape='full'] - One of 'full' / 'same' / 'valid'
|
|
132
|
-
* @returns {Matrix} c - Returns the convolution filtered by `shape`
|
|
133
|
-
* @private
|
|
134
|
-
* @memberOf matlab
|
|
135
|
-
*/
|
|
136
|
-
function convn(a, b1, b2, shape) {
|
|
137
|
-
if (shape === void 0) { shape = "full"; }
|
|
138
|
-
var mb = Math.max(b1.height, b1.width);
|
|
139
|
-
var nb = Math.max(b2.height, b2.width);
|
|
140
|
-
var temp = mxConv2(a, b1, "full");
|
|
141
|
-
var c = mxConv2(temp, b2, "full");
|
|
142
|
-
return reshape(c, shape, a.height, mb, a.width, nb);
|
|
143
|
-
}
|
|
144
|
-
/**
|
|
145
|
-
* `reshape` crops the resulting convolution matrix to match the values specified in `shape`.
|
|
146
|
-
*
|
|
147
|
-
* - **full**: Returns the input
|
|
148
|
-
* - **same**: Returns the central part of the convolution of the same size as `a`.
|
|
149
|
-
* - **valid**: Returns only those parts of the convolution that are computed without the
|
|
150
|
-
* zero-padded edges
|
|
151
|
-
*
|
|
152
|
-
* @method reshape
|
|
153
|
-
* @param {Matrix} c - The output matrix
|
|
154
|
-
* @param {String} shape - One of 'full' / 'same' / 'valid'
|
|
155
|
-
* @param {Number} ma - The number of rows of the input matrix
|
|
156
|
-
* @param {Number} mb - The number of rows of the input filter
|
|
157
|
-
* @param {Number} na - The number of columns of the input matrix
|
|
158
|
-
* @param {Number} nb - The number of columns of the input filter
|
|
159
|
-
* @returns {Matrix} c - Returns the input convolution filtered by `shape`
|
|
160
|
-
* @private
|
|
161
|
-
* @memberOf matlab
|
|
162
|
-
*/
|
|
163
|
-
function reshape(c, shape, ma, mb, na, nb) {
|
|
164
|
-
if (shape === "full") {
|
|
165
|
-
return c;
|
|
166
|
-
}
|
|
167
|
-
else if (shape === "same") {
|
|
168
|
-
var rowStart = Math.ceil((c.height - ma) / 2);
|
|
169
|
-
var colStart = Math.ceil((c.width - na) / 2);
|
|
170
|
-
return sub_1.sub(c, rowStart, ma, colStart, na);
|
|
171
|
-
}
|
|
172
|
-
return sub_1.sub(c, mb - 1, ma - mb + 1, nb - 1, na - nb + 1);
|
|
173
|
-
}
|
|
174
|
-
/**
|
|
175
|
-
* `C = conv2(a,b)` computes the two-dimensional convolution of matrices `a` and `b`. If one of
|
|
176
|
-
* these matrices describes a two-dimensional finite impulse response (FIR) filter, the other matrix
|
|
177
|
-
* is filtered in two dimensions.
|
|
178
|
-
*
|
|
179
|
-
* The size of `c` is determined as follows:
|
|
180
|
-
*
|
|
181
|
-
* ```
|
|
182
|
-
* if [ma,na] = size(a), [mb,nb] = size(b), and [mc,nc] = size(c), then
|
|
183
|
-
* mc = max([ma+mb-1,ma,mb]) and nc = max([na+nb-1,na,nb]).
|
|
184
|
-
* ```
|
|
185
|
-
*
|
|
186
|
-
* `shape` returns a subsection of the two-dimensional convolution, based on one of these values for
|
|
187
|
-
* the parameter:
|
|
188
|
-
*
|
|
189
|
-
* - **full**: Returns the full two-dimensional convolution (default).
|
|
190
|
-
* - **same**: Returns the central part of the convolution of the same size as `a`.
|
|
191
|
-
* - **valid**: Returns only those parts of the convolution that are computed without the
|
|
192
|
-
* zero-padded edges. Using this option, `size(c) === max([ma-max(0,mb-1),na-max(0,nb-1)],0)`
|
|
193
|
-
*
|
|
194
|
-
* Alternatively, 2 1-D filters may be provided as parameters, following the format:
|
|
195
|
-
* `conv2(a, b1, b2, shape)`. This is similar to Matlab's implementation allowing any number of 1-D
|
|
196
|
-
* filters to be applied but limited to 2
|
|
197
|
-
*
|
|
198
|
-
* This method mimics Matlab's `conv2` method.
|
|
199
|
-
*
|
|
200
|
-
* Given:
|
|
201
|
-
* const A = rand(3);
|
|
202
|
-
* const B = rand(4);
|
|
203
|
-
*
|
|
204
|
-
* @example conv2(A,B); // output is 6-by-6
|
|
205
|
-
* {
|
|
206
|
-
* data: [
|
|
207
|
-
* 0.1838, 0.2374, 0.9727, 1.2644, 0.7890, 0.3750,
|
|
208
|
-
* 0.6929, 1.2019, 1.5499, 2.1733, 1.3325, 0.3096,
|
|
209
|
-
* 0.5627, 1.5150, 2.3576, 3.1553, 2.5373, 1.0602,
|
|
210
|
-
* 0.9986, 2.3811, 3.4302, 3.5128, 2.4489, 0.8462,
|
|
211
|
-
* 0.3089, 1.1419, 1.8229, 2.1561, 1.6364, 0.6841,
|
|
212
|
-
* 0.3287, 0.9347, 1.6464, 1.7928, 1.2422, 0.5423
|
|
213
|
-
* ],
|
|
214
|
-
* width: 6,
|
|
215
|
-
* height: 6
|
|
216
|
-
* }
|
|
217
|
-
*
|
|
218
|
-
* @example conv2(A,B,'same') => // output is the same size as A: 3-by-3
|
|
219
|
-
* {
|
|
220
|
-
* data: [
|
|
221
|
-
* 2.3576, 3.1553, 2.5373,
|
|
222
|
-
* 3.4302, 3.5128, 2.4489,
|
|
223
|
-
* 1.8229, 2.1561, 1.6364
|
|
224
|
-
* ],
|
|
225
|
-
* width: 3,
|
|
226
|
-
* height: 3
|
|
227
|
-
* }
|
|
228
|
-
*
|
|
229
|
-
* @method conv2
|
|
230
|
-
* @param {Array} args - The list of arguments, see `mxConv2` and `convn` for the exact parameters
|
|
231
|
-
* @returns {Matrix} c - Returns the convolution filtered by `shape`
|
|
232
|
-
* @public
|
|
233
|
-
* @memberOf matlab
|
|
234
|
-
* @since 0.0.2
|
|
235
|
-
*/
|
|
236
|
-
function conv2() {
|
|
237
|
-
var args = [];
|
|
238
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
239
|
-
args[_i] = arguments[_i];
|
|
240
|
-
}
|
|
241
|
-
if (args[2] && args[2].data) {
|
|
242
|
-
return convn.apply(void 0, args);
|
|
243
|
-
}
|
|
244
|
-
else if (isBoxKernel(args[1])) {
|
|
245
|
-
return boxConv.apply(void 0, args);
|
|
246
|
-
}
|
|
247
|
-
return mxConv2.apply(void 0, args);
|
|
248
|
-
}
|
|
249
|
-
exports.conv2 = conv2;
|
|
250
|
-
//# sourceMappingURL=conv2.js.map
|
package/dist/matlab/conv2.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"conv2.js","sourceRoot":"","sources":["../../src/matlab/conv2.ts"],"names":[],"mappings":";;AAAA,gCAAqC;AACrC,+BAA8B;AAC9B,6BAA4B;AAC5B,iCAAgC;AAGhC;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,SAAS,OAAO,CACd,EAAyD,EACzD,CAAS,EACT,KAAqB;QAFnB,aAAS,EAAE,mBAAe,EAAE,qBAAiB;IAE/C,sBAAA,EAAA,cAAqB;IAErB,IAAM,MAAM,GAAG,QAAQ,GAAG,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC;IACtC,IAAM,OAAO,GAAG,SAAS,GAAG,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC;IACjC,IAAA,0CAAI,CAA4B;IAExC;;;;;OAKG;IACH,KAAK,IAAI,EAAE,GAAG,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,EAAE,EAAE;QACpC,KAAK,IAAI,EAAE,GAAG,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,EAAE,EAAE;YACnC,IAAM,KAAK,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC,KAAK,GAAG,EAAE,CAAC,CAAC;YAExC,IAAI,KAAK,EA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,CAAC,CAAC,CAAC;QAE/C,OAAO,SAAG,CAAC,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,QAAQ,EAAE,EAAE,CAAC,CAAC;KAC3C;IAED,OAAO,SAAG,CAAC,CAAC,EAAE,EAAE,GAAG,CAAC,EAAE,EAAE,GAAG,EAAE,GAAG,CAAC,EAAE,EAAE,GAAG,CAAC,EAAE,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;AAC1D,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6DG;AACH,SAAgB,KAAK;IACnB,cAAmE;SAAnE,UAAmE,EAAnE,qBAAmE,EAAnE,IAAmE;QAAnE,yBAAmE;;IAEnE,IAAI,IAAI,CAAC,CAAC,CAAC,IAAK,IAAI,CAAC,CAAC,CAAY,CAAC,IAAI,EAAE;QACvC,OAAO,KAAK,eAAK,IAAiC,EAAE;KACrD;SAAM,IAAI,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE;QAC/B,OAAO,OAAO,eAAK,IAAmC,EAAE;KACzD;IACD,OAAO,OAAO,eAAK,IAAmC,EAAE;AAC1D,CAAC;AATD,sBASC"}
|
package/dist/matlab/filter2.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { Matrix, Shape } from "../types";
|
|
2
|
-
/**
|
|
3
|
-
* Given a matrix X and a two-dimensional FIR filter h, filter2 rotates your filter matrix 180
|
|
4
|
-
* degrees to create a convolution kernel. It then calls conv2, the two-dimensional convolution
|
|
5
|
-
* function, to implement the filtering operation.
|
|
6
|
-
*
|
|
7
|
-
* This method mimics Matlab's `filter2` method
|
|
8
|
-
*
|
|
9
|
-
* @method filter2
|
|
10
|
-
* @param {Matrix} h - The FIR filter
|
|
11
|
-
* @param {Matrix} X - The input matrix
|
|
12
|
-
* @param string [shape='same'] - The convolution shape
|
|
13
|
-
* @returns {Matrix} conv - The 2D convolution of X with h
|
|
14
|
-
* @public
|
|
15
|
-
* @memberOf matlab
|
|
16
|
-
* @since 0.0.2
|
|
17
|
-
*/
|
|
18
|
-
export declare function filter2(h: Matrix, X: Matrix, shape?: Shape): Matrix;
|
package/dist/matlab/filter2.js
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
var conv2_1 = require("./conv2");
|
|
4
|
-
/**
|
|
5
|
-
* Rotates a matrix 180deg.
|
|
6
|
-
*
|
|
7
|
-
* @example
|
|
8
|
-
* 1 2 3 4 becomes: 8 7 6 5
|
|
9
|
-
* 5 6 7 8 4 3 2 1
|
|
10
|
-
*
|
|
11
|
-
* @method rotate1802d
|
|
12
|
-
* @param {Matrix} mx - The input matrix
|
|
13
|
-
* @returns {Matrix} out - The rotated matrix
|
|
14
|
-
* @private
|
|
15
|
-
* @memberOf matlab
|
|
16
|
-
* @since 0.0.2
|
|
17
|
-
*/
|
|
18
|
-
function rotate1802d(_a) {
|
|
19
|
-
var ref = _a.data, width = _a.width, height = _a.height;
|
|
20
|
-
var data = new Array(ref.length);
|
|
21
|
-
for (var i = 0; i < height; i++) {
|
|
22
|
-
for (var j = 0; j < width; j++) {
|
|
23
|
-
data[i * width + j] = ref[(height - 1 - i) * width + width - 1 - j];
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
return {
|
|
27
|
-
data: data,
|
|
28
|
-
width: width,
|
|
29
|
-
height: height
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Given a matrix X and a two-dimensional FIR filter h, filter2 rotates your filter matrix 180
|
|
34
|
-
* degrees to create a convolution kernel. It then calls conv2, the two-dimensional convolution
|
|
35
|
-
* function, to implement the filtering operation.
|
|
36
|
-
*
|
|
37
|
-
* This method mimics Matlab's `filter2` method
|
|
38
|
-
*
|
|
39
|
-
* @method filter2
|
|
40
|
-
* @param {Matrix} h - The FIR filter
|
|
41
|
-
* @param {Matrix} X - The input matrix
|
|
42
|
-
* @param string [shape='same'] - The convolution shape
|
|
43
|
-
* @returns {Matrix} conv - The 2D convolution of X with h
|
|
44
|
-
* @public
|
|
45
|
-
* @memberOf matlab
|
|
46
|
-
* @since 0.0.2
|
|
47
|
-
*/
|
|
48
|
-
function filter2(h, X, shape) {
|
|
49
|
-
if (shape === void 0) { shape = "same"; }
|
|
50
|
-
return conv2_1.conv2(X, rotate1802d(h), shape);
|
|
51
|
-
}
|
|
52
|
-
exports.filter2 = filter2;
|
|
53
|
-
//# sourceMappingURL=filter2.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"filter2.js","sourceRoot":"","sources":["../../src/matlab/filter2.ts"],"names":[],"mappings":";;AAAA,iCAAgC;AAGhC;;;;;;;;;;;;;GAaG;AACH,SAAS,WAAW,CAAC,EAAoC;QAAlC,aAAS,EAAE,gBAAK,EAAE,kBAAM;IAC7C,IAAM,IAAI,GAAG,IAAI,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAEnC,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,MAAM,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,KAAK,GAAG,KAAK,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;SACrE;KACF;IAED,OAAO;QACL,IAAI,MAAA;QACJ,KAAK,OAAA;QACL,MAAM,QAAA;KACP,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;;;GAeG;AACH,SAAgB,OAAO,CAAC,CAAS,EAAE,CAAS,EAAE,KAAqB;IAArB,sBAAA,EAAA,cAAqB;IACjE,OAAO,aAAK,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;AACzC,CAAC;AAFD,0BAEC"}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { Matrix } from "../types";
|
|
2
|
-
/**
|
|
3
|
-
* Create predefined 2-D filter
|
|
4
|
-
*
|
|
5
|
-
* `h = fspecial(type, parameters)` accepts the filter specified by type plus additional modifying
|
|
6
|
-
* parameters particular to the type of filter chosen. If you omit these arguments, fspecial uses
|
|
7
|
-
* default values for the parameters.
|
|
8
|
-
*
|
|
9
|
-
* This method mimics Matlab's `fspecial2` method with `type = 'gaussian'`. `hsize` cannot be a
|
|
10
|
-
* vector (unlike Matlab's implementation), only a Number is accepted.
|
|
11
|
-
*
|
|
12
|
-
* `h = fspecial('gaussian', hsize, sigma)` returns a rotationally symmetric Gaussian lowpass filter
|
|
13
|
-
* of size `hsize` with standard deviation sigma (positive). In this implementation `hsize` will
|
|
14
|
-
* always be a scalar, which will result in `h` being a square matrix.
|
|
15
|
-
*
|
|
16
|
-
* The gaussian logic follows: hg(hsize) = e^(-2*hsize^2 / 2σ^2)
|
|
17
|
-
*
|
|
18
|
-
* @example
|
|
19
|
-
* fspecial('gaussian', 3, 1.5) === {
|
|
20
|
-
* data: [
|
|
21
|
-
* 0.094742, 0.118318, 0.094742,
|
|
22
|
-
* 0.118318, 0.147761, 0.118318,
|
|
23
|
-
* 0.094742, 0.118318, 0.094742
|
|
24
|
-
* ],
|
|
25
|
-
* width: 3,
|
|
26
|
-
* height: 3
|
|
27
|
-
* };
|
|
28
|
-
*
|
|
29
|
-
* @method fspecial
|
|
30
|
-
* @param {String} [type='gaussian'] - The type of 2D filter to create (coerced to 'gaussian')
|
|
31
|
-
* @param {Number} [hsize=3] - The length of the filter
|
|
32
|
-
* @param {Number} [σ=1.5] - The filter sigma value
|
|
33
|
-
* @returns {Matrix} c - Returns the central part of the convolution of the same
|
|
34
|
-
* size as `a`.
|
|
35
|
-
* @public
|
|
36
|
-
* @memberOf matlab
|
|
37
|
-
* @since 0.0.2
|
|
38
|
-
*/
|
|
39
|
-
export declare function fspecial(_type?: "gaussian", hsize?: number, σ?: number): Matrix;
|
package/dist/matlab/fspecial.js
DELETED
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
var math_1 = require("../math");
|
|
4
|
-
/**
|
|
5
|
-
* Creates a matrix of lenght `2 * length + 1` with values being the sum of the square of the
|
|
6
|
-
* distance for each component from the center. E.g:
|
|
7
|
-
*
|
|
8
|
-
* For a length of 5 it results in a matrix size of 11. Looking at [0, 0] (distance: [-5, -5] from
|
|
9
|
-
* the center), the value at that position becomes `-5^2 + -5^2 = 50`
|
|
10
|
-
*
|
|
11
|
-
* @method rangeSquare2d
|
|
12
|
-
* @param {Number} length - The maxium distance from the matrix center
|
|
13
|
-
* @returns {Matrix} mx - The generated matrix
|
|
14
|
-
* @private
|
|
15
|
-
* @memberOf matlab
|
|
16
|
-
* @since 0.0.2
|
|
17
|
-
*/
|
|
18
|
-
function rangeSquare2d(length) {
|
|
19
|
-
var size = length * 2 + 1;
|
|
20
|
-
var data = new Array(Math.pow(size, 2));
|
|
21
|
-
for (var x = 0; x < size; x++) {
|
|
22
|
-
for (var y = 0; y < size; y++) {
|
|
23
|
-
data[x * size + y] = Math.pow((x - length), 2) + Math.pow((y - length), 2);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
return {
|
|
27
|
-
data: data,
|
|
28
|
-
width: size,
|
|
29
|
-
height: size
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Applies a gaussian filter of sigma to a given matrix
|
|
34
|
-
*
|
|
35
|
-
* @method gaussianFilter2d
|
|
36
|
-
* @param {Matrix} A - The input matrix
|
|
37
|
-
* @param {Number} σ - The sigma value
|
|
38
|
-
* @returns {Matrix} B - The matrix with the gaussian filter applied
|
|
39
|
-
* @private
|
|
40
|
-
* @memberOf matlab
|
|
41
|
-
* @since 0.0.2
|
|
42
|
-
*/
|
|
43
|
-
function gaussianFilter2d(_a, σ) {
|
|
44
|
-
var ref = _a.data, width = _a.width, height = _a.height;
|
|
45
|
-
var data = new Array(ref.length);
|
|
46
|
-
for (var x = 0; x < ref.length; x++) {
|
|
47
|
-
data[x] = Math.exp(-ref[x] / (2 * Math.pow(σ, 2)));
|
|
48
|
-
}
|
|
49
|
-
return {
|
|
50
|
-
data: data,
|
|
51
|
-
width: width,
|
|
52
|
-
height: height
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Create predefined 2-D filter
|
|
57
|
-
*
|
|
58
|
-
* `h = fspecial(type, parameters)` accepts the filter specified by type plus additional modifying
|
|
59
|
-
* parameters particular to the type of filter chosen. If you omit these arguments, fspecial uses
|
|
60
|
-
* default values for the parameters.
|
|
61
|
-
*
|
|
62
|
-
* This method mimics Matlab's `fspecial2` method with `type = 'gaussian'`. `hsize` cannot be a
|
|
63
|
-
* vector (unlike Matlab's implementation), only a Number is accepted.
|
|
64
|
-
*
|
|
65
|
-
* `h = fspecial('gaussian', hsize, sigma)` returns a rotationally symmetric Gaussian lowpass filter
|
|
66
|
-
* of size `hsize` with standard deviation sigma (positive). In this implementation `hsize` will
|
|
67
|
-
* always be a scalar, which will result in `h` being a square matrix.
|
|
68
|
-
*
|
|
69
|
-
* The gaussian logic follows: hg(hsize) = e^(-2*hsize^2 / 2σ^2)
|
|
70
|
-
*
|
|
71
|
-
* @example
|
|
72
|
-
* fspecial('gaussian', 3, 1.5) === {
|
|
73
|
-
* data: [
|
|
74
|
-
* 0.094742, 0.118318, 0.094742,
|
|
75
|
-
* 0.118318, 0.147761, 0.118318,
|
|
76
|
-
* 0.094742, 0.118318, 0.094742
|
|
77
|
-
* ],
|
|
78
|
-
* width: 3,
|
|
79
|
-
* height: 3
|
|
80
|
-
* };
|
|
81
|
-
*
|
|
82
|
-
* @method fspecial
|
|
83
|
-
* @param {String} [type='gaussian'] - The type of 2D filter to create (coerced to 'gaussian')
|
|
84
|
-
* @param {Number} [hsize=3] - The length of the filter
|
|
85
|
-
* @param {Number} [σ=1.5] - The filter sigma value
|
|
86
|
-
* @returns {Matrix} c - Returns the central part of the convolution of the same
|
|
87
|
-
* size as `a`.
|
|
88
|
-
* @public
|
|
89
|
-
* @memberOf matlab
|
|
90
|
-
* @since 0.0.2
|
|
91
|
-
*/
|
|
92
|
-
function fspecial(_type, hsize, σ) {
|
|
93
|
-
if (hsize === void 0) { hsize = 3; }
|
|
94
|
-
if (σ === void 0) { σ = 1.5; }
|
|
95
|
-
hsize = (hsize - 1) / 2;
|
|
96
|
-
var pos = rangeSquare2d(hsize);
|
|
97
|
-
var gauss = gaussianFilter2d(pos, σ);
|
|
98
|
-
var total = math_1.sum2d(gauss);
|
|
99
|
-
return math_1.divide2d(gauss, total);
|
|
100
|
-
}
|
|
101
|
-
exports.fspecial = fspecial;
|
|
102
|
-
//# sourceMappingURL=fspecial.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fspecial.js","sourceRoot":"","sources":["../../src/matlab/fspecial.ts"],"names":[],"mappings":";;AACA,gCAA0C;AAE1C;;;;;;;;;;;;;GAaG;AACH,SAAS,aAAa,CAAC,MAAc;IACnC,IAAM,IAAI,GAAG,MAAM,GAAG,CAAC,GAAG,CAAC,CAAC;IAC5B,IAAM,IAAI,GAAG,IAAI,KAAK,CAAC,SAAA,IAAI,EAAI,CAAC,CAAA,CAAC,CAAC;IAElC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,CAAC,EAAE,EAAE;QAC7B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,CAAC,EAAE,EAAE;YAC7B,IAAI,CAAC,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,SAAA,CAAC,CAAC,GAAG,MAAM,CAAC,E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@@
|
|
|
1
|
-
import { PaddingValue } from "./padarray";
|
|
2
|
-
import { Matrix, Shape } from "../types";
|
|
3
|
-
/**
|
|
4
|
-
* `B = imfilter(A,f)` filters a 2-dimensional array `A` with the 2-dimensional filter `f`. The
|
|
5
|
-
* result `B` has the same size as `A`.
|
|
6
|
-
*
|
|
7
|
-
* `imfilter` computes each element of the output, `B`. If `A` is an integer, `imfilter` will not
|
|
8
|
-
* truncate the output elements that exceed the range, and it will not round fractional values.
|
|
9
|
-
*
|
|
10
|
-
* This method mimics Matlab's `imfilter` method with `padval = 'symmetric'` without integer
|
|
11
|
-
* rounding. No other options have been implemented and, if set, they will be ignored.
|
|
12
|
-
*
|
|
13
|
-
* @method imfilter
|
|
14
|
-
* @param {Matrix} A - The target matrix
|
|
15
|
-
* @param {Matrix} f - The filter to apply
|
|
16
|
-
* @param {String} [pad="symmetric"] - The type of padding. Only "symmetric" is implemented
|
|
17
|
-
* @param {String} [resSize="same"] - The format to use for the filter size. Valid values are:
|
|
18
|
-
* "same", "valid" and "full"
|
|
19
|
-
* @returns {Matrix} B - The filtered array
|
|
20
|
-
* @public
|
|
21
|
-
* @memberOf matlab
|
|
22
|
-
* @since 0.0.2
|
|
23
|
-
*/
|
|
24
|
-
export declare function imfilter(A: Matrix, f: Matrix, pad?: PaddingValue, resSize?: Shape): Matrix;
|
package/dist/matlab/imfilter.js
DELETED
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
var mod_1 = require("./mod");
|
|
4
|
-
var padarray_1 = require("./padarray");
|
|
5
|
-
var math_1 = require("../math");
|
|
6
|
-
var filter2_1 = require("./filter2");
|
|
7
|
-
/**
|
|
8
|
-
* Adds padding to input matrix A
|
|
9
|
-
*
|
|
10
|
-
* @method padMatrix
|
|
11
|
-
* @param {Matrix} A - The target matrix
|
|
12
|
-
* @param {Number} frows - The number of rows in the filter
|
|
13
|
-
* @param {Number} fcols - The number of columns in the filter
|
|
14
|
-
* @param {String} pad - The type of padding to apply
|
|
15
|
-
* @param {Matrix} B - The padded input matrix
|
|
16
|
-
* @private
|
|
17
|
-
* @memberOf matlab
|
|
18
|
-
*/
|
|
19
|
-
function padMatrix(A, frows, fcols, pad) {
|
|
20
|
-
A = padarray_1.padarray(A, math_1.floor([frows / 2, fcols / 2]), pad);
|
|
21
|
-
if (mod_1.mod(frows, 2) === 0) {
|
|
22
|
-
// remove the last row
|
|
23
|
-
A.data = A.data.slice(0, -A.width);
|
|
24
|
-
A.height--;
|
|
25
|
-
}
|
|
26
|
-
if (mod_1.mod(fcols, 2) === 0) {
|
|
27
|
-
// remove the last column
|
|
28
|
-
var data = [];
|
|
29
|
-
for (var x = 0; x < A.data.length; x++) {
|
|
30
|
-
if ((x + 1) % A.width !== 0) {
|
|
31
|
-
data.push(A.data[x]);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
A.data = data;
|
|
35
|
-
A.width--;
|
|
36
|
-
}
|
|
37
|
-
return A;
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Gets the `shape` parameter for `conv2` based on the `resSize` parameter for `imfilter`. In most
|
|
41
|
-
* cases they are equivalent except for when `resSize` equals "same" which is converted to "valid".
|
|
42
|
-
*
|
|
43
|
-
* @method getConv2Size
|
|
44
|
-
* @param {String} resSize - The format to use for the `imfilter` call
|
|
45
|
-
* @returns {String} shape - The shape value to use for `conv2`
|
|
46
|
-
* @private
|
|
47
|
-
* @memberOf matlab
|
|
48
|
-
*/
|
|
49
|
-
function getConv2Size(resSize) {
|
|
50
|
-
if (resSize === "same") {
|
|
51
|
-
resSize = "valid";
|
|
52
|
-
}
|
|
53
|
-
return resSize;
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* `B = imfilter(A,f)` filters a 2-dimensional array `A` with the 2-dimensional filter `f`. The
|
|
57
|
-
* result `B` has the same size as `A`.
|
|
58
|
-
*
|
|
59
|
-
* `imfilter` computes each element of the output, `B`. If `A` is an integer, `imfilter` will not
|
|
60
|
-
* truncate the output elements that exceed the range, and it will not round fractional values.
|
|
61
|
-
*
|
|
62
|
-
* This method mimics Matlab's `imfilter` method with `padval = 'symmetric'` without integer
|
|
63
|
-
* rounding. No other options have been implemented and, if set, they will be ignored.
|
|
64
|
-
*
|
|
65
|
-
* @method imfilter
|
|
66
|
-
* @param {Matrix} A - The target matrix
|
|
67
|
-
* @param {Matrix} f - The filter to apply
|
|
68
|
-
* @param {String} [pad="symmetric"] - The type of padding. Only "symmetric" is implemented
|
|
69
|
-
* @param {String} [resSize="same"] - The format to use for the filter size. Valid values are:
|
|
70
|
-
* "same", "valid" and "full"
|
|
71
|
-
* @returns {Matrix} B - The filtered array
|
|
72
|
-
* @public
|
|
73
|
-
* @memberOf matlab
|
|
74
|
-
* @since 0.0.2
|
|
75
|
-
*/
|
|
76
|
-
function imfilter(A, f, pad, resSize) {
|
|
77
|
-
if (pad === void 0) { pad = "symmetric"; }
|
|
78
|
-
if (resSize === void 0) { resSize = "same"; }
|
|
79
|
-
A = padMatrix(A, f.width, f.height, pad);
|
|
80
|
-
resSize = getConv2Size(resSize);
|
|
81
|
-
return filter2_1.filter2(f, A, resSize);
|
|
82
|
-
}
|
|
83
|
-
exports.imfilter = imfilter;
|
|
84
|
-
//# sourceMappingURL=imfilter.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"imfilter.js","sourceRoot":"","sources":["../../src/matlab/imfilter.ts"],"names":[],"mappings":";;AAAA,6BAA4B;AAC5B,uCAAoD;AACpD,gCAAgC;AAChC,qCAAoC;AAGpC;;;;;;;;;;;GAWG;AACH,SAAS,SAAS,CAChB,CAAS,EACT,KAAa,EACb,KAAa,EACb,GAAiB;IAEjB,CAAC,GAAG,mBAAQ,CAAC,CAAC,EAAE,YAAK,CAAC,CAAC,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,CAAC,CAAC,CAAqB,EAAE,GAAG,CAAC,CAAC;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AAO,iBAAO,CAAC,CAAC,EAAE,CAAC,EAAE,OAAO,CAAC,CAAC;AAChC,CAAC;AATD,4BASC"}
|
package/dist/matlab/index.d.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Implements Matlab functions or functionality.
|
|
3
|
-
*
|
|
4
|
-
* The goal here is not a perfect reproduction of matlab logic but just a minimal implementation
|
|
5
|
-
* needed to correctly reproduce the SSIM matlab script.
|
|
6
|
-
*
|
|
7
|
-
* That means that functionality used will be implemented but additional / unused parameters will
|
|
8
|
-
* not.
|
|
9
|
-
*
|
|
10
|
-
* @namespace matlab
|
|
11
|
-
*/
|
|
12
|
-
export * from "./conv2";
|
|
13
|
-
export * from "./filter2";
|
|
14
|
-
export * from "./fspecial";
|
|
15
|
-
export * from "./imfilter";
|
|
16
|
-
export * from "./normpdf";
|
|
17
|
-
export * from "./ones";
|
|
18
|
-
export * from "./padarray";
|
|
19
|
-
export * from "./rgb2gray";
|
|
20
|
-
export * from "./skip2d";
|
|
21
|
-
export * from "./sub";
|
|
22
|
-
export * from "./transpose";
|
|
23
|
-
export * from "./zeros";
|
package/dist/matlab/index.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
function __export(m) {
|
|
3
|
-
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
|
|
4
|
-
}
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
/**
|
|
7
|
-
* Implements Matlab functions or functionality.
|
|
8
|
-
*
|
|
9
|
-
* The goal here is not a perfect reproduction of matlab logic but just a minimal implementation
|
|
10
|
-
* needed to correctly reproduce the SSIM matlab script.
|
|
11
|
-
*
|
|
12
|
-
* That means that functionality used will be implemented but additional / unused parameters will
|
|
13
|
-
* not.
|
|
14
|
-
*
|
|
15
|
-
* @namespace matlab
|
|
16
|
-
*/
|
|
17
|
-
__export(require("./conv2"));
|
|
18
|
-
__export(require("./filter2"));
|
|
19
|
-
__export(require("./fspecial"));
|
|
20
|
-
__export(require("./imfilter"));
|
|
21
|
-
__export(require("./normpdf"));
|
|
22
|
-
__export(require("./ones"));
|
|
23
|
-
__export(require("./padarray"));
|
|
24
|
-
__export(require("./rgb2gray"));
|
|
25
|
-
__export(require("./skip2d"));
|
|
26
|
-
__export(require("./sub"));
|
|
27
|
-
__export(require("./transpose"));
|
|
28
|
-
__export(require("./zeros"));
|
|
29
|
-
//# sourceMappingURL=index.js.map
|
package/dist/matlab/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/matlab/index.ts"],"names":[],"mappings":";;;;;AAAA;;;;;;;;;;GAUG;AACH,6BAAwB;AACxB,+BAA0B;AAC1B,gCAA2B;AAC3B,gCAA2B;AAC3B,+BAA0B;AAC1B,4BAAuB;AACvB,gCAA2B;AAC3B,gCAA2B;AAC3B,8BAAyB;AACzB,2BAAsB;AACtB,iCAA4B;AAC5B,6BAAwB"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { Matrix } from "../../types";
|
|
2
|
-
/**
|
|
3
|
-
* Create a matrix with each cell with the value of `num`
|
|
4
|
-
*
|
|
5
|
-
* @method numbers
|
|
6
|
-
* @param {Number} height - The number of rows
|
|
7
|
-
* @param {Number} width - The number of columns
|
|
8
|
-
* @param {Number} num - The value to set on each cell
|
|
9
|
-
* @returns {Matrix} B - An n-by-m matrix of `num`
|
|
10
|
-
* @private
|
|
11
|
-
* @memberOf matlab
|
|
12
|
-
* @since 0.0.2
|
|
13
|
-
*/
|
|
14
|
-
export declare function numbers(height: number, width: number, num: number): Matrix;
|