## 3 Materials and Methods
### Evolutionary Grid Optimization and Computer Vision Techniques for Petri Dish Detection
#### 3.3.2 Solution Candidate Definition and Grid Optimization  
Due to missing or incomplete grid lines, shown in Figure 3 in the extracted binary mask, the grid has to be extrapolated or estimated. Therefore, an evolution strategy is used to approximate the entire grid. As long as the underlying structure of the grid is visible within the extracted binary mask (a minimum of 50% vertical and horizontal lines), this mask can be used for highly accurate grid estimations using our evolution strategy. The overall idea is to use solution candidates, which represent the parameters used in grid reconstruction. The solution candidate grid is evaluated through the binary image used in the fitness function and adapted in the strategy mutation step. A solution candidate represents a grid with horizontal and vertical lines over the whole image defined by a certain distance between each line (shown in Figure 3 sub-image 3). Each solution candidate results in the grid estimation of the grid structure within the Petri dish. Each solution candidate is, therefore, defined by four mutable parameters and one fixed parameter spanning the estimated grid image. This fixed parameter is the width of the line drawn into the estimated image to span the grid. The four mutable parameters are loosely based on affine transformation parameters, which allow the manipulation of the grid while preserving the underlying structure. Our grid candidates are defined by the following parameters:  
* Rotation: rotation of the image to a horizontal line. * Scaling: width of an engraved grid cell (without borders). * Vertical offset: vertical translation of the grid regarding the top image border. * Horizontal offset: horizontal translation of the grid regarding the left image border. With these parameters, the candidates are generated. The initial configuration of these parameters is randomly set within a certain range of valid values. Valid values are defined by a maximum rotation (4 degrees), a minimum distance between lines (150 pixels), and a predefined grid thickness (31 pixels). These values can be changed for different setups or alternatively ignored, resulting in slower convergence. The fitness of each candidate is defined as the inverted Dice coefficient calculated between the solution candidate grid image (sub-image 3 in Figure 3) and the image with the extracted grid lines represented by Hough Lines in the extracted binary image (sub-image 2 in Figure 3). The used formula for the fitness function defined by the dice coefficient is shown in Equation (1). The calculated error given by the Dice coefficient between the predicted grid of the solution candidate and the extracted lines of the preprocessed petri dish image directly translates to mismatched pixels of unmatched lines. By adapting the grid through mutation operations in the solution candidate, an error reduction can be achieved over multiple generations by increasing the overlap between the lines in the extracted binary mask and the estimated grid of the solution candidate. Due to the repetitive pattern, a gradual improvement of the estimated grid is possible until the candidate's fitness can no longer be improved. For the adaptation of sigma and the generation of a new population, the one-fifth rule was used. Two approaches were used for the evaluation of the grid prediction results. Important metaparameters for the ES are population size, starting \(\sigma\), and maximum iterations needed. First, different metaparameters of the evolution strategy were evaluated based on the fitness score to evaluate the most important parameters and best parameter set. Second, the predicted grids with their corresponding metaparameter sets were evaluated based on a handcrafted ground truth image  
\[FitnessFunction=1-\frac{2*TP}{2*TP+FP+FN} \tag{1}\]  
where Dice coefficient is defined by TP: true positive; FP: false positive; and FN: false negative. The candidate parameters are used to draw the estimated grid into a blank image.