簡體   English   中英

cv2 - 用噪聲屏蔽圖像

[英]cv2 - Masking image with noise

我有一個形狀為 (448,448,3) 的cv2圖像,並且想要用噪聲掩蓋所有像素 rgb > 250。 我現在正在逐個像素地進行處理,但效率不高。 原來蒙面 我怎樣才能一次完成這樣的操作?

rand_mask = np.round(np.random.rand(448, 448, 3) * 255).astype(np.uint8)
    for i in range(0, 448):
        for j in range(0, 448):
                if arr[i, j, 0] and arr[i, j, 1] and arr[i, j, 2] > 250:
                    arr[i, j, :] = rand_mask[i, j, :]

idx = arr>250
arr[idx] = rand_mask[idx]

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM