def test_laplacian_pyramid(self): input_imgs = [ 'test_lapl1_pyr.npy', 'test_lapl2_pyr.npy', 'test_lapl3_pyr.npy' ] ref_imgs = [ 'test_lapl1_pyr_ref.npy', 'test_lapl2_pyr_ref.npy', 'test_lapl3_pyr_ref.npy' ] levels = [5, 5, 4] for i in range(3): f1 = input_imgs[i] f2 = ref_imgs[i] test_array = np.load(INPUT_DIR + f1) l_pyr = ps4.laplacian_pyramid(test_array) l_pyr_ref = np.load(INPUT_DIR + f2) for l in range(levels[i]): correct = np.allclose(l_pyr[l], l_pyr_ref[l], atol=0.1) error_msg = "Value at level {} does not match the answer. " \ "Make sure your expand() function is passing " \ "the autograder.\n".format(l) self.assertTrue(correct, error_msg)
def part_2(): yos_img_01 = cv2.imread( os.path.join(input_dir, 'DataSeq1', 'yos_img_01.jpg'), 0) / 255. # 2a levels = 4 yos_img_01_g_pyr = ps4.gaussian_pyramid(yos_img_01, levels) yos_img_01_g_pyr_img = ps4.create_combined_img(yos_img_01_g_pyr) cv2.imshow('combined', yos_img_01_g_pyr_img) cv2.waitKey(0) cv2.destroyAllWindows() cv2.imwrite("output/ps4-2-a-1.png", yos_img_01_g_pyr_img) # 2b yos_img_01_l_pyr = ps4.laplacian_pyramid(yos_img_01_g_pyr) yos_img_01_l_pyr_img = ps4.create_combined_img(yos_img_01_l_pyr) cv2.imshow('combined', yos_img_01_l_pyr_img) cv2.waitKey(0) cv2.destroyAllWindows() cv2.imwrite("output/ps4-2-b-1.png", yos_img_01_l_pyr_img)
def part_2(): yos_img_01 = cv2.imread( os.path.join(input_dir, 'DataSeq1', 'yos_img_01.jpg'), 0) / 255. # 2a levels = 4 yos_img_01_g_pyr = ps4.gaussian_pyramid(yos_img_01, levels) yos_img_01_g_pyr_img = ps4.create_combined_img(yos_img_01_g_pyr) cv2.imwrite(os.path.join(output_dir, "ps4-2-a-1.png"), yos_img_01_g_pyr_img) # 2b yos_img_01_l_pyr = ps4.laplacian_pyramid(yos_img_01_g_pyr) yos_img_01_l_pyr_img = ps4.create_combined_img(yos_img_01_l_pyr) cv2.imwrite(os.path.join(output_dir, "ps4-2-b-1.png"), yos_img_01_l_pyr_img)