image-js 1.0.0 → 1.2.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 (140) hide show
  1. package/dist/image-js.esm.js +1041 -245
  2. package/dist/image-js.esm.js.map +1 -1
  3. package/dist/image-js.esm.min.js +2 -2
  4. package/dist/image-js.esm.min.js.map +1 -1
  5. package/dist/image-js.umd.js +1009 -211
  6. package/dist/image-js.umd.js.map +1 -1
  7. package/dist/image-js.umd.min.js +2 -2
  8. package/dist/image-js.umd.min.js.map +1 -1
  9. package/dist-types/image-js.d.ts +4 -5
  10. package/lib/Mask.d.ts +1 -1
  11. package/lib/Mask.js +1 -1
  12. package/lib/draw/drawLineOnImage.d.ts.map +1 -1
  13. package/lib/draw/drawLineOnImage.js.map +1 -1
  14. package/lib/extra/draw/draw_text.d.ts +47 -0
  15. package/lib/extra/draw/draw_text.d.ts.map +1 -0
  16. package/lib/extra/draw/draw_text.js +108 -0
  17. package/lib/extra/draw/draw_text.js.map +1 -0
  18. package/lib/extra/draw/index.d.ts +3 -0
  19. package/lib/extra/draw/index.d.ts.map +1 -0
  20. package/lib/extra/draw/index.js +3 -0
  21. package/lib/extra/draw/index.js.map +1 -0
  22. package/lib/{ssim → extra/ssim}/compute_dssim.d.ts +2 -2
  23. package/lib/extra/ssim/compute_dssim.d.ts.map +1 -0
  24. package/lib/{ssim → extra/ssim}/compute_dssim.js +1 -1
  25. package/lib/extra/ssim/compute_dssim.js.map +1 -0
  26. package/lib/{ssim → extra/ssim}/compute_ssim.d.ts +1 -1
  27. package/lib/extra/ssim/compute_ssim.d.ts.map +1 -0
  28. package/lib/{ssim → extra/ssim}/compute_ssim.js +2 -2
  29. package/lib/extra/ssim/compute_ssim.js.map +1 -0
  30. package/lib/extra/ssim/index.d.ts +3 -0
  31. package/lib/extra/ssim/index.d.ts.map +1 -0
  32. package/lib/extra/ssim/index.js +3 -0
  33. package/lib/extra/ssim/index.js.map +1 -0
  34. package/lib/featureMatching/matching/filterEuclideanDistance.d.ts.map +1 -1
  35. package/lib/featureMatching/matching/filterEuclideanDistance.js +6 -7
  36. package/lib/featureMatching/matching/filterEuclideanDistance.js.map +1 -1
  37. package/lib/featureMatching/matching/filterSmallestDistanceMatches.d.ts.map +1 -1
  38. package/lib/featureMatching/matching/filterSmallestDistanceMatches.js +6 -3
  39. package/lib/featureMatching/matching/filterSmallestDistanceMatches.js.map +1 -1
  40. package/lib/featureMatching/utils/sortByDistance.d.ts.map +1 -1
  41. package/lib/featureMatching/utils/sortByDistance.js +3 -1
  42. package/lib/featureMatching/utils/sortByDistance.js.map +1 -1
  43. package/lib/featureMatching/utils/sortBySourceDest.d.ts.map +1 -1
  44. package/lib/featureMatching/utils/sortBySourceDest.js +6 -2
  45. package/lib/featureMatching/utils/sortBySourceDest.js.map +1 -1
  46. package/lib/index_browser.d.ts +3 -0
  47. package/lib/index_browser.d.ts.map +1 -0
  48. package/lib/index_browser.js +5 -0
  49. package/lib/index_browser.js.map +1 -0
  50. package/lib/index_full.d.ts +4 -0
  51. package/lib/index_full.d.ts.map +1 -0
  52. package/lib/index_full.js +5 -0
  53. package/lib/index_full.js.map +1 -0
  54. package/lib/load/decode.d.ts.map +1 -1
  55. package/lib/load/decode.js +2 -0
  56. package/lib/load/decode.js.map +1 -1
  57. package/lib/load/decodeBmp.d.ts +8 -0
  58. package/lib/load/decodeBmp.d.ts.map +1 -0
  59. package/lib/load/decodeBmp.js +36 -0
  60. package/lib/load/decodeBmp.js.map +1 -0
  61. package/lib/load/decodePng.d.ts.map +1 -1
  62. package/lib/load/decodePng.js +29 -5
  63. package/lib/load/decodePng.js.map +1 -1
  64. package/lib/load/decodeTiff.d.ts.map +1 -1
  65. package/lib/load/decodeTiff.js +44 -21
  66. package/lib/load/decodeTiff.js.map +1 -1
  67. package/lib/load/read.d.ts +1 -1
  68. package/lib/load/read.js +1 -1
  69. package/lib/maskAnalysis/utils/getMbrAngle.d.ts.map +1 -1
  70. package/lib/maskAnalysis/utils/getMbrAngle.js +2 -1
  71. package/lib/maskAnalysis/utils/getMbrAngle.js.map +1 -1
  72. package/lib/maskAnalysis/utils/monotoneChainConvexHull.d.ts.map +1 -1
  73. package/lib/maskAnalysis/utils/monotoneChainConvexHull.js +2 -1
  74. package/lib/maskAnalysis/utils/monotoneChainConvexHull.js.map +1 -1
  75. package/lib/save/encodeBmp.d.ts +4 -4
  76. package/lib/save/encodeBmp.d.ts.map +1 -1
  77. package/lib/save/encodeBmp.js +22 -14
  78. package/lib/save/encodeBmp.js.map +1 -1
  79. package/lib/save/write.d.ts +1 -1
  80. package/lib/save/write.js +1 -1
  81. package/lib/stack/load/decodeApng.d.ts +8 -0
  82. package/lib/stack/load/decodeApng.d.ts.map +1 -0
  83. package/lib/stack/load/decodeApng.js +60 -0
  84. package/lib/stack/load/decodeApng.js.map +1 -0
  85. package/lib/stack/load/decodeStack.d.ts.map +1 -1
  86. package/lib/stack/load/decodeStack.js +2 -0
  87. package/lib/stack/load/decodeStack.js.map +1 -1
  88. package/lib/utils/cross_platform.d.ts +8 -0
  89. package/lib/utils/cross_platform.d.ts.map +1 -1
  90. package/lib/utils/cross_platform.js +34 -2
  91. package/lib/utils/cross_platform.js.map +1 -1
  92. package/lib/utils/geometry/points.d.ts.map +1 -1
  93. package/lib/utils/geometry/points.js +3 -1
  94. package/lib/utils/geometry/points.js.map +1 -1
  95. package/lib/utils/geometry/removeClosePoints.d.ts.map +1 -1
  96. package/lib/utils/geometry/removeClosePoints.js +2 -1
  97. package/lib/utils/geometry/removeClosePoints.js.map +1 -1
  98. package/lib/utils/setBlendedPixel.d.ts +1 -1
  99. package/lib/utils/setBlendedPixel.js +1 -1
  100. package/lib/utils/setBlendedVisiblePixel.d.ts +1 -1
  101. package/lib/utils/setBlendedVisiblePixel.js +1 -1
  102. package/package.json +43 -29
  103. package/src/Mask.ts +1 -1
  104. package/src/draw/drawLineOnImage.ts +0 -1
  105. package/src/extra/draw/draw_text.ts +194 -0
  106. package/src/extra/draw/index.ts +2 -0
  107. package/src/{ssim → extra/ssim}/compute_dssim.ts +3 -3
  108. package/src/{ssim → extra/ssim}/compute_ssim.ts +3 -3
  109. package/src/extra/ssim/index.ts +2 -0
  110. package/src/featureMatching/matching/filterEuclideanDistance.ts +6 -13
  111. package/src/featureMatching/matching/filterSmallestDistanceMatches.ts +6 -9
  112. package/src/featureMatching/utils/sortByDistance.ts +3 -1
  113. package/src/featureMatching/utils/sortBySourceDest.ts +6 -2
  114. package/src/index_browser.ts +4 -0
  115. package/src/index_full.ts +4 -0
  116. package/src/load/decode.ts +2 -1
  117. package/src/load/decodeBmp.ts +37 -0
  118. package/src/load/decodePng.ts +39 -7
  119. package/src/load/decodeTiff.ts +53 -22
  120. package/src/load/read.ts +1 -1
  121. package/src/maskAnalysis/utils/getMbrAngle.ts +2 -1
  122. package/src/maskAnalysis/utils/monotoneChainConvexHull.ts +2 -1
  123. package/src/save/encodeBmp.ts +22 -15
  124. package/src/save/write.ts +1 -1
  125. package/src/stack/load/decodeApng.ts +71 -0
  126. package/src/stack/load/decodeStack.ts +2 -0
  127. package/src/utils/cross_platform.ts +47 -4
  128. package/src/utils/geometry/points.ts +3 -1
  129. package/src/utils/geometry/removeClosePoints.ts +2 -1
  130. package/src/utils/setBlendedPixel.ts +1 -1
  131. package/src/utils/setBlendedVisiblePixel.ts +1 -1
  132. package/lib/ssim/compute_dssim.d.ts.map +0 -1
  133. package/lib/ssim/compute_dssim.js.map +0 -1
  134. package/lib/ssim/compute_ssim.d.ts.map +0 -1
  135. package/lib/ssim/compute_ssim.js.map +0 -1
  136. package/lib/ssim/index.d.ts +0 -3
  137. package/lib/ssim/index.d.ts.map +0 -1
  138. package/lib/ssim/index.js +0 -3
  139. package/lib/ssim/index.js.map +0 -1
  140. package/src/ssim/index.ts +0 -2
