Files » test2.py
1 |
import cv2 as cv |
---|---|
2 |
import numpy as np |
3 |
|
4 |
overlap = 200 # Overlapping region width |
5 |
|
6 |
# Load the images
|
7 |
left = cv.imread("left.png", cv.IMREAD_COLOR) |
8 |
right = cv.imread("right.png", cv.IMREAD_COLOR) |
9 |
|
10 |
# Display shapes of the images
|
11 |
print(f"Left Shape: {left.shape}") |
12 |
print(f"Right Shape: {right.shape}") |
13 |
|
14 |
# Assuming both images have the same height
|
15 |
height = left.shape[0] |
16 |
|
17 |
# Define the x-coordinate of where the overlap starts in the left image (end of left image - overlap)
|
18 |
left_overlap_start = left.shape[1] - overlap |
19 |
|
20 |
# Extract the overlapping region
|
21 |
left_overlap = left[0:height, left_overlap_start:,:] |
22 |
|
23 |
# Example modification: Increase the brightness of the blue channel in the overlap region
|
24 |
left_overlap_mod = cv.convertScaleAbs(left_overlap, alpha=0.5, beta=0) # Adjust brightness |
25 |
|
26 |
# Replace the modified blue channel back into the original left image
|
27 |
left[0:height, left_overlap_start:,:] = left_overlap_mod |
28 |
|
29 |
# Display the modified original image with the blue overlap replaced
|
30 |
cv.imshow("Modified Left Image", left) |
31 |
cv.imshow("Modified Left Overlap Blue Channel", left_overlap_mod) |
32 |
|
33 |
cv.waitKey(0) |
34 |
cv.destroyAllWindows() |