getting indices when comparing multidimensional arrays
问题 I have two numpy arrays, one an RGB image, one a lookup table of pixel values, for example: img = np.random.randint(0, 9 , (3, 3, 3)) lut = np.random.randint(0, 9, (1,3,3)) What I'd like is to know the x,y coordinate in lut of pixels whose values are common to img and lut , so I tried: for x in xrange(img.shape[0]): for y in xrange(img.shape[1]): print np.transpose(np.concatenate(np.where(lut == img[x,y]))) At this point, the problem is that img[x,y] , which will be in the form of [int_r, int