#convert pixels's color from 0,255,255 to 0,0,0
h = mask.shape[0]
w = mask.shape[1]
for py in range(0,h):
for px in range(0,w):
if mask[py][px][0] ==0 and mask[py][px][1] == 255 and mask[py][px][2] == 255:
for i in range(3):
mask[py][px][i] = 0
# masking
masked = mask.copy()
for py in range(0,h):
for px in range(0,w):
if masked[py][px][0] != 0:
masked[py][px] = im[py][px]
masked = cv2.cvtColor(masked, cv2.COLOR_RGB2BGR)
有没有什么奇特的方法可以将我的脏代码转换为带有 cv2 或 numpy 函数的简单代码?
偶然的你
相关分类