_ _ | |_ ___ __| |____ ___ _ _ | __/ _ \/ _` |_ / / _ \ | | | | || __/ (_| |/ / | __/ |_| | \__\___|\__,_/___(_)___|\__,_|
#!/usr/bin/env python3
import cv2
import numpy as np
p1 = cv2.imread('q.png')
H,W = p1.shape[0],p1.shape[1]
p2 = np.full((H,W,3), 127, dtype=np.uint8)
for y in range(H):
for x in range(W):
for c in range(3):
p2[y][x][0] = p1[y][x][0]
p2[y][x][1] = p1[y][x][1]
p2[y][x][2] = p1[y][x][2]
p2 = cv2.line(p2, (0, H//4), (W-1,H//4), (255,0,0), 1)
cv2.imshow('win',p2)
cv2.waitKey(0)
cv2.destroyAllWindows()
cv2.imwrite('p2.png', p2);
This is file qq.png
:
This is file out.png
: