Image Preprocessing
Description
Use this Step to preprocess the input image, including enhancement, denoising, morphological transformations, grayscale inversion, and edge extraction. By combining multiple preprocessing methods flexibly, the image quality can be effectively improved, laying the foundation for subsequent vision tasks such as feature extraction and object detection.
Usage Scenario
This Step is suitable for scenarios where image quality needs to be improved and image features need to be highlighted. It is usually used as a preprocessing step for image analysis and works with subsequent Steps such as feature extraction and object detection.
Input Description
The input is the image to be processed.
In addition, if you need to adjust the ROI pose in sync with the target object’s pose transformation, you can input the Alignment Parameter Group.
Parameter Description
| Parameter | Description | ||
|---|---|---|---|
ROI Settings |
The ROI is used to define the area for image preprocessing. If no ROI is set, the Step will process the entire image. See ROI Settings to learn how to set and adjust the ROI. |
||
Preprocessing Methods |
Click the Open the editor button, and select and add up to 10 preprocessing methods. These methods can be flexibly combined to meet different task requirements. The currently supported preprocessing methods are as follows:
|
Method Selection Guide
Multiple preprocessing methods may overlap in functions and should be selected according to the actual image problems. Identify the main problem first, and then select the corresponding method to improve debugging efficiency.
|
| Image Issue | Recommended Method | Description |
|---|---|---|
Image looks gray (or has low contrast), and the target region is difficult to distinguish from the background region. |
CLAHE in Contrast Enhancement If there is only an overall lack of contrast, try histogram equalization or linear transformation. |
When lighting is uneven, CLAHE is usually the preferred method. If the image contains prominent highlights or reflective areas, avoid setting the enhancement strength too high in the initial stage, as this may amplify both noise and reflections. |
The image is generally dark or bright, but the target shape is still recognizable. |
If you also need to adjust the contrast simultaneously, you can use it with Linear Transformation. |
Gamma correction is mainly used to deal with situations where the brightness distribution is not ideal and is not suitable for noise suppression. If the main issue is noise interference, it is usually recommended to reduce noise first and then adjust the brightness. |
A small number of isolated bright or dark dots are scattered in the image, similar to black-and-white speckles. |
This method usually has a better effect on noise suppression. If such noise remains noticeable after applying the Gaussian or mean filter, the median filter is usually recommended. |
|
The image contains obvious noise, and edge extraction is required in subsequent processing. |
Gaussian filter usually strikes a good balance between noise removal and edge preservation. If Canny edge detection is required later, performing lightweight Gaussian filter first usually helps improve stability. |
|
Only overall image smoothing is needed, and edge detail is not critical. |
Mean filter is simple to implement, but it usually has a more pronounced effect on edge smoothing. In scenarios requiring high measurement or positioning accuracy, it is usually recommended to compare the performance of Gaussian filter or median filter first. |
|
In the binary image, the target edge has small burrs or a small amount of surface noise. |
Opening is usually more suitable for removing small protrusions and local noise. If the target is relatively thin, avoid using an excessively large kernel size, as it may weaken important structural details. |
|
In the binary image, the target has small internal holes or small gaps on the edges. |
Closing is usually more suitable for filling small holes and connecting locally broken edges. If the holes themselves are valid features, use closing with caution. |
|
The target region is thin with weak local connectivity, and better region continuity is expected. |
Dilation expands the target region. If subsequent dimensional measurement is required, make sure that this operation will not affect the measurement result by extending the target edge. |
|
The target edge is thick, or redundant outer regions are present, and edge shrinkage is desired. |
Erosion will shrink the target region. If the target is relatively thin, or the spacing between targets is small, excessive erosion may cause the targets to break apart. |
|
The light-dark relationship in the current image is opposite to the requirement of subsequent processing. |
This method is suitable for turning dark targets into bright targets or adjusting the grayscale relationship between the foreground and background. If subsequent Steps use bright targets as foreground by default, grayscale inversion is usually more straightforward than repeatedly adjusting the threshold. |
|
You only need to quickly obtain target edges for coarse positioning or result preview. |
Sobel edge detection in Edge Extraction. |
Sobel edge detection is faster at computation but usually more sensitive to noise. If the image stability is poor, it is recommended to perform lightweight noise removal first. |
Target edges need to be as clean and accurate as possible for subsequent precise positioning or measurement. |
Canny edge detection in Edge Extraction. |
Canny edge detection is usually more stable than Sobel edge detection, but it is more expensive to adjust parameters and the calculation speed is relatively slow. If the edge result is not continuous, perform denoising first, and then gradually adjust Canny low threshold. |
Target edges need to be as continuous and smooth as possible to reduce breaks or jaggedness. |
Edge drawing detector in Edge Extraction. |
This method is more suitable for scenarios requiring edge continuity. If the scenario prioritizes processing speed over edge continuity, it is generally preferable to compare the performance of Sobel or Canny edge detection methods. |
Appendix: Preprocessing Methods
Image Enhancement
This type of method enhances image contrast and brightness, making details more visible.
Contrast Enhancement
| Parameter | Description |
|---|---|
Enhancement Method |
You can select CLAHE or Sharpening.
|
Histogram Equalization
Enhances the image contrast. There is no need to set parameters for this method.
Gamma Correction
Adjusts image brightness according to the gamma value. Gamma Value: Controls the gamma correction level. A gamma value greater than 1 brightens dark regions, and a gamma value less than 1 darkens bright regions.
Linear Transformation
Performs a linear stretch on each pixel value in the image to adjust contrast and brightness, thereby effectively improving the visual quality of the image.
| Parameter | Description |
|---|---|
Scale Factor |
Controls the image contrast. A value greater than 1 increases contrast; a value less than 1 decreases contrast. |
Pixel Value Offset |
Controls the image brightness. A positive value makes the image brighter; a negative value makes it darker. |
Image Denoising
This kind of method removes random noise in images and retains valid information.
Gaussian Filter
Effectively removes certain noise from the image to smooth the image while preserving edges and details as much as possible. It is commonly used for image smoothing, noise reduction, and preprocessing before edge detection.
| Parameter | Description |
|---|---|
X-Direction Window Size |
Specifies the window size for X-direction filtering. |
Y-Direction Window Size |
Specifies the window size for Y-direction filtering. |
Sigma X |
Sigma in the X direction for Gaussian filter. |
Sigma Y |
Sigma in the Y direction for Gaussian filter. |
Morphological Transformations
This type of method can adjust the image structure to remove noise or fill holes.
Erosion
Removes small objects or noise in the image to make the image clearer.
| Parameter | Description |
|---|---|
Kernel Size |
Defines the scope of the operation. The larger the kernel, the more pixels are affected by each operation. |
Kernel Shape |
Specifies the distribution pattern of valid pixels within the kernel, including:
|
Dilation
Fills small holes in an image to make the image more complete.
| Parameter | Description |
|---|---|
Kernel Size |
Defines the scope of the operation. The larger the kernel, the more pixels are affected by each operation. |
Kernel Shape |
Specifies the distribution pattern of valid pixels within the kernel, including:
|
Opening
Essentially erosion followed by dilation. It can remove small noise in the image while preserving object edges and main structural features.
| Parameter | Description |
|---|---|
Kernel Size |
Defines the scope of the operation. The larger the kernel, the more pixels are affected by each operation. |
Kernel Shape |
Specifies the distribution pattern of valid pixels within the kernel, including:
|
Closing
Essentially dilation followed by erosion. It can fill small holes and smooth edges, effectively addressing the problem of rough edges caused by noise.
| Parameter | Description |
|---|---|
Kernel Size |
Defines the scope of the operation. The larger the kernel, the more pixels are affected by each operation. |
Kernel Shape |
Specifies the distribution pattern of valid pixels within the kernel, including:
|
Other
This kind of method highlights the target region in an image to facilitate subsequent segmentation and recognition.
Grayscale Inversion
Inverts the gray value of each pixel in the image, turning bright areas dark and dark areas bright, thereby highlighting certain features.
Edge Extraction
Uses edge detection methods to extract image edges. Please set relevant parameters according to the selected Edge Detection Method.
| Edge Detection Method | Parameter Settings |
|---|---|
Sobel edge detection |
Detects edges by computing pixel value gradients. It provides fast and coarse edge localization, but is sensitive to noise. No other parameters need to be set when this method is selected. |
Canny edge detection |
Detects edges by computing pixel value gradients after denoising. It provides accurate and fine-grained edge localization, but at a lower processing speed. When selecting this method, set Canny High Threshold and Canny Low Threshold:
|
Edge drawing detector |
Detects continuous and smooth edges. No other parameters need to be set when this method is selected. |
Troubleshooting
|
For common errors, see Error Code List. |