## 4 Synthetic Data Generation
### Scene Simulation and Ballast Data Rendering
#### 4.3.2 Rendering  
The data generation pipeline enters the rendering stage after the physical scene is fully simulated and every object within the scene is in a stable status. The rendering engine used is Cycles [32], Blender's physical-based path tracer for product rendering. A new rendering technique, adaptive texture mixing, was designed and adopted to make the scene renders more natural and closer to the field-collected images. This technique was used in addition to regular rendering techniques, such as smart UV mapping for fitting the same texture to different objects, adjustable environment mapping for lighting condition randomization, and bumps and displacements [33] for realistic terrain surface rendering.  
Before rendering, each ballast particle together with the fine material surface was assigned a random texture selected from a human-pre-screened texture library, which included 25 textures for the ballast particles and 38 textures for the fine material. A direct rendering with the assigned textures would result in unnatural outcomes (Figure 4e-g), because in real-world scenarios, ballast particles would seldom be clean on the surface. Fine materials would adhere to the surface of the ballast particles, especially under the effect of moisture. Thus, an adaptive texture mixing approach was designed to serve this purpose (Figure 4h).  
When employing adaptive texture mixing, the texture of ballast particles was combined with that of the fine material through a randomly generated noise mask, guided by input parameter '\(r\)'. This parameter '\(r\)' is related to the percentage of the particle surface area covered by fine materials. Figure 5 illustrates the progressive alteration in the rendering of a ballast particle as '\(r\)' increases during the texture-mixing step depicted in Figure 4h.  
The implementations for the adaptive texture mixing can vary, as long as they ensure the rule that a larger parameter '\(r\)' results in a larger rate at which the ballast particle surface is covered with fine materials. Equation (5) shows an example implementation of the adaptive texture mixing used for Figure 5:  
\[m(c,\ r)=\min\{1,\ r+r\times N(c)\} \tag{5}\]  
where \(N(c)\) is a randomly generated noise mask taking input point coordinate \(c\) and providing a random number ranging from 0 to 1. The result, \(m(c,\ r)\) of Equation (5),ranging from 0 to 1, stands for the texture mixing rate of the point '\(c\)' under the input parameter '\(r\)'. Then, the final texture \(T\) of point '\(c\)' in the output image will result in a mix of coarse ballast texture \(T_{coarse}\) and fine material texture \(T_{fine}\), following Equation (6) during rendering.  
\[T=m\times T_{fine}+(1-m)\times T_{coarse} \tag{6}\]  
During synthetic ballast generation, larger '\(r\)' values were assigned to ballast scenes exhibiting higher fouling conditions, thereby more accurately mirroring the appearance of field ballast.  
Figure 6 presents examples of synthetic ballast images generated by the proposed rendering method with different configurations of light conditions, particle size distributions, and textures of ballast particles and fine material surfaces.