Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

detect color space with openCV

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

thanks

like image 770
aneuryzm Avatar asked Jan 23 '10 09:01

aneuryzm


People also ask

Can OpenCV detect colors?

OpenCV has some built-in functions to perform Color detection and Segmentation operations. So what are Color Detection and Segmentation Techniques in Image Processing? Color detection is a technique of detecting any color in a given range of HSV (hue saturation value) color space.

What color space does OpenCV use?

BGR color space: OpenCV's default color space is RGB. However, it actually stores color in the BGR format. It is an additive color model where the different intensities of Blue, Green and Red give different shades of color.

How do I find the color space of an image?

To know the nature of the ICC profile of the image, i.e. its color space or working space, you must now go to the bottom left of the photo, in the status bar. Next to the display size (in percentage) of the photo opened in Photoshop appears its ICC profile.


1 Answers

Unfortunately, OpenCV doesn't provide any sort of indication as to the color space in the IplImage structure, so if you blindly pick up an IplImage from somewhere there is just no way to know how it was encoded. Furthermore, no algorithm can definitively tell you if an image should be interpreted as HSV vs. RGB - it's all just a bunch of bytes to the machine (should this be HSV or RGB?). I recommend you wrap your IplImages in another struct (or even a C++ class with templates!) to help you keep track of this information. If you're really desperate and you're dealing only with a certain type of images (outdoor scenes, offices, faces, etc.) you could try computing some statistics on your images (e.g. build histogram statistics for natural RGB images and some for natural HSV images), and then try to classify your totally unknown image by comparing which color space your image is closer to.

like image 171
rcv Avatar answered Sep 24 '22 22:09

rcv