import numpy as np from pipeline.frames import temporal_median3, box_blur3, binarize, pack_lsb def test_temporal_median_removes_single_frame_flash(): a = np.zeros((4, 4), dtype=np.uint8) b = np.zeros((4, 4), dtype=np.uint8) b[1, 1] = 255 c = np.zeros((4, 4), dtype=np.uint8) out = temporal_median3([a, b, c]) assert out[1, 1] == 0 def test_pack_lsb_is_leftmost_pixel_bit_zero(): mask = np.zeros((1, 8), dtype=bool) mask[0, 0] = True assert pack_lsb(mask) == b"\x01" mask[0, 7] = True assert pack_lsb(mask) == b"\x81" def test_binarize_black_is_true(): gray = np.array([[0, 255]], dtype=np.uint8) assert binarize(gray).tolist() == [[True, False]] def test_box_blur_softens_a_single_pixel(): gray = np.zeros((3, 3), dtype=np.uint8) gray[1, 1] = 9 out = box_blur3(gray) assert out[1, 1] == 1