@rosepetal/node-red-contrib-image-tools 1.6.2 → 1.6.4
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/node-red-contrib-image-tools/nodes/blend/add-bbs.html +11 -4
- package/node-red-contrib-image-tools/nodes/blend/add-mask.html +11 -4
- package/node-red-contrib-image-tools/nodes/blend/add-masks.html +11 -4
- package/node-red-contrib-image-tools/nodes/blend/blend.html +11 -4
- package/node-red-contrib-image-tools/nodes/io/image-out.html +11 -4
- package/node-red-contrib-image-tools/nodes/mix/advanced-mosaic.html +11 -4
- package/node-red-contrib-image-tools/nodes/mix/concat.html +11 -4
- package/node-red-contrib-image-tools/nodes/mix/mosaic.html +11 -4
- package/node-red-contrib-image-tools/nodes/specialized/heat-diff.html +50 -15
- package/node-red-contrib-image-tools/nodes/specialized/heat-diff.js +19 -8
- package/node-red-contrib-image-tools/nodes/specialized/image-align.html +3 -2
- package/node-red-contrib-image-tools/nodes/transform/crop.html +11 -4
- package/node-red-contrib-image-tools/nodes/transform/filter.html +11 -4
- package/node-red-contrib-image-tools/nodes/transform/padding.html +11 -4
- package/node-red-contrib-image-tools/nodes/transform/resize.html +3 -3
- package/node-red-contrib-image-tools/nodes/transform/rotate.html +11 -4
- package/npm/darwin-arm64/package.json +1 -1
- package/npm/darwin-x64/package.json +1 -1
- package/npm/linux-arm64/package.json +1 -1
- package/npm/linux-x64/package.json +1 -1
- package/npm/linuxmusl-x64/package.json +1 -1
- package/npm/win32-x64/package.json +1 -1
- package/package.json +6 -6
- package/rosepetal-image-engine/src/heat-diff.cpp +31 -14
|
@@ -326,6 +326,10 @@
|
|
|
326
326
|
const nodeElement = document.getElementById(nodeId);
|
|
327
327
|
if (!nodeElement) return;
|
|
328
328
|
|
|
329
|
+
// Size to the server-resized debug image (no display cap)
|
|
330
|
+
var debugWidth = data.debugWidth || 200;
|
|
331
|
+
var debugHeight = data.debugHeight || 200;
|
|
332
|
+
|
|
329
333
|
let debugContainer = document.getElementById('debug-img-container-' + nodeId);
|
|
330
334
|
|
|
331
335
|
if (!debugContainer) {
|
|
@@ -334,8 +338,8 @@
|
|
|
334
338
|
debugContainer.id = 'debug-img-container-' + nodeId;
|
|
335
339
|
debugContainer.setAttribute('x', '70');
|
|
336
340
|
debugContainer.setAttribute('y', '5');
|
|
337
|
-
debugContainer.setAttribute('width',
|
|
338
|
-
debugContainer.setAttribute('height',
|
|
341
|
+
debugContainer.setAttribute('width', debugWidth.toString());
|
|
342
|
+
debugContainer.setAttribute('height', debugHeight.toString());
|
|
339
343
|
debugContainer.style.overflow = 'visible';
|
|
340
344
|
|
|
341
345
|
// Create simple image directly inside foreignObject
|
|
@@ -345,8 +349,8 @@
|
|
|
345
349
|
img.style.height = 'auto';
|
|
346
350
|
img.style.display = 'block';
|
|
347
351
|
img.style.cursor = 'pointer';
|
|
348
|
-
img.style.maxHeight = '
|
|
349
|
-
img.style.maxWidth = '
|
|
352
|
+
img.style.maxHeight = 'none';
|
|
353
|
+
img.style.maxWidth = 'none';
|
|
350
354
|
|
|
351
355
|
img.onclick = function() {
|
|
352
356
|
removeDebugImage(nodeId);
|
|
@@ -354,6 +358,9 @@
|
|
|
354
358
|
|
|
355
359
|
debugContainer.appendChild(img);
|
|
356
360
|
nodeElement.appendChild(debugContainer);
|
|
361
|
+
} else {
|
|
362
|
+
debugContainer.setAttribute('width', debugWidth.toString());
|
|
363
|
+
debugContainer.setAttribute('height', debugHeight.toString());
|
|
357
364
|
}
|
|
358
365
|
|
|
359
366
|
const img = document.getElementById('debug-img-' + nodeId);
|
|
@@ -145,6 +145,10 @@
|
|
|
145
145
|
|
|
146
146
|
const nodeElement = document.getElementById(nodeId);
|
|
147
147
|
if (!nodeElement) return;
|
|
148
|
+
|
|
149
|
+
// Size to the server-resized debug image (no display cap)
|
|
150
|
+
var debugWidth = data.debugWidth || 200;
|
|
151
|
+
var debugHeight = data.debugHeight || 200;
|
|
148
152
|
|
|
149
153
|
let debugContainer = document.getElementById('debug-img-container-' + nodeId);
|
|
150
154
|
|
|
@@ -154,8 +158,8 @@
|
|
|
154
158
|
debugContainer.id = 'debug-img-container-' + nodeId;
|
|
155
159
|
debugContainer.setAttribute('x', '70');
|
|
156
160
|
debugContainer.setAttribute('y', '5');
|
|
157
|
-
debugContainer.setAttribute('width',
|
|
158
|
-
debugContainer.setAttribute('height',
|
|
161
|
+
debugContainer.setAttribute('width', debugWidth.toString());
|
|
162
|
+
debugContainer.setAttribute('height', debugHeight.toString());
|
|
159
163
|
debugContainer.style.overflow = 'visible';
|
|
160
164
|
|
|
161
165
|
// Create simple image directly inside foreignObject
|
|
@@ -165,8 +169,8 @@
|
|
|
165
169
|
img.style.height = 'auto';
|
|
166
170
|
img.style.display = 'block';
|
|
167
171
|
img.style.cursor = 'pointer';
|
|
168
|
-
img.style.maxHeight = '
|
|
169
|
-
img.style.maxWidth = '
|
|
172
|
+
img.style.maxHeight = 'none';
|
|
173
|
+
img.style.maxWidth = 'none';
|
|
170
174
|
|
|
171
175
|
img.onclick = function() {
|
|
172
176
|
removeDebugImage(nodeId);
|
|
@@ -174,6 +178,9 @@
|
|
|
174
178
|
|
|
175
179
|
debugContainer.appendChild(img);
|
|
176
180
|
nodeElement.appendChild(debugContainer);
|
|
181
|
+
} else {
|
|
182
|
+
debugContainer.setAttribute('width', debugWidth.toString());
|
|
183
|
+
debugContainer.setAttribute('height', debugHeight.toString());
|
|
177
184
|
}
|
|
178
185
|
|
|
179
186
|
const img = document.getElementById('debug-img-' + nodeId);
|
|
@@ -475,6 +475,10 @@
|
|
|
475
475
|
const nodeElement = document.getElementById(nodeId);
|
|
476
476
|
if (!nodeElement) return;
|
|
477
477
|
|
|
478
|
+
// Size to the server-resized debug image (no display cap)
|
|
479
|
+
var debugWidth = data.debugWidth || 200;
|
|
480
|
+
var debugHeight = data.debugHeight || 200;
|
|
481
|
+
|
|
478
482
|
let debugContainer = document.getElementById('debug-img-container-' + nodeId);
|
|
479
483
|
|
|
480
484
|
if (!debugContainer) {
|
|
@@ -483,8 +487,8 @@
|
|
|
483
487
|
debugContainer.id = 'debug-img-container-' + nodeId;
|
|
484
488
|
debugContainer.setAttribute('x', '70');
|
|
485
489
|
debugContainer.setAttribute('y', '5');
|
|
486
|
-
debugContainer.setAttribute('width',
|
|
487
|
-
debugContainer.setAttribute('height',
|
|
490
|
+
debugContainer.setAttribute('width', debugWidth.toString());
|
|
491
|
+
debugContainer.setAttribute('height', debugHeight.toString());
|
|
488
492
|
debugContainer.style.overflow = 'visible';
|
|
489
493
|
|
|
490
494
|
// Create simple image directly inside foreignObject
|
|
@@ -494,8 +498,8 @@
|
|
|
494
498
|
img.style.height = 'auto';
|
|
495
499
|
img.style.display = 'block';
|
|
496
500
|
img.style.cursor = 'pointer';
|
|
497
|
-
img.style.maxHeight = '
|
|
498
|
-
img.style.maxWidth = '
|
|
501
|
+
img.style.maxHeight = 'none';
|
|
502
|
+
img.style.maxWidth = 'none';
|
|
499
503
|
|
|
500
504
|
img.onclick = function() {
|
|
501
505
|
removeDebugImage(nodeId);
|
|
@@ -503,6 +507,9 @@
|
|
|
503
507
|
|
|
504
508
|
debugContainer.appendChild(img);
|
|
505
509
|
nodeElement.appendChild(debugContainer);
|
|
510
|
+
} else {
|
|
511
|
+
debugContainer.setAttribute('width', debugWidth.toString());
|
|
512
|
+
debugContainer.setAttribute('height', debugHeight.toString());
|
|
506
513
|
}
|
|
507
514
|
|
|
508
515
|
const img = document.getElementById('debug-img-' + nodeId);
|
|
@@ -198,6 +198,10 @@
|
|
|
198
198
|
|
|
199
199
|
const nodeElement = document.getElementById(nodeId);
|
|
200
200
|
if (!nodeElement) return;
|
|
201
|
+
|
|
202
|
+
// Size to the server-resized debug image (no display cap)
|
|
203
|
+
var debugWidth = data.debugWidth || 200;
|
|
204
|
+
var debugHeight = data.debugHeight || 200;
|
|
201
205
|
|
|
202
206
|
let debugContainer = document.getElementById('debug-img-container-' + nodeId);
|
|
203
207
|
|
|
@@ -207,8 +211,8 @@
|
|
|
207
211
|
debugContainer.id = 'debug-img-container-' + nodeId;
|
|
208
212
|
debugContainer.setAttribute('x', '70');
|
|
209
213
|
debugContainer.setAttribute('y', '5');
|
|
210
|
-
debugContainer.setAttribute('width',
|
|
211
|
-
debugContainer.setAttribute('height',
|
|
214
|
+
debugContainer.setAttribute('width', debugWidth.toString());
|
|
215
|
+
debugContainer.setAttribute('height', debugHeight.toString());
|
|
212
216
|
debugContainer.style.overflow = 'visible';
|
|
213
217
|
|
|
214
218
|
// Create simple image directly inside foreignObject
|
|
@@ -218,8 +222,8 @@
|
|
|
218
222
|
img.style.height = 'auto';
|
|
219
223
|
img.style.display = 'block';
|
|
220
224
|
img.style.cursor = 'pointer';
|
|
221
|
-
img.style.maxHeight = '
|
|
222
|
-
img.style.maxWidth = '
|
|
225
|
+
img.style.maxHeight = 'none';
|
|
226
|
+
img.style.maxWidth = 'none';
|
|
223
227
|
|
|
224
228
|
img.onclick = function() {
|
|
225
229
|
removeDebugImage(nodeId);
|
|
@@ -227,6 +231,9 @@
|
|
|
227
231
|
|
|
228
232
|
debugContainer.appendChild(img);
|
|
229
233
|
nodeElement.appendChild(debugContainer);
|
|
234
|
+
} else {
|
|
235
|
+
debugContainer.setAttribute('width', debugWidth.toString());
|
|
236
|
+
debugContainer.setAttribute('height', debugHeight.toString());
|
|
230
237
|
}
|
|
231
238
|
|
|
232
239
|
const img = document.getElementById('debug-img-' + nodeId);
|
|
@@ -288,6 +288,10 @@
|
|
|
288
288
|
var nodeElement = document.getElementById(nodeId);
|
|
289
289
|
if (!nodeElement) return;
|
|
290
290
|
|
|
291
|
+
// Size to the server-resized debug image (no display cap)
|
|
292
|
+
var debugWidth = data.debugWidth || 200;
|
|
293
|
+
var debugHeight = data.debugHeight || 200;
|
|
294
|
+
|
|
291
295
|
var debugContainer = document.getElementById('debug-img-container-' + nodeId);
|
|
292
296
|
|
|
293
297
|
if (!debugContainer) {
|
|
@@ -295,8 +299,8 @@
|
|
|
295
299
|
debugContainer.id = 'debug-img-container-' + nodeId;
|
|
296
300
|
debugContainer.setAttribute('x', '70');
|
|
297
301
|
debugContainer.setAttribute('y', '5');
|
|
298
|
-
debugContainer.setAttribute('width',
|
|
299
|
-
debugContainer.setAttribute('height',
|
|
302
|
+
debugContainer.setAttribute('width', debugWidth.toString());
|
|
303
|
+
debugContainer.setAttribute('height', debugHeight.toString());
|
|
300
304
|
debugContainer.style.overflow = 'visible';
|
|
301
305
|
|
|
302
306
|
var img = document.createElement('img');
|
|
@@ -305,8 +309,8 @@
|
|
|
305
309
|
img.style.height = 'auto';
|
|
306
310
|
img.style.display = 'block';
|
|
307
311
|
img.style.cursor = 'pointer';
|
|
308
|
-
img.style.maxHeight = '
|
|
309
|
-
img.style.maxWidth = '
|
|
312
|
+
img.style.maxHeight = 'none';
|
|
313
|
+
img.style.maxWidth = 'none';
|
|
310
314
|
|
|
311
315
|
img.onclick = function() {
|
|
312
316
|
removeDebugImage(nodeId);
|
|
@@ -314,6 +318,9 @@
|
|
|
314
318
|
|
|
315
319
|
debugContainer.appendChild(img);
|
|
316
320
|
nodeElement.appendChild(debugContainer);
|
|
321
|
+
} else {
|
|
322
|
+
debugContainer.setAttribute('width', debugWidth.toString());
|
|
323
|
+
debugContainer.setAttribute('height', debugHeight.toString());
|
|
317
324
|
}
|
|
318
325
|
|
|
319
326
|
var imgEl = document.getElementById('debug-img-' + nodeId);
|
|
@@ -1745,6 +1745,10 @@
|
|
|
1745
1745
|
|
|
1746
1746
|
const nodeElement = document.getElementById(nodeId);
|
|
1747
1747
|
if (!nodeElement) return;
|
|
1748
|
+
|
|
1749
|
+
// Size to the server-resized debug image (no display cap)
|
|
1750
|
+
var debugWidth = data.debugWidth || 200;
|
|
1751
|
+
var debugHeight = data.debugHeight || 200;
|
|
1748
1752
|
|
|
1749
1753
|
let debugContainer = document.getElementById('debug-img-container-' + nodeId);
|
|
1750
1754
|
|
|
@@ -1754,8 +1758,8 @@
|
|
|
1754
1758
|
debugContainer.id = 'debug-img-container-' + nodeId;
|
|
1755
1759
|
debugContainer.setAttribute('x', '70');
|
|
1756
1760
|
debugContainer.setAttribute('y', '5');
|
|
1757
|
-
debugContainer.setAttribute('width',
|
|
1758
|
-
debugContainer.setAttribute('height',
|
|
1761
|
+
debugContainer.setAttribute('width', debugWidth.toString());
|
|
1762
|
+
debugContainer.setAttribute('height', debugHeight.toString());
|
|
1759
1763
|
debugContainer.style.overflow = 'visible';
|
|
1760
1764
|
|
|
1761
1765
|
// Create simple image directly inside foreignObject
|
|
@@ -1765,8 +1769,8 @@
|
|
|
1765
1769
|
img.style.height = 'auto';
|
|
1766
1770
|
img.style.display = 'block';
|
|
1767
1771
|
img.style.cursor = 'pointer';
|
|
1768
|
-
img.style.maxHeight = '
|
|
1769
|
-
img.style.maxWidth = '
|
|
1772
|
+
img.style.maxHeight = 'none';
|
|
1773
|
+
img.style.maxWidth = 'none';
|
|
1770
1774
|
|
|
1771
1775
|
img.onclick = function() {
|
|
1772
1776
|
removeDebugImage(nodeId);
|
|
@@ -1774,6 +1778,9 @@
|
|
|
1774
1778
|
|
|
1775
1779
|
debugContainer.appendChild(img);
|
|
1776
1780
|
nodeElement.appendChild(debugContainer);
|
|
1781
|
+
} else {
|
|
1782
|
+
debugContainer.setAttribute('width', debugWidth.toString());
|
|
1783
|
+
debugContainer.setAttribute('height', debugHeight.toString());
|
|
1777
1784
|
}
|
|
1778
1785
|
|
|
1779
1786
|
const img = document.getElementById('debug-img-' + nodeId);
|
|
@@ -143,6 +143,10 @@
|
|
|
143
143
|
|
|
144
144
|
const nodeElement = document.getElementById(nodeId);
|
|
145
145
|
if (!nodeElement) return;
|
|
146
|
+
|
|
147
|
+
// Size to the server-resized debug image (no display cap)
|
|
148
|
+
var debugWidth = data.debugWidth || 200;
|
|
149
|
+
var debugHeight = data.debugHeight || 200;
|
|
146
150
|
|
|
147
151
|
let debugContainer = document.getElementById('debug-img-container-' + nodeId);
|
|
148
152
|
|
|
@@ -152,8 +156,8 @@
|
|
|
152
156
|
debugContainer.id = 'debug-img-container-' + nodeId;
|
|
153
157
|
debugContainer.setAttribute('x', '70');
|
|
154
158
|
debugContainer.setAttribute('y', '5');
|
|
155
|
-
debugContainer.setAttribute('width',
|
|
156
|
-
debugContainer.setAttribute('height',
|
|
159
|
+
debugContainer.setAttribute('width', debugWidth.toString());
|
|
160
|
+
debugContainer.setAttribute('height', debugHeight.toString());
|
|
157
161
|
debugContainer.style.overflow = 'visible';
|
|
158
162
|
|
|
159
163
|
// Create simple image directly inside foreignObject
|
|
@@ -163,8 +167,8 @@
|
|
|
163
167
|
img.style.height = 'auto';
|
|
164
168
|
img.style.display = 'block';
|
|
165
169
|
img.style.cursor = 'pointer';
|
|
166
|
-
img.style.maxHeight = '
|
|
167
|
-
img.style.maxWidth = '
|
|
170
|
+
img.style.maxHeight = 'none';
|
|
171
|
+
img.style.maxWidth = 'none';
|
|
168
172
|
|
|
169
173
|
img.onclick = function() {
|
|
170
174
|
removeDebugImage(nodeId);
|
|
@@ -172,6 +176,9 @@
|
|
|
172
176
|
|
|
173
177
|
debugContainer.appendChild(img);
|
|
174
178
|
nodeElement.appendChild(debugContainer);
|
|
179
|
+
} else {
|
|
180
|
+
debugContainer.setAttribute('width', debugWidth.toString());
|
|
181
|
+
debugContainer.setAttribute('height', debugHeight.toString());
|
|
175
182
|
}
|
|
176
183
|
|
|
177
184
|
const img = document.getElementById('debug-img-' + nodeId);
|
|
@@ -237,6 +237,10 @@
|
|
|
237
237
|
|
|
238
238
|
const nodeElement = document.getElementById(nodeId);
|
|
239
239
|
if (!nodeElement) return;
|
|
240
|
+
|
|
241
|
+
// Size to the server-resized debug image (no display cap)
|
|
242
|
+
var debugWidth = data.debugWidth || 200;
|
|
243
|
+
var debugHeight = data.debugHeight || 200;
|
|
240
244
|
|
|
241
245
|
let debugContainer = document.getElementById('debug-img-container-' + nodeId);
|
|
242
246
|
|
|
@@ -246,8 +250,8 @@
|
|
|
246
250
|
debugContainer.id = 'debug-img-container-' + nodeId;
|
|
247
251
|
debugContainer.setAttribute('x', '70');
|
|
248
252
|
debugContainer.setAttribute('y', '5');
|
|
249
|
-
debugContainer.setAttribute('width',
|
|
250
|
-
debugContainer.setAttribute('height',
|
|
253
|
+
debugContainer.setAttribute('width', debugWidth.toString());
|
|
254
|
+
debugContainer.setAttribute('height', debugHeight.toString());
|
|
251
255
|
debugContainer.style.overflow = 'visible';
|
|
252
256
|
|
|
253
257
|
// Create simple image directly inside foreignObject
|
|
@@ -257,8 +261,8 @@
|
|
|
257
261
|
img.style.height = 'auto';
|
|
258
262
|
img.style.display = 'block';
|
|
259
263
|
img.style.cursor = 'pointer';
|
|
260
|
-
img.style.maxHeight = '
|
|
261
|
-
img.style.maxWidth = '
|
|
264
|
+
img.style.maxHeight = 'none';
|
|
265
|
+
img.style.maxWidth = 'none';
|
|
262
266
|
|
|
263
267
|
img.onclick = function() {
|
|
264
268
|
removeDebugImage(nodeId);
|
|
@@ -266,6 +270,9 @@
|
|
|
266
270
|
|
|
267
271
|
debugContainer.appendChild(img);
|
|
268
272
|
nodeElement.appendChild(debugContainer);
|
|
273
|
+
} else {
|
|
274
|
+
debugContainer.setAttribute('width', debugWidth.toString());
|
|
275
|
+
debugContainer.setAttribute('height', debugHeight.toString());
|
|
269
276
|
}
|
|
270
277
|
|
|
271
278
|
const img = document.getElementById('debug-img-' + nodeId);
|
|
@@ -22,7 +22,9 @@
|
|
|
22
22
|
colormap:{value:"JET"},
|
|
23
23
|
blurSize:{value:0}, blurSizeType:{value:"num"},
|
|
24
24
|
threshold:{value:0}, thresholdType:{value:"num"},
|
|
25
|
+
imageEnabled:{value:true},
|
|
25
26
|
statsEnabled:{value:true},
|
|
27
|
+
ssimEnabled:{value:true},
|
|
26
28
|
statsPath:{value:"diffStats"}, statsPathType:{value:"msg"}
|
|
27
29
|
},
|
|
28
30
|
inputs:1,outputs:1,
|
|
@@ -41,13 +43,13 @@
|
|
|
41
43
|
default:'msg',types:['msg','flow','global'],
|
|
42
44
|
typeField:"#node-input-statsPathType"});
|
|
43
45
|
|
|
44
|
-
// Stats path only relevant when stats are enabled
|
|
46
|
+
// Stats path and SSIM option only relevant when stats are enabled
|
|
45
47
|
var statsCheckbox = $('#node-input-statsEnabled');
|
|
46
|
-
function
|
|
47
|
-
$("#stats-path-row").toggle(statsCheckbox.is(':checked'));
|
|
48
|
+
function updateStatsVisibility(){
|
|
49
|
+
$("#stats-path-row, #ssim-row").toggle(statsCheckbox.is(':checked'));
|
|
48
50
|
}
|
|
49
|
-
statsCheckbox.on('change',
|
|
50
|
-
|
|
51
|
+
statsCheckbox.on('change', updateStatsVisibility);
|
|
52
|
+
updateStatsVisibility();
|
|
51
53
|
|
|
52
54
|
$("#node-input-blurSize").typedInput({
|
|
53
55
|
default:'num',types:['num','msg','flow','global'],
|
|
@@ -58,10 +60,11 @@
|
|
|
58
60
|
|
|
59
61
|
// Output format visibility
|
|
60
62
|
function updateQualityVisibility(){
|
|
63
|
+
var withImage = $("#node-input-imageEnabled").is(':checked');
|
|
61
64
|
var format = $("#node-input-outputFormat").val();
|
|
62
|
-
$("#quality-row").toggle(format === "jpg" || format === "webp");
|
|
63
|
-
$("#png-optimize-row").toggle(format === "png");
|
|
64
|
-
var isWebp = format === 'webp';
|
|
65
|
+
$("#quality-row").toggle(withImage && (format === "jpg" || format === "webp"));
|
|
66
|
+
$("#png-optimize-row").toggle(withImage && format === "png");
|
|
67
|
+
var isWebp = withImage && format === 'webp';
|
|
65
68
|
$("#webp-lossless-row").toggle(isWebp);
|
|
66
69
|
$("#webp-smartsubsample-row").toggle(isWebp);
|
|
67
70
|
$("#webp-effort-row").toggle(isWebp);
|
|
@@ -78,10 +81,25 @@
|
|
|
78
81
|
typeField: "#node-input-debugWidthType"
|
|
79
82
|
});
|
|
80
83
|
function updateDebugWidthVisibility() {
|
|
81
|
-
|
|
84
|
+
var withImage = $("#node-input-imageEnabled").is(':checked');
|
|
85
|
+
debugWidthRow.toggle(withImage && debugCheckbox.is(':checked'));
|
|
82
86
|
}
|
|
83
|
-
updateDebugWidthVisibility();
|
|
84
87
|
debugCheckbox.on('change', updateDebugWidthVisibility);
|
|
88
|
+
|
|
89
|
+
// Stats-only mode: every image-output option becomes irrelevant
|
|
90
|
+
var imageCheckbox = $('#node-input-imageEnabled');
|
|
91
|
+
function updateImageVisibility(){
|
|
92
|
+
var withImage = imageCheckbox.is(':checked');
|
|
93
|
+
$("#output-path-row, #output-format-row, #debug-row").toggle(withImage);
|
|
94
|
+
// Without an image, stats are the only output left
|
|
95
|
+
if (!withImage) statsCheckbox.prop('checked', true);
|
|
96
|
+
statsCheckbox.prop('disabled', !withImage);
|
|
97
|
+
updateStatsVisibility();
|
|
98
|
+
updateQualityVisibility();
|
|
99
|
+
updateDebugWidthVisibility();
|
|
100
|
+
}
|
|
101
|
+
imageCheckbox.on('change', updateImageVisibility);
|
|
102
|
+
updateImageVisibility();
|
|
85
103
|
}
|
|
86
104
|
});
|
|
87
105
|
</script>
|
|
@@ -105,12 +123,18 @@
|
|
|
105
123
|
</div>
|
|
106
124
|
|
|
107
125
|
<div class="form-row">
|
|
126
|
+
<label for="node-input-imageEnabled"><i class="fa fa-fire"></i> Heat Image</label>
|
|
127
|
+
<input type="checkbox" id="node-input-imageEnabled" style="display:inline-block; width:auto; vertical-align:baseline;">
|
|
128
|
+
<label for="node-input-imageEnabled" style="width:auto; margin-left:5px;">Render the heat map (off = statistics only)</label>
|
|
129
|
+
</div>
|
|
130
|
+
|
|
131
|
+
<div class="form-row" id="output-path-row">
|
|
108
132
|
<label><i class="fa fa-sign-out"></i> Output</label>
|
|
109
133
|
<input type="text" id="node-input-outputPath" style="width:70%;">
|
|
110
134
|
<input type="hidden" id="node-input-outputPathType">
|
|
111
135
|
</div>
|
|
112
136
|
|
|
113
|
-
<div class="form-row">
|
|
137
|
+
<div class="form-row" id="output-format-row">
|
|
114
138
|
<label for="node-input-outputFormat"><i class="fa fa-file-image-o"></i> Output Format</label>
|
|
115
139
|
<select id="node-input-outputFormat" style="width: 200px;">
|
|
116
140
|
<option value="raw">Raw (fastest)</option>
|
|
@@ -130,6 +154,11 @@
|
|
|
130
154
|
<input type="text" id="node-input-statsPath" style="width:70%;">
|
|
131
155
|
<input type="hidden" id="node-input-statsPathType">
|
|
132
156
|
</div>
|
|
157
|
+
<div class="form-row" id="ssim-row">
|
|
158
|
+
<label for="node-input-ssimEnabled"><i class="fa fa-clone"></i> SSIM</label>
|
|
159
|
+
<input type="checkbox" id="node-input-ssimEnabled" style="display:inline-block; width:auto; vertical-align:baseline;">
|
|
160
|
+
<label for="node-input-ssimEnabled" style="width:auto; margin-left:5px;">Compute SSIM (dominates the stats cost)</label>
|
|
161
|
+
</div>
|
|
133
162
|
|
|
134
163
|
<div class="form-row" id="quality-row">
|
|
135
164
|
<label for="node-input-outputQuality"><i class="fa fa-sliders"></i> Quality</label>
|
|
@@ -159,7 +188,7 @@
|
|
|
159
188
|
</div>
|
|
160
189
|
|
|
161
190
|
<!-- Debug Configuration -->
|
|
162
|
-
<div class="form-row">
|
|
191
|
+
<div class="form-row" id="debug-row">
|
|
163
192
|
<label for="node-input-debugEnabled"><i class="fa fa-bug"></i> Debug</label>
|
|
164
193
|
<input type="checkbox" id="node-input-debugEnabled" style="display:inline-block; width:auto; vertical-align:baseline;">
|
|
165
194
|
<label for="node-input-debugEnabled" style="width:auto; margin-left:5px;">Show processed image</label>
|
|
@@ -218,8 +247,11 @@
|
|
|
218
247
|
<dt>Image 2 <span class="property-type">string</span></dt>
|
|
219
248
|
<dd>Path to the second image (e.g. the golden/reference image).</dd>
|
|
220
249
|
|
|
250
|
+
<dt>Heat Image <span class="property-type">boolean</span></dt>
|
|
251
|
+
<dd>When enabled (default), the colormapped heat map is rendered and written to the output property. Disable it for a statistics-only pass: the colormap and the image encoding are skipped entirely and no image buffer is allocated. Statistics are then always computed, since they are the node's only output.</dd>
|
|
252
|
+
|
|
221
253
|
<dt>Output to <span class="property-type">string</span></dt>
|
|
222
|
-
<dd>Message property where the heat map image will be stored.</dd>
|
|
254
|
+
<dd>Message property where the heat map image will be stored. Left untouched when Heat Image is disabled.</dd>
|
|
223
255
|
|
|
224
256
|
<dt>Colormap <span class="property-type">string</span></dt>
|
|
225
257
|
<dd>Color mapping applied to the difference: JET, HOT, INFERNO, TURBO, BONE, COOL, RAINBOW, OCEAN, PINK, HSV.</dd>
|
|
@@ -233,6 +265,9 @@
|
|
|
233
265
|
<dt>Statistics <span class="property-type">boolean</span></dt>
|
|
234
266
|
<dd>When enabled (default), numeric diff statistics are computed.</dd>
|
|
235
267
|
|
|
268
|
+
<dt>SSIM <span class="property-type">boolean</span></dt>
|
|
269
|
+
<dd>When enabled (default), structural similarity is included in the statistics. It is by far the most expensive statistic — six full-resolution floating-point blurs, typically more than the rest of the node put together — so disable it when the flow only uses the ratios and blobs. <code>ssim</code> is then reported as <code>null</code>.</dd>
|
|
270
|
+
|
|
236
271
|
<dt>Stats to <span class="property-type">string</span></dt>
|
|
237
272
|
<dd>Message property where the statistics object is stored. Default <code>msg.diffStats</code>.</dd>
|
|
238
273
|
</dl>
|
|
@@ -241,7 +276,7 @@
|
|
|
241
276
|
<p>Two images in the standard format (raw image object or encoded buffer), or two arrays of images of the same length — images are paired by index and one heat map is produced per pair. Mixing a single image with an array, or arrays of different lengths, raises an error. Images of different sizes are resized to match the larger one.</p>
|
|
242
277
|
|
|
243
278
|
<h3>Outputs</h3>
|
|
244
|
-
<p>A 3-channel BGR heat map image in the selected output format. If the inputs were arrays, the output is an array of heat maps in the same order.</p>
|
|
279
|
+
<p>A 3-channel BGR heat map image in the selected output format. If the inputs were arrays, the output is an array of heat maps in the same order. With Heat Image disabled the output property is not written at all, so the message passes through unchanged apart from the statistics.</p>
|
|
245
280
|
<p>When Statistics is enabled, the configured stats property (default <code>msg.diffStats</code>) holds an object (or array, matching the input shape) with:</p>
|
|
246
281
|
<dl class="message-properties">
|
|
247
282
|
<dt>validRatio <span class="property-type">number</span></dt>
|
|
@@ -251,7 +286,7 @@
|
|
|
251
286
|
<dt>meanDiff / maxDiff / p50 / p95 / p99 <span class="property-type">number</span></dt>
|
|
252
287
|
<dd>Mean, maximum and percentiles of the difference values (0-255) over valid pixels.</dd>
|
|
253
288
|
<dt>rmse / psnr / ssim <span class="property-type">number</span></dt>
|
|
254
|
-
<dd>Root-mean-square error, peak signal-to-noise ratio (dB, 100 = identical) and structural similarity (0-1, 1 = identical).</dd>
|
|
289
|
+
<dd>Root-mean-square error, peak signal-to-noise ratio (dB, 100 = identical) and structural similarity (0-1, 1 = identical). <code>ssim</code> is <code>null</code> when the SSIM option is disabled.</dd>
|
|
255
290
|
<dt>blobCount / largestBlobArea / blobs <span class="property-type">number | array</span></dt>
|
|
256
291
|
<dd>Connected regions of changed pixels. <code>blobs</code> lists up to 50 regions, largest first, each with <code>x, y, w, h, area, cx, cy</code> in output-image coordinates.</dd>
|
|
257
292
|
</dl>
|
|
@@ -139,18 +139,26 @@ module.exports = function (RED) {
|
|
|
139
139
|
const outputFormat = config.outputFormat || 'raw';
|
|
140
140
|
const outputQuality = parseInt(config.outputQuality) || 90;
|
|
141
141
|
const pngOptimize = config.pngOptimize || false;
|
|
142
|
-
//
|
|
143
|
-
const
|
|
142
|
+
// Heat image on by default; off = stats-only (no colormap, no encode, no buffer)
|
|
143
|
+
const imageEnabled = config.imageEnabled !== false && config.imageEnabled !== 'false';
|
|
144
|
+
// Stats on by default; existing flows without the property get them too.
|
|
145
|
+
// Stats-only mode forces them on, otherwise the node would produce nothing.
|
|
146
|
+
const statsEnabled = !imageEnabled ||
|
|
147
|
+
(config.statsEnabled !== false && config.statsEnabled !== 'false');
|
|
148
|
+
// SSIM is by far the costliest stat; flows that ignore it can opt out
|
|
149
|
+
const ssimEnabled = config.ssimEnabled !== false && config.ssimEnabled !== 'false';
|
|
144
150
|
const statsPath = config.statsPath || 'diffStats';
|
|
145
151
|
const statsPathType = config.statsPathType || 'msg';
|
|
146
|
-
const useSharpWebp = outputFormat === 'webp' &&
|
|
152
|
+
const useSharpWebp = imageEnabled && outputFormat === 'webp' &&
|
|
153
|
+
NodeUtils.hasAdvancedWebpOptions(config);
|
|
147
154
|
const cppFormat = useSharpWebp ? 'raw' : outputFormat;
|
|
148
155
|
|
|
149
156
|
/* One C++ call per pair (index-matched) */
|
|
150
157
|
const results = await Promise.all(
|
|
151
158
|
list1.map((img1, i) =>
|
|
152
159
|
Cpp.heatDiff(img1, list2[i], colormapType, blurSize, threshold,
|
|
153
|
-
cppFormat, outputQuality, pngOptimize, statsEnabled
|
|
160
|
+
cppFormat, outputQuality, pngOptimize, statsEnabled,
|
|
161
|
+
imageEnabled, ssimEnabled))
|
|
154
162
|
);
|
|
155
163
|
|
|
156
164
|
// Aggregate timings across pairs
|
|
@@ -163,7 +171,7 @@ module.exports = function (RED) {
|
|
|
163
171
|
},
|
|
164
172
|
{ convertMs: 0, taskMs: 0, encodeMs: 0 }
|
|
165
173
|
);
|
|
166
|
-
const images = results.map(r => r.image);
|
|
174
|
+
const images = imageEnabled ? results.map(r => r.image) : [];
|
|
167
175
|
|
|
168
176
|
if (useSharpWebp) {
|
|
169
177
|
for (let i = 0; i < images.length; i++) {
|
|
@@ -171,8 +179,10 @@ module.exports = function (RED) {
|
|
|
171
179
|
}
|
|
172
180
|
}
|
|
173
181
|
|
|
174
|
-
/* Write result — array in, array out */
|
|
175
|
-
|
|
182
|
+
/* Write result — array in, array out; stats-only leaves the output path untouched */
|
|
183
|
+
if (imageEnabled) {
|
|
184
|
+
RED.util.setMessageProperty(msg, outputPath, isArray ? images : images[0]);
|
|
185
|
+
}
|
|
176
186
|
|
|
177
187
|
/* Diff statistics, same shape as the image output */
|
|
178
188
|
if (statsEnabled) {
|
|
@@ -184,7 +194,8 @@ module.exports = function (RED) {
|
|
|
184
194
|
const total = performance.now() - t0;
|
|
185
195
|
|
|
186
196
|
let debugFormat = null;
|
|
187
|
-
const debugEnabled =
|
|
197
|
+
const debugEnabled = imageEnabled &&
|
|
198
|
+
(config.debugEnabled === true || config.debugEnabled === 'true');
|
|
188
199
|
if (debugEnabled) {
|
|
189
200
|
try {
|
|
190
201
|
let debugWidth = NodeUtils.resolveDimension(
|
|
@@ -335,8 +335,9 @@
|
|
|
335
335
|
|
|
336
336
|
const debugWidth = data.debugWidth || 200;
|
|
337
337
|
const debugHeight = data.debugHeight || 200;
|
|
338
|
-
|
|
339
|
-
const
|
|
338
|
+
// Display at the server-resized debug dimensions (no display cap)
|
|
339
|
+
const maxDisplayWidth = debugWidth;
|
|
340
|
+
const displayHeight = debugHeight;
|
|
340
341
|
|
|
341
342
|
let debugContainer = document.getElementById('debug-img-container-' + nodeId);
|
|
342
343
|
|
|
@@ -170,6 +170,10 @@
|
|
|
170
170
|
|
|
171
171
|
const nodeElement = document.getElementById(nodeId);
|
|
172
172
|
if (!nodeElement) return;
|
|
173
|
+
|
|
174
|
+
// Size to the server-resized debug image (no display cap)
|
|
175
|
+
var debugWidth = data.debugWidth || 200;
|
|
176
|
+
var debugHeight = data.debugHeight || 200;
|
|
173
177
|
|
|
174
178
|
let debugContainer = document.getElementById('debug-img-container-' + nodeId);
|
|
175
179
|
|
|
@@ -179,8 +183,8 @@
|
|
|
179
183
|
debugContainer.id = 'debug-img-container-' + nodeId;
|
|
180
184
|
debugContainer.setAttribute('x', '70');
|
|
181
185
|
debugContainer.setAttribute('y', '5');
|
|
182
|
-
debugContainer.setAttribute('width',
|
|
183
|
-
debugContainer.setAttribute('height',
|
|
186
|
+
debugContainer.setAttribute('width', debugWidth.toString());
|
|
187
|
+
debugContainer.setAttribute('height', debugHeight.toString());
|
|
184
188
|
debugContainer.style.overflow = 'visible';
|
|
185
189
|
|
|
186
190
|
// Create simple image directly inside foreignObject
|
|
@@ -190,8 +194,8 @@
|
|
|
190
194
|
img.style.height = 'auto';
|
|
191
195
|
img.style.display = 'block';
|
|
192
196
|
img.style.cursor = 'pointer';
|
|
193
|
-
img.style.maxHeight = '
|
|
194
|
-
img.style.maxWidth = '
|
|
197
|
+
img.style.maxHeight = 'none';
|
|
198
|
+
img.style.maxWidth = 'none';
|
|
195
199
|
|
|
196
200
|
img.onclick = function() {
|
|
197
201
|
removeDebugImage(nodeId);
|
|
@@ -199,6 +203,9 @@
|
|
|
199
203
|
|
|
200
204
|
debugContainer.appendChild(img);
|
|
201
205
|
nodeElement.appendChild(debugContainer);
|
|
206
|
+
} else {
|
|
207
|
+
debugContainer.setAttribute('width', debugWidth.toString());
|
|
208
|
+
debugContainer.setAttribute('height', debugHeight.toString());
|
|
202
209
|
}
|
|
203
210
|
|
|
204
211
|
const img = document.getElementById('debug-img-' + nodeId);
|
|
@@ -228,6 +228,10 @@
|
|
|
228
228
|
|
|
229
229
|
const nodeElement = document.getElementById(nodeId);
|
|
230
230
|
if (!nodeElement) return;
|
|
231
|
+
|
|
232
|
+
// Size to the server-resized debug image (no display cap)
|
|
233
|
+
var debugWidth = data.debugWidth || 200;
|
|
234
|
+
var debugHeight = data.debugHeight || 200;
|
|
231
235
|
|
|
232
236
|
let debugContainer = document.getElementById('debug-img-container-' + nodeId);
|
|
233
237
|
|
|
@@ -237,8 +241,8 @@
|
|
|
237
241
|
debugContainer.id = 'debug-img-container-' + nodeId;
|
|
238
242
|
debugContainer.setAttribute('x', '70');
|
|
239
243
|
debugContainer.setAttribute('y', '5');
|
|
240
|
-
debugContainer.setAttribute('width',
|
|
241
|
-
debugContainer.setAttribute('height',
|
|
244
|
+
debugContainer.setAttribute('width', debugWidth.toString());
|
|
245
|
+
debugContainer.setAttribute('height', debugHeight.toString());
|
|
242
246
|
debugContainer.style.overflow = 'visible';
|
|
243
247
|
|
|
244
248
|
// Create simple image directly inside foreignObject
|
|
@@ -248,8 +252,8 @@
|
|
|
248
252
|
img.style.height = 'auto';
|
|
249
253
|
img.style.display = 'block';
|
|
250
254
|
img.style.cursor = 'pointer';
|
|
251
|
-
img.style.maxHeight = '
|
|
252
|
-
img.style.maxWidth = '
|
|
255
|
+
img.style.maxHeight = 'none';
|
|
256
|
+
img.style.maxWidth = 'none';
|
|
253
257
|
|
|
254
258
|
img.onclick = function() {
|
|
255
259
|
removeDebugImage(nodeId);
|
|
@@ -257,6 +261,9 @@
|
|
|
257
261
|
|
|
258
262
|
debugContainer.appendChild(img);
|
|
259
263
|
nodeElement.appendChild(debugContainer);
|
|
264
|
+
} else {
|
|
265
|
+
debugContainer.setAttribute('width', debugWidth.toString());
|
|
266
|
+
debugContainer.setAttribute('height', debugHeight.toString());
|
|
260
267
|
}
|
|
261
268
|
|
|
262
269
|
const img = document.getElementById('debug-img-' + nodeId);
|
|
@@ -156,6 +156,10 @@
|
|
|
156
156
|
|
|
157
157
|
const nodeElement = document.getElementById(nodeId);
|
|
158
158
|
if (!nodeElement) return;
|
|
159
|
+
|
|
160
|
+
// Size to the server-resized debug image (no display cap)
|
|
161
|
+
var debugWidth = data.debugWidth || 200;
|
|
162
|
+
var debugHeight = data.debugHeight || 200;
|
|
159
163
|
|
|
160
164
|
let debugContainer = document.getElementById('debug-img-container-' + nodeId);
|
|
161
165
|
|
|
@@ -165,8 +169,8 @@
|
|
|
165
169
|
debugContainer.id = 'debug-img-container-' + nodeId;
|
|
166
170
|
debugContainer.setAttribute('x', '70');
|
|
167
171
|
debugContainer.setAttribute('y', '5');
|
|
168
|
-
debugContainer.setAttribute('width',
|
|
169
|
-
debugContainer.setAttribute('height',
|
|
172
|
+
debugContainer.setAttribute('width', debugWidth.toString());
|
|
173
|
+
debugContainer.setAttribute('height', debugHeight.toString());
|
|
170
174
|
debugContainer.style.overflow = 'visible';
|
|
171
175
|
|
|
172
176
|
// Create simple image directly inside foreignObject
|
|
@@ -176,8 +180,8 @@
|
|
|
176
180
|
img.style.height = 'auto';
|
|
177
181
|
img.style.display = 'block';
|
|
178
182
|
img.style.cursor = 'pointer';
|
|
179
|
-
img.style.maxHeight = '
|
|
180
|
-
img.style.maxWidth = '
|
|
183
|
+
img.style.maxHeight = 'none';
|
|
184
|
+
img.style.maxWidth = 'none';
|
|
181
185
|
|
|
182
186
|
img.onclick = function() {
|
|
183
187
|
removeDebugImage(nodeId);
|
|
@@ -185,6 +189,9 @@
|
|
|
185
189
|
|
|
186
190
|
debugContainer.appendChild(img);
|
|
187
191
|
nodeElement.appendChild(debugContainer);
|
|
192
|
+
} else {
|
|
193
|
+
debugContainer.setAttribute('width', debugWidth.toString());
|
|
194
|
+
debugContainer.setAttribute('height', debugHeight.toString());
|
|
188
195
|
}
|
|
189
196
|
|
|
190
197
|
const img = document.getElementById('debug-img-' + nodeId);
|
|
@@ -220,9 +220,9 @@
|
|
|
220
220
|
const debugWidth = data.debugWidth || 200;
|
|
221
221
|
const debugHeight = data.debugHeight || 200;
|
|
222
222
|
|
|
223
|
-
//
|
|
224
|
-
const maxDisplayWidth =
|
|
225
|
-
const displayHeight = debugHeight
|
|
223
|
+
// Display at the server-resized debug dimensions (no display cap)
|
|
224
|
+
const maxDisplayWidth = debugWidth;
|
|
225
|
+
const displayHeight = debugHeight;
|
|
226
226
|
|
|
227
227
|
let debugContainer = document.getElementById('debug-img-container-' + nodeId);
|
|
228
228
|
|
|
@@ -136,6 +136,10 @@
|
|
|
136
136
|
|
|
137
137
|
const nodeElement = document.getElementById(nodeId);
|
|
138
138
|
if (!nodeElement) return;
|
|
139
|
+
|
|
140
|
+
// Size to the server-resized debug image (no display cap)
|
|
141
|
+
var debugWidth = data.debugWidth || 200;
|
|
142
|
+
var debugHeight = data.debugHeight || 200;
|
|
139
143
|
|
|
140
144
|
let debugContainer = document.getElementById('debug-img-container-' + nodeId);
|
|
141
145
|
|
|
@@ -145,8 +149,8 @@
|
|
|
145
149
|
debugContainer.id = 'debug-img-container-' + nodeId;
|
|
146
150
|
debugContainer.setAttribute('x', '70');
|
|
147
151
|
debugContainer.setAttribute('y', '5');
|
|
148
|
-
debugContainer.setAttribute('width',
|
|
149
|
-
debugContainer.setAttribute('height',
|
|
152
|
+
debugContainer.setAttribute('width', debugWidth.toString());
|
|
153
|
+
debugContainer.setAttribute('height', debugHeight.toString());
|
|
150
154
|
debugContainer.style.overflow = 'visible';
|
|
151
155
|
|
|
152
156
|
// Create simple image directly inside foreignObject
|
|
@@ -156,8 +160,8 @@
|
|
|
156
160
|
img.style.height = 'auto';
|
|
157
161
|
img.style.display = 'block';
|
|
158
162
|
img.style.cursor = 'pointer';
|
|
159
|
-
img.style.maxHeight = '
|
|
160
|
-
img.style.maxWidth = '
|
|
163
|
+
img.style.maxHeight = 'none';
|
|
164
|
+
img.style.maxWidth = 'none';
|
|
161
165
|
|
|
162
166
|
img.onclick = function() {
|
|
163
167
|
removeDebugImage(nodeId);
|
|
@@ -165,6 +169,9 @@
|
|
|
165
169
|
|
|
166
170
|
debugContainer.appendChild(img);
|
|
167
171
|
nodeElement.appendChild(debugContainer);
|
|
172
|
+
} else {
|
|
173
|
+
debugContainer.setAttribute('width', debugWidth.toString());
|
|
174
|
+
debugContainer.setAttribute('height', debugHeight.toString());
|
|
168
175
|
}
|
|
169
176
|
|
|
170
177
|
const img = document.getElementById('debug-img-' + nodeId);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rosepetal/node-red-contrib-image-tools",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.4",
|
|
4
4
|
"description": "Node-RED Image Processing Toolkit",
|
|
5
5
|
"main": "install.sh",
|
|
6
6
|
"directories": {
|
|
@@ -36,11 +36,11 @@
|
|
|
36
36
|
"sharp": "^0.34.2"
|
|
37
37
|
},
|
|
38
38
|
"optionalDependencies": {
|
|
39
|
-
"@rosepetal/node-red-contrib-image-tools-linux-x64": "1.6.
|
|
40
|
-
"@rosepetal/node-red-contrib-image-tools-linux-arm64": "1.6.
|
|
41
|
-
"@rosepetal/node-red-contrib-image-tools-linuxmusl-x64": "1.6.
|
|
42
|
-
"@rosepetal/node-red-contrib-image-tools-darwin-x64": "1.6.
|
|
43
|
-
"@rosepetal/node-red-contrib-image-tools-darwin-arm64": "1.6.
|
|
39
|
+
"@rosepetal/node-red-contrib-image-tools-linux-x64": "1.6.4",
|
|
40
|
+
"@rosepetal/node-red-contrib-image-tools-linux-arm64": "1.6.4",
|
|
41
|
+
"@rosepetal/node-red-contrib-image-tools-linuxmusl-x64": "1.6.4",
|
|
42
|
+
"@rosepetal/node-red-contrib-image-tools-darwin-x64": "1.6.4",
|
|
43
|
+
"@rosepetal/node-red-contrib-image-tools-darwin-arm64": "1.6.4"
|
|
44
44
|
},
|
|
45
45
|
"node-red": {
|
|
46
46
|
"version": ">=1.0.0",
|
|
@@ -37,7 +37,9 @@ public:
|
|
|
37
37
|
std::string outputFormat,
|
|
38
38
|
int quality = 90,
|
|
39
39
|
bool pngOptimize = false,
|
|
40
|
-
bool computeStats = false
|
|
40
|
+
bool computeStats = false,
|
|
41
|
+
bool emitImage = true,
|
|
42
|
+
bool computeSsim = true)
|
|
41
43
|
: Napi::AsyncWorker(cb),
|
|
42
44
|
colormapType(colormapType),
|
|
43
45
|
blurSize(blurSize),
|
|
@@ -45,7 +47,9 @@ public:
|
|
|
45
47
|
outputFormat(std::move(outputFormat)),
|
|
46
48
|
quality(quality),
|
|
47
49
|
pngOptimize(pngOptimize),
|
|
48
|
-
computeStats(computeStats)
|
|
50
|
+
computeStats(computeStats),
|
|
51
|
+
emitImage(emitImage),
|
|
52
|
+
computeSsim(computeSsim)
|
|
49
53
|
{
|
|
50
54
|
const int64 t0 = cv::getTickCount();
|
|
51
55
|
mat1 = ConvertToMat(jsImg1);
|
|
@@ -103,14 +107,16 @@ protected:
|
|
|
103
107
|
|
|
104
108
|
if (computeStats) ComputeStats(diff, gray1, gray2);
|
|
105
109
|
|
|
106
|
-
// Apply colormap
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
+
// Apply colormap (skipped in stats-only mode)
|
|
111
|
+
if (emitImage) {
|
|
112
|
+
cv::applyColorMap(diff, result, colormapType);
|
|
113
|
+
// applyColorMap outputs BGR
|
|
114
|
+
outputChannel = "BGR";
|
|
115
|
+
}
|
|
110
116
|
|
|
111
117
|
taskMs = (cv::getTickCount() - t0) / cv::getTickFrequency() * 1e3;
|
|
112
118
|
|
|
113
|
-
if (outputFormat != "raw") {
|
|
119
|
+
if (emitImage && outputFormat != "raw") {
|
|
114
120
|
cv::Mat tmp = PrepareForEncoding(result, outputChannel, outputFormat);
|
|
115
121
|
encodeMs = EncodeToFormat(tmp, encodedBuf, outputFormat, quality, pngOptimize);
|
|
116
122
|
}
|
|
@@ -118,9 +124,12 @@ protected:
|
|
|
118
124
|
|
|
119
125
|
void OnOK() override {
|
|
120
126
|
Napi::Env env = Env();
|
|
121
|
-
Napi::Value jsImg = (
|
|
122
|
-
|
|
123
|
-
|
|
127
|
+
Napi::Value jsImg = env.Null();
|
|
128
|
+
if (emitImage) {
|
|
129
|
+
jsImg = (outputFormat != "raw")
|
|
130
|
+
? VectorToBuffer(env, std::move(encodedBuf))
|
|
131
|
+
: MatToRawJS(env, result, outputChannel);
|
|
132
|
+
}
|
|
124
133
|
|
|
125
134
|
Napi::Object out = Napi::Object::New(env);
|
|
126
135
|
out.Set("image", jsImg);
|
|
@@ -137,7 +146,8 @@ protected:
|
|
|
137
146
|
st.Set("p99", statP99);
|
|
138
147
|
st.Set("rmse", statRmse);
|
|
139
148
|
st.Set("psnr", statPsnr);
|
|
140
|
-
st.Set("ssim",
|
|
149
|
+
if (computeSsim) st.Set("ssim", statSsim);
|
|
150
|
+
else st.Set("ssim", env.Null());
|
|
141
151
|
st.Set("threshold", threshold);
|
|
142
152
|
st.Set("blobCount", statBlobCount);
|
|
143
153
|
st.Set("largestBlobArea", statLargestBlobArea);
|
|
@@ -202,7 +212,8 @@ private:
|
|
|
202
212
|
statRmse = std::sqrt(meanSq);
|
|
203
213
|
statPsnr = meanSq > 0 ? 10.0 * std::log10(255.0 * 255.0 / meanSq) : 100.0;
|
|
204
214
|
|
|
205
|
-
|
|
215
|
+
// SSIM is by far the costliest stat (6 full-res float blurs); optional
|
|
216
|
+
if (computeSsim) statSsim = MaskedSSIM(gray1, gray2, valid);
|
|
206
217
|
|
|
207
218
|
// Connected components on the changed mask -> blobs (largest first, capped)
|
|
208
219
|
cv::Mat labels, ccStats, centroids;
|
|
@@ -235,6 +246,8 @@ private:
|
|
|
235
246
|
int quality;
|
|
236
247
|
bool pngOptimize;
|
|
237
248
|
bool computeStats;
|
|
249
|
+
bool emitImage;
|
|
250
|
+
bool computeSsim;
|
|
238
251
|
double convertMs = 0, taskMs = 0, encodeMs = 0;
|
|
239
252
|
std::vector<uchar> encodedBuf;
|
|
240
253
|
|
|
@@ -249,7 +262,7 @@ Napi::Value HeatDiff(const Napi::CallbackInfo& info) {
|
|
|
249
262
|
|
|
250
263
|
if (info.Length() < 3 || !info[info.Length() - 1].IsFunction()) {
|
|
251
264
|
Napi::TypeError::New(env,
|
|
252
|
-
"heatDiff(image1, image2, colormapType, [blurSize], [threshold], [outputFormat], [quality], [pngOptimize], [computeStats], callback)")
|
|
265
|
+
"heatDiff(image1, image2, colormapType, [blurSize], [threshold], [outputFormat], [quality], [pngOptimize], [computeStats], [emitImage], [computeSsim], callback)")
|
|
253
266
|
.ThrowAsJavaScriptException();
|
|
254
267
|
return env.Null();
|
|
255
268
|
}
|
|
@@ -264,6 +277,8 @@ Napi::Value HeatDiff(const Napi::CallbackInfo& info) {
|
|
|
264
277
|
int quality = 90;
|
|
265
278
|
bool pngOptimize = false;
|
|
266
279
|
bool computeStats = false;
|
|
280
|
+
bool emitImage = true;
|
|
281
|
+
bool computeSsim = true;
|
|
267
282
|
size_t cbIdx = 3;
|
|
268
283
|
|
|
269
284
|
if (info.Length() >= 5) { blurSize = info[3].As<Napi::Number>().Int32Value(); cbIdx = 4; }
|
|
@@ -272,9 +287,11 @@ Napi::Value HeatDiff(const Napi::CallbackInfo& info) {
|
|
|
272
287
|
if (info.Length() >= 8) { quality = info[6].As<Napi::Number>().Int32Value(); cbIdx = 7; }
|
|
273
288
|
if (info.Length() >= 9) { pngOptimize = info[7].As<Napi::Boolean>().Value(); cbIdx = 8; }
|
|
274
289
|
if (info.Length() >= 10) { computeStats = info[8].As<Napi::Boolean>().Value(); cbIdx = 9; }
|
|
290
|
+
if (info.Length() >= 11) { emitImage = info[9].As<Napi::Boolean>().Value(); cbIdx = 10; }
|
|
291
|
+
if (info.Length() >= 12) { computeSsim = info[10].As<Napi::Boolean>().Value(); cbIdx = 11; }
|
|
275
292
|
|
|
276
293
|
(new HeatDiffWorker(info[cbIdx].As<Napi::Function>(),
|
|
277
294
|
jsImg1, jsImg2, colormapType, blurSize, threshold, outputFormat, quality, pngOptimize,
|
|
278
|
-
computeStats))->Queue();
|
|
295
|
+
computeStats, emitImage, computeSsim))->Queue();
|
|
279
296
|
return env.Undefined();
|
|
280
297
|
}
|