detect color space with openCV

前端 未结 5 479
予麋鹿
予麋鹿 2020-12-08 02:00

how can I see the color space of my image with openCV ?

I would like to be sure it is RGB, before to convert to another one using cvCvtColor() function

thank

5条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-08 02:42

    As rcv said, there is no method to programmatically detect the color space by inspecting the three color channels, unless you have a priori knowledge of the image content (e.g., there is a marker in the image whose color is known). If you will be accepting images from unknown sources, you must allow the user to specify the color space of their image. A good default would be to assume RGB.

    If you modify any of the pixel colors before display, and you are using a non-OpenCV viewer, you should probably use cvCvtColor(src,dst,CV_BGR2RGB) after you have finished running all of your color filters. If you are using OpenCV for the viewer or will be saving the images out to file, you should make sure they are in BGR color space.

提交回复
热议问题