-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLRGeneration.py
More file actions
26 lines (20 loc) · 787 Bytes
/
LRGeneration.py
File metadata and controls
26 lines (20 loc) · 787 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import os
import cv2
# Directory containing high-resolution images
input_dir = "in"
# Directory to save output images
output_dir = "outLR"
# Get filenames of all high-res images in input directory
input_filenames = os.listdir(input_dir)
# Iterate over each image file
for i, filename in enumerate(input_filenames, start=2):
# Load the high-res image
print("i", i)
print("filename", filename)
img = cv2.imread(os.path.join(input_dir, filename))
# Downsample using bicubic interpolation
img_downsampled = cv2.resize(
img, None, fx=0.25, fy=0.25, interpolation=cv2.INTER_CUBIC)
# Save the downsampled image with filename based on index
output_filename = f"{i:04}.png"
cv2.imwrite(os.path.join(output_dir, output_filename), img_downsampled)