Created
January 23, 2018 04:47
-
-
Save derwiki/f640dc497392d365f36a446574cbd122 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import cv2 | |
filenames = ["file1.jpg", ... ] | |
columns = [] | |
for i, filename in enumerate(filenames): | |
img: np.array = cv2.imread(f"p/{filename}") | |
height: int = len(img) | |
width: int = len(img[0]) | |
column_start = 2 * i | |
column_end = 2 * i + 2 | |
print(f"filename: {filename}, height: {height}, width: {width}, {column_start}-{column_end}") | |
column = img[0:height, column_start:column_end] | |
columns.append(column) | |
matrix = [[] for _ in range(height)] | |
for row_idx in range(height): | |
row = [] | |
for col_idx in range(len(columns)): | |
pixels = columns[col_idx][row_idx] | |
matrix[row_idx] += list(pixels) | |
new_img = np.array([np.array(list(row)) for row in matrix]) | |
cv2.imwrite('output.jpg', new_img) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment