def generateCountMaps(self, coords):
'''Generates a count map for the provided list of coordinates. It can
count at most 256 object within the receptive field. Beyond that it
overflows.
'''
s = self.config['receptive_field_size']
pad = s // 2
unpadded_size = self.config['tile_size']
target_size = 1 + unpadded_size + 2 * pad
countMaps = np.zeros((self.config['cls_nb'], target_size, target_size), dtype=np.int16)
y_min = 0
y_max = unpadded_size
x_min = 0
x_max = unpadded_size
for coord in coords:
if coord[1] >= y_min and coord[1] < y_max and coord[2] >= x_min and coord[2] < x_max:
self.inc_region(countMaps[coord[0]], coord[1] + pad, coord[2] + pad, s, s)
return np.moveaxis(countMaps, 0, -1).astype(np.float32)
评论列表
文章目录