Monday, 1 March 2021

python opencv 2

 
random pixels

copy paste region

import cv2
import random

img = cv2.imread('assets/beach.jpg', 1)

#print(img[100][50:60])
"""
[[ 1 53  0]
 [ 3 52  2]
 [ 3 50  1]
 [ 2 48  1]
 [ 1 47  0]
 [ 0 46  0]
 [ 0 45  0]
 [ 0 45  0]
 [ 0 44  1]
 [ 0 45  2]]
"""
"""
for i in range(500):
    for j in range(img.shape[1]):
        img[i][j] = [random.randint(0, 255), random.randint(0, 255), random.randint(0, 255)]
"""

select = img[0:500, 0:500]
img[500:1000, 500:1000] = select

cv2.imshow('Image', img)
cv2.waitKey(0)
cv2.destroyAllWindows()

reference:

No comments:

Post a Comment