'Opencv finding too many colors?

I'm trying to use opencv and numpy to make a matrix of all the BRG codes of colors in an image. I wrote this script that I think should give only the unique colors in the image, and although the image only has three colors, the matrix is showing it has forty something colors (obviously wrong, there's no gradient or anything in the image). Can anyone point out what I'm doing wrong?

image_path='H:\<path>\\truth.png' 
image = cv2.imdecode(np.fromfile(image_path, dtype=np.uint8), cv2.IMREAD_COLOR)

unique=np.unique(image.reshape(-1, image.shape[2]), axis=0)
for line in unique:
    print(' '.join(map(str,line)))


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source