@@ -1,6 +1,5 @@
1
1
  import type { BitDepth as BitDepth_2 } from 'fast-png';
2
2
  import { decode as decode_2 } from 'tiff';
3
- import { Image as Image_3 } from '../Image.ts';
4
3
  import type { PngEncoderOptions } from 'fast-png';
5
4
 
6
5
  /**
@@ -1279,7 +1278,7 @@ export declare interface FeretDiameter {
1279
1278
  * @param dataUrl - Image URL.
1280
1279
  * @returns decoded image data.
1281
1280
  */
1282
- export declare function fetchURL(dataUrl: string): Promise<Image_3>;
1281
+ export declare function fetchURL(dataUrl: string): Promise<Image_2>;
1283
1282
 
1284
1283
  /**
1285
1284
  * Apply a flip filter to an image.
@@ -2715,7 +2714,7 @@ export declare class Mask {
2715
2714
  setBitByIndex(index: number, value: BitValue): void;
2716
2715
  /**
2717
2716
  * Get the number of pixels that do not have the value 0.
2718
- * @returns
2717
+ * @returns The number of non-zero pixels.
2719
2718
  */
2720
2719
  getNbNonZeroPixels(): number;
2721
2720
  /**
@@ -3393,7 +3392,7 @@ export declare function readCanvas(canvas: HTMLCanvasElement): Image_2;
3393
3392
  export declare function readImg(img: Extract<CanvasImageSource, Record<'width' | 'height', number>>): Image_2;
3394
3393
 
3395
3394
  /**
3396
- * Synchronous version of @see {@link read}.
3395
+ * Synchronous version of {@link read}.
3397
3396
  * This method is only implemented for Node.js.
3398
3397
  * @param path - The path to the image.
3399
3398
  * @returns Image instance.
@@ -4249,7 +4248,7 @@ export declare type WriteOptionsJpeg = WriteOptions & EncodeOptionsJpeg;
4249
4248
  export declare type WriteOptionsPng = WriteOptions & EncodeOptionsPng;
4250
4249
 
4251
4250
  /**
4252
- * Synchronous version of @see {@link write}.
4251
+ * Synchronous version of {@link write}.
4253
4252
  * This method is only implemented for Node.js.
4254
4253
  * @param path - Path where the image should be written.
4255
4254
  * @param image - Image to save.
package/lib/Mask.d.ts CHANGED
@@ -156,7 +156,7 @@ export declare class Mask {
156
156
  setBitByIndex(index: number, value: BitValue): void;
157
157
  /**
158
158
  * Get the number of pixels that do not have the value 0.
159
- * @returns
159
+ * @returns The number of non-zero pixels.
160
160
  */
161
161
  getNbNonZeroPixels(): number;
162
162
  /**
package/lib/Mask.js CHANGED
@@ -209,7 +209,7 @@ export class Mask {
209
209
  }
210
210
  /**
211
211
  * Get the number of pixels that do not have the value 0.
212
- * @returns
212
+ * @returns The number of non-zero pixels.
213
213
  */
