@rosepetal/node-red-contrib-image-tools 1.7.0 → 1.8.1

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 (35) hide show
  1. package/.github/workflows/build-prebuild.yml +1 -1
  2. package/README.md +39 -21
  3. package/docs/index.md +156 -0
  4. package/docs/nodes/blend/add-bbs.md +116 -0
  5. package/docs/nodes/blend/add-mask.md +67 -224
  6. package/docs/nodes/blend/add-masks.md +74 -196
  7. package/docs/nodes/blend/blend.md +84 -200
  8. package/docs/nodes/io/folder-in.md +92 -0
  9. package/docs/nodes/io/image-in.md +61 -52
  10. package/docs/nodes/io/image-out.md +114 -93
  11. package/docs/nodes/mix/advanced-mosaic.md +124 -78
  12. package/docs/nodes/mix/concat.md +71 -56
  13. package/docs/nodes/mix/mosaic.md +81 -91
  14. package/docs/nodes/specialized/cropBB.md +76 -214
  15. package/docs/nodes/specialized/heat-diff.md +111 -0
  16. package/docs/nodes/specialized/image-align.md +125 -387
  17. package/docs/nodes/transform/color-convert.md +101 -0
  18. package/docs/nodes/transform/crop.md +56 -58
  19. package/docs/nodes/transform/draw.md +46 -26
  20. package/docs/nodes/transform/filter.md +110 -46
  21. package/docs/nodes/transform/padding.md +55 -55
  22. package/docs/nodes/transform/resize.md +81 -56
  23. package/docs/nodes/transform/rotate.md +67 -50
  24. package/node-red-contrib-image-tools/nodes/specialized/image-align.html +11 -4
  25. package/node-red-contrib-image-tools/nodes/specialized/image-align.js +2 -1
  26. package/npm/darwin-arm64/package.json +1 -1
  27. package/npm/darwin-x64/package.json +1 -1
  28. package/npm/linux-arm64/package.json +1 -1
  29. package/npm/linux-x64/package.json +1 -1
  30. package/npm/linuxmusl-x64/package.json +1 -1
  31. package/npm/win32-x64/package.json +1 -1
  32. package/package.json +6 -6
  33. package/rosepetal-image-engine/src/heat-diff.cpp +4 -0
  34. package/rosepetal-image-engine/src/image-align.cpp +71 -3
  35. package/scripts/build-opencv-static.sh +6 -0
@@ -1,271 +1,133 @@
1
+ ---
2
+ title: "CropBB Node - Crop Detection Bounding Boxes"
3
+ description: "Extract one image crop per bounding box of an inference result in Node-RED, filtered by a minimum confidence. Part of @rosepetal/node-red-contrib-image-tools."
4
+ head:
5
+ - - meta
6
+ - name: "keywords"
7
+ content: "node-red, cropBB, bounding box, object detection, crop, inference, confidence, opencv, rosepetal"
8
+ - - meta
9
+ - property: "og:title"
10
+ content: "CropBB Node - @rosepetal/node-red-contrib-image-tools"
11
+ - - meta
12
+ - property: "og:description"
13
+ content: "Extract one image crop per bounding box of an inference result in Node-RED, filtered by a minimum confidence."
14
+ ---
15
+
1
16
  # CropBB Node (Crop Bounding Boxes)
2
17
 
3
18
  ## Purpose & Use Cases
4
19
 
5
- The `cropBB` node is specialized for AI/ML workflows, extracting image crops from object detection bounding box results. It processes detection data and extracts individual objects or regions of interest from images, making it essential for computer vision pipelines.
20
+ The `cropBB` node cuts one crop out of an image for every box of an object detection result whose confidence reaches a minimum. Each crop keeps the tag, the confidence and the position of its box, so the crops can go straight to a classifier or be saved one by one.
6
21
 
7
22
  **Real-World Applications:**
