This paper introduces a novel algorithm for the rigorous characterization of three-dimensional (3D) particles, particularly for railway ballast. Degraded railway ballast must be replaced with fresh material for efficient functioning. This study examined the shape and form of degraded (used) ballast to guide future maintenance efforts. Laboratory-generated used ballast, obtained via the Los Angeles abrasion test, was compared to fresh ballast. Thirteen fundamental morphological parameters of fresh and used ballasts were investigated by utilizing the shape information obtained through 3D scanning. The algorithm efficiently processed datasets comprising multiple irregular particles and monitored the morphological characteristics of ballasts based on the shape of the particles. The trimesh library was imported for 3D processing, facilitating the mathematical calculation of diverse parameters using the developed algorithm. The algorithm also incorporated mechanisms for simultaneously storing parameters provided in various 3D configuration models. With the support of the trimesh library, a morphology analyzer was used to analyze various 3D model file formats, such as .stl, .obj, and csg. This method demonstrated its efficacy with reduced runtime and computation cost. Thus, the proposed algorithm has emerged as a valuable resource for researchers investigating the influence of ballast particle shape on the mechanical behavior of granular assemblies.