214
214
  getNbNonZeroPixels() {
215
215
  let count = 0;
@@ -1 +1 @@
1
- {"version":3,"file":"drawLineOnImage.d.ts","sourceRoot":"","sources":["../../src/draw/drawLineOnImage.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;AAOzD,MAAM,WAAW,sBAAsB;IACrC;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB;;;OAGG;IACH,MAAM,CAAC,EAAE,KAAK,CAAC;IACf;;OAEG;IACH,GAAG,CAAC,EAAE,KAAK,CAAC;CACb;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAC7B,KAAK,EAAE,KAAK,EACZ,IAAI,EAAE,KAAK,EACX,EAAE,EAAE,KAAK,EACT,OAAO,GAAE,sBAA2B,GACnC,KAAK,CAuBP"}
1
+ {"version":3,"file":"drawLineOnImage.d.ts","sourceRoot":"","sources":["../../src/draw/drawLineOnImage.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;AAOzD,MAAM,WAAW,sBAAsB;IACrC;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB;;;OAGG;IACH,MAAM,CAAC,EAAE,KAAK,CAAC;IACf;;OAEG;IACH,GAAG,CAAC,EAAE,KAAK,CAAC;CACb;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAC7B,KAAK,EAAE,KAAK,EACZ,IAAI,EAAE,KAAK,EACX,EAAE,EAAE,KAAK,EACT,OAAO,GAAE,sBAA2B,GACnC,KAAK,CAsBP"}
@@ -1 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jC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,GAAG,EAAE,CAAC,MAAM,CAAC,EACrC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,GAAG,EAAE,CAAC,GAAG,CAAC,EAC/B,CAAC,MAAc,EAAE,GAAW,EAAE,EAAE;QAC9B,sBAAsB,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,WAAW,CAAC,CAAC;IAC7D,CAAC,CACF,CAAC;IACF,OAAO,QAAQ,CAAC;AAClB,CAAC"}
@@ -0,0 +1,47 @@
1
+ import type { Image } from '../../Image.ts';
2
+ import type { Point } from '../../geometry/index.ts';
3
+ export interface DrawTextLabel {
4
+ /**
5
+ * Text of the label.
6
+ */
7
+ content: number | string;
8
+ /**
9
+ * Position to draw the label at.
10
+ */
11
+ position: Point;
12
+ /**
13
+ * Size and type of font.
14
+ * If specified, this overrides the general font from DrawTextOptions.
15
+ */
16
+ font?: string;
17
+ /**
18
+ * Font color. Should be in rgba8 format.
19
+ * If specified, this overrides the general fontColor from DrawTextOptions.
20
+ */
21
+ fontColor?: number[];
22
+ }
23
+ export interface DrawTextOptions {
24
+ /**
25
+ * General size and type of font.
26
+ * Used as the default when font is not specified in individual text labels.
27
+ */
28
+ font?: string;
29
+ /**
30
+ * General font color.
31
+ * Used as the default when fontColor is not specified in individual text labels.
32
+ */
33
+ fontColor?: number[];
34
+ /**
35
+ * Image to which the resulting image has to be put.
36
+ */
37
+ out?: Image;
38
+ }
39
+ /**
40
+ * Draws text on an image.
41
+ * @param image - Image to write text on.
42
+ * @param text - Text to write on the image.
43
+ * @param options - Out Options
44
+ * @returns Image with drawn text.
45
+ */
46
+ export declare function drawText(image: Image, text: DrawTextLabel | DrawTextLabel[], options?: DrawTextOptions): Image;
47
+ //# sourceMappingURL=draw_text.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"draw_text.d.ts","sourceRoot":"","sources":["../../../src/extra/draw/draw_text.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,KAAK,EAAkB,MAAM,gBAAgB,CAAC;AAC5D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAKrD,MAAM,WAAW,aAAa;IAC5B;;OAEG;IACH,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC;IACzB;;OAEG;IACH,QAAQ,EAAE,KAAK,CAAC;IAChB;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;CACtB;AAED,MAAM,WAAW,eAAe;IAC9B;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IACrB;;OAEG;IACH,GAAG,CAAC,EAAE,KAAK,CAAC;CACb;AAED;;;;;;GAMG;AACH,wBAAgB,QAAQ,CACtB,KAAK,EAAE,KAAK,EACZ,IAAI,EAAE,aAAa,GAAG,aAAa,EAAE,EACrC,OAAO,CAAC,EAAE,eAAe,SA2B1B"}
@@ -0,0 +1,108 @@
1
+ import { getCanvasContext } from "../../utils/cross_platform.js";
2
+ import { getOutputImage } from "../../utils/getOutputImage.js";
3
+ import { validateValues } from "../../utils/validators/validators.js";
4
+ /**
5
+ * Draws text on an image.
6
+ * @param image - Image to write text on.
7
+ * @param text - Text to write on the image.
8
+ * @param options - Out Options
9
+ * @returns Image with drawn text.
10
+ */
11
+ export function drawText(image, text, options) {
12
+ if (Array.isArray(text) && text.length === 0) {
13
+ throw new Error('At least one text element must be provided');
14
+ }
15
+ const newImage = getOutputImage(image, options, { clone: true });
16
+ const defaultFont = options?.font ?? '12px Helvetica';
17
+ const defaultColor = options?.fontColor ?? [255, 255, 255, 255];
18
+ const ctx = getCanvasContext(image.width, image.height);
19
+ if (!Array.isArray(text)) {
20
+ drawTextElement(image, ctx, text, defaultFont, defaultColor);
21
+ }
22
+ else {
23
+ for (const label of text) {
24
+ drawTextElement(image, ctx, label, defaultFont, defaultColor);
25
+ }
26
+ }
27
+ layerCanvas(newImage.getRawImage().data, ctx.getImageData(0, 0, image.width, image.height).data, image.channels, image.bitDepth);
28
+ return newImage;
29
+ }
30
+ function drawTextElement(image, ctx, text, defaultFont, defaultColor) {
31
+ ctx.font = text.font ?? defaultFont;
32
+ const fontColor = text.fontColor ?? defaultColor;
33
+ validateValues(fontColor, image);
34
+ const alpha = fontColor[3] ? fontColor[3] / 255 : 1;
35
+ const normalizedColor = [
36
+ fontColor[0] ?? 0,
37
+ fontColor[1] ?? 0,
38
+ fontColor[2] ?? 0,
39
+ alpha,
40
+ ];
41
+ ctx.fillStyle = `rgba(${normalizedColor.join(',')})`;
42
+ ctx.fillText(String(text.content), text.position.column, text.position.row);
43
+ }
44
+ /**
45
+ * Draws labels on the image data from canvas.
46
+ * @param imageData - Image data to draw text on.
47
+ * @param canvasData - Canvas data to draw on the image.
48
+ * @param numberOfChannels - Number of channels of the initial image.
49
+ * @param bitDepth - Bit depth of the initial image.
50
+ */
51
+ function layerCanvas(imageData, canvasData, numberOfChannels, bitDepth) {
52
+ const config = CHANNEL_CONFIGS[numberOfChannels] || CHANNEL_CONFIGS[1];
53
+ const pixelCount = canvasData.length >>> 2;
54
+ const bitShift = bitDepth - 8;
55
+ let imageIndex = 0;
56
+ let canvasIndex = 0;
57
+ for (let pixel = 0; pixel < pixelCount; pixel++) {
58
+ const canvasAlpha = canvasData[canvasIndex + 3] / 255;
59
+ // Skip transparent canvas pixels completely
60
+ if (canvasAlpha === 0) {
61
+ imageIndex += numberOfChannels;
62
+ canvasIndex += 4;
63
+ continue;
64
+ }
65
+ const invAlpha = 1 - canvasAlpha;
66
+ for (const channel of config.channelOffsets) {
67
+ const targetIndex = imageIndex + channel;
68
+ imageData[targetIndex] =
69
+ Math.round(canvasData[canvasIndex + channel] * canvasAlpha +
70
+ imageData[targetIndex] * invAlpha) << bitShift;
71
+ }
72
+ if (config.hasAlpha) {
73
+ const alphaIndex = imageIndex + config.alphaOffset;
74
+ const imageAlpha = (imageData[alphaIndex] >>> bitShift) / 255;
75
+ const newAlpha = canvasAlpha + imageAlpha * (1 - canvasAlpha);
76
+ imageData[alphaIndex] = Math.round(newAlpha * 255) << bitShift;
77
+ }
78
+ imageIndex += numberOfChannels;
79
+ canvasIndex += 4;
80
+ }
81
+ }
82
+ const CHANNEL_CONFIGS = {
83
+ // GREY
84
+ 1: {
85
+ channelOffsets: [0],
86
+ hasAlpha: false,
87
+ alphaOffset: undefined,
88
+ },
89
+ // GREYA
90
+ 2: {
91
+ channelOffsets: [0],
92
+ hasAlpha: true,
93
+ alphaOffset: 1,
94
+ },
95
+ 3: {
96
+ // RGB
97
+ channelOffsets: [0, 1, 2],
98
+ hasAlpha: false,
99
+ alphaOffset: undefined,
100
+ },
101
+ 4: {
102
+ // RGBA
103
+ channelOffsets: [0, 1, 2],
104
+ hasAlpha: true,
105
+ alphaOffset: 3,
106
+ },
107
+ };
108
+ //# sourceMappingURL=draw_text.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"draw_text.js","sourceRoot":"","sources":["../../../src/extra/draw/draw_text.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,cAAc,EAAE,MAAM,sCAAsC,CAAC;AAwCtE;;;;;;GAMG;AACH,MAAM,UAAU,QAAQ,CACtB,KAAY,EACZ,IAAqC,EACrC,OAAyB;IAEzB,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC7C,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAC;IAChE,CAAC;IAED,MAAM,QAAQ,GAAG,cAAc,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IACjE,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ACd,WAAW,EAAE,CAAC;KACf;CACF,CAAC"}
@@ -0,0 +1,3 @@
1
+ export * from './draw_text.ts';
2
+ export * from '../../draw/index.ts';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/extra/draw/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,qBAAqB,CAAC"}
@@ -0,0 +1,3 @@
1
+ export * from "./draw_text.js";
2
+ export * from "../../draw/index.js";
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/extra/draw/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,qBAAqB,CAAC"}
@@ -1,5 +1,5 @@
1
- import type { Image } from '../Image.js';
2
- import type { SsimOptions } from './compute_ssim.js';
1
+ import type { Image } from '../../Image.ts';
2
+ import type { SsimOptions } from './compute_ssim.ts';
3
3
  /**
4
4
  * Compute the Structural Dissimilarity (DSSIM) of two GREY images.
5
5
  * @see {@link https://en.wikipedia.org/wiki/Structural_similarity}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compute_dssim.d.ts","sourceRoot":"","sources":["../../../src/extra/ssim/compute_dssim.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAE5C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGrD;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAC1B,KAAK,EAAE,KAAK,EACZ,UAAU,EAAE,KAAK,EACjB,OAAO,GAAE,WAAgB,GACxB,MAAM,CAGR"}
@@ -1,4 +1,4 @@
1
- import { computeSsim } from './compute_ssim.js';
1
+ import { computeSsim } from "./compute_ssim.js";
2
2
  /**
3
3
  * Compute the Structural Dissimilarity (DSSIM) of two GREY images.
4
4
  * @see {@link https://en.wikipedia.org/wiki/Structural_similarity}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compute_dssim.js","sourceRoot":"","sources":["../../../src/extra/ssim/compute_dssim.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD;;;;;;;GAOG;AACH,MAAM,UAAU,YAAY,CAC1B,KAAY,EACZ,UAAiB,EACjB,UAAuB,EAAE;IAEzB,MAAM,IAAI,GAAG,WAAW,CAAC,KAAK,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC,KAAK,CAAC;IAC3D,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC;AACxB,CAAC"}
@@ -1,4 +1,4 @@
1
- import type { Image } from '../Image.js';
1
+ import type { Image } from '../../Image.ts';
2
2
  export interface SsimOptions {
3
3
  /**
4
4
  * Window size for SSIM map.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compute_ssim.d.ts","sourceRoot":"","sources":["../../../src/extra/ssim/compute_ssim.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAI5C,MAAM,WAAW,WAAW;IAC1B;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,GAAG,UAAU,GAAG,WAAW,GAAG,OAAO,CAAC;CACzD;AAED,MAAM,WAAW,IAAI;IACnB;;;OAGG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,OAAO,EAAE;QAAE,IAAI,EAAE,MAAM,EAAE,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;CAC5D;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,WAAW,CACzB,KAAK,EAAE,KAAK,EACZ,UAAU,EAAE,KAAK,EACjB,OAAO,GAAE,WAAgB,GACxB,IAAI,CA8CN"}
@@ -1,6 +1,6 @@
1
1
  import { ssim as bufferSsim } from 'ssim.js';
2
- import checkProcessable from '../utils/validators/checkProcessable.js';
3
- import { validateForComparison } from '../utils/validators/validators.js';
2
+ import checkProcessable from "../../utils/validators/checkProcessable.js";
3
+ import { validateForComparison } from "../../utils/validators/validators.js";
4
4
  /**
5
5
  * Compute the Structural Similarity (SSIM) of two RGBA or two GREY images.
6
6
  * "The resultant SSIM index is a decimal value between -1 and 1,
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compute_ssim.js","sourceRoot":"","sources":["../../../src/extra/ssim/compute_ssim.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,IAAI,UAAU,EAAE,MAAM,SAAS,CAAC;AAG7C,OAAO,gBAAgB,MAAM,4CAA4C,CAAC;AAC1E,OAAO,EAAE,qBAAqB,EAAE,MAAM,sCAAsC,CAAC;AA4B7E;;;;;;;;;;GAUG;AACH,MAAM,UAAU,WAAW,CACzB,KAAY,EACZ,UAAiB,EACjB,UAAuB,EAAE;IAEzB,IAAI,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC;IAC7B,MAAM,EAAE,SAAS,GAAG,UAAU,EAAE,GAAG,OAAO,CAAC;IAE3C,IAAI,UAAU,EAAE,CAAC;QACf,IAAI,UAAU,GAAG,KAAK,CAAC,KAAK,IAAI,UAAU,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC;YAC1D,MAAM,IAAI,UAAU,CAAC,2CAA2C,CAAC,CAAC;QACpE,CAAC;IACH,CAAC;SAAM,CAAC;QACN,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC;IACvD,CAAC;IACD,gBAAgB,CAAC,KAAK,EAAE;QACtB,QAAQ,EAAE,CAAC,CAAC,CAAC;QACb,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;KACpB,CAAC,CAAC;IAEH,qBAAqB,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC;IAEzC,IAAI,KAAK,CAAC,UAAU,KAAK,MAAM,EAAE,CAAC;QAChC,KAAK,GAAG,KAAK,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;QACnC,UAAU,GAAG,UAAU,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;IAC/C,CAAC;IAED,MAAM,SAAS,GAAG,IAAI,iBAAiB,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC,IAAI,CAAC,CAAC;IAClE,MAAM,WAAW,GAAG;QAClB,MAAM,EAAE,KAAK,CAAC,MAAM;QACpB,KAAK,EAAE,KAAK,CAAC,KAAK;QAClB,IAAI,EAAE,SAAS;KAChB,CAAC;IAEF,MAAM,SAAS,GAAG,IAAI,iBAAiB,CAAC,UAAU,CAAC,WAAW,EAAE,CAAC,IAAI,CAAC,CAAC;IACvE,MAAM,WAAW,GAAG;QAClB,MAAM,EAAE,UAAU,CAAC,MAAM;QACzB,KAAK,EAAE,UAAU,CAAC,KAAK;QACvB,IAAI,EAAE,SAAS;KAChB,CAAC;IAEF,MAAM,IAAI,GAAG,UAAU,CAAC,WAAW,EAAE,WAAW,EAAE;QAChD,UAAU;QACV,IAAI,EAAE,SAAS;KAChB,CAAC,CAAC;IAEH,OAAO;QACL,KAAK,EAAE,IAAI,CAAC,KAAK;QACjB,OAAO,EAAE,IAAI,CAAC,QAAQ;KACvB,CAAC;AACJ,CAAC"}
@@ -0,0 +1,3 @@
1
+ export * from './compute_dssim.ts';
2
+ export * from './compute_ssim.ts';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/extra/ssim/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC"}
@@ -0,0 +1,3 @@
1
+ export * from "./compute_dssim.js";
2
+ export * from "./compute_ssim.js";
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/extra/ssim/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"filterEuclideanDistance.d.ts","sourceRoot":"","sources":["../../../src/featureMatching/matching/filterEuclideanDistance.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAErE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAElD,MAAM,WAAW,qCAAqC;IACpD;;;OAGG;IACH,MAAM,CAAC,EAAE,KAAK,CAAC;CAChB;AAED;;;;;;;;GAQG;AACH,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,KAAK,EAAE,EAChB,eAAe,EAAE,YAAY,EAAE,EAC/B,oBAAoB,EAAE,YAAY,EAAE,EACpC,OAAO,GAAE,qCAA0C,GAClD,KAAK,EAAE,CA2CT"}
1
+ {"version":3,"file":"filterEuclideanDistance.d.ts","sourceRoot":"","sources":["../../../src/featureMatching/matching/filterEuclideanDistance.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAErE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAElD,MAAM,WAAW,qCAAqC;IACpD;;;OAGG;IACH,MAAM,CAAC,EAAE,KAAK,CAAC;CAChB;AAED;;;;;;;;GAQG;AACH,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,KAAK,EAAE,EAChB,eAAe,EAAE,YAAY,EAAE,EAC/B,oBAAoB,EAAE,YAAY,EAAE,EACpC,OAAO,GAAE,qCAA0C,GAClD,KAAK,EAAE,CAoCT"}
@@ -9,7 +9,8 @@
9
9
  */
10
10
  export function filterEuclideanDistance(matches, sourceKeypoints, destinationKeypoints, options = {}) {
11
11
  const { origin = { column: 0, row: 0 } } = options;
12
- const sorted = matches.sort((a, b) => a.destinationIndex - b.destinationIndex);
12
+ const sorted = matches.slice();
13
+ sorted.sort((a, b) => a.destinationIndex - b.destinationIndex);
13
14
  const result = [];
14
15
  let sameDestMatches = [];
15
16
  let currentIndex = sorted[0].destinationIndex;
@@ -18,16 +19,14 @@ export function filterEuclideanDistance(matches, sourceKeypoints, destinationKey
18
19
  sameDestMatches.push(match);
19
20
  }
20
21
  else {
21
- result.push(...sameDestMatches
22
- .sort((a, b) => distanceSquared(a) - distanceSquared(b))
23
- .slice(0, 1));
22
+ sameDestMatches.sort((a, b) => distanceSquared(a) - distanceSquared(b));
23
+ result.push(...sameDestMatches.slice(0, 1));
24
24
  currentIndex = match.destinationIndex;
25
25
  sameDestMatches = [match];
26
26
  }
27
27
  }
28
- result.push(...sameDestMatches
29
- .sort((a, b) => distanceSquared(a) - distanceSquared(b))
30
- .slice(0, 1));
28
+ sameDestMatches.sort((a, b) => distanceSquared(a) - distanceSquared(b));
29
+ result.push(...sameDestMatches.slice(0, 1));
31
30
  return result;
32
31
  function distanceSquared(match) {
33
32
  return ((sourceKeypoints[match.sourceIndex].origin.row -
@@ -1 +1 @@
1
- {"version":3,"file":"filterEuclideanDistance.js","sourceRoot":"","sources":["../../../src/featureMatching/matching/filterEuclideanDistance.ts"],"names":[],"mappings":"AAaA;;;;;;;;GAQG;AACH,MAAM,UAAU,uBAAuB,CACrC,OAAgB,EAChB,eAA+B,EAC/B,oBAAoC,EACpC,UAAiD,EAAE;IAEnD,MAAM,EAAE,MAAM,GAAG,EAAE,MAAM,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,EAAE,GAAG,OAAO,CAAC;IAEnD,MAAM,MAAM,GAAG,OAAO,CAAC,IAAI,CACzB,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,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C,CAAC;YAE5C,YAAY,GAAG,KAAK,CAAC,gBAAgB,CAAC;YACtC,eAAe,GAAG,CAAC,KAAK,CAAC,CAAC;QAC5B,CAAC;IACH,CAAC;IACD,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,eAAe,CAAC,CAAC,CAAC,GAAG,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC;IACxE,MAAM,CAAC,IAAI,CAAC,GAAG,eAAe,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IAC5C,OAAO,MAAM,CAAC;IAEd,SAAS,eAAe,CAAC,KAAY;QACnC,OAAO,CACL,CAAC,eAAe,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,MAAM,CAAC,GAAG;YAC5C,CAAC,oBAAoB,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC,MAAM,CAAC,GAAG;gBACtD,MAAM,CAAC,GAAG,CAAC,CAAC;YACd,CAAC;YACH,CAAC,eAAe,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,MAAM,CAAC,MAAM;gBAC/C,oBAAoB,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC,MAAM,CAAC,MAAM;gBAC1D,MAAM,CAAC,MAAM,CAAC;gBACd,CAAC,CACJ,CAAC;IACJ,CAAC;AACH,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"filterSmallestDistanceMatches.d.ts","sourceRoot":"","sources":["../../../src/featureMatching/matching/filterSmallestDistanceMatches.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAElD;;;;;GAKG;AACH,wBAAgB,6BAA6B,CAAC,OAAO,EAAE,KAAK,EAAE,GAAG,KAAK,EAAE,CAwBvE"}
1
+ {"version":3,"file":"filterSmallestDistanceMatches.d.ts","sourceRoot":"","sources":["../../../src/featureMatching/matching/filterSmallestDistanceMatches.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAElD;;;;;GAKG;AACH,wBAAgB,6BAA6B,CAAC,OAAO,EAAE,KAAK,EAAE,GAAG,KAAK,EAAE,CAqBvE"}
@@ -5,7 +5,8 @@
5
5
  * @returns Only the matches from source to destination with the smallest distance.
6
6
  */
7
7
  export function filterSmallestDistanceMatches(matches) {
8
- const sorted = matches.sort((a, b) => a.destinationIndex - b.destinationIndex);
8
+ const sorted = matches.slice();
9
+ sorted.sort((a, b) => a.destinationIndex - b.destinationIndex);
9
10
  const result = [];
10
11
  let sameDestMatches = [];
11
12
  let currentIndex = sorted[0].destinationIndex;
@@ -14,12 +15,14 @@ export function filterSmallestDistanceMatches(matches) {
14
15
  sameDestMatches.push(match);
15
16
  }
16
17
  else {
17
- result.push(...sameDestMatches.sort((a, b) => a.distance - b.distance).slice(0, 1));
18
+ sameDestMatches.sort((a, b) => a.distance - b.distance);
19
+ result.push(...sameDestMatches.slice(0, 1));
18
20
  currentIndex = match.destinationIndex;
19
21
  sameDestMatches = [match];
20
22
  }
21
23
  }
22
- result.push(...sameDestMatches.sort((a, b) => a.distance - b.distance).slice(0, 1));
24
+ sameDestMatches.sort((a, b) => a.distance - b.distance);
25
+ result.push(...sameDestMatches.slice(0, 1));
23
26
  return result;
24
27
  }
25
28
  //# sourceMappingURL=filterSmallestDistanceMatches.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"filterSmallestDistanceMatches.js","sourceRoot":"","sources":["../../../src/featureMatching/matching/filterSmallestDistanceMatches.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,MAAM,UAAU,6BAA6B,CAAC,OAAgB;IAC5D,MAAM,MAAM,GAAG,OAAO,CAAC,IAAI,CACzB,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,gBAAgB,GAAG,CAAC,CAAC,gBAAgB,CAClD,CAAC;IAEF,MAAM,MAAM,GAAY,EAAE,CAAC;IAC3B,IAAI,eAAe,GAAY,EAAE,CAAC;IAClC,IAAI,YAAY,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,gBAAgB,CAAC;IAC9C,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,IAAI,KAAK,CAAC,gBAAgB,KAAK,YAAY,EAAE,CAAC;YAC5C,eAAe,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC9B,CAAC;aAAM,CAAC;YACN,MAAM,CAAC,IAAI,CACT,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,GAAG,CAAC,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CACvE,CAAC;YAEF,YAAY,GAAG,KAAK,CAAC,gBAAgB,CAAC;YACtC,eAAe,GAAG,CAAC,KAAK,CAAC,CAAC;QAC5B,CAAC;IACH,CAAC;IACD,MAAM,CAAC,IAAI,CACT,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,GAAG,CAAC,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CACvE,CAAC;IACF,OAAO,MAAM,CAAC;AAChB,CAAC"}
1
+ {"version":3,"file":"filterSmallestDistanceMatches.js","sourceRoot":"","sources":["../../../src/featureMatching/matching/filterSmallestDistanceMatches.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,MAAM,UAAU,6BAA6B,CAAC,OAAgB;IAC5D,MAAM,MAAM,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC;IAC/B,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,gBAAgB,GAAG,CAAC,CAAC,gBAAgB,CAAC,CAAC;IAE/D,MAAM,MAAM,GAAY,EAAE,CAAC;IAC3B,IAAI,eAAe,GAAY,EAAE,CAAC;IAClC,IAAI,YAAY,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,gBAAgB,CAAC;IAC9C,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,IAAI,KAAK,CAAC,gBAAgB,KAAK,YAAY,EAAE,CAAC;YAC5C,eAAe,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC9B,CAAC;aAAM,CAAC;YACN,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,GAAG,CAAC,CAAC,QAAQ,CAAC,CAAC;YACxD,MAAM,CAAC,IAAI,CAAC,GAAG,eAAe,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;YAE5C,YAAY,GAAG,KAAK,CAAC,gBAAgB,CAAC;YACtC,eAAe,GAAG,CAAC,KAAK,CAAC,CAAC;QAC5B,CAAC;IACH,CAAC;IACD,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,GAAG,CAAC,CAAC,QAAQ,CAAC,CAAC;IACxD,MAAM,CAAC,IAAI,CAAC,GAAG,eAAe,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IAC5C,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"sortByDistance.d.ts","sourceRoot":"","sources":["../../../src/featureMatching/utils/sortByDistance.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gCAAgC,CAAC;AAE5D;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,KAAK,EAAE,GAAG,KAAK,EAAE,CAIxD"}
1
+ {"version":3,"file":"sortByDistance.d.ts","sourceRoot":"","sources":["../../../src/featureMatching/utils/sortByDistance.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gCAAgC,CAAC;AAE5D;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,KAAK,EAAE,GAAG,KAAK,EAAE,CAMxD"}
@@ -4,8 +4,10 @@
4
4
  * @returns Sorted copy of the array of matches.
5
5
  */
6
6
  export function sortByDistance(matches) {
7
- return matches.slice().sort((match1, match2) => {
7
+ const sorted = matches.slice();
8
+ sorted.sort((match1, match2) => {
8
9
  return match1.distance - match2.distance;
9
10
  });
11
+ return sorted;
10
12
  }
11
13
  //# sourceMappingURL=sortByDistance.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"sortByDistance.js","sourceRoot":"","sources":["../../../src/featureMatching/utils/sortByDistance.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAAC,OAAgB;IAC7C,OAAO,OAAO,CAAC,KAAK,EAAE,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE;QAC7C,OAAO,MAAM,CAAC,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC;IAC3C,CAAC,CAAC,CAAC;AACL,CAAC"}
1
+ {"version":3,"file":"sortByDistance.js","sourceRoot":"","sources":["../../../src/featureMatching/utils/sortByDistance.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAAC,OAAgB;IAC7C,MAAM,MAAM,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC;IAC/B,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE;QAC7B,OAAO,MAAM,CAAC,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC;IAC3C,CAAC,CAAC,CAAC;IACH,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"sortBySourceDest.d.ts","sourceRoot":"","sources":["../../../src/featureMatching/utils/sortBySourceDest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gCAAgC,CAAC;AAE5D;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,KAAK,EAAE,GAAG,KAAK,EAAE,CAM1D;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,KAAK,EAAE,GAAG,KAAK,EAAE,CAM1D"}
1
+ {"version":3,"file":"sortBySourceDest.d.ts","sourceRoot":"","sources":["../../../src/featureMatching/utils/sortBySourceDest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gCAAgC,CAAC;AAE5D;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,KAAK,EAAE,GAAG,KAAK,EAAE,CAQ1D;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,KAAK,EAAE,GAAG,KAAK,EAAE,CAQ1D"}
@@ -4,13 +4,15 @@
4
4
  * @returns Sorted copy of the array of matches.
5
5
  */
6
6
  export function sortBySourceDest(matches) {
7
- return matches.slice().sort((match1, match2) => {
7
+ const sorted = matches.slice();
8
+ sorted.sort((match1, match2) => {
8
9
  if (match1.sourceIndex < match2.sourceIndex)
9
10
  return -1;
10
11
  if (match1.sourceIndex > match2.sourceIndex)
11
12
  return 1;
12
13
  return match1.destinationIndex - match2.destinationIndex;
13
14
  });
15
+ return sorted;
14
16
  }
15
17
  /**
16
18
  * Sort array of matches by destination index and then source index.
@@ -18,12 +20,14 @@ export function sortBySourceDest(matches) {
18
20
  * @returns Sorted copy of the array of matches.
19
21
  */
20
22
  export function sortByDestSource(matches) {
21
- return matches.slice().sort((match1, match2) => {
23
+ const sorted = matches.slice();
24
+ sorted.sort((match1, match2) => {
22
25
  if (match1.destinationIndex < match2.destinationIndex)
23
26
  return -1;
24
27
  if (match1.destinationIndex > match2.destinationIndex)
25
28
  return 1;
26
29
  return match1.sourceIndex - match2.sourceIndex;
27
30
  });
31
+ return sorted;
28
32
  }
29
33
  //# sourceMappingURL=sortBySourceDest.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"sortBySourceDest.js","sourceRoot":"","sources":["../../../src/featureMatching/utils/sortBySourceDest.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAAC,OAAgB;IAC/C,OAAO,OAAO,CAAC,KAAK,EAAE,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE;QAC7C,IAAI,MAAM,CAAC,WAAW,GAAG,MAAM,CAAC,WAAW;YAAE,OAAO,CAAC,CAAC,CAAC;QACvD,IAAI,MAAM,CAAC,WAAW,GAAG,MAAM,CAAC,WAAW;YAAE,OAAO,CAAC,CAAC;QACtD,OAAO,MAAM,CAAC,gBAAgB,GAAG,MAAM,CAAC,gBAAgB,CAAC;IAC3D,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAAC,OAAgB;IAC/C,OAAO,OAAO,CAAC,KAAK,EAAE,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE;QAC7C,IAAI,MAAM,CAAC,gBAAgB,GAAG,MAAM,CAAC,gBAAgB;YAAE,OAAO,CAAC,CAAC,CAAC;QACjE,IAAI,MAAM,CAAC,gBAAgB,GAAG,MAAM,CAAC,gBAAgB;YAAE,OAAO,CAAC,CAAC;QAChE,OAAO,MAAM,CAAC,WAAW,GAAG,MAAM,CAAC,WAAW,CAAC;IACjD,CAAC,CAAC,CAAC;AACL,CAAC"}
1
+ {"version":3,"file":"sortBySourceDest.js","sourceRoot":"","sources":["../../../src/featureMatching/utils/sortBySourceDest.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAAC,OAAgB;IAC/C,MAAM,MAAM,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC;IAC/B,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE;QAC7B,IAAI,MAAM,CAAC,WAAW,GAAG,MAAM,CAAC,WAAW;YAAE,OAAO,CAAC,CAAC,CAAC;QACvD,IAAI,MAAM,CAAC,WAAW,GAAG,MAAM,CAAC,WAAW;YAAE,OAAO,CAAC,CAAC;QACtD,OAAO,MAAM,CAAC,gBAAgB,GAAG,MAAM,CAAC,gBAAgB,CAAC;IAC3D,CAAC,CAAC,CAAC;IACH,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAAC,OAAgB;IAC/C,MAAM,MAAM,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC;IAC/B,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE;QAC7B,IAAI,MAAM,CAAC,gBAAgB,GAAG,MAAM,CAAC,gBAAgB;YAAE,OAAO,CAAC,CAAC,CAAC;QACjE,IAAI,MAAM,CAAC,gBAAgB,GAAG,MAAM,CAAC,gBAAgB;YAAE,OAAO,CAAC,CAAC;QAChE,OAAO,MAAM,CAAC,WAAW,GAAG,MAAM,CAAC,WAAW,CAAC;IACjD,CAAC,CAAC,CAAC;IACH,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,3 @@
1
+ export * from './index.ts';
2
+ export * from './extra/draw/index.ts';
3
+ //# sourceMappingURL=index_browser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index_browser.d.ts","sourceRoot":"","sources":["../src/index_browser.ts"],"names":[],"mappings":"AAEA,cAAc,YAAY,CAAC;AAC3B,cAAc,uBAAuB,CAAC"}
@@ -0,0 +1,5 @@
1
+ // API for the browser build.
2
+ // TODO: figure out how to bundle the SSIM library. Then we can just use `index_full.ts` instead.
3
+ export * from "./index.js";
4
+ export * from "./extra/draw/index.js";
5
+ //# sourceMappingURL=index_browser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index_browser.js","sourceRoot":"","sources":["../src/index_browser.ts"],"names":[],"mappings":"AAAA,6BAA6B;AAC7B,iGAAiG;AACjG,cAAc,YAAY,CAAC;AAC3B,cAAc,uBAAuB,CAAC"}
@@ -0,0 +1,4 @@
1
+ export * from './index.ts';
2
+ export * from './extra/draw/index.ts';
3
+ export * from './extra/ssim/index.ts';
4
+ //# sourceMappingURL=index_full.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index_full.d.ts","sourceRoot":"","sources":["../src/index_full.ts"],"names":[],"mappings":"AACA,cAAc,YAAY,CAAC;AAC3B,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC"}
@@ -0,0 +1,5 @@
1
+ // Full API.
2
+ export * from "./index.js";
3
+ export * from "./extra/draw/index.js";
4
+ export * from "./extra/ssim/index.js";
5
+ //# sourceMappingURL=index_full.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index_full.js","sourceRoot":"","sources":["../src/index_full.ts"],"names":[],"mappings":"AAAA,YAAY;AACZ,cAAc,YAAY,CAAC;AAC3B,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"decode.d.ts","sourceRoot":"","sources":["../../src/load/decode.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAMzC;;;;;GAKG;AACH,wBAAgB,MAAM,CAAC,IAAI,EAAE,eAAe,GAAG,KAAK,CAcnD"}
1
+ {"version":3,"file":"decode.d.ts","sourceRoot":"","sources":["../../src/load/decode.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAMzC;;;;;GAKG;AACH,wBAAgB,MAAM,CAAC,IAAI,EAAE,eAAe,GAAG,KAAK,CAenD"}
@@ -1,5 +1,6 @@
1
1
  import imageType from 'image-type';
2
2
  import { match } from 'ts-pattern';
3
+ import { decodeBmp } from "./decodeBmp.js";
3
4
  import { decodeJpeg } from './decodeJpeg.js';
4
5
  import { decodePng } from './decodePng.js';
5
6
  import { decodeTiff } from './decodeTiff.js';
@@ -16,6 +17,7 @@ export function decode(data) {
16
17
  .with({ mime: 'image/png' }, () => decodePng(typedArray))
17
18
  .with({ mime: 'image/jpeg' }, () => decodeJpeg(typedArray))
18
19
  .with({ mime: 'image/tiff' }, () => decodeTiff(typedArray))
20
+ .with({ mime: 'image/bmp' }, () => decodeBmp(typedArray))
19
21
  .otherwise(() => {
20
22
  throw new RangeError(`invalid data format: ${type?.mime}`);
21
23
  });
@@ -1 +1 @@
1
- {"version":3,"file":"decode.js","sourceRoot":"","sources":["../../src/load/decode.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAInC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C;;;;;GAKG;AACH,MAAM,UAAU,MAAM,CAAC,IAAqB;IAC1C,MAAM,UAAU,GAAG,IAAI,UAAU,CAC/B,IAAI,CAAC,MAAM,EACX,IAAI,CAAC,UAAU,EACf,IAAI,CAAC,UAAU,CAChB,CAAC;IACF,MAAM,IAAI,GAAG,SAAS,CAAC,UAAU,CAAC,CAAC;IACnC,OAAO,KAAK,CAAC,IAAI,CAAC;SACf,IAAI,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,EAAE,GAAG,EAAE,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;SACxD,IAAI,CAAC,EAAE,IAAI,EAAE,YAAY,EAAE,EAAE,GAAG,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;SAC1D,IAAI,CAAC,EAAE,IAAI,EAAE,YAAY,EAAE,EAAE,GAAG,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;SAC1D,SAAS,CAAC,GAAG,EAAE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AE,CAAC,CAAC;IAC7D,CAAC,CAAC,CAAC;AACP,CAAC"}
@@ -0,0 +1,8 @@
1
+ import { Image } from '../Image.ts';
2
+ /**
3
+ * Decode a BMP. See the fast-bmp npm module.
4
+ * @param data - The data to decode.
5
+ * @returns The decoded image or mask.
6
+ */
7
+ export declare function decodeBmp(data: Uint8Array): Image;
8
+ //# sourceMappingURL=decodeBmp.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decodeBmp.d.ts","sourceRoot":"","sources":["../../src/load/decodeBmp.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAIpC;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,UAAU,GAAG,KAAK,CAyBjD"}
@@ -0,0 +1,36 @@
1
+ import { decode } from 'fast-bmp';
2
+ import { Image } from "../Image.js";
3
+ import { Mask } from "../Mask.js";
4
+ /**
5
+ * Decode a BMP. See the fast-bmp npm module.
6
+ * @param data - The data to decode.
7
+ * @returns The decoded image or mask.
8
+ */
9
+ export function decodeBmp(data) {
10
+ const decodedData = decode(data);
11
+ if (decodedData.bitsPerPixel === 1) {
12
+ const mask = new Mask(decodedData.width, decodedData.height, {
13
+ data: decodedData.data,
14
+ });
15
+ return mask.convertColor('GREY');
16
+ }
17
+ else {
18
+ let colorModel;
19
+ switch (decodedData.channels) {
20
+ case 1:
21
+ colorModel = 'GREY';
22
+ break;
23
+ case 3:
24
+ colorModel = 'RGB';
25
+ break;
26
+ default:
27
+ colorModel = 'RGBA';
28
+ break;
29
+ }
30
+ return new Image(decodedData.width, decodedData.height, {
31
+ colorModel,
32
+ data: decodedData.data,
33
+ });
34
+ }
35
+ }
36
+ //# sourceMappingURL=decodeBmp.js.map