3 回答

TA貢獻(xiàn)1806條經(jīng)驗(yàn) 獲得超5個(gè)贊
在這里,分配將是比串聯(lián)更有效的選擇。
blank = np.full((640, 512), 255, dtype=np.uint8)
for i in range(blank.shape[1]-1, -1, -1):
blank[:, i] = 0
cv2.imshow('img', blank)
cv2.waitKey(1)
產(chǎn)生這個(gè):
對(duì)于非白色圖像,您可以roll使用:
blank = np.random.randint(1, 256, (640, 512), dtype=np.uint8)
for i in range(blank.shape[1]-1, -1, -1):
blank = np.roll(blank, -1, axis=1)
blank[:, -1] = 0
cv2.imshow('img', blank)
cv2.waitKey(1)
這會(huì)產(chǎn)生:

TA貢獻(xiàn)1784條經(jīng)驗(yàn) 獲得超9個(gè)贊
我看不到你提供的圖片。你說(shuō)的是這樣的效果嗎?
import cv2
import numpy as np
blank_pixels = np.ones([512, 640], dtype=np.uint8)*255
for i in range(640):
# Pop
blank_pixels[:, :-1] = blank_pixels[:, 1:]
# Push
blank_pixels[:, -1] = 0
cv2.imshow('blank_pixels', blank_pixels)
cv2.waitKey(1)
cv2.waitKey(0)
cv2.destroyAllWindows()
添加回答
舉報(bào)