1.前言
视频的特征提取可以分为声音的特征特提取和图像的特征提取(抽取关键帧), 特征提取是一个关键的步骤,为后面机器学习算法的应用提供了基础。
2.特征
(1)lighting key
multiplying the average value V (in HSV) by the standard deviation of the values V (in HSV).
在HSV颜色空间中,lighting key计算方法为亮度值V的平均值和V的标准差的乘积。
在opencv中提供了:
C++: void meanStdDev(InputArray src, OutputArray mean, OutputArray stddev, InputArray mask=noArray())
来计算图片的平均值和标准差,因此,lighting key直接把v的计算结果相乘就OK了。
代码实现:
//calculate lighting key double calculateLightingKey(Mat &hsvImage){ Mat hsvmean, hsvSDev; meanStdDev(hsvImage, hsvmean, hsvSDev); cout << "rows:" << hsvmean.rows << " cols:" << hsvmean.cols << endl; cout << "mean:" << hsvmean.at<double>(0, 0) << " " << hsvmean.at<double>(1, 0) << " " << hsvmean.at<double>(2, 0) << endl; cout << "SDev:" << hsvSDev.at<double>(0, 0) << " " << hsvSDev.at<double>(1, 0) << " " << hsvSDev.at<double>(2, 0) << endl; return hsvmean.at<double>(2, 0)*hsvSDev.at<double>(2, 0); }
obtained in the CIE LUV color space by computing the determinant of the covariance matrix of L,U, and V.
在LUV颜色空间中,分别计算L,U,V的协方差矩阵的行列式。
协方差矩阵具体可参考:浅谈协方差矩阵
首先,需要重RGB转到CIE LUV颜色空间,之后拆分为L、U、V三个通道,分别计算协方差矩阵及其行列式。
代码实现:
//calculate color variance double *calculateColorVariance(Mat &luvImage){ Mat luvChannel[3]; Mat covar[3], mean; double detLuv[3] = { 0.0 }; split(luvImage, luvChannel); for (int i = 0; i < 3; ++i){ //计算每个通道的协方差矩阵 calcCovarMatrix(luvChannel[i], covar[i], mean, CV_COVAR_NORMAL | CV_COVAR_ROWS); //calculate the determinant of covariance matrix //计算协方差的行列式 detLuv[i] = determinant(covar[i]); cout << (double)detLuv[i] << endl; } return detLuv; }
但是遇到的一个问题是,计算出来的行列式是无穷大的,只能判断正负性,所以需要通过标准化或者是对原图片进行压缩处理,目前没有看到相关的处理手段。
(3)Colors and their proportion
A 20-bin color histogram of hue and lightness values in the HSV space was computed for each I-frame and subsequently averaged over all frames. The resulting bin averages were used as video content-based
features. The median of the L value in HSL space was computed to obtain the median lightness of a frame.
首先,在HSV颜色空间中,得到20bin的HSV直方图,具体可参考opencv得到图像的RGB颜色直方图,基本上是一样的。然后计算H和V的平均数;
第二个特征是在HSL中,计算L的中位数,这个也很简单。