# Revision history [back]

Because imshow displays the image az a BGR image.

In fact the im variable is a WxHx3 matrix, and OpenCV doesn't know if it's RGB, HSV, YUV or something else. so it considers that it's BGR.

To display it correctly, you have to convert it back to BGR color space:

cvtColor(im,result,COLOR_YUV2BGR);
imshow(result);


(add the cv2. before the expressions for python)

It should show correctly the grayscale image.

Because imshow displays the image az a BGR image.

In fact the im im variable is a WxHx3 matrix, and OpenCV doesn't know if it's RGB, HSV, YUV or something else. so it considers that it's BGR.BGR. The fact that you set to 0 the second and third channels basically erases the green and red channels. That's why your image turned blue.

To display it correctly, you have to convert it back to BGR color space:

cvtColor(im,result,COLOR_YUV2BGR);
imshow(result);


(add the cv2. cv2. before the expressions for python)

It should show correctly the grayscale image.