+ # diag0 = block0 + .5
+ # diag0[
+ # max(y - 21, 0):max(y + 22, 0),
+ # max(x - 1, 0):max(x + 2, 0),
+ # :
+ # ] = 0.
+ # diag0[
+ # max(y - 1, 0):max(y + 2, 0),
+ # max(x - 21, 0):max(x + 22, 0),
+ # :
+ # ] = 0.
+ # gamma.write_image(f'diag_{xc:d}_{yc:d}_0.jpg', diag0)
+
+ # diag1 = block1 + .5
+ # diag1[
+ # max(y - 21, 0):max(y + 22, 0),
+ # max(x - 1, 0):max(x + 2, 0),
+ # :
+ # ] = 0.
+ # diag1[
+ # max(y - 1, 0):max(y + 2, 0),
+ # max(x - 21, 0):max(x + 22, 0),
+ # :
+ # ] = 0.
+ # gamma.write_image(f'diag_{xc:d}_{yc:d}_1.jpg', diag1)
+
+ # return offset and feature relative to block centre
+ return xo - XS, yo - YS, xf - XM // 2, yf - YM // 2
+
+
+
+diag = False
+if len(sys.argv) >= 2 and sys.argv[1] == '--diag':
+ diag = True
+ del sys.argv[1]
+
+in_jpg0 = 'tank_battle/down_2364.jpg'
+in_jpg1 = 'tank_battle/down_2365.jpg'
+out_jpg0 = 'out0_2364.jpg'
+out_jpg1 = 'out0_2365.jpg'
+
+print(f'read {in_jpg0:s}')
+image0 = gamma.read_image(in_jpg0)
+shape = image0.shape
+
+print('bandpass')
+bandpass0 = calc_bandpass(image0)
+if diag:
+ gamma.write_image('bandpass0.jpg', bandpass0 + .5)
+
+print(f'read {in_jpg1:s}')
+image1 = gamma.read_image(in_jpg1)
+assert image1.shape == shape
+
+print('bandpass')
+bandpass1 = calc_bandpass(image1)
+if diag:
+ gamma.write_image('bandpass1.jpg', bandpass1 + .5)
+
+ys, xs, cs = shape
+xb = (xs // 2 - XM - 2 * XS) // XP
+yb = (ys // 2 - YM - 2 * YS) // YP
+print('xb', xb, 'yb', yb)