| 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 each ‘bg_img’ in ‘bg_imgs’ do Open the corresponding file in ‘bg_txts’ and read lines into ‘bg_lines’ For each ‘bg_line’ in ‘bg_lines’ do 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’ If ‘prev_bbox’ exists, then Calculate ‘iou’ If ‘iou’ equals 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’ Return ‘results’ |