Skip to main content
. 2024 Apr 8;24(7):2371. doi: 10.3390/s24072371
Algorithm 1. Set Up Maximum and Minimum Bounding Boxes for Each Section
Input:
   - ‘bg_imgs’: List of background images
   - ‘bg_txts’: List of text files corresponding to ‘bg_imgs
Output:
   - ‘results’: Dictionary of containing bounding box statistics
For eachbg_imginbg_imgsdo
   Open the corresponding file in ‘bg_txts’ and read lines into ‘bg_lines

   For eachbg_lineinbg_linesdo
     Parse ‘x’, ‘y’, ‘w’, ‘h’ as floats from ‘bg_line
     Adjust ‘y’ to (‘y’ − ‘h’/2)
     Create ‘bbox’ as a tensor [‘x’, ‘y’, ‘w’, ‘h’]
     Calculate ‘area’ as ‘w’ * ‘h
     Increment ‘count
     Update bounding box statistics:
       ‘ymin’, ‘ymax’, ‘bboxmin’, ‘bboxmax’ based on ‘y
       ‘areamax’, ‘widthmax’, ‘heightmax’, ‘widthmin’, ‘heightmin’ based on ‘w’, ‘h’, and ‘area
     Ifprev_bboxexists, then
       Calculate ‘iou
       Ifiouequals 0, then
         Store current statistics in ‘results’ for ‘section_num’
         Reset statistics
         Increment ‘section_num
     Set ‘prev_bbox’ to ‘bbox

   Store final statistics in ‘results’ for the last ‘section_num

Returnresults