确定颜色“图像中有多少单一颜色”

问题描述:

我试图计算一个颜色在整个图像的平均值,以确定如何颜色,饱和度或Intencity或eny其他值描述视频的frmaes之间的变化。
但是我想获得一个值描述整个框架(和sigle,它选择的颜色)。计算帧中颜色的简单平均值给出了视频帧之间的非常小的差异,在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.

您使用哪个库进行图像处理?如果是OpenCV(或Matlab),那么这里的步骤将会很容易。

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.


  1. 在RGB(或灰色,任何一个)上使用均值平移滤波器以群集图像中的颜色 - 几乎相似的颜色聚集在一起。

  2. 更改为灰度级,并使用存在于图像中的像素值[0 ... 255]计算频率直方图

  3. 最高频率 - 中值 - 将对应于最显示的bin(颜色)。每个bin的频率将给你no。

  4. 使用中间值作为单一颜色来描述框架 - 框架中呈现的最大颜色的颜色。

  1. 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.
  2. Change to gray-level and compute a frequency histogram with bins [0...255] of pixel values that are present in the image
  3. 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.
  4. 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.