1
嗨我想複製一個28x28矩陣的隨機部分,然後使用生成的24x24矩陣插入到一個28x28矩陣 image = image.reshape(28,28)複製一個24x24圖像到一個28x28陣列的零
getx = random.randint(0,4)
gety = random.randint(0,4)
# get a 24 x 24 tile from a 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)
塊是24×24的ROI工作按計劃
blank_image[gety:gety+24,getx:getx+24] = tile
blank_image在我的例子沒有得到與值來自片更新
感謝提前幫助
[更新墊的子矩陣中的OpenCV]的可能重複(http://stackoverflow.com/questions/11664097/updating-一個-子矩陣-的-MAT-在-OpenCV的) –