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

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

问题描述

如何查看我的图像与openCV的颜色空间?

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

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

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天全站免登陆