I'm using python with cv2 library. I have a small image that I want to fill some blank space around. Say the blank image is as following: (each x means a pixel, [255,255,255])
x x x x
x x x x
x x x x
x x x x
I want to exchange some parts of it to the data from another image (each a means a pixel from another image)
x x x x
x a a x
x a a x
x x x x
What would be the quickest way of doing it? I tried looping through each pixel and do the job, but it seems to be highly inefficient.
import cv2
import numpy as np
tmp=np.zeros((1024,768,3),np.uint_8)
image= .. #image captured from camera
for(i in range(480)):
for(j in range(640)):
tmp[i+144][j+197]=image[i][j]