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.
Files changed (151) hide show
  1. package/CLA.md +66 -0
  2. package/CONTRIBUTING.md +119 -0
  3. package/LICENSE +1 -1
  4. package/LICENSES/LIVE Images Database +18 -0
  5. package/LICENSES/Subjective quality assessment - IVC database +5 -0
  6. package/LICENSES/Wang et al SSIM +24 -0
  7. package/LICENSES/bezkrovny +49 -0
  8. package/LICENSES/cell2csv +2 -0
  9. package/LICENSES/obartra-ssim +21 -0
  10. package/LICENSES/rhys-e +21 -0
  11. package/README.md +216 -34
  12. package/dist/bezkrovnySsim.d.ts +5 -19
  13. package/dist/bezkrovnySsim.js +113 -72
  14. package/dist/bezkrovnySsim.js.map +1 -1
  15. package/dist/browser.d.mts +9 -0
  16. package/dist/browser.d.ts +9 -0
  17. package/dist/browser.js +37 -0
  18. package/dist/browser.js.map +1 -0
  19. package/dist/browser.mjs +742 -0
  20. package/dist/browser.mjs.map +7 -0
  21. package/dist/defaults.d.ts +3 -1
  22. package/dist/defaults.js +14 -4
  23. package/dist/defaults.js.map +1 -1
  24. package/dist/gaussian.d.ts +2 -0
  25. package/dist/gaussian.js +168 -0
  26. package/dist/gaussian.js.map +1 -0
  27. package/dist/gaussianSymmetric.d.ts +3 -0
  28. package/dist/gaussianSymmetric.js +62 -0
  29. package/dist/gaussianSymmetric.js.map +1 -0
  30. package/dist/index.d.mts +9 -0
  31. package/dist/index.d.ts +8 -19
  32. package/dist/index.js +19 -88
  33. package/dist/index.js.map +1 -1
  34. package/dist/index.mjs +718 -0
  35. package/dist/index.mjs.map +7 -0
  36. package/dist/options.d.ts +2 -0
  37. package/dist/options.js +60 -0
  38. package/dist/options.js.map +1 -0
  39. package/dist/originalSsim.d.ts +3 -26
  40. package/dist/originalSsim.js +5 -57
  41. package/dist/originalSsim.js.map +1 -1
  42. package/dist/pixels.d.ts +5 -0
  43. package/dist/pixels.js +157 -0
  44. package/dist/pixels.js.map +1 -0
  45. package/dist/prepare.d.ts +7 -0
  46. package/dist/prepare.js +48 -0
  47. package/dist/prepare.js.map +1 -0
  48. package/dist/referenceSsim.d.ts +4 -0
  49. package/dist/referenceSsim.js +59 -0
  50. package/dist/referenceSsim.js.map +1 -0
  51. package/dist/result.d.ts +2 -0
  52. package/dist/result.js +20 -0
  53. package/dist/result.js.map +1 -0
  54. package/dist/ssim.d.ts +3 -21
  55. package/dist/ssim.js +4 -126
  56. package/dist/ssim.js.map +1 -1
  57. package/dist/ssim.web.js +2 -2
  58. package/dist/ssim.web.js.map +7 -1
  59. package/dist/types.d.ts +27 -7
  60. package/dist/weberSsim.d.ts +19 -0
  61. package/dist/weberSsim.js +119 -0
  62. package/dist/weberSsim.js.map +1 -0
  63. package/package.json +116 -1
  64. package/src/bezkrovnySsim.ts +133 -67
  65. package/src/browser.ts +49 -0
  66. package/src/defaults.ts +16 -6
  67. package/src/gaussian.ts +228 -0
  68. package/src/gaussianSymmetric.ts +95 -0
  69. package/src/index.ts +47 -96
  70. package/src/options.ts +74 -0
  71. package/src/originalSsim.ts +9 -79
  72. package/src/pixels.ts +198 -0
  73. package/src/prepare.ts +73 -0
  74. package/src/referenceSsim.ts +71 -0
  75. package/src/result.ts +23 -0
  76. package/src/ssim.ts +9 -168
  77. package/src/types.ts +44 -15
  78. package/src/weberSsim.ts +132 -0
  79. package/dist/downsample.d.ts +0 -12
  80. package/dist/downsample.js +0 -70
  81. package/dist/downsample.js.map +0 -1
  82. package/dist/math.d.ts +0 -155
  83. package/dist/math.js +0 -394
  84. package/dist/math.js.map +0 -1
  85. package/dist/matlab/conv2.d.ts +0 -137
  86. package/dist/matlab/conv2.js +0 -250
  87. package/dist/matlab/conv2.js.map +0 -1
  88. package/dist/matlab/filter2.d.ts +0 -18
  89. package/dist/matlab/filter2.js +0 -53
  90. package/dist/matlab/filter2.js.map +0 -1
  91. package/dist/matlab/fspecial.d.ts +0 -39
  92. package/dist/matlab/fspecial.js +0 -102
  93. package/dist/matlab/fspecial.js.map +0 -1
  94. package/dist/matlab/imfilter.d.ts +0 -24
  95. package/dist/matlab/imfilter.js +0 -84
  96. package/dist/matlab/imfilter.js.map +0 -1
  97. package/dist/matlab/index.d.ts +0 -23
  98. package/dist/matlab/index.js +0 -29
  99. package/dist/matlab/index.js.map +0 -1
  100. package/dist/matlab/internal/numbers.d.ts +0 -14
  101. package/dist/matlab/internal/numbers.js +0 -28
  102. package/dist/matlab/internal/numbers.js.map +0 -1
  103. package/dist/matlab/mod.d.ts +0 -21
  104. package/dist/matlab/mod.js +0 -27
  105. package/dist/matlab/mod.js.map +0 -1
  106. package/dist/matlab/normpdf.d.ts +0 -36
  107. package/dist/matlab/normpdf.js +0 -55
  108. package/dist/matlab/normpdf.js.map +0 -1
  109. package/dist/matlab/ones.d.ts +0 -15
  110. package/dist/matlab/ones.js +0 -22
  111. package/dist/matlab/ones.js.map +0 -1
  112. package/dist/matlab/padarray.d.ts +0 -37
  113. package/dist/matlab/padarray.js +0 -349
  114. package/dist/matlab/padarray.js.map +0 -1
  115. package/dist/matlab/rgb2gray.d.ts +0 -15
  116. package/dist/matlab/rgb2gray.js +0 -58
  117. package/dist/matlab/rgb2gray.js.map +0 -1
  118. package/dist/matlab/skip2d.d.ts +0 -34
  119. package/dist/matlab/skip2d.js +0 -55
  120. package/dist/matlab/skip2d.js.map +0 -1
  121. package/dist/matlab/sub.d.ts +0 -17
  122. package/dist/matlab/sub.js +0 -33
  123. package/dist/matlab/sub.js.map +0 -1
  124. package/dist/matlab/transpose.d.ts +0 -18
  125. package/dist/matlab/transpose.js +0 -34
  126. package/dist/matlab/transpose.js.map +0 -1
  127. package/dist/matlab/zeros.d.ts +0 -15
  128. package/dist/matlab/zeros.js +0 -22
  129. package/dist/matlab/zeros.js.map +0 -1
  130. package/dist/version.d.ts +0 -2
  131. package/dist/version.js +0 -5
  132. package/dist/version.js.map +0 -1
  133. package/src/downsample.ts +0 -81
  134. package/src/math.ts +0 -447
  135. package/src/matlab/conv2.ts +0 -272
  136. package/src/matlab/filter2.ts +0 -52
  137. package/src/matlab/fspecial.ts +0 -107
  138. package/src/matlab/imfilter.ts +0 -93
  139. package/src/matlab/index.ts +0 -23
  140. package/src/matlab/internal/numbers.ts +0 -28
  141. package/src/matlab/mod.ts +0 -23
  142. package/src/matlab/normpdf.ts +0 -57
  143. package/src/matlab/ones.ts +0 -19
  144. package/src/matlab/padarray.ts +0 -375
  145. package/src/matlab/rgb2gray.ts +0 -65
  146. package/src/matlab/skip2d.ts +0 -58
  147. package/src/matlab/sub.ts +0 -38
  148. package/src/matlab/transpose.ts +0 -33
  149. package/src/matlab/zeros.ts +0 -19
  150. package/src/types/bmp-js.d.ts +0 -1
  151. package/src/version.ts +0 -2
