Open omocomo opened 2 years ago
하늘과 이미지 경계를 그라데이션을 이용해 자연스럽게 연결되도록 한다.
import numpy as np def get_gradient_3d(width, height, start_list, stop_list, is_horizontal_list): result = np.zeros((height, width, len(start_list)), dtype=np.float) for i, (start, stop, is_horizontal) in enumerate(zip(start_list, stop_list, is_horizontal_list)): result[:, :, i] = get_gradient_2d(start, stop, width, height, is_horizontal) return result def get_gradient_2d(start, stop, width, height, is_horizontal): if is_horizontal: return np.tile(np.linspace(start, stop, width), (height, 1)) else: return np.tile(np.linspace(start, stop, height), (width, 1)).T array = get_gradient_3d(512, 256, (0, 0, 0), (200, 200, 200), (False, False, False)) Image.fromarray(np.uint8(array)).save('C:/Users/Downloads/gray_gradient_v5.jpg', quality=95)
array1 = get_gradient_3d(512, 96, (0, 0, 0), (95, 95, 95), (False, False, False)) array2 = get_gradient_3d(512, 64, (95, 95, 95), (95, 95, 95), (False, False, False)) array3 = get_gradient_3d(512, 96, (95, 95, 95), (200, 200, 200), (False, False, False)) array = np.concatenate((array1, array2, array3), axis=0) Image.fromarray(np.uint8(array)).save('C:/Users/Downloads/gray_gradient_v7.jpg', quality=100)
src1 = np.array(Image.open('C:/Users/omocomo/Downloads/origin.jpg')) src2 = np.array(Image.open('C:/Users/omocomo/Downloads/dehazed_cloud_image (23).jpg').resize(src1.shape[1::-1], Image.BILINEAR)) mask1 = np.array(Image.open('C:/Users/omocomo/Downloads/gray_gradient_v.jpg').resize(src1.shape[1::-1], Image.BILINEAR)) mask1 = mask1 / 255 dst = src1 * mask1 + src2 * (1 - mask1)
Background
하늘과 이미지 경계를 그라데이션을 이용해 자연스럽게 연결되도록 한다.
Content
Details
그라데이션 이미지 만들기 참고
custom 예시
이미지에 적용 참고