8
- - **Object Detection Workflows**: Extract detected objects from AI analysis results
9
- - **Quality Control Systems**: Crop defective areas identified by inspection AI
10
- - **Security/Surveillance**: Extract detected persons or objects from camera feeds
11
- - **Medical Imaging**: Extract abnormalities or regions of interest from diagnostic scans
12
- - **E-commerce Automation**: Extract product images from catalog photos using AI detection
13
-
14
- *[PLACEHOLDER - Add GIF showing AI detection results being converted to individual cropped objects]*
23
+ - **Two-Stage Inspection**: Detect parts or defects, then classify each crop with a second model
24
+ - **Quality Control Systems**: Save the defective areas found by an inspection model
25
+ - **Dataset Building**: Collect crops of detected objects for training
15
26
 
16
27
  ## Input/Output Specification
17
28
 
18
29
  ### Inputs
19
- - **Images**: Single image or array of images to crop from
20
- - **Detection Data**: Bounding box detection results from AI/ML inference
21
- - **Confidence Filtering**: Minimum confidence threshold for including detections
30
+ Only `msg` properties are read and written: the editor also offers `flow` and `global`, but the node reads the typed text as a `msg` path.
31
+
32
+ - **Input from** (`msg.image` by default): a raw image object. An array is accepted, but only its first image is cropped. Encoded `Buffer`s are rejected (`cropBB requires raw images with width/height metadata`)
33
+ - **Bounding Boxes** (`msg.default` by default): the array of detections
34
+ - **Min Confidence**: detections below it are skipped
22
35
 
23
36
  ### Detection Data Format
24
- The node expects detection results in this format:
25
37
  ```javascript
26
38
  [
27
39
  {
28
- "box": [[x1,y1], [x2,y1], [x2,y2], [x1,y2]], // Normalized 0-1 coordinates
40
+ "raw_boxes": [[x1,y1], [x2,y1], [x2,y2], [x1,y2]], // normalized 0-1, axis-aligned
29
41
  "confidence": 0.97,
30
- "class_name": "person",
31
- "class_tag": 3
42
+ "tag": "person"
32
43
  },
33
44
  // ... more detections
34
45
  ]
35
46
  ```
36
47
 
48
+ - `raw_boxes` must be four corners in the order top-left, top-right, bottom-right, bottom-left of an axis-aligned box; other shapes are skipped with the warning `Inconsistent corner points in detection raw_boxes: ...` or `Invalid raw_boxes format in detection: ...`
49
+ - `confidence` is optional; a detection without it (or with 0) counts as 1.0
50
+ - `tag` is optional; without it the crop is tagged `unknown`
51
+
37
52
  ### Outputs
53
+ One output. **Output to** (`msg.payload` by default) receives an array with one crop per kept detection, in the order of the detections:
54
+
38
55
  ```javascript
39
56
  [
40
57
  {
41
- crop: ImageObject, // Cropped image
42
- tag: {
43
- label: "person", // Detection class name
44
- confidence: 0.97, // Detection confidence
45
- bbox: { // Bounding box information
46
- x: 150, y: 100, // Pixel coordinates
47
- width: 200, height: 300,
48
- normalized: { x1: 0.1, y1: 0.2, x2: 0.3, y2: 0.5 }
49
- }
58
+ data: Buffer, width: 200, height: 300, channels: 3, colorSpace: "RGB", dtype: "uint8",
59
+ tag: "person", // tag of the detection
60
+ confidence: 0.97, // confidence of the detection
61
+ bbox: { // the crop in pixels of the source image (here 1000 × 1000)
62
+ x: 150, y: 100, width: 200, height: 300,
63
+ normalized: { x1: 0.15, y1: 0.1, x2: 0.35, y2: 0.4 }
50
64
  }
51
65
  },
52
66
  // ... more crops
53
67
  ]
54
68
  ```
55
69
 
56
- ## Configuration Options
57
-
58
- ### Input Paths
59
- - **Image Input Path**: Location of source images (default: `msg.images`)
60
- - **Bounding Box Input Path**: Location of detection data (default: `msg.default`)
61
- - **Path Sources**: `msg.*`, `flow.*`, `global.*`
70
+ `msg.performance.rpimage.<key>` receives `{ conversion, task, total }` in milliseconds.
62
71
 
63
- ### Output Configuration
64
- - **Output Path**: Where to store crop results (default: `msg.payload`)
65
- - **Output Format**: Raw, JPEG, PNG, or WebP
66
- - **Quality Settings**: Compression settings for encoded formats
67
-
68
- ### Detection Filtering
72
+ ## Configuration Options
69
73
 
