标签: python numpy
我从图片中加载numpy array形状(height, width, 3)。我想用特定颜色[0, 0, 0]替换所有黑色像素[r, g, b]。有numpy方法吗?
numpy array
(height, width, 3)
[0, 0, 0]
[r, g, b]
numpy
答案 0 :(得分:1)
import numpy as np orig_color = (0, 0, 0) replacement_color = (r, g, b) data[(data == orig_color).all(axis = -1)] = replacement_color