## 4 Synthetic Data Generation
### Scene Simulation and Ballast Data Rendering
#### 4.3.1 Physical Simulation  
The physical simulation was performed using Blender software [20], which internally adopts the Bullet physics engine [29], a free and open-sourced development kit for real-time collision detection and multi-physics simulation. Ballast particles in a railroad track lie stably on the underlying sub-ballast or subgrade layer under the effects of gravity. Under repeated train loading, ballast particles will degrade and may break into smaller particles. Therefore, the particle size distribution (PSD) indicates the fouling condition of the ballast. The shape of each ballast particle within the scene was randomly selected from the prepared meshes of 120 ballast particles. Each scene was assigned a target number of ballast objects (in the range of 400-600), and these ballast objects were properly scaled to satisfy the target PSD, to simulate various fouling conditions. Since applying physics simulation on such a number of objects with sophisticated meshes can be extremely resource-intensive, the ballast objects were represented by a simplified mesh (~100 facets left) with the decimation algorithm [30] until final rendering, a trade-off between precision and efficiency. When the simulation started, ballast particles over 3/8 in. (9.5 mm) first started free-falling from different random heights without overlapping (Figure 4b) to a 3.3 ft \(\times\) 3.3 ft (1 m \(\times\) 1 m) sub-ballast or subgrade plane surrounded by transparent walls of 6.6 ft (2 m)  
Figure 4: Generation of synthetic ballast data. (**a**) Initialize base container. The bottom of the container is 3.3 ft \(\times\) 3.3 ft (1 m \(\times\) 1 m), and the transparent walls of the container are 6.6 ft (2 m) in height. (**b**) Generate particles \(>\)3/8 in. (9.5 mm) according to the input particle size distribution (PSD) and freely release them from random locations inside the container without overlapping under gravity. (**c**) Shake the container by periodically changing the direction of the gravity to ensure uniform mixing of the ballast particles. (**d**) Calculate the height of the fine surface according to the input PSD, then add the fine surface of the same size as the bottom of the container to the scene. (**e**) Place a camera to visualize the plan view of the ballast scene and assign random textures to the ballast particles and fine material surface. (**f**) An enlarged view of the image (**e**). (**g**) Add ballast particles in sizes of 0.1-3/8 in. (2.54-9.5 mm) on top of the fine material surface to better resemble real ballast sizes in the field. (**h**) Mix textures of the fine material and the ballast particles to mimic the appearance of field ballast particles covered with fine materials. (**i**) Add ballast particles in sizes of 0.03-0.1 in. (0.762-2.54 mm) on top of the fine material surface with a hair particle system [23]. in height (Figure 4a) to prevent ballast particles from falling out. However, free-falling tends to make the smaller particles settle down to the bottom through vacancies. To mix all sizes evenly, the virtual container was shaken by periodically changing the direction of gravity (Figure 4c). Considering the large quantities of ballast particles and the simulation precision, it is exceptionally challenging to simulate fine materials with the same approach. Thus, only the surface of the fine materials was added to the scene (Figure 4d). The height of the fine materials surface, \(h_{f}\), was cautiously calculated so that the mass of the fine materials satisfies the input PSD. The net volume of the fine materials, \(V_{f}\), is calculated by  
\[V_{f}=(1-n)V_{h_{f}} \tag{4}\]  
where \(V_{h_{f}}\) is the vacant space underneath the surface of the container (excluding ballast particles over 3/8 in. (9.5 mm)), and \(n\) is the porosity of the fine material [31]. To make the fine material surface more realistic, 400 to 600 randomly picked smaller ballast particles, with sizes uniformly sampled in the range from 0.1 in. (2.54 mm) to 3/8 in.