## 3 Materials and Methods
### Evolutionary Grid Optimization and Computer Vision Techniques for Petri Dish Detection
#### 3.3.1 Petri Dish Preprocessing for Fitness Function Evaluation  
Image processing is required to extract the underlying pattern as a binary mask of the grid, which allows a fitness calculation of an error between the preprocessed image and a candidate. This error is defined by the inverted Dice coefficient between the candidate's estimated grid and the preprocessed image's actual grid structure [22]. Multiple preprocessing steps are performed to create the required binary mask. First, Hough Circle extraction is applied to detect the Petri dish itself [23]. Second, a filter mechanism identifies parts of the actual grid lines that are further used for Hough Line detection to estimate the entire grid in the image. Multiple parameter values and parameter sets were compared to validate the used parameters and evaluate the robustness of the workflow. The evaluations for each preprocessing step are based on the fitness function. The final extracted grid is additionally evaluated based on a ground truth grid and the Dice coefficient. The extraction of the Petri dish is done by detecting the dish's circular outer border with the Hough Circle algorithm. After blurring the image for improved edge detection, a stable threshold for the Canny edge detection, accumulator threshold, and suitable minimum/maximum radius sizes are determined manually based on unseen images used only for training and parameter evaluation (Canny threshold: 125, accumulator threshold: 200, radius (min): 37.5%, radius (max): 75%). The size of the image itself defines the radius size to stay independent for different cameras, allowing better adaptability. Due to the thickness of the border of the Petri dish, multiple Hough Circles are detected and filtered by defining a minimum circle distance, eliminating neighboring circles. To further increase robustness, based on the ratio of the image shape and center, circles outside of a predefined area are discarded. An evaluation of metaparameters was applied to show the applicability of multiple parameter sets and to extract the best metaparameters. Multiple settings for the Hough Circles Canny edge detection thresholds were used, and the mentioned minimum and maximum radius were evaluated. Finally, if multiple fitting circles are proposed by the algorithm, the best-fitting circle is chosen based on the highest sum of intensity covered by the proposed circle region. A similar approach used in previous research provides reasonable results also on different resolutions and positions of the Petri dish within the image, showing its robustness and applicability on a slightly changed setup [13]. For the extraction of the grid structure, it is necessary to extract as many lines as possible while reducing noise, false positives, and artifacts. Therefore, the lines are detected using a combination of edge and line detection with Hough Lines. First, intensity equalization is applied with CLAHE to increase the contrast and emphasize the brighter lines (and their edges) of the Petri dish in the image. For the detection of the lines, edge detection is applied. Due to the thickness of the grid lines, multiple edges are detected for a single grid line, which are merged into a single thicker line using closing as morphological operations. Figure 3: Overview of steps for the evolution strategy. 1: Extracted Petri dish with Hough Circles (insufficient extraction of grid cells), 2: Extracted Hough Lines 3: grid of a solution candidate, 4: Compute fitness of solution candidates with overlap based on Dice coefficient, 5: Final results. Hough Line detection is applied to extract lines only based on the extracted edges of cells within the compartment. The minimum length and maximum gap are a priori defined for the Hough Line extraction to allow a robust line extraction parameter like an accumulator threshold. All parameters are derived based on ratios compared with the overall size of the taken image to allow size-independent execution of the line extraction.