43 height, width, _ = left_image.shape
46 alpha_left = np.linspace(1, 0, blend_width).reshape(1, blend_width, 1)
47 alpha_left = np.repeat(alpha_left, height, axis=0)
48 alpha_right = np.linspace(0, 1, blend_width).reshape(1, blend_width, 1)
49 alpha_right = np.repeat(alpha_right, height, axis=0)
51 left_overlap = left_image[:, -blend_width:]
52 right_overlap = right_image[:, :blend_width]
53 gamma_corrected_left_overlap = self.
gamma_corrector.gamma_correction(left_overlap)
54 gamma_corrected_right_overlap = self.
gamma_corrector.gamma_correction(right_overlap)
56 left_image[:, -blend_width:] = gamma_corrected_left_overlap
57 right_image[:, :blend_width] = gamma_corrected_right_overlap
59 left_image[:, -blend_width:] = (left_image[:, -blend_width:].astype(np.float32) * alpha_left).astype(np.uint8)
60 right_image[:, :blend_width] = (right_image[:, :blend_width].astype(np.float32) * alpha_right).astype(np.uint8)
62 return left_image, right_image
75 left_image = cv.imread(left_image_path, cv.IMREAD_COLOR)
76 right_image = cv.imread(right_image_path, cv.IMREAD_COLOR)
78 if left_image
is None or right_image
is None:
79 raise FileNotFoundError(
"One of the input images is not found.")
81 gamma_corrected_left = self.
gamma_corrector.gamma_correction(left_image)
82 gamma_corrected_right = self.
gamma_corrector.gamma_correction(right_image)
84 adjusted_left, adjusted_right = self.
blend_images(gamma_corrected_left, gamma_corrected_right)
86 height, width, _ = left_image.shape
89 left_non_overlap = adjusted_left[:, :-blend_width]
90 right_non_overlap = adjusted_right[:, blend_width:]
92 left_blend = adjusted_left[:, -blend_width:]
93 right_blend = adjusted_right[:, :blend_width]
94 blended_area = left_blend + right_blend
96 blended_image = np.hstack((left_non_overlap, blended_area, right_non_overlap))
98 return adjusted_left, adjusted_right, blended_image