Adaptive
AI-generatedOverview
This node integrates OpenCV.js functionality into n8n workflows, enabling advanced image processing directly within automation pipelines. It supports multiple OpenCV modules such as thresholding, color modifications, blurring, edge detection, morphological operations, contours, binary operations, and image statistics.
The Adaptive operation specifically applies adaptive thresholding to an input image. Adaptive thresholding is useful when the lighting conditions in an image are non-uniform, allowing for local threshold values to be computed dynamically based on pixel neighborhoods rather than a single global threshold. This makes it ideal for preprocessing images before further analysis, such as OCR, object detection, or segmentation tasks.
Practical examples:
- Enhancing scanned documents with uneven illumination by converting them to high-contrast black-and-white images.
- Preparing images of handwritten notes for better recognition by isolating text from background shadows.
- Segmenting objects in photos taken under varying light conditions for computer vision applications.
Properties
| Name | Meaning |
|---|---|
| Input Image Field Name | The name of the binary property in the input data that contains the image to be processed. This must be an image stored in binary format. |
| Module | The OpenCV module to use. For this operation, it is fixed to "Thresholding" (adaptive thresholding). Other modules include Binary Operations, Blurring, Color Modifications, Contours, Edge Detection, Image Stats, Morphological. |
| Block Size | Size of the pixel neighborhood used to calculate the threshold value for each pixel. Must be an odd number (e.g., 3, 5, 7). |
| C | A constant subtracted from the mean or weighted mean calculated over the neighborhood. Controls the thresholding sensitivity. |
| Advanced Options | Collection of optional parameters: |
| - Output Image Field Name | The name of the binary property where the output image will be stored. Defaults to "out". |
Output
The node outputs the processed image as a binary property in the output data. The property name can be customized via the "Output Image Field Name" advanced option (default is "out"). The output image represents the result of the adaptive thresholding operation, typically a binary (black and white) image highlighting features based on local pixel intensity variations.
No other JSON fields are explicitly added by this operation.
Dependencies
- Requires OpenCV.js runtime initialized in the environment.
- No external API keys or services are needed; all processing is done locally using OpenCV.js.
- The node expects input images to be provided as binary data within the workflow.
Troubleshooting
- Input image missing or invalid: Ensure the specified "Input Image Field Name" exists in the incoming data and contains valid image binary data.
- Block Size not odd: The block size parameter must be an odd integer. Using even numbers may cause errors or unexpected results.
- Incorrect property names: Double-check the spelling and case of input/output binary property names.
- Large images performance: Processing very large images may be slow or consume significant memory due to client-side JavaScript execution.
- Empty output: If the output image is empty or unchanged, verify that the input image is correctly loaded and that parameters like block size and C are set appropriately.