如何用Numpy比较另一个数组中是否存在一个数组的多维元素?

时间:2019-11-04 20:09:34

标签: python numpy comparison

我主要是在寻找类似numpy的解决方案,但任何其他有效的解决方案都值得欢迎。

我想检测图像的像素颜色是否存在于另一个存储一组RGB颜色的数组中。我将像素的颜色堆叠在rgb_img的{​​{1}}数组中,并且有一个(1, n, 3)数组矩阵set_color

(1, n, 3)

所需结果:

color_set = np.array([[[ 75,  99, 147],
                       [ 75,  98, 148],
                       [ 75,  97, 154],
                       [ 75,  97, 156],
                       [ 75,  97, 157]]], dtype=np.uint8)

rgb_img = np.array([[[ 2,  3,  4],
                     [ 9, 11, 15],
                     [11, 14, 19],
                     [75,  97, 155],
                     [75,  97, 156],
                     [ 5,  6,  9]]], dtype=np.uint8)

0 个答案:

没有答案