# no target return [] if all partitions are deleted
iflen(connect_remain)<2:
return[]
# Get peak_point points in each light bar
# This is not a good implement.
# We can first crop this component from label map according to component info
# This use something like np.argmin, np.argmax
bar_peak_point=[]
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] ?
iflen(top_x_series)==0:
return[]
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
iflen(down_x_series)==0:
return[]
n2=int((np.max(down_x_series)+np.min(down_x_series))/2+connect_remain[i][0])# x coordinate of mid point of bottom line of light bar s
bar_peak_point.append([n1,top_y,n2,down_y,connect_remain[i][4]])#FIXME # Should be [top_mid_x, top_mid_y, down_mid_x, down_mid_y, pixel count]