70
- #### Minimum Confidence
71
- - **Range**: 0.0 to 1.0 (0% to 100%)
72
- - **Default**: 0.5 (50% confidence)
73
- - **Purpose**: Filter out low-confidence detections
74
- - **Sources**: Number, `msg.*`, `flow.*`, `global.*`
74
+ | Property | Default | Meaning |
75
+ |----------|---------|---------|
76
+ | Name | empty | Label of the node; also the key of its timings in `msg.performance.rpimage` |
77
+ | Input from | `msg.image` | The source image |
78
+ | Bounding Boxes | `msg.default` | The detections |
79
+ | Output to | `msg.payload` | Where the array of crops is written |
80
+ | Output Format | Raw (fastest) | Keep **Raw**: see the note below |
81
+ | Quality, PNG Optimize, WebP options | `90`, off, off | Encoding options of the output formats |
82
+ | Debug / Debug Width | off / `200` | **Show processed image**: a preview of the first crop under the node in the editor |
83
+ | Min Confidence | `0.5` | 0.0 to 1.0: a number, or read from `msg`, `flow` or `global`. A value of 0 is read as 0.5 |
75
84
 
76
- #### Class Filtering
77
- - **Specific Classes**: Only crop detections of specified classes
78
- - **Class Names**: Filter by class_name field (e.g., "person", "car")
79
- - **Class Tags**: Filter by numeric class_tag field
85
+ **Output Format**: with JPEG, PNG or WebP the current version does not return usable crops (the encoded data is not kept as a `Buffer` next to the tag, and with the WebP options the tag, confidence and bbox are lost). Use Raw and encode the crops later, for example with [image-out](../io/image-out.md).
80
86
 
81
- ### Processing Options
87
+ ### Coordinate Handling
88
+ - Normalized coordinates are multiplied by the width and height of the image and rounded to whole pixels
89
+ - Crops are clipped to the image; a box with no width or height is skipped with a warning
82
90
 
83
- #### Coordinate Handling
84
- - **Normalized Input**: Handles 0-1 coordinate format (standard)
85
- - **Pixel Conversion**: Automatically converts to pixel coordinates
86
- - **Bounds Clipping**: Ensures crops stay within image boundaries
87
- - **Validation**: Checks for valid box formats and dimensions
91
+ ## Status and Errors
88
92
 
89
- #### Output Format Options
90
- - **Raw**: Standard image objects (fastest for processing chains)
91
- - **JPEG**: Compressed crops with quality control
92
- - **PNG**: Lossless crops preserving quality
93
- - **WebP**: Modern format with excellent compression
93
+ - **Success**: green dot `OK: <n> img in <t> ms (conv <c> ms | task <k> ms)`, where `<n>` is the number of crops; with Debug on, the preview format and size follow
94
+ - **No box kept**: the warning `No valid bounding boxes found with confidence >= <min>`, an empty array at Output to, and the message is sent
95
+ - **Failure**: `msg.error` is set, an empty array is written to Output to, a warning is logged, the status shows a red ring `Error: <first 30 characters>` and the message is still sent. Messages include `No image data found at image`, `No bounding box data found at default` and `Invalid bounding box data structure. Expected array at default`
94
96
 
95
97
  ## Performance Notes
96
98
 
97
- ### C++ Backend Processing
98
- - **Parallel Cropping**: Multiple crops extracted simultaneously
99
- - **Memory Efficient**: Direct region extraction without full image copying
100
- - **Bounds Checking**: Automatic coordinate validation and clipping
101
- - **Batch Processing**: Optimized for multiple detections per image
102
-
103
- ### Detection Processing
104
- - **Format Validation**: Robust parsing of various detection formats
105
- - **Coordinate Conversion**: Efficient normalized-to-pixel coordinate conversion
106
- - **Confidence Filtering**: Fast threshold-based filtering before cropping
107
- - **Error Handling**: Graceful handling of malformed detection data
99
+ - The crops are cut in parallel by the native OpenCV addon, on the libuv thread pool
108
100
 
109
101
  ## Real-World Examples
110
102
 
