## 3 Implementation of the Model-Based Algorithm and the Experimental Setup  
### Numerical Implementation of the Algorithm  
The model-based wedge detection algorithm is implemented in the programming language _Python_. The steps to determine the position \(x_{i}\), the size parameters \((h_{i},w_{i})\) and the area \(A_{i}\) of each turbulence wedge are outlined in a flowchart in Figure 5.  
As a first step, either the simulated thermogram is created or the recorded thermogram of the wind turbine blade is loaded. The loaded thermogram is then preprocessed, which includes an optional normalization of the thermogram intensities by the maximum intensity as well as an image rotation. The rotation aligns the natural transition line of the thermogram horizontally, which simplifies the calculation of the correlations as the \(y\)-positions of the line remain constant. To determine the rotation angle, the \(y\)-positions of the natural transition line \(y_{\text{NT}}\) are at first detected in the unprocessed thermogram, using the classical gradient-based method described in Section 2.2. Using the coordinates of the natural transition line, the rotation angle \(\varphi\) is calculated according to  
\[\varphi=\arctan\biggl{(}\frac{y_{\text{NT}}(x_{\text{end}})-y_{\text{NT}}(x_{ 0})}{x_{\text{end}}-x_{0}}\biggr{)}, \tag{10}\]where \(y^{\text{NT}}(x_{\text{end}})\) and \(x_{\text{end}}\) are the last coordinates of the natural transition line and \(y^{\text{NT}}(x_{0})\) and \(x_{0}\) are the first coordinates of the natural transition line in the original, i.e., non-rotated thermogram. The whole thermogram is rotated by the angle \(\varphi\) using the _rotate_ functionality from the _Python Image Library_ (PIL). Note that the image rotation is not necessary for simulated images, where the natural transition line is already aligned horizontally. The preprocessing also includes the determination of the angle \(\alpha_{i}\) of the turbulence wedges, which is currently the only manually estimated input parameter for the wedge detection algorithm. However, \(\alpha_{i}\) remains the same for all turbulence wedges until the flow condition changes at which the thermograms are captured. After the preprocessing, the \(y\)-positions of the leading edge \(y_{\text{LE}}\) and the trailing edge \(y_{\text{TE}}\), as well as the natural transition line \(y_{\text{NT}}\), are detected in the thermogram by using the gradient-based method introduced in Section 2.2. The values obtained by the gradient-based method are fitted with a linear regression using the _RANSAC_ algorithm of _Python_'s _sklearn_ library. To use the leading edge and the natural transition line in the wedge detection algorithm, the \(y\)-position values are rounded to the next integer. With the \(y\)-positions of the leading edge and the natural transition line, the maximum height \(h_{\text{max}}\) of the turbulence wedges is calculated according to  
\[h_{\text{max}}=\langle y_{\text{LE}}(x)-y_{\text{NT}}(x)\rangle, \tag{11}\]  
where the mean is taken over all \(x\)-positions. As the next step, the wedges and their \(x\)-positions \(x_{i}\) are detected along the natural transition line by cross-correlating the thermogram with the wedge-shaped templates, see Section 2.3.2. For the position detection, \(J\in\mathbb{N}\) differently sized templates with running template index \(j\) are randomly generated, where \(J=100\) is the default value. The templates' heights \(h_{j}^{\prime}\) are drawn from a uniform distribution in the interval \([0.5\cdot h_{\text{max}},0.95\cdot h_{\text{max}}]\). This interval has proven adequate for detecting wedges in real thermograms, but the interval can also be adapted to any values in \((0,h_{\text{max}}]\) if needed. The investigation of real thermograms (see Section 3.2) has further shown that the height-to-width ratio of real turbulence wedges is, on average, \(\langle h_{i}/w_{i}\rangle=3\).