## 3 SAM-Based Approach to Improve Panoramic Image Segmentation in Indoor Construction Environments
### Object Extract
#### 3.1.3 Handling Duplicate and Overlapping Objects  
While updating the input images and prompt labels mitigated redundant object detections, duplicate and overlapping objects were still observed. Object overlaps posed significant challenges in the subsequent label assignment process, where a single object could receive multiple conflicting labels. Addressing these issues was crucial. Two primary challenges were identified, namely (1) duplication and overlap among newly detectedobject masks and (2) duplication and overlap between newly detected masks and previously stored object masks. To resolve these issues, Algorithm 3 was implemented, with the overall process illustrated in Figure 5.  
```
Input: Sorted list of masks \(\mathbf{M}\) Output: Updated list of masks \(\mathbf{M}_{\text{new}}\)
1:Step 1: Duplicate Mask Removal
2:for each pair of masks (\(m_{1}\), \(m_{2}\)) \(\in\mathbf{M}\)do
3: Compute IoU: iou \(\leftarrow\) IoU(\(m_{1}\), \(m_{2}\))
4:if iou > 0.85 then
5: Remove \(m_{2}\)
6:endif
7:endfor
8:Step 2: Separate Masks Based on Intersection
9: Initialize \(\mathbf{M}_{\text{inter}}\), \(\mathbf{M}_{\text{non-inter}}\)
10:for each mask \(m_{1}\in\mathbf{M}\)do
11:if\(m_{1}\) intersects any \(m_{2}\in\mathbf{M}\) where \(m_{1}\
eq m_{2}\)then
12: Add \(m_{1}\) to \(\mathbf{M}_{\text{inter}}\)
13:else
14: Add \(m1\) to \(\mathbf{M}_{\text{non-inter}}\)
15:endif
16:endfor
17:Step 3: Process and Combine Masks
18: Extract intersection regions: \(\mathbf{I}\leftarrow\) GetIntersections(\(\mathbf{M}_{\text{inter}}\))
19:if\(\mathbf{I}\) is not empty then
20: Perform set difference: \(\mathbf{D}\leftarrow\) ComputeSetDifference(\(\mathbf{M}_{\text{inter}}\), \(\mathbf{I}\))
21:else
22: Set \(\mathbf{D}\leftarrow\emptyset\)
23:endif
24: Combine all masks: \(\mathbf{M}_{\text{new}}\leftarrow\mathbf{M}_{\text{non-inter}}+\mathbf{I}+ \mathbf{D}\)
25:Return\(\mathbf{M}_{\text{new}}\)
```  
**Algorithm 3**Mask overlap resolution and intersection division  
First, to resolve object duplication, masks were sorted in descending order based on their stability scores. The IoU was calculated between each mask, and if it exceeded a threshold of 0.85, the mask was considered duplicate. In such cases, only the most stable mask was retained, while all redundant masks were discarded. Next, for handling overlapping objects, masks were categorized into the following two groups: those with  
Figure 4: Process of updating the input image and input point labels (green: points for segmentation; red: points excluded from segmentation).  
overlapping regions and those without. The intersection regions (i.e., overlapping object areas) were extracted, and each mask was updated by subtracting these intersections from their respective areas. Finally, the updated masks were combined with non-overlapping masks and intersection masks to form the final set of object masks.  
In the first case, overlap was more prevalent than duplication, and the number of masks was relatively small, allowing Algorithm 3 to resolve overlap issues efficiently. However, in the second case, duplication was more significant, and the number of processed masks was more than twice that of the first case. Thus, an additional step was introduced, namely removing duplicate objects first, followed by applying Algorithm 3 to resolve overlapping cases. These optimizations enabled the extraction and storage of non-duplicated, non-overlapping objects from the panoramic images.