111
- ### Object Detection Pipeline
103
+ ### Two-Stage Inspection
112
104
  ```
113
- [Image] → [AI Detection Model] → [CropBB: confidence=0.7] → [Individual Objects]
105
+ [Camera] → [Detection model] → [CropBB: Min Confidence 0.7] → [Split] → [Classifier] → [Join]
114
106
  ```
115
- Extract all detected objects with 70%+ confidence from AI analysis.
107
+ Classify every detected part with a second model; `tag` and `bbox` stay on each crop.
116
108
 
117
- ### Quality Control System
109
+ ### Save the Defects
118
110
  ```
119
- [Product Image] → [Defect Detection AI] → [CropBB: class="defect"] → [Defect Crops] → [Analysis]
111
+ [Product Image] → [Defect detector] → [CropBB] → [Function: build { bitmap, outputDir, filename } items] → [Image-Out: Multiple images]
120
112
  ```
121
- Extract defective areas for detailed quality analysis.
122
-
123
- ### Security Surveillance
124
- ```
125
- [Camera Feed] → [Person Detection] → [CropBB: class="person", confidence=0.8] → [Person Crops] → [Recognition]
126
- ```
127
- Extract detected persons for facial recognition processing.
128
-
129
- ### Medical Imaging Analysis
130
- ```
131
- [Medical Scan] → [Anomaly Detection] → [CropBB: confidence=0.9] → [Suspicious Regions] → [Specialist Review]
132
- ```
133
- Extract high-confidence anomalies for medical specialist review.
134
-
135
- ### E-commerce Automation
136
- ```
137
- [Catalog Photo] → [Product Detection] → [CropBB: class="product"] → [Product Crops] → [Individual Listings]
138
- ```
139
- Automatically extract individual products from multi-product photos.
113
+ Save each defect crop with its tag in the file name.
140
114
 
141
115
  ## Common Issues & Troubleshooting
142
116
 
143
117
  ### No Crops Generated
144
- - **Issue**: Node outputs empty array despite detection data
145
- - **Causes**: Confidence threshold too high, incorrect data format, missing detection data
146
- - **Solution**: Lower confidence threshold, verify detection format, check input paths
118
+ - **Issue**: Empty array and the warning `No valid bounding boxes found ...`
119
+ - **Causes**: Min Confidence too high, boxes not in the `raw_boxes` form, or boxes that are rotated or have their corners in another order
120
+ - **Solution**: Lower Min Confidence, convert the detections to axis-aligned `raw_boxes` (top-left, top-right, bottom-right, bottom-left)
147
121
 
148
- ### Malformed Detection Data
149
- - **Issue**: Node warns about invalid box format
150
- - **Cause**: Detection data doesn't match expected 4-corner format
151
- - **Solution**: Verify AI model output format, transform data if needed
122
+ ### Wrong Paths
123
+ - **Issue**: `No image data found at ...` or `No bounding box data found at ...`
124
+ - **Solution**: Set **Input from** and **Bounding Boxes** to the `msg` properties that hold the image and the detections (defaults `msg.image` and `msg.default`)
152
125
 
153
- ### Poor Crop Quality
154
- - **Issue**: Crops appear pixelated or low quality
155
- - **Cause**: Source image resolution too low for detection boxes
156
- - **Solution**: Use higher resolution source images or adjust detection model
126
+ ### Encoded Image Rejected
127
+ - **Issue**: `cropBB requires raw images with width/height metadata`
128
+ - **Solution**: Decode the image first, for example with [image-in](../io/image-in.md), or keep Raw output in the node before
157
129
 
158
130
  ### Coordinate Issues
159
131
  - **Issue**: Crops appear in wrong locations or are empty
