def test_neighbors_on_row_edge(self): pixels_right = neighbors(self.img_1, 1, 2) answer_right = ([255, 153, 153], [255, 153, 51], [255, 101, 255], [255, 205, 255]) # raises AssertionError if wrong, otherwise returns None assert_array_equal(pixels_right, answer_right) pixels_left = neighbors(self.img_1, 2, 0) answer_left = ([255, 205, 255], [255, 204, 153], [255, 153, 51], [255, 255, 51]) assert_array_equal(pixels_left, answer_left)
def test_dual_gradient(self): img1_21 = dual_gradient_energy(*neighbors(self.img_1, 2, 1)) self.assertEqual(img1_21, 52024) img1_11 = dual_gradient_energy(*neighbors(self.img_1, 1, 1)) self.assertEqual(img1_11, 52225)
def test_neighbors_on_corner(self): pixels = neighbors(self.img_1, 0, 0) answer = ([255, 101, 255], [255, 101, 153], [255, 255, 51], [255, 153, 51]) assert_array_equal(pixels, answer)
def test_neighbors_on_col_edge(self): pixels = neighbors(self.img_1, 3, 1) answer = ([255, 255, 51], [255, 255, 255], [255, 204, 153], [255, 101, 153]) assert_array_equal(pixels, answer)