I have a cv2
image with shape (448,448,3) and want to mask all pixels rgb > 250 with noise. I am doing pixel by pixel now, but it is not efficient. original masked . How can I do such operation in one pass?
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]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.