160
- - **Cause**: Coordinate system mismatch between detection model and expectations
161
- - **Solution**: Verify detection model uses normalized 0-1 coordinates
162
-
163
- ### Memory Usage
164
- - **Issue**: High memory usage with many detections
165
- - **Optimization**: Process images in smaller batches, use appropriate output formats
166
- - **Monitoring**: Monitor crop count and source image sizes
167
-
168
- ## Integration Patterns
169
-
170
- ### Computer Vision Pipeline
171
- ```
172
- Image → AI Detection → CropBB → Individual Analysis → Results Aggregation
173
- ```
174
- Standard computer vision workflow for object analysis.
175
-
176
- ### Quality Inspection System
177
- ```
178
- Product → Defect Detection → CropBB → Defect Classification → Pass/Fail Decision
179
- ```
180
- Automated quality control with defect analysis.
181
-
182
- ### Surveillance Processing
183
- ```
184
- Video Frame → Object Detection → CropBB → Tracking/Recognition → Alert System
185
- ```
186
- Security surveillance with object tracking.
187
-
188
- ### Medical Analysis Workflow
189
- ```
190
- Medical Image → AI Analysis → CropBB → Specialist Review → Diagnosis Support
191
- ```
192
- Medical imaging analysis with region extraction.
193
-
194
- ## Advanced Usage
195
-
196
- ### Dynamic Confidence Adjustment
197
- ```javascript
198
- // In function node before cropBB:
199
- // Adjust confidence based on detection class
200
- msg.detections.forEach(det => {
201
- if (det.class_name === 'person') {
202
- det.useConfidence = 0.8; // High confidence for people
203
- } else if (det.class_name === 'vehicle') {
204
- det.useConfidence = 0.6; // Medium confidence for vehicles
205
- } else {
206
- det.useConfidence = 0.5; // Default confidence
207
- }
208
- });
209
- ```
210
-
211
- ### Detection Filtering and Sorting
212
- ```javascript
213
- // Filter and sort detections before cropping
214
- msg.detections = msg.detections
215
- .filter(det => det.confidence > 0.7)
216
- .filter(det => ['person', 'car', 'truck'].includes(det.class_name))
217
- .sort((a, b) => b.confidence - a.confidence); // Sort by confidence descending
218
- ```
219
-
220
- ### Crop Size Validation
221
- ```javascript
222
- // Filter out crops that would be too small
223
- msg.detections = msg.detections.filter(det => {
224
- const box = det.box;
225
- const width = (box[2][0] - box[0][0]) * msg.image.width;
226
- const height = (box[2][1] - box[0][1]) * msg.image.height;
227
- return width > 50 && height > 50; // Minimum 50x50 pixels
228
- });
229
- ```
230
-
231
- ### Multi-Class Processing
232
- ```javascript
233
- // Process different classes with different settings
234
- const personDetections = msg.detections.filter(d => d.class_name === 'person');
235
- const vehicleDetections = msg.detections.filter(d => d.class_name === 'vehicle');
236
-
237
- msg.personCropSettings = { confidence: 0.8, outputFormat: 'png' };
238
- msg.vehicleCropSettings = { confidence: 0.6, outputFormat: 'jpg' };
239
- ```
240
-
241
- ## Best Practices
242
-
243
- ### Detection Data Quality
244
- - Ensure AI models output consistent coordinate formats
245
- - Validate detection data before processing
246
- - Handle edge cases (empty detections, malformed data)
247
- - Monitor detection confidence distributions
248
-
249
- ### Performance Optimization
250
- - Use appropriate confidence thresholds to reduce processing load
251
- - Process images at appropriate resolutions for your detection models
252
- - Use raw format for processing chains, encoded formats for final output
253
- - Consider batch processing for large image sets
254
-
255
- ### Quality Control
256
- - Implement validation checks for crop dimensions
257
- - Monitor crop quality and adjust source image resolution if needed
258
- - Set appropriate confidence thresholds for your use case
259
- - Test with representative data sets
260
-
261
- ### Error Handling
262
- - Implement fallback behavior for missing detection data
263
- - Handle coordinate validation errors gracefully
264
- - Log processing statistics for monitoring and optimization
265
- - Provide meaningful error messages for debugging
266
-
267
- ### Integration Strategy
268
- - Design detection data format standards for your pipeline
269
- - Implement confidence threshold tuning based on performance metrics
270
- - Consider storage and processing requirements for crop outputs
271
- - Plan for scalability with large detection volumes
132
+ - **Cause**: The detection uses pixel coordinates
133
+ - **Solution**: Divide the coordinates by the image width and height
@@ -0,0 +1,111 @@
1
+ ---
2
+ title: "Heat-Diff Node - Difference Heat Map of Two Images"
3
+ description: "Compute the per-pixel difference of two images in Node-RED as a color-mapped heat image, with optional difference statistics, SSIM and changed regions. Part of @rosepetal/node-red-contrib-image-tools."
4
+ head:
5
+ - - meta
6
+ - name: "keywords"
7
+ content: "node-red, heat-diff, image difference, heat map, golden image, change detection, ssim, psnr, opencv, rosepetal"
8
+ - - meta
9
+ - property: "og:title"
10
+ content: "Heat-Diff Node - @rosepetal/node-red-contrib-image-tools"
11
+ - - meta
12
+ - property: "og:description"
13
+ content: "Compute the per-pixel difference of two images in Node-RED as a color-mapped heat image, with optional difference statistics, SSIM and changed regions."
14
+ ---
15
+
16
+ # Heat-Diff Node
17
+
18
+ > **Type**: `rp-heat-diff` · **Category**: Specialized · **Since**: v1.5.1
19
+
20
+ ## Overview
21
+
22
+ Heat-Diff compares two images pixel by pixel: it takes the absolute difference of their grayscale versions, optionally blurs it and suppresses small values, and returns it as a heat map in a chosen colormap. It can also measure the difference (mean, maximum, percentiles, RMSE, PSNR, SSIM, share of changed pixels and the changed regions), with or without the heat image.
23
+
24
+ **Use cases**
25
+ - Compare each product image with a golden image and see where they differ
26
+ - Decide pass or fail from `changedRatio`, `maxDiff` or the largest changed region, without rendering an image
27
+ - Check the result of [image-align](./image-align.md) before comparing
28
+
29
+ ## Inputs
30
+
31
+ Only `msg` properties are read for the images: the editor also offers `flow` and `global`, but the node reads the typed text as a `msg` path.
32
+
33
+ - **Image 1** (`msg.payload` by default) and **Image 2** (`msg.goldenImage` by default): raw image objects or encoded JPEG/PNG/WebP/BMP `Buffer`s, in any color space. Both may also be arrays of the same length: the images are then paired by index, compared in parallel, and the outputs become arrays in the same order.
34
+ - Images of different sizes are both scaled (without keeping the aspect ratio) to the largest width and height of the two.
35
+
36
+ ## Outputs
37
+
38
+ One output.
39
+
40
+ - **Output** (`msg.payload` by default; a `msg` property): the heat image, a 3-channel image (`colorSpace` `BGR` in raw form) of the compared size, or an encoded `Buffer`. With **Heat Image** off, Output is left untouched.
41
+ - **Stats to** (`msg.diffStats` by default; `msg`, `flow` or `global`), with **Statistics** on:
42
+
43
+ ```javascript
44
+ {
45
+ validRatio: 0.98, // share of pixels compared (see below)
46
+ changedRatio: 0.012, // share of compared pixels whose difference is above Threshold
47
+ meanDiff: 3.4, // mean difference, 0-255
48
+ maxDiff: 187, // largest difference
49
+ p50: 2, p95: 11, p99: 40, // difference percentiles
50
+ rmse: 6.1,
51
+ psnr: 32.4, // dB; 100 when the images are identical
52
+ ssim: 0.97, // null when SSIM is off
53
+ threshold: 25,
54
+ blobCount: 3, // connected regions of changed pixels
55
+ largestBlobArea: 412, // pixels
56
+ blobs: [ { x, y, w, h, area, cx, cy }, ... ] // up to 50 regions, largest first, in pixels
57
+ }
58
+ ```
59
+
60
+ Pixels that are pure black (0) in either grayscale image are left out of every statistic: they are usually the borders of an alignment or the padding of a composite. Their difference is also set to 0 before the blur, so a black border does not spread into the pixels next to it. `validRatio` is the share of pixels that remain. The statistics are computed on the difference after Blur and Threshold, except SSIM, which compares the two grayscale images.
61
+
62
+ - `msg.performance.rpimage.<key>`: `{ conversion, task, total }` in milliseconds.
63
+ - On failure: `msg.error` (`message`, `operation`, `hint`, `details`, `timestamp`, `nodeId`, `nodeName`, `nodeType`), with Image 1 written to **Output**; the message is still sent.
64
+
65
+ ## Configuration
66
+
67
+ | Field | Type | Default | Description |
68
+ |---|---|---|---|
69
+ | Name | string | empty | Label of the node; also the key of its timings in `msg.performance.rpimage` |
70
+ | Image 1 | msg path | `msg.payload` | First image (for example the capture) |
71
+ | Image 2 | msg path | `msg.goldenImage` | Second image (for example the golden image) |
72
+ | Heat Image | boolean | on | **Render the heat map (off = statistics only)**. Off also turns Statistics on |
73
+ | Output | msg path | `msg.payload` | Where the heat image is written |
74
+ | Output Format | enum | Raw (fastest) | Raw (fastest), JPEG, PNG or WebP, with Quality (`90`), PNG Optimize and the WebP options as in [resize](../transform/resize.md#output-format-options) |
75
+ | Statistics | boolean | on | **Compute diff statistics** |
76
+ | Stats to | TypedInput (msg/flow/global) | `msg.diffStats` | Where the statistics are written |
77
+ | SSIM | boolean | on | **Compute SSIM (dominates the stats cost)**: structural similarity with an 11 × 11 Gaussian window |
78
+ | Debug / Debug Width | boolean / number | off / `200` | **Show processed image** under the node in the editor |
79
+ | Colormap | enum | Jet | Jet, Hot, Inferno, Turbo, Bone, Cool, Rainbow, Ocean, Pink or HSV (the OpenCV colormaps of those names) |
80
+ | Blur | number | `0` | Gaussian blur of the difference: kernel size, made odd; 0 = off. Number, or read from `msg`, `flow` or `global` |
81
+ | Threshold | number | `0` | 0-255: differences at or below it are set to 0, and only larger ones count as changed. Number, or read from `msg`, `flow` or `global` |
82
+
83
+ The status shows a green dot `OK: <n> img in <t> ms (conv <c> ms | task <k> ms)`, where `<n>` is the number of pairs, and a red ring `Error: <first 30 characters>` after a failure. Failures include `image1 and image2 must both be single images or both be arrays`, `Image arrays must be non-empty and of equal length (got <a> and <b>)`, `First image input is invalid or missing` and `Second image input is invalid or missing`.
84
+
85
+ ## Examples
86
+
87
+ ```
88
+ [camera] → [rp-image-align: reference golden] → [Change: msg.goldenImage = golden] → [rp-heat-diff: Threshold 25, Blur 5] → [rp-image-out]
89
+ ```
90
+
91
+ Aligns each capture with the golden image, then saves a heat map of what changed; small differences from noise are suppressed.
92
+
93
+ ```
94
+ [camera] → [rp-heat-diff: Heat Image off, SSIM off, Threshold 30] → [Switch: msg.diffStats.largestBlobArea > 200] → [reject]
95
+ ```
96
+
97
+ Statistics only: rejects a part when a changed region larger than 200 pixels appears.
98
+
99
+ ## Troubleshooting
100
+
101
+ - **The whole heat map is bright** — Cause: the images are not aligned, or differ in exposure. · Solution: align them first with [image-align](./image-align.md); raise Threshold.
102
+ - **`validRatio` is low** — Cause: large black areas (alignment borders, padding, dark backgrounds) are left out of the statistics. · Solution: expected for black borders; for dark scenes, keep in mind that pixels of value 0 are never compared.
103
+ - **`changedRatio` counts noise** — Cause: Threshold is 0, so any difference counts. · Solution: set Threshold, or Blur, to ignore small differences.
104
+ - **Statistics are slow** — Cause: SSIM costs more than all other statistics. · Solution: turn SSIM off when it is not used.
105
+ - **`Second image input is invalid or missing`** — Cause: Image 2 is not at `msg.goldenImage`. · Solution: point Image 2 at the `msg` property that holds the golden image.
106
+
107
+ ## See Also
108
+
109
+ - [image-align](./image-align.md): align the two images before comparing them
110
+ - [blend](../blend/blend.md): overlay the heat map on the original image
111
+ - [cropBB](./cropBB.md): cut out regions for closer inspection