Ask Your Question

Revision history [back]

Different results between imread as grayscale and cvtColor

Did anyone notice that if you load a color image directly as gray scale, the resulting image is slightly different than loading it to a color image and then cvtColor to grayscale? Anyone know why?

img1=cv2.imread("imge.jpg", 0)
img2=cv2.imread("imge.jpg", 1)
img2=cv2.cvtColor(img2, cv2.COLOR_BGR2GRAY)
print np.max(img1!=img2)
# True
print np.max(img1.astype('float32')-img2.astype('float32'))
# 2.0

BTW, this happens under both Linux and Windows (either c++ or python).