Image Preprocessing

You are currently viewing the documentation for the latest version (2.2.0). To access a different version, click the "Switch version" button located in the upper-right corner of the page.

■ If you are not sure which version of the product you are currently using, please feel free to contact Mech-Mind Technical Support.

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:

For details about preprocessing method selection, see Method Selection Guide.

Output Description

The output is the image after preprocessing.

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.

  • If a large number of preprocessing methods need to be added to achieve acceptable results, the root cause is usually poor image quality, rather than improper preprocessing methods. In this case, it is recommended to optimize the image acquisition conditions first rather than adding too many preprocessing methods.

  • It is usually recommended to limit the number of preprocessing methods to 2 or 4. Too many preprocessing methods will make debugging more difficult and may introduce other problems.

Image Issue Recommended Method Description

Image looks gray (or has low contrast), and the target region is difficult to distinguish from the background region.

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.

  • CLAHE: Enhances image contrast using Contrast Limited Adaptive Histogram Equalization (CLAHE). It is suitable for images with insufficient local contrast, while avoiding the over-enhancement of traditional histogram equalization.

    • Clip Limit: Limits the mode gray value of local histograms to prevent excessive contrast enhancement. A larger value results in a stronger enhancement effect.

  • Sharpening: Enhances edges and details for a clearer image.

    • X-Direction Window Size: Specifies the window size for X-direction filtering. A larger window produces softer sharpening effects.

    • Y-Direction Window Size: Specifies the window size for Y-direction filtering. A larger window produces softer sharpening effects.

    • Sharpening Strength: Controls how strongly sharpening is applied. Higher values produce clearer edges and details, but may increase noise.

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.

Median Filter

Replaces the value of each pixel with the median of the pixel and its neighbors to effectively reduce noise in the image, especially salt and pepper noise (typically appearing as random black and white points). When using this method, you should set the Kernel Size parameter.

Mean Filter

Replaces the value of each pixel with the mean of the pixel and its neighbors, thereby smoothing the image and reducing random noise. When using this method, you should set the Kernel Size parameter.

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:

  • Rectangle: Use a regular rectangular region.

  • Cross: Suitable for processing linear structures.

  • Ellipse: Suitable for edge smoothing and fine transformation.

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:

  • Rectangle: Use a regular rectangular region.

  • Cross: Suitable for processing linear structures.

  • Ellipse: Suitable for edge smoothing and fine transformation.

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:

  • Rectangle: Use a regular rectangular region.

  • Cross: Suitable for processing linear structures.

  • Ellipse: Suitable for edge smoothing and fine transformation.

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:

  • Rectangle: Use a regular rectangular region.

  • Cross: Suitable for processing linear structures.

  • Ellipse: Suitable for edge smoothing and fine transformation.

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:

  • Canny high threshold: Determines the reliability and continuity of the detected edges. A higher value implies fewer pixels recognized as edge points.

  • Canny low threshold: Defines the lower sensitivity limit for edge detection. Lowering this value detects more faint or blurred edges.

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.

Is this page helpful?

You can give a feedback in any of the following ways:

We Value Your Privacy

We use cookies to provide you with the best possible experience on our website. By continuing to use the site, you acknowledge that you agree to the use of cookies. If you decline, a single cookie will be used to ensure you're not tracked or remembered when you visit this website.