foriinrange(len(connect_remain)):# connect_remain: data tuple of remained connecetd components
top_y=connect_remain[i][1]# top y coordinate of connecetd components
top_x_series=np.where(connect_label[top_y+1,connect_remain[i][0]:connect_remain[i][0]+connect_remain[i][2]]!=0)[0]# locate a sereis of x coordinate of the light bar # Unsure: why first y, then x ? why only keep index[0] ?
n1=int((np.max(top_x_series)+np.min(top_x_series))/2+connect_remain[i][0])# x coordinate of mid point of top line of light bar
down_y=connect_remain[i][1]+connect_remain[i][3]-1# y coordinate of bottom line of light bar
down_x_series=np.where(connect_label[down_y-1,connect_remain[i][0]:connect_remain[i][0]+connect_remain[i][2]]!=0)[0]# series of x coordinate of bottom line of light bar