使用 openCV 检测颜色空间 [英] detect color space with openCV

查看:54
本文介绍了使用 openCV 检测颜色空间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用 openCV 查看图像的色彩空间?

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

在使用 cvCvtColor() 函数转换为另一个之前,我想确定它是 RGB

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

谢谢

推荐答案

不幸的是,OpenCV 没有提供关于 IplImage 结构中颜色空间的任何类型的指示,所以如果你盲目地从某个地方拿起一个 IplImage只是无法知道它是如何编码的.此外,没有算法可以明确地告诉您图像是否应该被解释为 HSV 还是 RGB - 这只是机器的一堆字节(应该 这个是 HSV 还是 RGB?).我建议您将 IplImages 包装在另一个结构(甚至是带有模板的 C++ 类!)中,以帮助您跟踪此信息.如果你真的很绝望并且你只处理某种类型的图像(户外场景、办公室、人脸等),你可以尝试计算图像的一些统计数据(例如为自然 RGB 图像构建直方图统计数据,有些自然 HSV 图像),然后尝试通过比较您的图像更接近哪个颜色空间来对完全未知的图像进行分类.

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.

这篇关于使用 openCV 检测颜色空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