- Altering the threshold values and parameters in rule-based algorithms can have a significant impact on production. Our goal was to improve the performance and efficiency of such algorithms through the automatic optimization of these parameters.

- We called the image processing program implemented in Halcon from Python so that we could calculate the loss function from the output image. Based on the loss function, Bayesian optimization of the parameters using Optuna was performed, enabling efficient parameter search.

- By automating the search of parameters, we made it possible for the optimal parameters to be found by simply executing the program and waiting.

The performance of many algorithms is highly dependent on the value of their parameters. There are categorical parameters (e.g., selecting between a simple thresholding method and Otsu’s method in the case of binarization) and numerical parameters (e.g., selecting a specific threshold value in the range of 0 to 255 in the case of binarization), and depending on the complexity of the algorithm in question, the number of possible combinations may be innumerable.

In practice, the search of any set of parameters whose number of possible combinations exceeds a 40-digit number for the image processing algorithm implemented by Halcon had to be performed manually. Moreover, users had to alter the parameters, run the algorithm again, and conduct a visual check of the output images to compare the quality of the different images.

Rule-based algorithms are usually associated with the following three issues.

- The quality of the parameters used in rule-based algorithms needs to be determined by making a visual comparison of the output images.
- Each time the program has finished running after several minutes, the results need to be checked and the program executed again.
- Searching parameters manually is not comprehensive and is highly inefficient.

We were able to improve the performance of the image processing algorithm by calling the Halcon program with Python, evaluating the algorithm based on the loss function, and optimizing its parameters using Optuna. The image processing program implemented by Halcon is called from Python to calculate the loss function from the output image. The parameters are then optimized using Optuna. As a result, we were able to efficiently search parameters whose number of possible combinations exceeds a 40-digit number and automatically find parameters that yield better output images than before.