I'm analyzing image color, but am getting rid of any RGB color pixel that is 0,0,0 (black). (Using this top answer as reference)
I have an array of pixels
pixels = np.float32(img.reshape(-1, 3))
[[ 126. 94. 51.]
[ 171. 115. 65.]
[ 188. 119. 64.]
...,
[ 0. 0. 0.]
[ 0. 0. 0.]
[ 0. 0. 0.]]
I then try to go through and delete any sub arrays that are black.
pixelstoignore = np.delete(pixels, np.where(pixels == [0,0,0]), axis=0)
However the difference between the average color and dominant color tell you otherwise. The Average color is working correctly. Here is my picture:
What appears to be happening, is my code is deleting any subarray containing a 0. For example the red above has an RGB value as 255,0,0. My code is deleting this. But I only want to delete it if all 3 values are 0!
I got the average to work using np.all, but I can't get this to work with the delete function. Help!
EDIT: Solution seems to be this:
pixelstoignore = np.delete(pixels, np.where((pixels == [0,0,0]).all(axis=1)), axis=0)