def test_clear_green(): io = ImageO("images/test_picture.png") test_case = np.array([[[255, 0, 0, 255], [0, 0, 0, 255], [0, 0, 255, 255], [255, 0, 255, 255]], [[0, 0, 0, 255], [0, 0, 0, 255], [255, 0, 255, 255], [255, 0, 255, 255]], [[255, 0, 255, 255], [0, 0, 255, 255], [0, 0, 0, 255], [255, 0, 0, 255]], [[247, 0, 255, 255], [255, 0, 255, 255], [0, 0, 0, 255], [0, 0, 0, 255]]]) assert (io.clear_green("", returnable=True) == test_case).all()
def test_gray_scale(): io = ImageO("images/test_picture.png") test_case = np.array([[[85, 85, 85, 255], [85, 85, 85, 255], [85, 85, 85, 255], [255, 255, 255, 255]], [[0, 0, 0, 255], [0, 0, 0, 255], [255, 255, 255, 255], [255, 255, 255, 255]], [[255, 255, 255, 255], [85, 85, 85, 255], [85, 85, 85, 255], [85, 85, 85, 255]], [[250, 250, 250, 255], [255, 255, 255, 255], [0, 0, 0, 255], [0, 0, 0, 255]]]) assert (io.gray_scale("", returnable=True) == test_case).all()
def test_upper_half(): io = ImageO("images/test_picture.png") test_case = np.array([[[255, 128, 128, 255], [128, 255, 128, 255], [128, 128, 255, 255], [255, 255, 255, 255]], [[128, 128, 128, 255], [128, 128, 128, 255], [255, 255, 255, 255], [255, 255, 255, 255]], [[255, 255, 255, 255], [128, 128, 255, 255], [128, 255, 128, 255], [255, 128, 128, 255]], [[251, 252, 255, 255], [255, 255, 255, 255], [128, 128, 128, 255], [128, 128, 128, 255]]]) assert (io.upper_half("", returnable=True) == test_case).all()
def test_lower_half(): io = ImageO("images/test_picture.png") test_case = np.array([[[127, 0, 0, 255], [0, 127, 0, 255], [0, 0, 127, 255], [127, 127, 127, 255]], [[0, 0, 0, 255], [0, 0, 0, 255], [127, 127, 127, 255], [127, 127, 127, 255]], [[127, 127, 127, 255], [0, 0, 127, 255], [0, 127, 0, 255], [127, 0, 0, 255]], [[123, 124, 127, 255], [127, 127, 127, 255], [0, 0, 0, 255], [0, 0, 0, 255]]]) assert (io.lower_half("", returnable=True) == test_case).all()
def test_only_blue(): io = ImageO("images/test_picture.png") test_case = np.array([[[0, 0, 0, 255], [0, 0, 0, 255], [0, 0, 255, 255], [0, 0, 255, 255]], [[0, 0, 0, 255], [0, 0, 0, 255], [0, 0, 255, 255], [0, 0, 255, 255]], [[0, 0, 255, 255], [0, 0, 255, 255], [0, 0, 0, 255], [0, 0, 0, 255]], [[0, 0, 255, 255], [0, 0, 255, 255], [0, 0, 0, 255], [0, 0, 0, 255]]]) assert (io.blue_only("", returnable=True) == test_case).all()
def test_invert_color(): io = ImageO("images/test_picture.png") test_case = np.array([[[0, 255, 255, 255], [255, 0, 255, 255], [255, 255, 0, 255], [0, 0, 0, 255]], [[255, 255, 255, 255], [255, 255, 255, 255], [0, 0, 0, 255], [0, 0, 0, 255]], [[0, 0, 0, 255], [255, 255, 0, 255], [255, 0, 255, 255], [0, 255, 255, 255]], [[8, 7, 0, 255], [0, 0, 0, 255], [255, 255, 255, 255], [255, 255, 255, 255]]]) assert (io.invert_color("", returnable=True) == test_case).all()
def test_block(): io = ImageO("images/test_picture.png") # in this case since it is 4x4 it will just block it by 1 pixel blocks and so not do anything test_case = np.array([[[255, 0, 0, 255], [0, 255, 0, 255], [0, 0, 255, 255], [255, 255, 255, 255]], [[0, 0, 0, 255], [0, 0, 0, 255], [255, 255, 255, 255], [255, 255, 255, 255]], [[255, 255, 255, 255], [0, 0, 255, 255], [0, 255, 0, 255], [255, 0, 0, 255]], [[247, 248, 255, 255], [255, 255, 255, 255], [0, 0, 0, 255], [0, 0, 0, 255]]]) assert (io.block_image("", returnable=True) == test_case).all()