## 4 Method for Calculating Rebar Mesh Spacing
### Calculation of Rebar Mesh Spacing Based on Intersection Detection (Figure 9)  
The rebar mesh consists of interwoven longitudinal and transverse rebars, making it necessary to handle the calculation of their spacing separately. However, due to the complexity of the interlacing mesh, traditional methods struggle to clearly differentiate between the spacing of the transverse and longitudinal rebars. Therefore, this paper proposes an automated spacing calculation method based on intersection detection which accurately distinguishes and measures the spacing of both the transverse and longitudinal rebars. The specific steps are as follows:  
Step 1--Intersection Classification: After completing intersection detection, the first task is to classify the intersections. This is performed by calculating the Euclidean distance and the absolute slope between each intersection and its neighboring intersections. The intersections are classified based on the slope of the lines connecting them to their neighboring points. Intersections with larger slopes are typically considered longitudinal intersections, while those with smaller slopes are classified as transverse intersections. Each intersection is calculated 8 times during the spacing measurement to ensure that the distances to all the neighboring points are fully considered. Finally, the four closest intersections representing the vertical and horizontal directions will be retained.  
It should be noted that this method becomes more accurate as the distribution of detected intersections becomes sparser. Therefore, in practical rebar mesh intersection detection, the user can selectively crop the target rebar mesh to reduce the number of intersections detected.  
Step 2--Spacing Calculation: In this step, the transverse reinforcement spacing is calculated by measuring the distance between the intersections with smaller slopes, while the longitudinal reinforcement spacing is obtained by calculating the distance between the intersections with larger slopes. The final spacing result is computed using the following formula, where taking the average effectively avoids the deviations caused by single calculation errors, ensuring a more accurate result.  
Figure 8: Schematic diagram of duplicate suppression mask.  
\[D_{rebar}=\frac{m\sum_{n}^{0}d_{i}}{r(n+1)} \tag{3}\]  
where \(D_{rebar}\) represents the final reinforcement spacing, \(m\) is the actual diameter of the reinforcement (based on the actual rebar dimensions), and \(r\) is the pixel length of the reinforcement diameter (obtained in the feature map by arranging measurement lines).  
Step 3--Outlier Removal: During the calculation process, certain intersections may produce outlier values due to issues like image segmentation errors or other factors, which could affect the final spacing results. To eliminate these outliers, the Interquartile Range (IQR) method is introduced in this study. By applying the IQR method, abnormal data points are identified and removed, ensuring that the calculated spacing is not skewed by such anomalies.  
The Interquartile Range (_IQR_) method is an outlier detection technique based on the medians and quartiles of the data distribution, particularly suitable for removing outliers in univariate continuous data. The core idea of the IQR method is to identify outliers by analyzing the range of the data distribution, thereby avoiding the influence of extreme values on the calculation results. Quartiles divide the ordered data into four equal parts. The _IQR_ represents the range of the middle 50% of the data, and its calculation formula is as follows:  
\[IQR=Q3-Q1 \tag{4}\]  
where \(Q1\) is the first quartile (the 25 th percentile), and \(Q3\) is the third quartile (the 75 th percentile). Data points that fall below \(Q1-1.5\times IQR\) or above \(Q3+1.5\times IQR\) are considered outliers and are excluded from the final calculations.