Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个从图像加载numpy array的形状。(height, width, 3)我想[0, 0, 0]用特定颜色替换所有黑色像素[r, g, b]。有没有numpy办法做到这一点?
numpy array
(height, width, 3)
[0, 0, 0]
[r, g, b]
numpy
import numpy as np orig_color = (0, 0, 0) replacement_color = (r, g, b) data[(data == orig_color).all(axis = -1)] = replacement_color