How imshow recognize the color space in Mat

When we convert the color space of Mat object like below:

    yuv = cv.cvtColor(image, cv.COLOR_BGR2YUV)
    cv.imshow("yuv image", yuv)

How imshow function know the color space of Mat object yuv, I can not find the variable to recognize the color space in Mat class.
Can anyone provide some help for me.

it doesnt, exactly at all.
the only colorspace here is bgr. 3channel images are just mapped to that, float/16bit images also get scaled

Thank you for your reply.
I see the the only colorspace here is bgr for 3channel. I want to know what varible in Mat class can recognize the colorspace . If Mat class don not have this varible, how can we know the data in Mat is BGR or YUV or other format.

there is none.

the programmer has to keep that in mind. it is not tracked by cv::Mat

Some related discussions in:

1 Like