@@ -1,28 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- /**
4
- * Create a matrix with each cell with the value of `num`
5
- *
6
- * @method numbers
7
- * @param {Number} height - The number of rows
8
- * @param {Number} width - The number of columns
9
- * @param {Number} num - The value to set on each cell
10
- * @returns {Matrix} B - An n-by-m matrix of `num`
11
- * @private
12
- * @memberOf matlab
13
- * @since 0.0.2
14
- */
15
- function numbers(height, width, num) {
16
- var size = width * height;
17
- var data = new Array(size);
18
- for (var x = 0; x < size; x++) {
19
- data[x] = num;
20
- }
21
- return {
22
- data: data,
23
- width: width,
24
- height: height
25
- };
26
- }
27
- exports.numbers = numbers;
28
- //# sourceMappingURL=numbers.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"numbers.js","sourceRoot":"","sources":["../../../src/matlab/internal/numbers.ts"],"names":[],"mappings":";;AAEA;;;;;;;;;;;GAWG;AACH,SAAgB,OAAO,CAAC,MAAc,EAAE,KAAa,EAAE,GAAW;IAChE,IAAM,IAAI,GAAG,KAAK,GAAG,MAAM,CAAC;IAC5B,IAAM,IAAI,GAAG,IAAI,KAAK,CAAC,IAAI,CAAC,CAAC;IAE7B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,CAAC,EAAE,EAAE;QAC7B,IAAI,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC;KACf;IAED,OAAO;QACL,IAAI,MAAA;QACJ,KAAK,OAAA;QACL,MAAM,QAAA;KACP,CAAC;AACJ,CAAC;AAbD,0BAaC"}
@@ -1,21 +0,0 @@
1
- /**
2
- * `M = mod(X,Y)` returns the remainder `X - Y.*floor(X./Y)` for nonzero `Y`, and returns `X`
3
- * otherwise. `mod(X,Y)` always differs from `X` by a multiple of `Y`.
4
- *
5
- * So long as operands `X` and `Y` are of the same sign, the function `mod(X,Y)` returns the same
6
- * result as does `rem(X,Y)`. However, for positive `X` and `Y`, `mod(-x,y) = rem(-x,y)+y`.
7
- *
8
- * The mod function is useful for congruence relationships: x and y are congruent (mod m) if and
9
- * only if mod(x,m) == mod(y,m).
10
- *
11
- * This method mimics Matlab's `mod` method
12
- *
13
- * @method mod
14
- * @param {Number} x - The dividend
15
- * @param {Numvwe} y - The divisor
16
- * @returns {Number} M - Returns the signed remainder after division.
17
- * @private
18
- * @memberOf matlab
19
- * @since 0.0.2
20
- */
21
- export declare function mod(x: number, y: number): number;
@@ -1,27 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- /**
4
- * `M = mod(X,Y)` returns the remainder `X - Y.*floor(X./Y)` for nonzero `Y`, and returns `X`
5
- * otherwise. `mod(X,Y)` always differs from `X` by a multiple of `Y`.
6
- *
7
- * So long as operands `X` and `Y` are of the same sign, the function `mod(X,Y)` returns the same
8
- * result as does `rem(X,Y)`. However, for positive `X` and `Y`, `mod(-x,y) = rem(-x,y)+y`.
9
- *
10
- * The mod function is useful for congruence relationships: x and y are congruent (mod m) if and
11
- * only if mod(x,m) == mod(y,m).
12
- *
13
- * This method mimics Matlab's `mod` method
14
- *
15
- * @method mod
16
- * @param {Number} x - The dividend
17
- * @param {Numvwe} y - The divisor
18
- * @returns {Number} M - Returns the signed remainder after division.
19
- * @private
20
- * @memberOf matlab
21
- * @since 0.0.2
22
- */
23
- function mod(x, y) {
24
- return x - y * Math.floor(x / y);
25
- }
26
- exports.mod = mod;
27
- //# sourceMappingURL=mod.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"mod.js","sourceRoot":"","sources":["../../src/matlab/mod.ts"],"names":[],"mappings":";;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,SAAgB,GAAG,CAAC,CAAS,EAAE,CAAS;IACtC,OAAO,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;AACnC,CAAC;AAFD,kBAEC"}
@@ -1,36 +0,0 @@
1
- import { Matrix } from "../types";
2
- /**
3
- * `Y = normpdf(X,μ,σ)` computes the pdf at each of the values in `X` using the normal
4
- * distribution with mean `μ` and standard deviation `σ`. `X`, `μ`, and `σ` can be vectors,
5
- * matrices, or multidimensional arrays that all have the same size. A scalar input is expanded to a
6
- * constant array with the same dimensions as the other inputs. The parameters in `σ` must be
7
- * positive.
8
- *
9
- * The normal pdf is: `y = f(x|μ,σ) = (1 / (σ√(2π))) * e^(-(x-μ)^2/2σ^2)`
10
- *
11
- * The likelihood function is the pdf viewed as a function of the parameters. Maximum likelihood
12
- * estimators (MLEs) are the values of the parameters that maximize the likelihood function for a
13
- * fixed value of `x`.
14
- *
15
- * The standard normal distribution has `µ = 0` and `σ = 1`.
16
- * If x is standard normal, then `xσ + µ` is also normal with mean `µ` and standard deviation `σ`.
17
- * Conversely, if `y` is normal with mean `µ` and standard deviation `σ`, then `x = (y – µ) / σ` is
18
- * standard normal.
19
- *
20
- * `Y = normpdf(X)` uses the standard normal distribution (`µ = 0`, `σ = 1`).
21
- * `Y = normpdf(X,µ)` uses the normal distribution with unit standard deviation (`σ = 1`).
22
- *
23
- * @example normpdf({ data: [2, 1, 0, 1, 2], width: 5, height: 1 }, 0, 1.5) =>
24
- * { data: [ 0.10934, 0.21297, 0.26596, 0.21297, 0.10934], width: 5, height: 1 }
25
- *
26
- * @method normpdf
27
- * @param {Matrix} X - The input matrix
28
- * @param {Number} [µ=0] - The length of the filter
29
- * @param {Number} [σ=1] - The filter sigma value
30
- * @returns {Matrix} Y - Returns the central part of the convolution of the same
31
- * size as `a`.
32
- * @public
33
- * @memberOf matlab
34
- * @since 0.0.2
35
- */
36
- export declare function normpdf({ data: ref, width, height }: Matrix, µ?: number, σ?: number): Matrix;
@@ -1,55 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- /**
4
- * `Y = normpdf(X,μ,σ)` computes the pdf at each of the values in `X` using the normal
5
- * distribution with mean `μ` and standard deviation `σ`. `X`, `μ`, and `σ` can be vectors,
6
- * matrices, or multidimensional arrays that all have the same size. A scalar input is expanded to a
7
- * constant array with the same dimensions as the other inputs. The parameters in `σ` must be
8
- * positive.
9
- *
10
- * The normal pdf is: `y = f(x|μ,σ) = (1 / (σ√(2π))) * e^(-(x-μ)^2/2σ^2)`
11
- *
12
- * The likelihood function is the pdf viewed as a function of the parameters. Maximum likelihood
13
- * estimators (MLEs) are the values of the parameters that maximize the likelihood function for a
14
- * fixed value of `x`.
15
- *
16
- * The standard normal distribution has `µ = 0` and `σ = 1`.
17
- * If x is standard normal, then `xσ + µ` is also normal with mean `µ` and standard deviation `σ`.
18
- * Conversely, if `y` is normal with mean `µ` and standard deviation `σ`, then `x = (y – µ) / σ` is
19
- * standard normal.
20
- *
21
- * `Y = normpdf(X)` uses the standard normal distribution (`µ = 0`, `σ = 1`).
22
- * `Y = normpdf(X,µ)` uses the normal distribution with unit standard deviation (`σ = 1`).
23
- *
24
- * @example normpdf({ data: [2, 1, 0, 1, 2], width: 5, height: 1 }, 0, 1.5) =>
25
- * { data: [ 0.10934, 0.21297, 0.26596, 0.21297, 0.10934], width: 5, height: 1 }
26
- *
27
- * @method normpdf
28
- * @param {Matrix} X - The input matrix
29
- * @param {Number} [µ=0] - The length of the filter
30
- * @param {Number} [σ=1] - The filter sigma value
31
- * @returns {Matrix} Y - Returns the central part of the convolution of the same
32
- * size as `a`.
33
- * @public
34
- * @memberOf matlab
35
- * @since 0.0.2
36
- */
37
- function normpdf(_a, µ, σ) {
38
- var ref = _a.data, width = _a.width, height = _a.height;
39
- if (µ === void 0) { µ = 0; }
40
- if (σ === void 0) { σ = 1; }
41
- // data = ((2 * pi)^(-1 / 2)) * exp(-((x - µ) / σ)^2 / 2) / σ;
42
- var SQ2PI = 2.506628274631000502415765284811;
43
- var data = new Array(ref.length);
44
- for (var i = 0; i < ref.length; i++) {
45
- var z = (ref[i] - µ) / σ;
46
- data[i] = Math.exp(-(Math.pow(z, 2)) / 2) / (σ * SQ2PI);
47
- }
48
- return {
49
- data: data,
50
- width: width,
51
- height: height
52
- };
53
- }
54
- exports.normpdf = normpdf;
55
- //# sourceMappingURL=normpdf.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"normpdf.js","sourceRoot":"","sources":["../../src/matlab/normpdf.ts"],"names":[],"mappings":";;AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,SAAgB,OAAO,CACrB,EAAoC,EACpC,CAAK,EACL,CAAK;QAFH,aAAS,EAAE,gBAAK,EAAE,kBAAM;IAC1B,kBAAA,EAAA,KAAK;IACL,kBAAA,EAAA,KAAK;IAEL,8DAA8D;IAC9D,IAAM,KAAK,GAAG,gCAAgC,CAAC;IAC/C,IAAM,IAAI,GAAG,IAAI,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAEnC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QACnC,IAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;QAE3B,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,SAAA,CAAC,EAAI,CAAC,CAAA,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC;KACjD;IAED,OAAO;QACL,IAAI,MAAA;QACJ,KAAK,OAAA;QACL,MAAM,QAAA;KACP,CAAC;AACJ,CAAC;AApBD,0BAoBC"}
@@ -1,15 +0,0 @@
1
- import { Matrix } from "../types";
2
- /**
3
- * Create a matrix of all ones
4
- *
5
- * This method mimics Matlab's `ones` method
6
- *
7
- * @method ones
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 ones
11
- * @public
12
- * @memberOf matlab
13
- * @since 0.0.2
14
- */
15
- export declare function ones(height: number, width?: number): Matrix;
@@ -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 ones
6
- *
7
- * This method mimics Matlab's `ones` method
8
- *
9
- * @method ones
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 ones
13
- * @public
14
- * @memberOf matlab
15
- * @since 0.0.2
16
- */
17
- function ones(height, width) {
18
- if (width === void 0) { width = height; }
19
- return numbers_1.numbers(height, width, 1);
20
- }
21
- exports.ones = ones;
22
- //# sourceMappingURL=ones.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ones.js","sourceRoot":"","sources":["../../src/matlab/ones.ts"],"names":[],"mappings":";;AACA,8CAA6C;AAE7C;;;;;;;;;;;;GAYG;AACH,SAAgB,IAAI,CAAC,MAAc,EAAE,KAAsB;IAAtB,sBAAA,EAAA,cAAsB;IACzD,OAAO,iBAAO,CAAC,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;AACnC,CAAC;AAFD,oBAEC"}
@@ -1,37 +0,0 @@
1
- import { Matrix } from "../types";
2
- export declare type PaddingValue = "symmetric";
3
- export declare type PaddingDirection = "both";
4
- /**
5
- * `B = padarray(A,padsize)` pads array `A`. padsize is a vector of nonnegative integers that
6
- * specifies both, the amount of padding to add and the dimension along which to add it. The value
7
- * of an element in the vector specifies the amount of padding to add. The order of the element in
8
- * the vector specifies the dimension along which to add the padding.
9
- *
10
- * For example, a padsize value of `[2 3]` means add 2 elements of padding along the first dimension
11
- * and 3 elements of padding along the second dimension.
12
- *
13
- * By default, paddarray adds padding before the first element and after the last element along the
14
- * specified dimension.
15
- *
16
- * `B = padarray(A,padsize,padval)` pads array `A` where `padval` specifies the value to use as the
17
- * pad value. `padval` can only be 'symmetric' for this implementation of `padarray` which will pad
18
- * the array with mirror reflections of itself.
19
- *
20
- * This method mimics Matlab's `padarray` method with `padval = 'symmetric'` and
21
- * `direction = 'both'`. No other options have been implemented and, if set, they will be ignored.
22
- *
23
- * This method has been unfolded for performance and switched to simple for loops. Readability
24
- * suffers.
25
- *
26
- * @method padarray
27
- * @param {Matrix} A - The target matrix
28
- * @param {Array<number>} padding - An array where the first element is the padding to apply to
29
- * each side on each row and the second one is the vertical padding for each side of each column
30
- * @param {String} [padval='symmetric'] - The type of padding to apply (coerced to 'symmetric')
31
- * @param {String} [direction='both'] - The direction to which apply padding (coerced to 'both')
32
- * @returns {Matrix} c - An array with padding added on each side.
33
- * @public
34
- * @memberOf matlab
35
- * @since 0.0.2
36
- */
37
- export declare function padarray(A: Matrix, [padHeight, padWidth]: [number, number], _padval?: PaddingValue, _direction?: PaddingDirection): Matrix;
@@ -1,349 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- var mod_1 = require("./mod");
4
- /**
5
- * Mirrors a matrix horizontally.
6
- *
7
- * @example
8
- * 1 2 3 4 becomes: 4 3 2 1
9
- * 5 6 7 8 8 7 6 5
10
- *
11
- * @method mirrorHorizonal
12
- * @param {Matrix} A - The input matrix
13
- * @returns {Matrix} B - The rotated matrix
14
- * @private
15
- * @memberOf matlab
16
- * @since 0.0.2
17
- */
18
- function mirrorHorizonal(_a) {
19
- var ref = _a.data, width = _a.width, height = _a.height;
20
- var data = new Array(ref.length);
21
- for (var x = 0; x < height; x++) {
22
- for (var y = 0; y < width; y++) {
23
- data[x * width + y] = ref[x * width + width - 1 - y];
24
- }
25
- }
26
- return {
27
- data: data,
28
- width: width,
29
- height: height
30
- };
31
- }
32
- /**
33
- * Mirrors a matrix vertically.
34
- *
35
- * @example
36
- * 1 2 3 4 becomes: 9 0 F E
37
- * 5 6 7 8 5 6 7 8
38
- * 9 0 F E 1 2 3 4
39
- *
40
- * @method mirrorVertical
41
- * @param {Matrix} A - The input matrix
42
- * @returns {Matrix} B - The rotated matrix
43
- * @private
44
- * @memberOf matlab
45
- * @since 0.0.2
46
- */
47
- function mirrorVertical(_a) {
48
- var ref = _a.data, width = _a.width, height = _a.height;
49
- var data = new Array(ref.length);
50
- for (var x = 0; x < height; x++) {
51
- for (var y = 0; y < width; y++) {
52
- data[x * width + y] = ref[(height - 1 - x) * width + y];
53
- }
54
- }
55
- return {
56
- data: data,
57
- width: width,
58
- height: height
59
- };
60
- }
61
- /**
62
- * Concatenates 2 matrices of the same height horizontally.
63
- *
64
- * @example
65
- * 1 2 3 4 becomes: 1 2 3 4
66
- * 5 6 7 8 5 6 7 8
67
- *
68
- * @method concatHorizontal
69
- * @param {Matrix} A - The first matrix
70
- * @param {Matrix} B - The second matrix
71
- * @returns {Matrix} out - The combined matrix
72
- * @private
73
- * @memberOf matlab
74
- * @since 0.0.2
75
- */
76
- function concatHorizontal(A, B) {
77
- var width = A.width + B.width;
78
- var data = new Array(A.height * width);
79
- for (var x = 0; x < A.height; x++) {
80
- for (var y = 0; y < A.width; y++) {
81
- data[x * width + y] = A.data[x * A.width + y];
82
- }
83
- for (var y = 0; y < B.width; y++) {
84
- data[x * width + y + A.width] = B.data[x * B.width + y];
85
- }
86
- }
87
- return {
88
- data: data,
89
- width: width,
90
- height: A.height
91
- };
92
- }
93
- /**
94
- * Concatenates 2 matrices of the same height vertically.
95
- *
96
- * @example
97
- * 1 2 3 4 becomes: 1 2
98
- * 5 6 7 8 5 6
99
- * 3 4
100
- * 7 8
101
- *
102
- * @method concatVertical
103
- * @param {Matrix} A - The first matrix
104
- * @param {Matrix} B - The second matrix
105
- * @returns {Matrix} out - The combined matrix
106
- * @private
107
- * @memberOf matlab
108
- * @since 0.0.2
109
- */
110
- function concatVertical(A, B) {
111
- return {
112
- data: A.data.concat(B.data),
113
- height: A.height + B.height,
114
- width: A.width
115
- };
116
- }
117
- /**
118
- * Adds 2 * `pad` cells to a matrix horizontally. The values used are mirrored from the input
119
- * matrix.
120
- *
121
- * @example
122
- * with padding 1:
123
- * 1 2 3 4 becomes: 1 1 2 3 4 4
124
- * 5 6 7 8 5 5 6 7 8 8
125
- *
126
- * With padding 2:
127
- * 1 2 3 4 becomes: 2 1 1 2 3 4 4 3
128
- * 5 6 7 8 6 5 5 6 7 8 8 7
129
- *
130
- * @method padHorizontal
131
- * @param {Matrix} A - The input matrix
132
- * @param {Number} pad - The nummber of cells to add to each side (left / right)
133
- * @returns {Matrix} B - The padded matrix
134
- * @private
135
- * @memberOf matlab
136
- * @since 0.0.2
137
- */
138
- function padHorizontal(A, pad) {
139
- var width = A.width + 2 * pad;
140
- var data = new Array(width * A.height);
141
- var mirrored = concatHorizontal(A, mirrorHorizonal(A));
142
- for (var x = 0; x < A.height; x++) {
143
- for (var y = -pad; y < A.width + pad; y++) {
144
- data[x * width + y + pad] =
145
- mirrored.data[x * mirrored.width + mod_1.mod(y, mirrored.width)];
146
- }
147
- }
148
- return {
149
- data: data,
150
- width: width,
151
- height: A.height
152
- };
153
- }
154
- /**
155
- * Adds 2 * `pad` cells to a matrix vertically. The values used are mirrored from the input
156
- * matrix.
157
- *
158
- * @example
159
- * with padding 1:
160
- * 1 2 3 4 becomes: 1 2 3 4
161
- * 5 6 7 8 1 2 3 4
162
- * 5 6 7 8
163
- * 5 6 7 8
164
- * With padding 2:
165
- * 1 2 3 4 becomes: 5 6 7 8
166
- * 5 6 7 8 1 2 3 4
167
- * 1 2 3 4
168
- * 5 6 7 8
169
- * 5 6 7 8
170
- * 1 2 3 4
171
- *
172
- * @method padVertical
173
- * @param {Matrix} A - The input matrix
174
- * @param {Number} pad - The nummber of cells to add to each side (top / bottom)
175
- * @returns {Matrix} B - The padded matrix
176
- * @private
177
- * @memberOf matlab
178
- * @since 0.0.2
179
- */
180
- function padVertical(A, pad) {
181
- var mirrored = concatVertical(A, mirrorVertical(A));
182
- var height = A.height + pad * 2;
183
- var data = new Array(A.width * height);
184
- for (var x = -pad; x < A.height + pad; x++) {
185
- for (var y = 0; y < A.width; y++) {
186
- data[(x + pad) * A.width + y] =
187
- mirrored.data[mod_1.mod(x, mirrored.height) * A.width + y];
188
- }
189
- }
190
- return {
191
- data: data,
192
- width: A.width,
193
- height: height
194
- };
195
- }
196
- /**
197
- * Implements `padarray` matching Matlab only for the case where:
198
- *
199
- * `padHeight <= A.height && padWidth <= A.width`
200
- *
201
- * For an input Matrix `E`, we add padding A, B, C, D, F, G, H and I of size `padHeight` and
202
- * `padWidth` where appropriate. For instance, given E:
203
- *
204
- * 1 2 3
205
- * 4 5 6
206
- *
207
- * Placed in a padding matrix like this:
208
- *
209
- * | A | B | C |
210
- * |---|---|---|
211
- * | D | E | F |
212
- * |---|---|---|
213
- * | G | H | I |
214
- *
215
- * with padding [1, 1] it becomes:
216
- *
217
- * | 1 | 1 2 3 | 3 |
218
- * |---|-------|---|
219
- * | 1 | 1 2 3 | 3 |
220
- * | 4 | 4 5 6 | 6 |
221
- * |---|-------|---|
222
- * | 4 | 4 5 6 | 6 |
223
- *
224
- * with padding [2, 3] it becomes:
225
- *
226
- * | 6 5 4 | 4 5 6 | 6 5 4 |
227
- * | 3 2 1 | 1 2 3 | 3 2 1 |
228
- * |-------|-------|-------|
229
- * | 3 2 1 | 1 2 3 | 3 2 1 |
230
- * | 6 5 4 | 4 5 6 | 6 5 4 |
231
- * |-------|-------|-------|
232
- * | 6 5 4 | 4 5 6 | 6 5 4 |
233
- * | 3 2 1 | 1 2 3 | 3 2 1 |
234
- *
235
- * @method fastPadding
236
- * @param {Matrix} A - The input matrix
237
- * @param {Array<number>} padding - An array where the first element is the padding to apply to each
238
- * side on each row and the second one is the vertical padding for each side of each column
239
- * @returns {Matrix} B - The padded matrix
240
- * @private
241
- * @memberOf matlab
242
- * @since 0.0.4
243
- */
244
- function fastPadding(A, _a) {
245
- var padHeight = _a[0], padWidth = _a[1];
246
- var width = A.width + padWidth * 2;
247
- var height = A.height + padHeight * 2;
248
- var data = new Array(width * height);
249
- for (var x = -padHeight; x < 0; x++) {
250
- // A
251
- for (var y = -padWidth; y < 0; y++) {
252
- data[(x + padHeight) * width + y + padWidth] =
253
- A.data[(Math.abs(x) - 1) * A.width + Math.abs(y) - 1];
254
- }
255
- // B
256
- for (var y = 0; y < A.width; y++) {
257
- data[(x + padHeight) * width + y + padWidth] =
258
- A.data[(Math.abs(x) - 1) * A.width + y];
259
- }
260
- // C
261
- for (var y = A.width; y < A.width + padWidth; y++) {
262
- data[(x + padHeight) * width + y + padWidth] =
263
- A.data[(Math.abs(x) - 1) * A.width + 2 * A.width - y - 1];
264
- }
265
- }
266
- for (var x = 0; x < A.height; x++) {
267
- // D
268
- for (var y = -padWidth; y < 0; y++) {
269
- data[(x + padHeight) * width + y + padWidth] =
270
- A.data[x * A.width + Math.abs(y) - 1];
271
- }
272
- // E
273
- for (var y = 0; y < A.width; y++) {
274
- data[(x + padHeight) * width + y + padWidth] = A.data[x * A.width + y];
275
- }
276
- // F
277
- for (var y = A.width; y < A.width + padWidth; y++) {
278
- data[(x + padHeight) * width + y + padWidth] =
279
- A.data[x * A.width + 2 * A.width - y - 1];
280
- }
281
- }
282
- for (var x = A.height; x < A.height + padHeight; x++) {
283
- // G
284
- for (var y = -padWidth; y < 0; y++) {
285
- data[(x + padHeight) * width + y + padWidth] =
286
- A.data[(2 * A.height - x - 1) * A.width + Math.abs(y) - 1];
287
- }
288
- // H
289
- for (var y = 0; y < A.width; y++) {
290
- data[(x + padHeight) * width + y + padWidth] =
291
- A.data[(2 * A.height - x - 1) * A.width + y];
292
- }
293
- // I
294
- for (var y = A.width; y < A.width + padWidth; y++) {
295
- data[(x + padHeight) * width + y + padWidth] =
296
- A.data[(2 * A.height - x - 1) * A.width + 2 * A.width - y - 1];
297
- }
298
- }
299
- return {
300
- data: data,
301
- width: width,
302
- height: height
303
- };
304
- }
305
- /**
306
- * `B = padarray(A,padsize)` pads array `A`. padsize is a vector of nonnegative integers that
307
- * specifies both, the amount of padding to add and the dimension along which to add it. The value
308
- * of an element in the vector specifies the amount of padding to add. The order of the element in
309
- * the vector specifies the dimension along which to add the padding.
310
- *
311
- * For example, a padsize value of `[2 3]` means add 2 elements of padding along the first dimension
312
- * and 3 elements of padding along the second dimension.
313
- *
314
- * By default, paddarray adds padding before the first element and after the last element along the
315
- * specified dimension.
316
- *
317
- * `B = padarray(A,padsize,padval)` pads array `A` where `padval` specifies the value to use as the
318
- * pad value. `padval` can only be 'symmetric' for this implementation of `padarray` which will pad
319
- * the array with mirror reflections of itself.
320
- *
321
- * This method mimics Matlab's `padarray` method with `padval = 'symmetric'` and
322
- * `direction = 'both'`. No other options have been implemented and, if set, they will be ignored.
323
- *
324
- * This method has been unfolded for performance and switched to simple for loops. Readability
325
- * suffers.
326
- *
327
- * @method padarray
328
- * @param {Matrix} A - The target matrix
329
- * @param {Array<number>} padding - An array where the first element is the padding to apply to
330
- * each side on each row and the second one is the vertical padding for each side of each column
331
- * @param {String} [padval='symmetric'] - The type of padding to apply (coerced to 'symmetric')
332
- * @param {String} [direction='both'] - The direction to which apply padding (coerced to 'both')
333
- * @returns {Matrix} c - An array with padding added on each side.
334
- * @public
335
- * @memberOf matlab
336
- * @since 0.0.2
337
- */
338
- function padarray(A, _a, _padval, _direction) {
339
- var padHeight = _a[0], padWidth = _a[1];
340
- // If the padding to mirror is not greater than `A` dimensions, we can use `fastPadding`,
341
- // otherwise we fall back to a slower implementation that mimics Matlab behavior for longer
342
- // matrices
343
- if (A.height >= padHeight && A.width >= padWidth) {
344
- return fastPadding(A, [padHeight, padWidth]);
345
- }
346
- return padVertical(padHorizontal(A, padWidth), padHeight);
347
- }
348
- exports.padarray = padarray;
349
- //# sourceMappingURL=padarray.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"padarray.js","sourceRoot":"","sources":["../../src/matlab/padarray.ts"],"names":[],"mappings":";;AACA,6BAA4B;AAE5B;;;;;;;;;;;;;GAaG;AACH,SAAS,eAAe,CAAC,EAAoC;QAAlC,aAAS,EAAE,gBAAK,EAAE,kBAAM;IACjD,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,GAAG,KAAK,GAAG,KAAK,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;SACtD;KACF;IAED,OAAO;QACL,IAAI,MAAA;QACJ,KAAK,OAAA;QACL,MAAM,QAAA;KACP,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;;GAcG;AACH,SAAS,cAAc,CAAC,EAAoC;QAAlC,aAAS,EAAE,gBAAK,EAAE,kBAAM;IAChD,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,C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yF;IACzF,2FAA2F;IAC3F,WAAW;IACX,IAAI,CAAC,CAAC,MAAM,IAAI,SAAS,IAAI,CAAC,CAAC,KAAK,IAAI,QAAQ,EAAE;QAChD,OAAO,WAAW,CAAC,CAAC,EAAE,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC,CAAC;KAC9C;IAED,OAAO,WAAW,CAAC,aAAa,CAAC,CAAC,EAAE,QAAQ,CAAC,EAAE,SAAS,CAAC,CAAC;AAC5D,CAAC;AAdD,4BAcC"}
@@ -1,15 +0,0 @@
1
- import { Matrix } from "../types";
2
- /**
3
- * Converts an imageData object of { width, height, data } into a 2d matrix [row, column]
4
- * where the value is the grayscale equivalent of the rgb input.
5
- *
6
- * This method mimics Matlab's `rgb2gray` method
7
- *
8
- * @method rgb2gray
9
- * @param {Matrix | ImageData} imageData - The input imageData
10
- * @returns {Object} grayscale - A grayscale representation of the input image
11
- * @public
12
- * @memberOf matlab
13
- * @since 0.0.2
14
- */
15
- export declare function rgb2gray({ data: d, width, height }: Matrix | ImageData): Matrix;