Revision history [back]

Understanding YUV to BGR color spaces conversion

bgr=cv2.imread('bgr.png')


I convert it to YUV color space:

yuv=cv2.cvtColor(bgr,cv2.COLOR_BGR2YUV)


Now I set U and V values of yuv image to 0:

for i in range(yuv.shape[0]):
for j in range(yuv.shape[1]):
yuv[i,j,1]=0
yuv[i,j,2]=0


Now I convert yuv to BGR and display it:

BGR=cv2.cvtColor(yuv,cv2.COLOR_YUV2BGR)
cv2.imshow('BGR',BGR)


The problem is that BGR is displayed totally green (Blue and Red channels are always 0 on all the pixels)

Does this mean that Y in YUV color space is saved as G in BGR when we convert an image from YUV to BGR colorspaces ?