确定颜色“图像中单一颜色的含量”
我试图计算整个图像上一种颜色的平均值,以确定颜色、饱和度或强度或描述视频帧之间这种变化的任何其他值。 然而,我只想得到一个可以描述整个框架的值(以及其中的单个选定颜色)。计算帧中颜色的简单平均值可以使视频帧之间的差异非常小,在 0..255 空间上只有 2-3 个差异。
除了直方图之外,还有其他方法可以确定图像的颜色吗?据我了解,直方图将为我提供多个描述单帧的值。
I’m trying to calculate an average value of one color over the whole image in order to determine how color, saturation or intencity or eny other value describing this changes between frmaes of the video.
However i would like to get just one value that will describe whole frame (and sigle, chosen color in it). Calculating simple average value of color in frame gives me very small differences between video frames, just 2-3 on a 0..255 space.
Is there any other method to determine color of the image other than histogram which as i understand will give me more than one value describing single frame.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您使用哪个库进行图像处理?如果是 OpenCV(或 Matlab),那么这里的步骤将非常简单。否则你需要环顾四周并进行一些实验。
使用 RGB(或灰色)上的均值平移滤波器对图像中的颜色进行聚类 - 几乎相似的颜色会聚类在一起。这减少了要处理的颜色数量。
更改为灰度并使用图像中存在的像素值的区间 [0...255] 计算频率直方图
最高频率 - 中值 - 将对应于图像中存在的 bin(颜色)最多。每个垃圾箱的频率将为您提供编号。帧中存在的颜色的像素数。
将中值作为单一颜色来描述您的框架 - 框架中出现最多的颜色。
这里的关键点是上述步骤对于实时视频是否足够快。我猜你必须尝试找出答案。
Which library are you using for image processing? If it's OpenCV (or Matlab) then the steps here will be quite easy. Otherwise you'd need to look around and experiment a bit.
Use a Mean Shift filter on RGB (or gray, whichever) to cluster the colors in the image - nearly similar colors are clustered together. This lessens the number of colors to deal with.
Change to gray-level and compute a frequency histogram with bins [0...255] of pixel values that are present in the image
The highest frequency - the median - will correspond to the bin (color) that is present the most. The frequency of each bin will give you the no. of pixels of the color that is present in the frame.
Take the median value as the single color to describe your frame - the color present in the largest amount in the frame.
The key point here is if the above steps are fast enough for realtime video. You'd have to try to find out I guess.
最坏的情况是,您可以循环图像中的所有像素并进行计数。不确定你正在使用什么编程方式,但我使用 Python 和 Numpy 类似的东西。其中 pb 是一个 gtk pixbuf,其中包含我的图像。
除此之外,我通常会使用直方图并从中获取我需要的数据。主要是,这不会是您最快的选择,尤其是对于视频而言,但如果您有时间或只有几帧,那么就放弃吧:P
Worst case scenario, you could loop over all the pixels in the image and do a count. Not sure what you are using programming wise but I use Python with Numpy something similar to this. Where pb is a gtk pixbuf with my image in it.
Other than that, I would normally use a histogram and get the data I need from that. Mainly, this will not be your fastest option, especially for a video, but if you have time or just a few frames then hack away :P