def _main(): # pragma: no cover img = cv2.imread(r"img/imori.jpg", cv2.IMREAD_GRAYSCALE) diff_kernel_v = np.array([ [0, -1, 0], [0, 1, 0], [0, 0, 0], ]) diff_kernel_h = np.array([ [0, 0, 0], [-1, 1, 0], [0, 0, 0], ]) img_v = q9.apply_filter( img, diff_kernel_v.shape[0], functools.partial(q9.get_filter_value, kernel=diff_kernel_v)) img_h = q9.apply_filter( img, diff_kernel_h.shape[0], functools.partial(q9.get_filter_value, kernel=diff_kernel_h)) cv2.imshow("result_v", img_v) cv2.waitKey(0) cv2.imshow("result_h", img_h) cv2.waitKey(0) cv2.imwrite(r"img/answer_14_v.jpg", img_v) cv2.imwrite(r"img/answer_14_h.jpg", img_h)
def _main(): # pragma: no cover img = cv2.imread(r"img/imori.jpg", 0) img = q9.apply_filter(img, 3, _get_maxmin_diff) cv2.imshow("result", img) cv2.waitKey(0) cv2.imwrite(r"img/answer_13.jpg", img)
def _main(): # pragma: no cover img = cv2.imread(r"img/imori_noise.jpg") img = q9.apply_filter(img, 3, np.median) cv2.imshow("result", img) cv2.waitKey(0) cv2.imwrite(r"img/answer_10.jpg", img)
def _main(): # pragma: no cover img = cv2.imread(r"img/imori.jpg") motion_kernel = np.array([ [1 / 3, 0, 0], [0, 1 / 3, 0], [0, 0, 1 / 3], ]) img = q9.apply_filter( img, motion_kernel.shape[0], functools.partial(q9.get_filter_value, kernel=motion_kernel)) cv2.imshow("result", img) cv2.waitKey(0) cv2.imwrite(r"img/answer_12.jpg", img)
def _main(): # pragma: no cover img = cv2.imread(r"img/imori.jpg", 0) laplacian_kernel = np.array([ [0, 1, 0], [1, -4, 1], [0, 1, 0], ]) img = q9.apply_filter( img, laplacian_kernel.shape[0], functools.partial(q9.get_filter_value, kernel=laplacian_kernel)) cv2.imshow("result", img) cv2.waitKey(0) cv2.imwrite(r"img/answer_17.jpg", img)
def _main(): # pragma: no cover img = cv2.imread(r"img/imori.jpg", 0) emboss_kernel = np.array([ [-2, -1, 0], [-1, 1, 1], [0, 1, 2], ]) img = q9.apply_filter( img, emboss_kernel.shape[0], functools.partial(q9.get_filter_value, kernel=emboss_kernel)) cv2.imshow("result", img) cv2.waitKey(0) cv2.imwrite(r"img/answer_18.jpg", img)
def _main(): # pragma: no cover img = cv2.imread(r"img/imori_noise.jpg", 0) log_kernel = np.array([ [1, 3, 4, 3, 1], [3, 6, 7, 6, 3], [4, 7, 8, 7, 4], [3, 6, 7, 6, 3], [1, 3, 4, 3, 1], ]) / 100 img = q9.apply_filter(img, log_kernel.shape[0], functools.partial( q9.get_filter_value, kernel=log_kernel)) cv2.imshow("result", img) cv2.waitKey(0) cv2.imwrite(r"img/answer_19.jpg", img)