def _crop_roi(fullframe, roisz):
xpos = roisz[0]
ypos = roisz[1]
xlen = roisz[2]
ylen = roisz[3]
# numpy array indexing: lines are the first index => y direction goes first
chan = np.ndim(fullframe)
if xpos == -1:
cropped = np.zeros((36, 36))
else:
if chan == 2:
cropped = fullframe[ypos:ypos+ylen, xpos:xpos+xlen]
elif chan == 3:
cropped = fullframe[ypos:ypos + ylen, xpos:xpos + xlen, :]
else:
raise Exception('unsupported nb of channels')
return cropped
评论列表
文章目录