python - copying a 24x24 image into a 28x28 array of zeros -
hi want copy random portion of 28x28 matrix , use resulting 24x24 matrix inserted 28x28 matrix image = image.reshape(28, 28)
getx = random.randint(0,4) gety = random.randint(0,4) # 24 x 24 tile random location in img blank_image = np.zeros((28,28), np.uint8) tile= image[gety:gety+24,getx:getx+24] cv2.imshow("the 24x24 image",tile)
tile 24x24 roi works planned
blank_image[gety:gety+24,getx:getx+24] = tile
blank_image in example not updated values tile
thanks in advance
if getting error, might because np array dimensions different. if image rgb image, blank image should defined :
blank_image = np.zeros((28,28,3), uint8)
Comments
Post a Comment